his_api_controller.go 381KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  353. } else {
  354. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  356. }
  357. resp, requestErr := http.Get(api)
  358. if requestErr != nil {
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. body, ioErr := ioutil.ReadAll(resp.Body)
  363. if ioErr != nil {
  364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. var respJSON map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var status string
  375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  376. if status == "0" { //读卡成功
  377. var card_info string //卡信息
  378. var busi_card_info string
  379. var res ResultTwo //1101结果
  380. var res10265 ResultTwo10265 //1101结果
  381. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  382. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  383. fmt.Println(card_info)
  384. fmt.Println(busi_card_info)
  385. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  386. result, _ := json.Marshal(respJSON)
  387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  388. utils.ErrorLog("解析失败:%v", err)
  389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  390. return
  391. }
  392. res.ErrMsg = res10265.ErrMsg
  393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  394. res.Infcode = infocode
  395. res.Output = res10265.Output
  396. res.InfRefmsgid = res10265.InfRefmsgid
  397. if res.Infcode == 0 {
  398. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  399. if err == gorm.ErrRecordNotFound {
  400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  401. return
  402. } else if err != nil {
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  404. return
  405. } else {
  406. bas := strings.Split(card_info, "|")
  407. basNumber := bas[2]
  408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  410. infoStr := string(Iinfos)
  411. idetinfoStr := string(Idetinfos)
  412. psn := &models.HisPsn{
  413. PsnNo: res.Output.Baseinfo.PsnNo,
  414. Age: res.Output.Baseinfo.Age,
  415. PatientId: patient.ID,
  416. Certno: res.Output.Baseinfo.Certno,
  417. Brdy: res.Output.Baseinfo.Brdy,
  418. Gend: res.Output.Baseinfo.Gend,
  419. Naty: res.Output.Baseinfo.Naty,
  420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  421. PsnName: res.Output.Baseinfo.PsnName,
  422. Idetinfo: idetinfoStr,
  423. Insuinfo: infoStr,
  424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  425. CardInfo: card_info,
  426. VerifyNumber: busi_card_info,
  427. }
  428. service.CreateHisPsn(psn)
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "patient": patient,
  431. "number": basNumber,
  432. })
  433. }
  434. } else {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  436. return
  437. }
  438. } else { //读卡失败
  439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  440. return
  441. }
  442. } else {
  443. if initFlag == 0 {
  444. c.TestGetBasBaseInit()
  445. }
  446. basStr := c.GetBasBaseInfo()
  447. if len(basStr) == 0 {
  448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  449. return
  450. }
  451. fmt.Println(basStr)
  452. bas := strings.Split(basStr, "|")
  453. basNumber := bas[1]
  454. fmt.Println(basNumber)
  455. card_sn := bas[3]
  456. fmt.Println(card_sn)
  457. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  458. var dat map[string]interface{}
  459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  460. fmt.Println(dat)
  461. } else {
  462. fmt.Println(err)
  463. }
  464. userJSONBytes, _ := json.Marshal(dat)
  465. var res ResultTwo
  466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  467. utils.ErrorLog("解析失败:%v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. if res.Infcode == 0 {
  472. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  473. if err == gorm.ErrRecordNotFound {
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  475. return
  476. } else if err != nil {
  477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  478. return
  479. } else {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "patient": patient,
  482. "number": basNumber,
  483. })
  484. }
  485. } else {
  486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  487. return
  488. }
  489. break
  490. }
  491. case 2:
  492. SFZStr := c.GetSFZBaseInfo()
  493. id_card_str := strings.Split(SFZStr, "^")
  494. id_card_number := id_card_str[0]
  495. card_sn := ""
  496. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  497. var dat map[string]interface{}
  498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  499. fmt.Println(dat)
  500. } else {
  501. fmt.Println(err)
  502. }
  503. userJSONBytes, _ := json.Marshal(dat)
  504. var res ResultTwo
  505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == 0 {
  511. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  512. if err == gorm.ErrRecordNotFound {
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  514. return
  515. } else if err != nil {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  517. return
  518. } else {
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "patient": patient,
  521. "number": id_card_number,
  522. })
  523. }
  524. } else {
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  526. return
  527. }
  528. break
  529. case 3:
  530. break
  531. }
  532. }
  533. var initFlag int64 = 0
  534. func (c *HisApiController) TestGetBasBaseInit() {
  535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  536. Iinit := DllDef.MustFindProc("Init")
  537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  538. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  539. if ret != 0 {
  540. fmt.Println("SSCard的报错原因:", err)
  541. fmt.Println("SSCard的运算结果为:", ret)
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  543. return
  544. }
  545. result := int(ret)
  546. fmt.Println("SSCard的运算结果为1:", result)
  547. initFlag = 1
  548. return
  549. }
  550. func (c *HisApiController) GetSFZBaseInfo() string {
  551. DllDef := syscall.MustLoadDLL("SSCard.dll")
  552. readCard := DllDef.MustFindProc("ReadSFZ")
  553. if readCard == nil {
  554. fmt.Println("readcard is nil")
  555. readCard = DllDef.MustFindProc("ReadSFZ")
  556. }
  557. str := make([]byte, 256)
  558. str1 := make([]byte, 256)
  559. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  560. fmt.Println(r)
  561. return string(str)
  562. }
  563. func (c *HisApiController) GetBasBaseInfo() string {
  564. DllDef := syscall.MustLoadDLL("SSCard.dll")
  565. readCard := DllDef.MustFindProc("ReadCardBas")
  566. if readCard == nil {
  567. fmt.Println("readcard is nil")
  568. readCard = DllDef.MustFindProc("ReadCardBas")
  569. }
  570. str := make([]byte, 1024)
  571. str1 := make([]byte, 1024)
  572. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  573. fmt.Println(string(str1))
  574. fmt.Println(string(str))
  575. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  576. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  577. if ret2 != 0 {
  578. return ""
  579. }
  580. return string(str)
  581. }
  582. type CustomFundPay struct {
  583. FundPayType string `json:"fund_pay_type"`
  584. FundPayamt float64 `json:"fund_payamt"`
  585. }
  586. func (c *HisApiController) GetSettleList() {
  587. order_id, _ := c.GetInt64("order_id")
  588. admin_user_id, _ := c.GetInt64("admin_user_id")
  589. order, _ := service.GetHisOrderByIDTwo(order_id)
  590. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  591. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  592. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  593. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  594. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  596. if order.ID == 0 {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  598. return
  599. }
  600. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  601. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  602. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  603. fmt.Println(count)
  604. var zero string
  605. number := count + 1
  606. if number >= 1000 {
  607. zero = "0000" + strconv.FormatInt(number, 10)
  608. } else if number >= 10000 {
  609. zero = "000" + strconv.FormatInt(number, 10)
  610. } else if number >= 100000 {
  611. zero = "00" + strconv.FormatInt(number, 10)
  612. } else if number >= 1000000 {
  613. zero = "0" + strconv.FormatInt(number, 10)
  614. } else {
  615. zero = strconv.FormatInt(number, 10)
  616. }
  617. fmt.Println(zero)
  618. struct4101 := service.Struct4101{
  619. PsnNo: order.PsnNo,
  620. MdtrtId: order.MdtrtId,
  621. SetlId: order.SetlId,
  622. PsnName: order.PsnName,
  623. Gend: order.Gend,
  624. Brdy: his.Brdy,
  625. Age: his.Age,
  626. Naty: order.Naty,
  627. PatnCertType: "01",
  628. Certno: order.Certno,
  629. Prfs: "90",
  630. ConerName: roles[0].UserName,
  631. PatnRlts: "99",
  632. ConerAddr: miConfig.OrgName,
  633. ConerTel: admin.Mobile,
  634. HiType: order.Insutype,
  635. Insuplc: miConfig.InsuplcAdmdvs,
  636. MaindiagFlag: "1",
  637. BillCode: last_order.FaPiaoCode,
  638. BillNo: zero,
  639. BizSn: order.Number,
  640. PsnSelfPay: order.PsnPartAmt,
  641. PsnOwnPay: order.PsnPartAmt,
  642. AcctPay: order.AcctPay,
  643. PsnCashpay: order.PsnCashPay,
  644. HiPaymtd: "1",
  645. Hsorg: miConfig.InsuplcAdmdvs,
  646. HsorgOpter: miConfig.InsuplcAdmdvs,
  647. MedinsFillPsn: curRoles.UserName,
  648. MedinsFillDept: depart.Name,
  649. IptMedType: "2",
  650. }
  651. struct4101.SetlBegnDate = order.SetlTime
  652. struct4101.SetlEndDate = order.SetlTime
  653. time_arr := strings.Split(order.SetlTime, " ")
  654. struct4101.AdmTime = time_arr[0]
  655. struct4101.AdmEndTime = time_arr[0]
  656. var rf []CustomFundPay
  657. json.Unmarshal([]byte(order.SetlDetail), &rf)
  658. var tempFunPays []service.CustomStruct
  659. for _, item := range rf {
  660. var tempFunPay service.CustomStruct
  661. tempFunPay.FundPayamt = item.FundPayamt
  662. tempFunPay.FundPayType = item.FundPayType
  663. tempFunPays = append(tempFunPays, tempFunPay)
  664. }
  665. struct4101.CustomStruct = tempFunPays
  666. var tempDiaginfos []service.DiaginfoStructTwo
  667. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  668. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  669. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  670. var config []*models.HisXtDiagnoseConfig
  671. for _, item := range diagnosis_ids {
  672. id, _ := strconv.ParseInt(item, 10, 64)
  673. diagnosisConfig, _ := service.FindDiagnoseById(id)
  674. config = append(config, &diagnosisConfig)
  675. }
  676. for index, item := range config {
  677. if index == 0 {
  678. var tempDiaginfo service.DiaginfoStructTwo
  679. tempDiaginfo.DiagCode = item.CountryCode
  680. tempDiaginfo.DiagName = item.CountryContentName
  681. tempDiaginfo.DiagType = "1"
  682. tempDiaginfo.MaindiagFlag = "1"
  683. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  684. } else {
  685. var tempDiaginfo service.DiaginfoStructTwo
  686. tempDiaginfo.DiagCode = item.CountryCode
  687. tempDiaginfo.DiagName = item.CountryContentName
  688. tempDiaginfo.DiagType = "2"
  689. tempDiaginfo.MaindiagFlag = "0"
  690. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  691. }
  692. }
  693. struct4101.Diseinfo = tempDiaginfos
  694. sickConfigTwo, _ := service.FindSickById(his.SickType)
  695. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  696. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  697. tempOpspdiseinfo2.OprnOprtCode = ""
  698. tempOpspdiseinfo2.OprnOprtName = ""
  699. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  700. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  701. var iteminfo service.IteminfoStruct
  702. var bedCostTotal float64 = 0 //床位总费
  703. var bedCostSelfTotal float64 = 0 //床位自费
  704. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  705. var operationCostTotal float64 = 0 //手术费
  706. var operationCostSelfTotal float64 = 0 //手术费
  707. var operationCostPartSelfTotal float64 = 0 //手术费
  708. var otherCostTotal float64 = 0 //其他费用
  709. var otherCostSelfTotal float64 = 0 //其他费用
  710. var otherCostPartSelfTotal float64 = 0 //其他费用
  711. var materialCostTotal float64 = 0 //材料费
  712. var materialCostSelfTotal float64 = 0 //材料费
  713. var materialCostPartSelfTotal float64 = 0 //材料费
  714. var westernMedicineCostTotal float64 = 0 //西药费
  715. var westernMedicineCostSelfTotal float64 = 0 //西药费
  716. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  717. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  718. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  719. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  720. var checkCostTotal float64 = 0 //检查费
  721. var checkCostSelfTotal float64 = 0 //检查费
  722. var checkCostPartSelfTotal float64 = 0 //检查费
  723. var laboratoryCostTotal float64 = 0 //化验费
  724. var laboratoryCostSelfTotal float64 = 0 //化验费
  725. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  726. var treatCostTotal float64 = 0 //治疗费用
  727. var treatCostSelfTotal float64 = 0 //治疗费用
  728. var treatCostPartSelfTotal float64 = 0 //治疗费用
  729. decimal.DivisionPrecision = 2
  730. var bed_fulamt_ownpay_amt float64 = 0
  731. var operation_fulamt_ownpay_amt float64 = 0
  732. var other_fulamt_ownpay_amt float64 = 0
  733. var westernMedicine_fulamt_ownpay_amt float64 = 0
  734. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  735. var check_fulamt_ownpay_amt float64 = 0
  736. var material_fulamt_ownpay_amt float64 = 0
  737. var laboratory_fulamt_ownpay_amt float64 = 0
  738. var treat_fulamt_ownpay_amt float64 = 0
  739. var bed_claa_sunmfee float64 = 0
  740. var bed_clab_amt float64 = 0
  741. var bed_other_amt float64 = 0
  742. var operation_claa_sunmfee float64 = 0
  743. var operation_clab_amt float64 = 0
  744. var operation_other_amt float64 = 0
  745. var other_claa_sunmfee float64 = 0
  746. var other_clab_amt float64 = 0
  747. var other_other_amt float64 = 0
  748. var westernMedicine_claa_sunmfee float64 = 0
  749. var westernMedicine_clab_amt float64 = 0
  750. var westernMedicine_other_amt float64 = 0
  751. var chineseTraditional_claa_sunmfee float64 = 0
  752. var chineseTraditional_clab_amt float64 = 0
  753. var chineseTraditional_other_amt float64 = 0
  754. var check_claa_sunmfee float64 = 0
  755. var check_clab_amt float64 = 0
  756. var check_other_amt float64 = 0
  757. var material_claa_sunmfee float64 = 0
  758. var material_clab_amt float64 = 0
  759. var material_other_amt float64 = 0
  760. var laboratory_claa_sunmfee float64 = 0
  761. var laboratory_clab_amt float64 = 0
  762. var laboratory_other_amt float64 = 0
  763. var treat_claa_sunmfee float64 = 0
  764. var treat_clab_amt float64 = 0
  765. var treat_other_amt float64 = 0
  766. for _, item := range order.HisOrderInfo {
  767. if item.MedChrgitmType == "01" { //床位费
  768. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  769. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  770. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  771. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  772. if item.ChrgitmLv == "1" {
  773. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  774. }
  775. if item.ChrgitmLv == "2" {
  776. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  777. }
  778. if item.ChrgitmLv == "3" {
  779. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  780. }
  781. }
  782. if item.MedChrgitmType == "03" { //检查费
  783. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  784. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  785. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  786. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  787. if item.ChrgitmLv == "1" {
  788. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  789. }
  790. if item.ChrgitmLv == "2" {
  791. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  792. }
  793. if item.ChrgitmLv == "3" {
  794. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  795. }
  796. }
  797. if item.MedChrgitmType == "04" { //化验费
  798. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  799. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  800. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  801. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  802. if item.ChrgitmLv == "1" {
  803. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  804. }
  805. if item.ChrgitmLv == "2" {
  806. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  807. }
  808. if item.ChrgitmLv == "3" {
  809. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  810. }
  811. }
  812. if item.MedChrgitmType == "05" { //治疗费
  813. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  814. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  815. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  816. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  817. if item.ChrgitmLv == "1" {
  818. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  819. }
  820. if item.ChrgitmLv == "2" {
  821. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  822. }
  823. if item.ChrgitmLv == "3" {
  824. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  825. }
  826. }
  827. if item.MedChrgitmType == "06" { //手术费
  828. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  829. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  830. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  831. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  832. if item.ChrgitmLv == "1" {
  833. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  834. }
  835. if item.ChrgitmLv == "2" {
  836. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  837. }
  838. if item.ChrgitmLv == "3" {
  839. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  840. }
  841. }
  842. if item.MedChrgitmType == "08" { //材料费
  843. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  844. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  845. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  846. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  847. if item.ChrgitmLv == "1" {
  848. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  849. }
  850. if item.ChrgitmLv == "2" {
  851. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  852. }
  853. if item.ChrgitmLv == "3" {
  854. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  855. }
  856. }
  857. if item.MedChrgitmType == "09" { //西药费
  858. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  859. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  860. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  861. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  862. if item.ChrgitmLv == "1" {
  863. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  864. }
  865. if item.ChrgitmLv == "2" {
  866. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  867. }
  868. if item.ChrgitmLv == "3" {
  869. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  870. }
  871. }
  872. if item.MedChrgitmType == "11" { //中成费
  873. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  874. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  875. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  876. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  877. if item.ChrgitmLv == "1" {
  878. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  879. }
  880. if item.ChrgitmLv == "2" {
  881. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  882. }
  883. if item.ChrgitmLv == "3" {
  884. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  885. }
  886. }
  887. if item.MedChrgitmType == "14" { //其他费
  888. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  889. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  890. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  891. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  892. if item.ChrgitmLv == "1" {
  893. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  894. }
  895. if item.ChrgitmLv == "2" {
  896. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  897. }
  898. if item.ChrgitmLv == "3" {
  899. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  900. }
  901. }
  902. }
  903. var iteminfoStructs []service.IteminfoStruct
  904. if bedCostTotal != 0 {
  905. iteminfo.MedChrgitm = "01"
  906. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  907. iteminfo.Amt = bedCostTotal
  908. iteminfo.ClaaSumfee = bed_claa_sunmfee
  909. iteminfo.ClabAmt = bed_clab_amt
  910. iteminfo.OthAmt = bed_other_amt
  911. iteminfoStructs = append(iteminfoStructs, iteminfo)
  912. }
  913. if checkCostTotal != 0 {
  914. iteminfo.MedChrgitm = "03"
  915. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  916. iteminfo.Amt = checkCostTotal
  917. iteminfo.ClaaSumfee = check_claa_sunmfee
  918. iteminfo.ClabAmt = check_clab_amt
  919. iteminfo.OthAmt = check_other_amt
  920. iteminfoStructs = append(iteminfoStructs, iteminfo)
  921. }
  922. if laboratoryCostTotal != 0 {
  923. iteminfo.MedChrgitm = "04"
  924. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  925. iteminfo.Amt = laboratoryCostTotal
  926. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  927. iteminfo.ClabAmt = laboratory_clab_amt
  928. iteminfo.OthAmt = laboratory_other_amt
  929. iteminfoStructs = append(iteminfoStructs, iteminfo)
  930. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  931. }
  932. if treatCostTotal != 0 {
  933. iteminfo.MedChrgitm = "05"
  934. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  935. iteminfo.Amt = treatCostTotal
  936. iteminfo.ClaaSumfee = treat_claa_sunmfee
  937. iteminfo.ClabAmt = treat_clab_amt
  938. iteminfo.OthAmt = treat_other_amt
  939. iteminfoStructs = append(iteminfoStructs, iteminfo)
  940. //(struct4101.IteminfoStruct, iteminfo)
  941. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  942. }
  943. if operationCostTotal != 0 {
  944. iteminfo.MedChrgitm = "06"
  945. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  946. iteminfo.Amt = operationCostTotal
  947. iteminfo.ClaaSumfee = operation_claa_sunmfee
  948. iteminfo.ClabAmt = operation_clab_amt
  949. iteminfo.OthAmt = operation_other_amt
  950. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  951. iteminfoStructs = append(iteminfoStructs, iteminfo)
  952. }
  953. if materialCostTotal != 0 {
  954. iteminfo.MedChrgitm = "08"
  955. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  956. iteminfo.Amt = materialCostTotal
  957. iteminfo.ClaaSumfee = material_claa_sunmfee
  958. iteminfo.ClabAmt = material_clab_amt
  959. iteminfo.OthAmt = material_other_amt
  960. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  961. iteminfoStructs = append(iteminfoStructs, iteminfo)
  962. }
  963. if westernMedicineCostTotal != 0 {
  964. iteminfo.MedChrgitm = "09"
  965. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  966. iteminfo.Amt = westernMedicineCostTotal
  967. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  968. iteminfo.ClabAmt = westernMedicine_clab_amt
  969. iteminfo.OthAmt = westernMedicine_other_amt
  970. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  971. iteminfoStructs = append(iteminfoStructs, iteminfo)
  972. }
  973. if chineseTraditionalMedicineCostTotal != 0 {
  974. iteminfo.MedChrgitm = "11"
  975. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  976. iteminfo.Amt = westernMedicineCostTotal
  977. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  978. iteminfo.ClabAmt = westernMedicine_clab_amt
  979. iteminfo.OthAmt = westernMedicine_other_amt
  980. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  981. iteminfoStructs = append(iteminfoStructs, iteminfo)
  982. }
  983. if otherCostTotal != 0 {
  984. iteminfo.MedChrgitm = "14"
  985. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  986. iteminfo.Amt = otherCostTotal
  987. iteminfo.ClaaSumfee = other_claa_sunmfee
  988. iteminfo.ClabAmt = other_clab_amt
  989. iteminfo.OthAmt = other_other_amt
  990. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  991. iteminfoStructs = append(iteminfoStructs, iteminfo)
  992. }
  993. struct4101.IteminfoStruct = iteminfoStructs
  994. struct4101.Ntly = "中国"
  995. struct4101.AdmCaty = "A03.06"
  996. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  997. fmt.Println(result)
  998. var dat map[string]interface{}
  999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1000. fmt.Println(dat)
  1001. } else {
  1002. fmt.Println(err)
  1003. }
  1004. userJSONBytes, _ := json.Marshal(dat)
  1005. var res ResultSeventeen
  1006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1007. utils.ErrorLog("解析失败:%v", err)
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1009. return
  1010. }
  1011. if res.Infcode != 0 {
  1012. c.ServeSuccessJSON(map[string]interface{}{
  1013. "failed_code": -10,
  1014. "msg": res.ErrMsg,
  1015. })
  1016. return
  1017. } else {
  1018. order.FaPiaoNumber = zero
  1019. order.FaPiaoCode = last_order.FaPiaoCode
  1020. service.UpdateOrder(order)
  1021. hisFundSettleListResult := &models.HisFundSettleListResult{
  1022. Number: res.Output.SetlListId,
  1023. Status: 1,
  1024. Ctime: time.Now().Unix(),
  1025. Mtime: time.Now().Unix(),
  1026. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1027. IsUpload: 1,
  1028. OrderId: order_id,
  1029. }
  1030. service.CreateUploadRecord(hisFundSettleListResult)
  1031. c.ServeSuccessJSON(map[string]interface{}{
  1032. "msg": "上传成功",
  1033. "result": hisFundSettleListResult,
  1034. })
  1035. return
  1036. }
  1037. }
  1038. func (c *HisApiController) GetSettleListHospital() {
  1039. order_id, _ := c.GetInt64("order_id")
  1040. admin_user_id, _ := c.GetInt64("admin_user_id")
  1041. order, _ := service.GetHisOrderByIDTwo(order_id)
  1042. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1043. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1044. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1045. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1046. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1047. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1048. if order.ID == 0 {
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1050. return
  1051. }
  1052. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1053. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1054. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1055. fmt.Println(count)
  1056. var zero string
  1057. number := count + 1
  1058. if number >= 1000 {
  1059. zero = "0000" + strconv.FormatInt(number, 10)
  1060. } else if number >= 10000 {
  1061. zero = "000" + strconv.FormatInt(number, 10)
  1062. } else if number >= 100000 {
  1063. zero = "00" + strconv.FormatInt(number, 10)
  1064. } else if number >= 1000000 {
  1065. zero = "0" + strconv.FormatInt(number, 10)
  1066. } else {
  1067. zero = strconv.FormatInt(number, 10)
  1068. }
  1069. fmt.Println(zero)
  1070. struct4101 := service.Struct4101{
  1071. PsnNo: order.PsnNo,
  1072. MdtrtId: order.MdtrtId,
  1073. SetlId: order.SetlId,
  1074. PsnName: order.PsnName,
  1075. Gend: order.Gend,
  1076. Brdy: his.Brdy,
  1077. Age: int64(order.Age),
  1078. Naty: order.Naty,
  1079. PatnCertType: "01",
  1080. Certno: order.Certno,
  1081. Prfs: "90",
  1082. ConerName: roles[0].UserName,
  1083. PatnRlts: "99",
  1084. ConerAddr: miConfig.OrgName,
  1085. ConerTel: admin.Mobile,
  1086. HiType: order.Insutype,
  1087. Insuplc: miConfig.InsuplcAdmdvs,
  1088. MaindiagFlag: "1",
  1089. BillCode: last_order.FaPiaoCode,
  1090. BillNo: zero,
  1091. BizSn: order.Number,
  1092. PsnSelfPay: order.PsnPartAmt,
  1093. PsnOwnPay: order.PsnPartAmt,
  1094. AcctPay: order.AcctPay,
  1095. PsnCashpay: order.PsnCashPay,
  1096. HiPaymtd: "1",
  1097. Hsorg: miConfig.InsuplcAdmdvs,
  1098. HsorgOpter: miConfig.InsuplcAdmdvs,
  1099. MedinsFillPsn: curRoles.UserName,
  1100. MedinsFillDept: depart.Name,
  1101. IptMedType: "2",
  1102. }
  1103. struct4101.SetlBegnDate = order.SetlTime
  1104. struct4101.SetlEndDate = order.SetlTime
  1105. var rf []CustomFundPay
  1106. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1107. var tempFunPays []service.CustomStruct
  1108. for _, item := range rf {
  1109. var tempFunPay service.CustomStruct
  1110. tempFunPay.FundPayamt = item.FundPayamt
  1111. tempFunPay.FundPayType = item.FundPayType
  1112. tempFunPays = append(tempFunPays, tempFunPay)
  1113. }
  1114. struct4101.CustomStruct = tempFunPays
  1115. var tempDiaginfos []service.DiaginfoStructTwo
  1116. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1117. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1118. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1119. var config []*models.HisXtDiagnoseConfig
  1120. for _, item := range diagnosis_ids {
  1121. id, _ := strconv.ParseInt(item, 10, 64)
  1122. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1123. config = append(config, &diagnosisConfig)
  1124. }
  1125. for index, item := range config {
  1126. if index == 0 {
  1127. var tempDiaginfo service.DiaginfoStructTwo
  1128. tempDiaginfo.DiagCode = item.CountryCode
  1129. tempDiaginfo.DiagName = item.CountryContentName
  1130. tempDiaginfo.DiagType = "1"
  1131. tempDiaginfo.MaindiagFlag = "1"
  1132. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1133. } else {
  1134. var tempDiaginfo service.DiaginfoStructTwo
  1135. tempDiaginfo.DiagCode = item.CountryCode
  1136. tempDiaginfo.DiagName = item.CountryContentName
  1137. tempDiaginfo.DiagType = "2"
  1138. tempDiaginfo.MaindiagFlag = "0"
  1139. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1140. }
  1141. }
  1142. struct4101.Diseinfo = tempDiaginfos
  1143. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1144. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1145. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1146. tempOpspdiseinfo2.OprnOprtCode = ""
  1147. tempOpspdiseinfo2.OprnOprtName = ""
  1148. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1149. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1150. var iteminfo service.IteminfoStruct
  1151. var bedCostTotal float64 = 0 //床位总费
  1152. var bedCostSelfTotal float64 = 0 //床位自费
  1153. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1154. var operationCostTotal float64 = 0 //手术费
  1155. var operationCostSelfTotal float64 = 0 //手术费
  1156. var operationCostPartSelfTotal float64 = 0 //手术费
  1157. var otherCostTotal float64 = 0 //其他费用
  1158. var otherCostSelfTotal float64 = 0 //其他费用
  1159. var otherCostPartSelfTotal float64 = 0 //其他费用
  1160. var materialCostTotal float64 = 0 //材料费
  1161. var materialCostSelfTotal float64 = 0 //材料费
  1162. var materialCostPartSelfTotal float64 = 0 //材料费
  1163. var westernMedicineCostTotal float64 = 0 //西药费
  1164. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1165. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1166. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1167. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1168. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1169. var checkCostTotal float64 = 0 //检查费
  1170. var checkCostSelfTotal float64 = 0 //检查费
  1171. var checkCostPartSelfTotal float64 = 0 //检查费
  1172. var laboratoryCostTotal float64 = 0 //化验费
  1173. var laboratoryCostSelfTotal float64 = 0 //化验费
  1174. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1175. var treatCostTotal float64 = 0 //治疗费用
  1176. var treatCostSelfTotal float64 = 0 //治疗费用
  1177. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1178. decimal.DivisionPrecision = 2
  1179. var bed_fulamt_ownpay_amt float64 = 0
  1180. var operation_fulamt_ownpay_amt float64 = 0
  1181. var other_fulamt_ownpay_amt float64 = 0
  1182. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1183. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1184. var check_fulamt_ownpay_amt float64 = 0
  1185. var material_fulamt_ownpay_amt float64 = 0
  1186. var laboratory_fulamt_ownpay_amt float64 = 0
  1187. var treat_fulamt_ownpay_amt float64 = 0
  1188. var bed_claa_sunmfee float64 = 0
  1189. var bed_clab_amt float64 = 0
  1190. var bed_other_amt float64 = 0
  1191. var operation_claa_sunmfee float64 = 0
  1192. var operation_clab_amt float64 = 0
  1193. var operation_other_amt float64 = 0
  1194. var other_claa_sunmfee float64 = 0
  1195. var other_clab_amt float64 = 0
  1196. var other_other_amt float64 = 0
  1197. var westernMedicine_claa_sunmfee float64 = 0
  1198. var westernMedicine_clab_amt float64 = 0
  1199. var westernMedicine_other_amt float64 = 0
  1200. var chineseTraditional_claa_sunmfee float64 = 0
  1201. var chineseTraditional_clab_amt float64 = 0
  1202. var chineseTraditional_other_amt float64 = 0
  1203. var check_claa_sunmfee float64 = 0
  1204. var check_clab_amt float64 = 0
  1205. var check_other_amt float64 = 0
  1206. var material_claa_sunmfee float64 = 0
  1207. var material_clab_amt float64 = 0
  1208. var material_other_amt float64 = 0
  1209. var laboratory_claa_sunmfee float64 = 0
  1210. var laboratory_clab_amt float64 = 0
  1211. var laboratory_other_amt float64 = 0
  1212. var treat_claa_sunmfee float64 = 0
  1213. var treat_clab_amt float64 = 0
  1214. var treat_other_amt float64 = 0
  1215. for _, item := range order.HisOrderInfo {
  1216. if item.MedChrgitmType == "01" { //床位费
  1217. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1218. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1219. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1220. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1221. if item.ChrgitmLv == "1" {
  1222. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1223. }
  1224. if item.ChrgitmLv == "2" {
  1225. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1226. }
  1227. if item.ChrgitmLv == "3" {
  1228. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1229. }
  1230. }
  1231. if item.MedChrgitmType == "03" { //检查费
  1232. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1233. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1234. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1235. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1236. if item.ChrgitmLv == "1" {
  1237. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1238. }
  1239. if item.ChrgitmLv == "2" {
  1240. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1241. }
  1242. if item.ChrgitmLv == "3" {
  1243. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1244. }
  1245. }
  1246. if item.MedChrgitmType == "04" { //化验费
  1247. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1248. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1249. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1250. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1251. if item.ChrgitmLv == "1" {
  1252. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1253. }
  1254. if item.ChrgitmLv == "2" {
  1255. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1256. }
  1257. if item.ChrgitmLv == "3" {
  1258. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1259. }
  1260. }
  1261. if item.MedChrgitmType == "05" { //治疗费
  1262. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1263. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1264. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1265. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1266. if item.ChrgitmLv == "1" {
  1267. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1268. }
  1269. if item.ChrgitmLv == "2" {
  1270. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1271. }
  1272. if item.ChrgitmLv == "3" {
  1273. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1274. }
  1275. }
  1276. if item.MedChrgitmType == "06" { //手术费
  1277. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1278. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1279. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1280. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1281. if item.ChrgitmLv == "1" {
  1282. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1283. }
  1284. if item.ChrgitmLv == "2" {
  1285. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1286. }
  1287. if item.ChrgitmLv == "3" {
  1288. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1289. }
  1290. }
  1291. if item.MedChrgitmType == "08" { //材料费
  1292. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1293. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1294. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1295. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1296. if item.ChrgitmLv == "1" {
  1297. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1298. }
  1299. if item.ChrgitmLv == "2" {
  1300. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1301. }
  1302. if item.ChrgitmLv == "3" {
  1303. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1304. }
  1305. }
  1306. if item.MedChrgitmType == "09" { //西药费
  1307. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1308. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1309. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1310. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1311. if item.ChrgitmLv == "1" {
  1312. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1313. }
  1314. if item.ChrgitmLv == "2" {
  1315. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1316. }
  1317. if item.ChrgitmLv == "3" {
  1318. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1319. }
  1320. }
  1321. if item.MedChrgitmType == "11" { //中成费
  1322. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1323. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1324. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1325. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1326. if item.ChrgitmLv == "1" {
  1327. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1328. }
  1329. if item.ChrgitmLv == "2" {
  1330. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1331. }
  1332. if item.ChrgitmLv == "3" {
  1333. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1334. }
  1335. }
  1336. if item.MedChrgitmType == "14" { //其他费
  1337. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1338. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1339. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1340. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1341. if item.ChrgitmLv == "1" {
  1342. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1343. }
  1344. if item.ChrgitmLv == "2" {
  1345. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1346. }
  1347. if item.ChrgitmLv == "3" {
  1348. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1349. }
  1350. }
  1351. }
  1352. var iteminfoStructs []service.IteminfoStruct
  1353. if bedCostTotal != 0 {
  1354. iteminfo.MedChrgitm = "01"
  1355. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1356. iteminfo.Amt = bedCostTotal
  1357. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1358. iteminfo.ClabAmt = bed_clab_amt
  1359. iteminfo.OthAmt = bed_other_amt
  1360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1361. }
  1362. if checkCostTotal != 0 {
  1363. iteminfo.MedChrgitm = "03"
  1364. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1365. iteminfo.Amt = checkCostTotal
  1366. iteminfo.ClaaSumfee = check_claa_sunmfee
  1367. iteminfo.ClabAmt = check_clab_amt
  1368. iteminfo.OthAmt = check_other_amt
  1369. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1370. }
  1371. if laboratoryCostTotal != 0 {
  1372. iteminfo.MedChrgitm = "04"
  1373. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1374. iteminfo.Amt = laboratoryCostTotal
  1375. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1376. iteminfo.ClabAmt = laboratory_clab_amt
  1377. iteminfo.OthAmt = laboratory_other_amt
  1378. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1379. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1380. }
  1381. if treatCostTotal != 0 {
  1382. iteminfo.MedChrgitm = "05"
  1383. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1384. iteminfo.Amt = treatCostTotal
  1385. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1386. iteminfo.ClabAmt = treat_clab_amt
  1387. iteminfo.OthAmt = treat_other_amt
  1388. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1389. //(struct4101.IteminfoStruct, iteminfo)
  1390. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1391. }
  1392. if operationCostTotal != 0 {
  1393. iteminfo.MedChrgitm = "06"
  1394. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1395. iteminfo.Amt = operationCostTotal
  1396. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1397. iteminfo.ClabAmt = operation_clab_amt
  1398. iteminfo.OthAmt = operation_other_amt
  1399. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1400. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1401. }
  1402. if materialCostTotal != 0 {
  1403. iteminfo.MedChrgitm = "08"
  1404. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1405. iteminfo.Amt = materialCostTotal
  1406. iteminfo.ClaaSumfee = material_claa_sunmfee
  1407. iteminfo.ClabAmt = material_clab_amt
  1408. iteminfo.OthAmt = material_other_amt
  1409. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1410. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1411. }
  1412. if westernMedicineCostTotal != 0 {
  1413. iteminfo.MedChrgitm = "09"
  1414. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1415. iteminfo.Amt = westernMedicineCostTotal
  1416. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1417. iteminfo.ClabAmt = westernMedicine_clab_amt
  1418. iteminfo.OthAmt = westernMedicine_other_amt
  1419. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1420. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1421. }
  1422. if chineseTraditionalMedicineCostTotal != 0 {
  1423. iteminfo.MedChrgitm = "11"
  1424. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1425. iteminfo.Amt = westernMedicineCostTotal
  1426. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1427. iteminfo.ClabAmt = westernMedicine_clab_amt
  1428. iteminfo.OthAmt = westernMedicine_other_amt
  1429. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1430. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1431. }
  1432. if otherCostTotal != 0 {
  1433. iteminfo.MedChrgitm = "14"
  1434. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1435. iteminfo.Amt = otherCostTotal
  1436. iteminfo.ClaaSumfee = other_claa_sunmfee
  1437. iteminfo.ClabAmt = other_clab_amt
  1438. iteminfo.OthAmt = other_other_amt
  1439. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1440. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1441. }
  1442. struct4101.IteminfoStruct = iteminfoStructs
  1443. struct4101.Ntly = "中国"
  1444. struct4101.AdmCaty = "A03.06"
  1445. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1446. fmt.Println(result)
  1447. var dat map[string]interface{}
  1448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1449. fmt.Println(dat)
  1450. } else {
  1451. fmt.Println(err)
  1452. }
  1453. userJSONBytes, _ := json.Marshal(dat)
  1454. var res ResultSeventeen
  1455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1456. utils.ErrorLog("解析失败:%v", err)
  1457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1458. return
  1459. }
  1460. if res.Infcode != 0 {
  1461. c.ServeSuccessJSON(map[string]interface{}{
  1462. "failed_code": -10,
  1463. "msg": res.ErrMsg,
  1464. })
  1465. return
  1466. } else {
  1467. order.FaPiaoNumber = zero
  1468. order.FaPiaoCode = last_order.FaPiaoCode
  1469. service.UpdateOrder(order)
  1470. hisFundSettleListResult := &models.HisFundSettleListResult{
  1471. Number: res.Output.SetlListId,
  1472. Status: 1,
  1473. Ctime: time.Now().Unix(),
  1474. Mtime: time.Now().Unix(),
  1475. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1476. IsUpload: 1,
  1477. OrderId: order_id,
  1478. }
  1479. service.CreateUploadRecord(hisFundSettleListResult)
  1480. c.ServeSuccessJSON(map[string]interface{}{
  1481. "msg": "上传成功",
  1482. "result": hisFundSettleListResult,
  1483. })
  1484. return
  1485. }
  1486. }
  1487. func (c *HisApiController) GetBatchSettleList() {
  1488. orders, _ := service.GetAllHisOrder(9504)
  1489. for _, item := range orders {
  1490. order_id := item.ID
  1491. order, _ := service.GetHisOrderByIDTwo(order_id)
  1492. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1493. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1494. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1495. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2100)
  1496. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1497. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1498. if order.ID == 0 {
  1499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1500. return
  1501. }
  1502. if his.BalanceAccountsType == 2 {
  1503. continue
  1504. }
  1505. struct4101 := service.Struct4101{
  1506. PsnNo: order.PsnNo,
  1507. MdtrtId: order.MdtrtId,
  1508. SetlId: order.SetlId,
  1509. PsnName: order.PsnName,
  1510. Gend: order.Gend,
  1511. Brdy: his.Brdy,
  1512. Age: his.Age,
  1513. Naty: order.Naty,
  1514. PatnCertType: "01",
  1515. Certno: order.Certno,
  1516. Prfs: "90",
  1517. ConerName: roles[0].UserName,
  1518. PatnRlts: "99",
  1519. ConerAddr: miConfig.OrgName,
  1520. ConerTel: admin.Mobile,
  1521. HiType: order.Insutype,
  1522. Insuplc: his.InsuplcAdmdvs,
  1523. MaindiagFlag: "1",
  1524. BillCode: order.FaPiaoCode,
  1525. BillNo: order.FaPiaoNumber,
  1526. BizSn: order.Number,
  1527. PsnSelfPay: order.PsnPartAmt,
  1528. PsnOwnPay: order.PsnPartAmt,
  1529. AcctPay: order.AcctPay,
  1530. PsnCashpay: order.PsnCashPay,
  1531. HiPaymtd: "1",
  1532. Hsorg: his.InsuplcAdmdvs,
  1533. HsorgOpter: his.InsuplcAdmdvs,
  1534. MedinsFillPsn: curRoles.UserName,
  1535. MedinsFillDept: depart.Name,
  1536. IptMedType: "2",
  1537. }
  1538. struct4101.SetlBegnDate = order.SetlTime
  1539. struct4101.SetlEndDate = order.SetlTime
  1540. //if order.SettleType == 1 {
  1541. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1542. // dateStr := t.Format("2006-01-02")
  1543. // struct4101.SetlBegnDate = dateStr
  1544. // struct4101.SetlEndDate = dateStr
  1545. //} else {
  1546. // t := time.Unix(int64(order.SettleStartTime), 0)
  1547. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1548. // dateStartStr := t.Format("2006-01-02")
  1549. // dateEndStr := t2.Format("2006-01-02")
  1550. // struct4101.SetlBegnDate = dateStartStr
  1551. // struct4101.SetlEndDate = dateEndStr
  1552. //}
  1553. var rf []CustomFundPay
  1554. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1555. var tempFunPays []service.CustomStruct
  1556. var tempFunPay610100 service.CustomStruct
  1557. for _, item := range rf {
  1558. if item.FundPayType == "610100" {
  1559. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1560. tempFunPay610100.FundPayType = item.FundPayType
  1561. } else {
  1562. var tempFunPay service.CustomStruct
  1563. tempFunPay.FundPayamt = item.FundPayamt
  1564. tempFunPay.FundPayType = item.FundPayType
  1565. tempFunPays = append(tempFunPays, tempFunPay)
  1566. }
  1567. }
  1568. tempFunPays = append(tempFunPays, tempFunPay610100)
  1569. struct4101.CustomStruct = tempFunPays
  1570. var tempDiaginfos []service.DiaginfoStructTwo
  1571. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1572. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1573. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1574. var config []*models.HisXtDiagnoseConfig
  1575. for _, item := range diagnosis_ids {
  1576. id, _ := strconv.ParseInt(item, 10, 64)
  1577. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1578. config = append(config, &diagnosisConfig)
  1579. }
  1580. for index, item := range config {
  1581. if index == 0 {
  1582. var tempDiaginfo service.DiaginfoStructTwo
  1583. tempDiaginfo.DiagCode = item.CountryCode
  1584. tempDiaginfo.DiagName = item.CountryContentName
  1585. tempDiaginfo.DiagType = "1"
  1586. tempDiaginfo.MaindiagFlag = "1"
  1587. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1588. } else {
  1589. var tempDiaginfo service.DiaginfoStructTwo
  1590. tempDiaginfo.DiagCode = item.CountryCode
  1591. tempDiaginfo.DiagName = item.CountryContentName
  1592. tempDiaginfo.DiagType = "2"
  1593. tempDiaginfo.MaindiagFlag = "0"
  1594. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1595. }
  1596. }
  1597. struct4101.Diseinfo = tempDiaginfos
  1598. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1599. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1600. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1601. tempOpspdiseinfo2.OprnOprtCode = ""
  1602. tempOpspdiseinfo2.OprnOprtName = ""
  1603. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1604. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1605. var iteminfo service.IteminfoStruct
  1606. var bedCostTotal float64 = 0 //床位总费
  1607. var bedCostSelfTotal float64 = 0 //床位自费
  1608. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1609. var examineCostTotal float64 = 0 //诊查总费
  1610. var examineCostSelfTotal float64 = 0 //诊查自费
  1611. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1612. var nursingCostTotal float64 = 0 //护理总费
  1613. var nursingCostSelfTotal float64 = 0 //护理自费
  1614. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1615. var chineseMedicineCostTotal float64 = 0 //中成药
  1616. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1617. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1618. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1619. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1620. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1621. var registerCostTotal float64 = 0 //一般诊疗费
  1622. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1623. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1624. var operationCostTotal float64 = 0 //手术费
  1625. var operationCostSelfTotal float64 = 0 //手术费
  1626. var operationCostPartSelfTotal float64 = 0 //手术费
  1627. var otherCostTotal float64 = 0 //其他费用
  1628. var otherCostSelfTotal float64 = 0 //其他费用
  1629. var otherCostPartSelfTotal float64 = 0 //其他费用
  1630. var materialCostTotal float64 = 0 //材料费
  1631. var materialCostSelfTotal float64 = 0 //材料费
  1632. var materialCostPartSelfTotal float64 = 0 //材料费
  1633. var westernMedicineCostTotal float64 = 0 //西药费
  1634. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1635. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1636. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1637. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1638. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1639. var checkCostTotal float64 = 0 //检查费
  1640. var checkCostSelfTotal float64 = 0 //检查费
  1641. var checkCostPartSelfTotal float64 = 0 //检查费
  1642. var laboratoryCostTotal float64 = 0 //化验费
  1643. var laboratoryCostSelfTotal float64 = 0 //化验费
  1644. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1645. var treatCostTotal float64 = 0 //治疗费用
  1646. var treatCostSelfTotal float64 = 0 //治疗费用
  1647. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1648. decimal.DivisionPrecision = 2
  1649. var bed_fulamt_ownpay_amt float64 = 0
  1650. var examine_fulamt_ownpay_amt float64 = 0
  1651. var nursing_fulamt_ownpay_amt float64 = 0
  1652. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1653. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1654. var register_fulamt_ownpay_amt float64 = 0
  1655. var operation_fulamt_ownpay_amt float64 = 0
  1656. var other_fulamt_ownpay_amt float64 = 0
  1657. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1658. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1659. var check_fulamt_ownpay_amt float64 = 0
  1660. var material_fulamt_ownpay_amt float64 = 0
  1661. var laboratory_fulamt_ownpay_amt float64 = 0
  1662. var treat_fulamt_ownpay_amt float64 = 0
  1663. var bed_claa_sunmfee float64 = 0
  1664. var bed_clab_amt float64 = 0
  1665. var bed_other_amt float64 = 0
  1666. var examine_claa_sunmfee float64 = 0
  1667. var examine_clab_amt float64 = 0
  1668. var examine_other_amt float64 = 0
  1669. var nursing_claa_sunmfee float64 = 0
  1670. var nursing_clab_amt float64 = 0
  1671. var nursing_other_amt float64 = 0
  1672. var chinese_medicine_claa_sunmfee float64 = 0
  1673. var chinese_medicine_clab_amt float64 = 0
  1674. var chinese_medicine_other_amt float64 = 0
  1675. var commonly_treatment_claa_sunmfee float64 = 0
  1676. var commonly_treatment_clab_amt float64 = 0
  1677. var commonly_treatment_other_amt float64 = 0
  1678. var operation_claa_sunmfee float64 = 0
  1679. var operation_clab_amt float64 = 0
  1680. var operation_other_amt float64 = 0
  1681. var other_claa_sunmfee float64 = 0
  1682. var other_clab_amt float64 = 0
  1683. var other_other_amt float64 = 0
  1684. var westernMedicine_claa_sunmfee float64 = 0
  1685. var westernMedicine_clab_amt float64 = 0
  1686. var westernMedicine_other_amt float64 = 0
  1687. var chineseTraditional_claa_sunmfee float64 = 0
  1688. var chineseTraditional_clab_amt float64 = 0
  1689. var chineseTraditional_other_amt float64 = 0
  1690. var check_claa_sunmfee float64 = 0
  1691. var check_clab_amt float64 = 0
  1692. var check_other_amt float64 = 0
  1693. var material_claa_sunmfee float64 = 0
  1694. var material_clab_amt float64 = 0
  1695. var material_other_amt float64 = 0
  1696. var laboratory_claa_sunmfee float64 = 0
  1697. var laboratory_clab_amt float64 = 0
  1698. var laboratory_other_amt float64 = 0
  1699. var treat_claa_sunmfee float64 = 0
  1700. var treat_clab_amt float64 = 0
  1701. var treat_other_amt float64 = 0
  1702. var register_claa_sunmfee float64 = 0
  1703. var register_clab_amt float64 = 0
  1704. var register_other_amt float64 = 0
  1705. for _, item := range order.HisOrderInfo {
  1706. if item.MedChrgitmType == "01" { //床位费
  1707. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1708. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1709. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1710. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1711. if item.ChrgitmLv == "1" {
  1712. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1713. }
  1714. if item.ChrgitmLv == "2" {
  1715. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1716. }
  1717. if item.ChrgitmLv == "3" {
  1718. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1719. }
  1720. }
  1721. if item.MedChrgitmType == "02" { //诊查
  1722. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1723. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1724. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1725. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1726. if item.ChrgitmLv == "1" {
  1727. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1728. }
  1729. if item.ChrgitmLv == "2" {
  1730. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1731. }
  1732. if item.ChrgitmLv == "3" {
  1733. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1734. }
  1735. }
  1736. if item.MedChrgitmType == "03" { //检查费
  1737. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1738. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1739. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1740. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1741. if item.ChrgitmLv == "1" {
  1742. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1743. }
  1744. if item.ChrgitmLv == "2" {
  1745. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1746. }
  1747. if item.ChrgitmLv == "3" {
  1748. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1749. }
  1750. }
  1751. if item.MedChrgitmType == "04" { //化验费
  1752. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1753. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1754. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1755. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1756. if item.ChrgitmLv == "1" {
  1757. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1758. }
  1759. if item.ChrgitmLv == "2" {
  1760. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1761. }
  1762. if item.ChrgitmLv == "3" {
  1763. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1764. }
  1765. }
  1766. if item.MedChrgitmType == "05" { //治疗费
  1767. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1768. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1769. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1770. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1771. if item.ChrgitmLv == "1" {
  1772. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1773. }
  1774. if item.ChrgitmLv == "2" {
  1775. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1776. }
  1777. if item.ChrgitmLv == "3" {
  1778. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1779. }
  1780. }
  1781. if item.MedChrgitmType == "06" { //手术费
  1782. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1783. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1784. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1785. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1786. if item.ChrgitmLv == "1" {
  1787. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1788. }
  1789. if item.ChrgitmLv == "2" {
  1790. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1791. }
  1792. if item.ChrgitmLv == "3" {
  1793. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1794. }
  1795. }
  1796. if item.MedChrgitmType == "07" { //手术费
  1797. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1798. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1799. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1800. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1801. if item.ChrgitmLv == "1" {
  1802. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1803. }
  1804. if item.ChrgitmLv == "2" {
  1805. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1806. }
  1807. if item.ChrgitmLv == "3" {
  1808. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1809. }
  1810. }
  1811. if item.MedChrgitmType == "08" { //材料费
  1812. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1813. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1814. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1815. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1816. if item.ChrgitmLv == "1" {
  1817. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1818. }
  1819. if item.ChrgitmLv == "2" {
  1820. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1821. }
  1822. if item.ChrgitmLv == "3" {
  1823. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1824. }
  1825. }
  1826. if item.MedChrgitmType == "09" { //西药费
  1827. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1828. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1829. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1830. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1831. if item.ChrgitmLv == "1" {
  1832. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1833. }
  1834. if item.ChrgitmLv == "2" {
  1835. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1836. }
  1837. if item.ChrgitmLv == "3" {
  1838. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1839. }
  1840. }
  1841. if item.MedChrgitmType == "10" { //中药饮片
  1842. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1843. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1844. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1845. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1846. if item.ChrgitmLv == "1" {
  1847. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1848. }
  1849. if item.ChrgitmLv == "2" {
  1850. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1851. }
  1852. if item.ChrgitmLv == "3" {
  1853. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1854. }
  1855. }
  1856. if item.MedChrgitmType == "11" { //中成费
  1857. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1858. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1859. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1860. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1861. if item.ChrgitmLv == "1" {
  1862. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1863. }
  1864. if item.ChrgitmLv == "2" {
  1865. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1866. }
  1867. if item.ChrgitmLv == "3" {
  1868. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1869. }
  1870. }
  1871. if item.MedChrgitmType == "12" { //中成费
  1872. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1873. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1874. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1875. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1876. if item.ChrgitmLv == "1" {
  1877. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1878. }
  1879. if item.ChrgitmLv == "2" {
  1880. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1881. }
  1882. if item.ChrgitmLv == "3" {
  1883. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1884. }
  1885. }
  1886. if item.MedChrgitmType == "13" { //中成费
  1887. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1888. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1889. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1890. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1891. if item.ChrgitmLv == "1" {
  1892. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1893. }
  1894. if item.ChrgitmLv == "2" {
  1895. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1896. }
  1897. if item.ChrgitmLv == "3" {
  1898. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1899. }
  1900. }
  1901. if item.MedChrgitmType == "14" { //其他费
  1902. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1903. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1904. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1905. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1906. if item.ChrgitmLv == "1" {
  1907. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1908. }
  1909. if item.ChrgitmLv == "2" {
  1910. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1911. }
  1912. if item.ChrgitmLv == "3" {
  1913. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1914. }
  1915. }
  1916. }
  1917. var iteminfoStructs []service.IteminfoStruct
  1918. if bedCostTotal != 0 {
  1919. iteminfo.MedChrgitm = "01"
  1920. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1921. iteminfo.Amt = bedCostTotal
  1922. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1923. iteminfo.ClabAmt = bed_clab_amt
  1924. iteminfo.OthAmt = bed_other_amt
  1925. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1926. }
  1927. if examineCostTotal != 0 {
  1928. iteminfo.MedChrgitm = "02"
  1929. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1930. iteminfo.Amt = examineCostTotal
  1931. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1932. iteminfo.ClabAmt = examine_clab_amt
  1933. iteminfo.OthAmt = examine_other_amt
  1934. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1935. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1936. }
  1937. if checkCostTotal != 0 {
  1938. iteminfo.MedChrgitm = "03"
  1939. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1940. iteminfo.Amt = checkCostTotal
  1941. iteminfo.ClaaSumfee = check_claa_sunmfee
  1942. iteminfo.ClabAmt = check_clab_amt
  1943. iteminfo.OthAmt = check_other_amt
  1944. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1945. }
  1946. if laboratoryCostTotal != 0 {
  1947. iteminfo.MedChrgitm = "04"
  1948. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1949. iteminfo.Amt = laboratoryCostTotal
  1950. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1951. iteminfo.ClabAmt = laboratory_clab_amt
  1952. iteminfo.OthAmt = laboratory_other_amt
  1953. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1954. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1955. }
  1956. if treatCostTotal != 0 {
  1957. iteminfo.MedChrgitm = "05"
  1958. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1959. iteminfo.Amt = treatCostTotal
  1960. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1961. iteminfo.ClabAmt = treat_clab_amt
  1962. iteminfo.OthAmt = treat_other_amt
  1963. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1964. //(struct4101.IteminfoStruct, iteminfo)
  1965. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1966. }
  1967. if operationCostTotal != 0 {
  1968. iteminfo.MedChrgitm = "06"
  1969. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1970. iteminfo.Amt = operationCostTotal
  1971. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1972. iteminfo.ClabAmt = operation_clab_amt
  1973. iteminfo.OthAmt = operation_other_amt
  1974. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1975. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1976. }
  1977. if nursingCostTotal != 0 {
  1978. iteminfo.MedChrgitm = "07"
  1979. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1980. iteminfo.Amt = nursingCostTotal
  1981. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1982. iteminfo.ClabAmt = nursing_clab_amt
  1983. iteminfo.OthAmt = nursing_other_amt
  1984. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1985. }
  1986. if materialCostTotal != 0 {
  1987. iteminfo.MedChrgitm = "08"
  1988. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1989. iteminfo.Amt = materialCostTotal
  1990. iteminfo.ClaaSumfee = material_claa_sunmfee
  1991. iteminfo.ClabAmt = material_clab_amt
  1992. iteminfo.OthAmt = material_other_amt
  1993. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1994. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1995. }
  1996. if westernMedicineCostTotal != 0 {
  1997. iteminfo.MedChrgitm = "09"
  1998. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1999. iteminfo.Amt = westernMedicineCostTotal
  2000. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2001. iteminfo.ClabAmt = westernMedicine_clab_amt
  2002. iteminfo.OthAmt = westernMedicine_other_amt
  2003. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2004. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2005. }
  2006. if chineseMedicineCostTotal != 0 {
  2007. iteminfo.MedChrgitm = "10"
  2008. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2009. iteminfo.Amt = chineseMedicineCostTotal
  2010. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2011. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2012. iteminfo.OthAmt = chinese_medicine_other_amt
  2013. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2014. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2015. }
  2016. if chineseTraditionalMedicineCostTotal != 0 {
  2017. iteminfo.MedChrgitm = "11"
  2018. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2019. iteminfo.Amt = westernMedicineCostTotal
  2020. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2021. iteminfo.ClabAmt = westernMedicine_clab_amt
  2022. iteminfo.OthAmt = westernMedicine_other_amt
  2023. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2024. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2025. }
  2026. if commonlyTreatmentCostTotal != 0 {
  2027. iteminfo.MedChrgitm = "12"
  2028. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2029. iteminfo.Amt = commonlyTreatmentCostTotal
  2030. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2031. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2032. iteminfo.OthAmt = commonly_treatment_other_amt
  2033. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2034. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2035. }
  2036. if registerCostTotal != 0 {
  2037. iteminfo.MedChrgitm = "13"
  2038. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2039. iteminfo.Amt = registerCostTotal
  2040. iteminfo.ClaaSumfee = register_claa_sunmfee
  2041. iteminfo.ClabAmt = register_clab_amt
  2042. iteminfo.OthAmt = register_other_amt
  2043. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2044. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2045. }
  2046. if otherCostTotal != 0 {
  2047. iteminfo.MedChrgitm = "14"
  2048. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2049. iteminfo.Amt = otherCostTotal
  2050. iteminfo.ClaaSumfee = other_claa_sunmfee
  2051. iteminfo.ClabAmt = other_clab_amt
  2052. iteminfo.OthAmt = other_other_amt
  2053. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2054. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2055. }
  2056. struct4101.IteminfoStruct = iteminfoStructs
  2057. struct4101.Ntly = "中国"
  2058. struct4101.AdmCaty = "A03.06"
  2059. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2060. fmt.Println(result)
  2061. var dat map[string]interface{}
  2062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2063. fmt.Println(dat)
  2064. } else {
  2065. fmt.Println(err)
  2066. }
  2067. userJSONBytes, _ := json.Marshal(dat)
  2068. var res ResultSeventeen
  2069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2070. utils.ErrorLog("解析失败:%v", err)
  2071. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2072. adminUser := c.GetAdminUserInfo()
  2073. errlog := &models.HisOrderError{
  2074. UserOrgId: adminUser.CurrentOrgId,
  2075. Ctime: time.Now().Unix(),
  2076. Mtime: time.Now().Unix(),
  2077. ErrMsg: res.ErrMsg + "解析失败",
  2078. Status: 1,
  2079. PatientId: order_id,
  2080. Stage: 2000,
  2081. }
  2082. service.CreateErrMsgLog(errlog)
  2083. continue
  2084. }
  2085. if res.Infcode != 0 {
  2086. adminUser := c.GetAdminUserInfo()
  2087. errlog := &models.HisOrderError{
  2088. UserOrgId: adminUser.CurrentOrgId,
  2089. Ctime: time.Now().Unix(),
  2090. Mtime: time.Now().Unix(),
  2091. ErrMsg: res.ErrMsg,
  2092. Status: 1,
  2093. PatientId: order_id,
  2094. Stage: 9504,
  2095. }
  2096. service.CreateErrMsgLog(errlog)
  2097. continue
  2098. } else {
  2099. hisFundSettleListResult := &models.HisFundSettleListResult{
  2100. Number: res.Output.SetlListId,
  2101. Status: 1,
  2102. Ctime: time.Now().Unix(),
  2103. Mtime: time.Now().Unix(),
  2104. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2105. IsUpload: 1,
  2106. OrderId: order_id,
  2107. }
  2108. service.CreateUploadRecord(hisFundSettleListResult)
  2109. continue
  2110. }
  2111. }
  2112. }
  2113. func (c *HisApiController) GetOrgInfo() {
  2114. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2115. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2116. }
  2117. func (c *HisApiController) GetHisPatientInfo() {
  2118. medical_insurance_card := c.GetString("medical_insurance_card")
  2119. id_card_type, _ := c.GetInt64("id_card_type")
  2120. id_card := c.GetString("id_card")
  2121. adminInfo := c.GetAdminUserInfo()
  2122. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2123. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2124. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2125. IdCardNo := ""
  2126. if id_card_type == 1 {
  2127. IdCardNo = medical_insurance_card
  2128. } else if id_card_type == 2 {
  2129. IdCardNo = id_card
  2130. }
  2131. if config.IsOpen == 1 {
  2132. 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
  2133. resp, requestErr := http.Get(api)
  2134. if requestErr != nil {
  2135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2136. return
  2137. }
  2138. defer resp.Body.Close()
  2139. body, ioErr := ioutil.ReadAll(resp.Body)
  2140. if ioErr != nil {
  2141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2143. return
  2144. }
  2145. var respJSON map[string]interface{}
  2146. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2149. return
  2150. }
  2151. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2152. userJSONBytes, _ := json.Marshal(userJSON)
  2153. var res ResultTwo
  2154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2155. utils.ErrorLog("解析失败:%v", err)
  2156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2157. return
  2158. }
  2159. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2160. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2161. infoStr := string(Iinfos)
  2162. idetinfoStr := string(Idetinfos)
  2163. if res.Infcode == 0 {
  2164. his := models.VMHisPatient{
  2165. Status: 1,
  2166. Ctime: time.Now().Unix(),
  2167. Mtime: time.Now().Unix(),
  2168. PsnNo: res.Output.Baseinfo.PsnNo,
  2169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2170. Certno: res.Output.Baseinfo.Certno,
  2171. PsnName: res.Output.Baseinfo.PsnName,
  2172. Gend: res.Output.Baseinfo.Gend,
  2173. Naty: res.Output.Baseinfo.Naty,
  2174. Brdy: res.Output.Baseinfo.Brdy,
  2175. Age: res.Output.Baseinfo.Age,
  2176. Iinfo: infoStr,
  2177. Idetinfo: idetinfoStr,
  2178. UserOrgId: adminInfo.CurrentOrgId,
  2179. IsReturn: 1,
  2180. IdCardType: id_card_type,
  2181. }
  2182. c.ServeSuccessJSON(map[string]interface{}{
  2183. "info": his,
  2184. })
  2185. } else {
  2186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2187. return
  2188. }
  2189. }
  2190. }
  2191. //func GetBasBaseInfo() (jsonStr string, err error) {
  2192. //
  2193. // handle := syscall.NewLazyDLL("SSCard.dll")
  2194. // add := handle.NewProc("ReadCardBas")
  2195. // str := make([]byte, 1024)
  2196. // str1 := make([]byte, 1024)
  2197. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2198. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2199. //
  2200. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2201. //
  2202. // fmt.Println("> Add(4,5)的结果为:", ret)
  2203. // handle.Release()
  2204. //
  2205. // return "", nil
  2206. //
  2207. //}
  2208. //func GetQRBaseInfo() (jsonStr string, err error) {
  2209. // handle := syscall.LoadDLL("SSCard.dll")
  2210. // ReadCardBas := handle.FindProc("GetQRBase")
  2211. //
  2212. // str := make([]byte, 256)
  2213. // str1 := make([]byte, 256)
  2214. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2215. //
  2216. // fmt.Println(string(str))
  2217. // fmt.Println(r)
  2218. // return string(str), nil
  2219. //}
  2220. //func CardInit() int {
  2221. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2222. // add := DllTestDef.MustFindProc("Init")
  2223. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2224. // if err != nil {
  2225. // fmt.Println("SSCard的运算结果为:", ret)
  2226. // }
  2227. // result := int(ret)
  2228. // return result
  2229. //}
  2230. //func CardInit() int {
  2231. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2232. // if err != nil {
  2233. // fmt.Println("SSCard的运算结果为:", ret)
  2234. // }
  2235. // fmt.Println(err)
  2236. // result := int(ret)
  2237. // return result
  2238. //}
  2239. func IntPtr(n int) uintptr {
  2240. return uintptr(n)
  2241. }
  2242. func StrPtr(s string) uintptr {
  2243. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2244. }
  2245. type Result2001 struct {
  2246. Cainfo interface{} `json:"cainfo"`
  2247. ErrMsg string `json:"err_msg"`
  2248. InfRefmsgid string `json:"inf_refmsgid"`
  2249. Infcode int64 `json:"infcode"`
  2250. Output struct {
  2251. Trtinfo struct {
  2252. PsnNo string `json:"psn_no"`
  2253. TrtChkType string `json:"trt_chk_type"`
  2254. FundPayType string `json:"fund_pay_type"`
  2255. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2256. Begndate string `json:"begndate"`
  2257. Enddate string `json:"enddate"`
  2258. TrtChkRslt string `json:"trt_chk_rslt"`
  2259. } `json:"trtinfo"`
  2260. } `json:"output"`
  2261. RefmsgTime string `json:"refmsg_time"`
  2262. RespondTime string `json:"respond_time"`
  2263. Signtype interface{} `json:"signtype"`
  2264. WarnMsg interface{} `json:"warn_msg"`
  2265. }
  2266. type Result2001Org10265 struct {
  2267. Cainfo interface{} `json:"cainfo"`
  2268. ErrMsg string `json:"err_msg"`
  2269. InfRefmsgid string `json:"inf_refmsgid"`
  2270. Infcode string `json:"infcode"`
  2271. Output struct {
  2272. Trtinfo struct {
  2273. PsnNo string `json:"psn_no"`
  2274. TrtChkType string `json:"trt_chk_type"`
  2275. FundPayType string `json:"fund_pay_type"`
  2276. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2277. Begndate string `json:"begndate"`
  2278. Enddate string `json:"enddate"`
  2279. TrtChkRslt string `json:"trt_chk_rslt"`
  2280. } `json:"trtinfo"`
  2281. } `json:"output"`
  2282. RefmsgTime string `json:"refmsg_time"`
  2283. RespondTime string `json:"respond_time"`
  2284. Signtype interface{} `json:"signtype"`
  2285. WarnMsg interface{} `json:"warn_msg"`
  2286. }
  2287. type ResultTwo struct {
  2288. ErrMsg string `json:"err_msg"`
  2289. InfRefmsgid string `json:"inf_refmsgid"`
  2290. Infcode int64 `json:"infcode"`
  2291. Output struct {
  2292. Baseinfo struct {
  2293. Age float64 `json:"age"`
  2294. Brdy string `json:"brdy"`
  2295. Certno string `json:"certno"`
  2296. Gend string `json:"gend"`
  2297. Naty string `json:"naty"`
  2298. PsnCertType string `json:"psn_cert_type"`
  2299. PsnName string `json:"psn_name"`
  2300. PsnNo string `json:"psn_no"`
  2301. } `json:"baseinfo"`
  2302. Idetinfo []interface{} `json:"idetinfo"`
  2303. Iinfo []struct {
  2304. Balc float64 `json:"balc"`
  2305. CvlservFlag string `json:"cvlserv_flag"`
  2306. EmpName string `json:"emp_name"`
  2307. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2308. Insutype string `json:"insutype"`
  2309. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2310. PausInsuDate string `json:"paus_insu_date"`
  2311. PsnInsuDate string `json:"psn_insu_date"`
  2312. PsnInsuStas string `json:"psn_insu_stas"`
  2313. PsnType string `json:"psn_type"`
  2314. } `json:"insuinfo"`
  2315. } `json:"output"`
  2316. RefmsgTime string `json:"refmsg_time"`
  2317. RespondTime string `json:"respond_time"`
  2318. Signtype interface{} `json:"signtype"`
  2319. WarnInfo interface{} `json:"warn_info"`
  2320. }
  2321. type ResultTwo10265 struct {
  2322. ErrMsg string `json:"err_msg"`
  2323. InfRefmsgid string `json:"inf_refmsgid"`
  2324. Infcode string `json:"infcode"`
  2325. Output struct {
  2326. Baseinfo struct {
  2327. Age float64 `json:"age"`
  2328. Brdy string `json:"brdy"`
  2329. Certno string `json:"certno"`
  2330. Gend string `json:"gend"`
  2331. Naty string `json:"naty"`
  2332. PsnCertType string `json:"psn_cert_type"`
  2333. PsnName string `json:"psn_name"`
  2334. PsnNo string `json:"psn_no"`
  2335. } `json:"baseinfo"`
  2336. Idetinfo []interface{} `json:"idetinfo"`
  2337. Iinfo []struct {
  2338. Balc float64 `json:"balc"`
  2339. CvlservFlag string `json:"cvlserv_flag"`
  2340. EmpName string `json:"emp_name"`
  2341. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2342. Insutype string `json:"insutype"`
  2343. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2344. PausInsuDate string `json:"paus_insu_date"`
  2345. PsnInsuDate string `json:"psn_insu_date"`
  2346. PsnInsuStas string `json:"psn_insu_stas"`
  2347. PsnType string `json:"psn_type"`
  2348. } `json:"insuinfo"`
  2349. } `json:"output"`
  2350. RefmsgTime string `json:"refmsg_time"`
  2351. RespondTime string `json:"respond_time"`
  2352. Signtype interface{} `json:"signtype"`
  2353. WarnInfo interface{} `json:"warn_info"`
  2354. }
  2355. type ResultThree struct {
  2356. Cainfo interface{} `json:"cainfo"`
  2357. ErrMsg string `json:"err_msg"`
  2358. InfRefmsgid string `json:"inf_refmsgid"`
  2359. Infcode int64 `json:"infcode"`
  2360. Output struct {
  2361. Data struct {
  2362. IptOtpNo string `json:"ipt_otp_no"`
  2363. MdtrtID string `json:"mdtrt_id"`
  2364. PsnNo string `json:"psn_no"`
  2365. } `json:"data"`
  2366. } `json:"output"`
  2367. RefmsgTime string `json:"refmsg_time"`
  2368. RespondTime string `json:"respond_time"`
  2369. Signtype interface{} `json:"signtype"`
  2370. WarnMsg interface{} `json:"warn_msg"`
  2371. }
  2372. type ResultThree10265 struct {
  2373. Cainfo interface{} `json:"cainfo"`
  2374. ErrMsg string `json:"err_msg"`
  2375. InfRefmsgid string `json:"inf_refmsgid"`
  2376. Infcode string `json:"infcode"`
  2377. Output struct {
  2378. Data struct {
  2379. IptOtpNo string `json:"ipt_otp_no"`
  2380. MdtrtID string `json:"mdtrt_id"`
  2381. PsnNo string `json:"psn_no"`
  2382. } `json:"data"`
  2383. } `json:"output"`
  2384. RefmsgTime string `json:"refmsg_time"`
  2385. RespondTime string `json:"respond_time"`
  2386. Signtype interface{} `json:"signtype"`
  2387. WarnMsg interface{} `json:"warn_msg"`
  2388. }
  2389. type ResultFour struct {
  2390. Cainfo string `json:"cainfo"`
  2391. ErrMsg string `json:"err_msg"`
  2392. InfRefmsgid string `json:"inf_refmsgid"`
  2393. Infcode int64 `json:"infcode"`
  2394. Output struct {
  2395. Result []struct {
  2396. BasMednFlag string `json:"bas_medn_flag"`
  2397. ChldMedcFlag string `json:"chld_medc_flag"`
  2398. ChrgitmLv string `json:"chrgitm_lv"`
  2399. Cnt float64 `json:"cnt"`
  2400. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2401. DrtReimFlag string `json:"drt_reim_flag"`
  2402. FeedetlSn string `json:"feedetl_sn"`
  2403. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2404. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2405. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2406. ListSpItemFlag string `json:"list_sp_item_flag"`
  2407. LmtUsedFlag string `json:"lmt_used_flag"`
  2408. MedChrgitmType string `json:"med_chrgitm_type"`
  2409. Memo string `json:"memo"`
  2410. OverlmtAmt float64 `json:"overlmt_amt"`
  2411. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2412. Pric float64 `json:"pric"`
  2413. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2414. SelfpayProp float64 `json:"selfpay_prop"`
  2415. } `json:"result"`
  2416. } `json:"output"`
  2417. RefmsgTime string `json:"refmsg_time"`
  2418. RespondTime string `json:"respond_time"`
  2419. Signtype string `json:"signtype"`
  2420. WarnMsg string `json:"warn_msg"`
  2421. }
  2422. type ResultFour10265 struct {
  2423. Cainfo string `json:"cainfo"`
  2424. ErrMsg string `json:"err_msg"`
  2425. InfRefmsgid string `json:"inf_refmsgid"`
  2426. Infcode string `json:"infcode"`
  2427. Output struct {
  2428. Result []struct {
  2429. BasMednFlag string `json:"bas_medn_flag"`
  2430. ChldMedcFlag string `json:"chld_medc_flag"`
  2431. ChrgitmLv string `json:"chrgitm_lv"`
  2432. Cnt float64 `json:"cnt"`
  2433. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2434. DrtReimFlag string `json:"drt_reim_flag"`
  2435. FeedetlSn string `json:"feedetl_sn"`
  2436. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2437. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2438. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2439. ListSpItemFlag string `json:"list_sp_item_flag"`
  2440. LmtUsedFlag string `json:"lmt_used_flag"`
  2441. MedChrgitmType string `json:"med_chrgitm_type"`
  2442. Memo string `json:"memo"`
  2443. OverlmtAmt float64 `json:"overlmt_amt"`
  2444. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2445. Pric float64 `json:"pric"`
  2446. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2447. SelfpayProp float64 `json:"selfpay_prop"`
  2448. } `json:"result"`
  2449. } `json:"output"`
  2450. RefmsgTime string `json:"refmsg_time"`
  2451. RespondTime string `json:"respond_time"`
  2452. Signtype string `json:"signtype"`
  2453. WarnMsg string `json:"warn_msg"`
  2454. }
  2455. type ResultFive struct {
  2456. Balc float64 `json:"balc"`
  2457. CvlservFlag string `json:"cvlserv_flag"`
  2458. EmpName string `json:"emp_name"`
  2459. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2460. Insutype string `json:"insutype"`
  2461. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2462. PausInsuDate string `json:"paus_insu_date"`
  2463. PsnInsuDate string `json:"psn_insu_date"`
  2464. PsnInsuStas string `json:"psn_insu_stas"`
  2465. PsnType string `json:"psn_type"`
  2466. }
  2467. type ResultSix struct {
  2468. Cainfo interface{} `json:"cainfo"`
  2469. ErrMsg string `json:"err_msg"`
  2470. InfRefmsgid string `json:"inf_refmsgid"`
  2471. Infcode int64 `json:"infcode"`
  2472. Output struct {
  2473. } `json:"output"`
  2474. RefmsgTime string `json:"refmsg_time"`
  2475. RespondTime string `json:"respond_time"`
  2476. Signtype interface{} `json:"signtype"`
  2477. WarnMsg interface{} `json:"warn_msg"`
  2478. }
  2479. type ResultSix10265 struct {
  2480. Cainfo interface{} `json:"cainfo"`
  2481. ErrMsg string `json:"err_msg"`
  2482. InfRefmsgid string `json:"inf_refmsgid"`
  2483. Infcode string `json:"infcode"`
  2484. Output struct {
  2485. } `json:"output"`
  2486. RefmsgTime string `json:"refmsg_time"`
  2487. RespondTime string `json:"respond_time"`
  2488. Signtype interface{} `json:"signtype"`
  2489. WarnMsg interface{} `json:"warn_msg"`
  2490. }
  2491. type ResultSeven struct {
  2492. Cainfo string `json:"cainfo"`
  2493. ErrMsg string `json:"err_msg"`
  2494. InfRefmsgid string `json:"inf_refmsgid"`
  2495. Infcode int64 `json:"infcode"`
  2496. Output struct {
  2497. Setldetail []interface{} `json:"setldetail"`
  2498. Setlinfo struct {
  2499. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2500. AcctPay float64 `json:"acct_pay"`
  2501. ActPayDedc float64 `json:"act_pay_dedc"`
  2502. Age float64 `json:"age"`
  2503. Balc float64 `json:"balc"`
  2504. Brdy string `json:"brdy"`
  2505. Certno string `json:"certno"`
  2506. ClrOptins string `json:"clr_optins"`
  2507. ClrType string `json:"clr_type"`
  2508. ClrWay string `json:"clr_way"`
  2509. CvlservFlag string `json:"cvlserv_flag"`
  2510. CvlservPay float64 `json:"cvlserv_pay"`
  2511. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2512. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2513. Gend string `json:"gend"`
  2514. HifesPay float64 `json:"hifes_pay"`
  2515. HifmiPay float64 `json:"hifmi_pay"`
  2516. HifpPay float64 `json:"hifp_pay"`
  2517. HospPartAmt float64 `json:"hosp_part_amt"`
  2518. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2519. Insutype string `json:"insutype"`
  2520. MafPay float64 `json:"maf_pay"`
  2521. MdtrtCertType string `json:"mdtrt_cert_type"`
  2522. HifobPay float64 `json:"hifob_pay"`
  2523. MdtrtID string `json:"mdtrt_id"`
  2524. MedType string `json:"med_type"`
  2525. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2526. MedinsSetlID string `json:"medins_setl_id"`
  2527. Naty string `json:"naty"`
  2528. OthPay float64 `json:"oth_pay"`
  2529. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2530. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2531. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2532. PsnCashPay float64 `json:"psn_cash_pay"`
  2533. PsnCertType string `json:"psn_cert_type"`
  2534. PsnName string `json:"psn_name"`
  2535. PsnNo string `json:"psn_no"`
  2536. PsnPartAmt float64 `json:"psn_part_amt"`
  2537. PsnType string `json:"psn_type"`
  2538. SetlID string `json:"setl_id"`
  2539. SetlTime string `json:"setl_time"`
  2540. } `json:"setlinfo"`
  2541. } `json:"output"`
  2542. RefmsgTime string `json:"refmsg_time"`
  2543. RespondTime string `json:"respond_time"`
  2544. Signtype interface{} `json:"signtype"`
  2545. WarnMsg interface{} `json:"warn_msg"`
  2546. }
  2547. type ResultSeven10265 struct {
  2548. Cainfo string `json:"cainfo"`
  2549. ErrMsg string `json:"err_msg"`
  2550. InfRefmsgid string `json:"inf_refmsgid"`
  2551. Infcode string `json:"infcode"`
  2552. Output struct {
  2553. Setldetail []interface{} `json:"setldetail"`
  2554. Setlinfo struct {
  2555. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2556. AcctPay float64 `json:"acct_pay"`
  2557. ActPayDedc float64 `json:"act_pay_dedc"`
  2558. Age float64 `json:"age"`
  2559. Balc float64 `json:"balc"`
  2560. Brdy string `json:"brdy"`
  2561. Certno string `json:"certno"`
  2562. ClrOptins string `json:"clr_optins"`
  2563. ClrType string `json:"clr_type"`
  2564. ClrWay string `json:"clr_way"`
  2565. CvlservFlag string `json:"cvlserv_flag"`
  2566. CvlservPay float64 `json:"cvlserv_pay"`
  2567. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2568. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2569. Gend string `json:"gend"`
  2570. HifesPay float64 `json:"hifes_pay"`
  2571. HifmiPay float64 `json:"hifmi_pay"`
  2572. HifpPay float64 `json:"hifp_pay"`
  2573. HospPartAmt float64 `json:"hosp_part_amt"`
  2574. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2575. Insutype string `json:"insutype"`
  2576. MafPay float64 `json:"maf_pay"`
  2577. MdtrtCertType string `json:"mdtrt_cert_type"`
  2578. HifobPay float64 `json:"hifob_pay"`
  2579. MdtrtID string `json:"mdtrt_id"`
  2580. MedType string `json:"med_type"`
  2581. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2582. MedinsSetlID string `json:"medins_setl_id"`
  2583. Naty string `json:"naty"`
  2584. OthPay float64 `json:"oth_pay"`
  2585. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2586. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2587. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2588. PsnCashPay float64 `json:"psn_cash_pay"`
  2589. PsnCertType string `json:"psn_cert_type"`
  2590. PsnName string `json:"psn_name"`
  2591. PsnNo string `json:"psn_no"`
  2592. PsnPartAmt float64 `json:"psn_part_amt"`
  2593. PsnType string `json:"psn_type"`
  2594. SetlID string `json:"setl_id"`
  2595. SetlTime string `json:"setl_time"`
  2596. } `json:"setlinfo"`
  2597. } `json:"output"`
  2598. RefmsgTime string `json:"refmsg_time"`
  2599. RespondTime string `json:"respond_time"`
  2600. Signtype interface{} `json:"signtype"`
  2601. WarnMsg interface{} `json:"warn_msg"`
  2602. }
  2603. type ResultEight struct {
  2604. Cainfo string `json:"cainfo"`
  2605. ErrMsg string `json:"err_msg"`
  2606. InfRefmsgid string `json:"inf_refmsgid"`
  2607. Infcode int64 `json:"infcode"`
  2608. Output struct {
  2609. Stmtinfo struct {
  2610. SetlOptins string `json:"setl_optins"`
  2611. StmtRslt string `json:"stmt_rslt"`
  2612. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2613. } `json:"stmtinfo"`
  2614. } `json:"output"`
  2615. RefmsgTime string `json:"refmsg_time"`
  2616. RespondTime string `json:"respond_time"`
  2617. Signtype interface{} `json:"signtype"`
  2618. WarnMsg interface{} `json:"warn_msg"`
  2619. }
  2620. type ResultEightFor10188 struct {
  2621. Cainfo string `json:"cainfo"`
  2622. ErrMsg string `json:"err_msg"`
  2623. InfRefmsgid string `json:"inf_refmsgid"`
  2624. Infcode string `json:"infcode"`
  2625. Output struct {
  2626. Stmtinfo struct {
  2627. SetlOptins string `json:"setl_optins"`
  2628. StmtRslt string `json:"stmt_rslt"`
  2629. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2630. } `json:"stmtinfo"`
  2631. } `json:"output"`
  2632. RefmsgTime string `json:"refmsg_time"`
  2633. RespondTime string `json:"respond_time"`
  2634. Signtype interface{} `json:"signtype"`
  2635. WarnMsg interface{} `json:"warn_msg"`
  2636. }
  2637. type ResultNine struct {
  2638. Cainfo string `json:"cainfo"`
  2639. ErrMsg string `json:"err_msg"`
  2640. InfRefmsgid string `json:"inf_refmsgid"`
  2641. Infcode int64 `json:"infcode"`
  2642. Output struct {
  2643. FileQuryNo string `json:"file_qury_no"`
  2644. } `json:"output"`
  2645. RefmsgTime string `json:"refmsg_time"`
  2646. RespondTime string `json:"respond_time"`
  2647. Signtype interface{} `json:"signtype"`
  2648. WarnMsg interface{} `json:"warn_msg"`
  2649. }
  2650. type ResultTen struct {
  2651. Cainfo string `json:"cainfo"`
  2652. ErrMsg string `json:"err_msg"`
  2653. InfRefmsgid string `json:"inf_refmsgid"`
  2654. Infcode int64 `json:"infcode"`
  2655. Output struct {
  2656. DldEndtime string `json:"dld_endtime"`
  2657. FileQuryNo string `json:"file_qury_no"`
  2658. Filename string `json:"filename"`
  2659. } `json:"output"`
  2660. RefmsgTime string `json:"refmsg_time"`
  2661. RespondTime string `json:"respond_time"`
  2662. Signtype interface{} `json:"signtype"`
  2663. WarnMsg interface{} `json:"warn_msg"`
  2664. }
  2665. //type Autogenerated struct {
  2666. // Output struct {
  2667. // Setlinfo struct {
  2668. // SetlTime string `json:"setl_time"`
  2669. // CvlservPay float64 `json:"cvlserv_pay"`
  2670. // Year string `json:"year"`
  2671. // MedType string `json:"med_type"`
  2672. // PsnPay float64 `json:"psn_pay"`
  2673. // OpterID string `json:"opter_id"`
  2674. // Begndate string `json:"begndate"`
  2675. // FlxempeFlag string `json:"flxempe_flag"`
  2676. // HifmiPay float64 `json:"hifmi_pay"`
  2677. // PsnNo string `json:"psn_no"`
  2678. // ActPayDedc float64 `json:"act_pay_dedc"`
  2679. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2680. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2681. // ClrWay string `json:"clr_way"`
  2682. // OthPay float64 `json:"oth_pay"`
  2683. // Gend string `json:"gend"`
  2684. // MdtrtID string `json:"mdtrt_id"`
  2685. // AcctPay float64 `json:"acct_pay"`
  2686. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2687. // Insutype string `json:"insutype"`
  2688. // Invono interface{} `json:"invono"`
  2689. // Enddate string `json:"enddate"`
  2690. // CashPayamt float64 `json:"cash_payamt"`
  2691. // PsnType string `json:"psn_type"`
  2692. // FixmedinsName string `json:"fixmedins_name"`
  2693. // HifpPay float64 `json:"hifp_pay"`
  2694. // NewFlag interface{} `json:"new_flag"`
  2695. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2696. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2697. // PayLoc string `json:"pay_loc"`
  2698. // ClrType string `json:"clr_type"`
  2699. // RefdSetlFlag string `json:"refd_setl_flag"`
  2700. // CvlservFlag string `json:"cvlserv_flag"`
  2701. // EmpName string `json:"emp_name"`
  2702. // Brdy string `json:"brdy"`
  2703. // Naty string `json:"naty"`
  2704. // Certno string `json:"certno"`
  2705. // DiseCode string `json:"dise_code"`
  2706. // FixmedinsCode string `json:"fixmedins_code"`
  2707. // DedcHospLv string `json:"dedc_hosp_lv"`
  2708. // OpterName string `json:"opter_name"`
  2709. // Balc float64 `json:"balc"`
  2710. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2711. // PsnCertType string `json:"psn_cert_type"`
  2712. // HifobPay float64 `json:"hifob_pay"`
  2713. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2714. // HifesPay float64 `json:"hifes_pay"`
  2715. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2716. // OptTime string `json:"opt_time"`
  2717. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2718. // SetlID string `json:"setl_id"`
  2719. // MafPay float64 `json:"maf_pay"`
  2720. // PsnName string `json:"psn_name"`
  2721. // InsuOptins interface{} `json:"insu_optins"`
  2722. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2723. // ClrOptins string `json:"clr_optins"`
  2724. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2725. // DiseName string `json:"dise_name"`
  2726. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2727. // Age float64 `json:"age"`
  2728. // DtrtCertType string `json:"dtrt_cert_type"`
  2729. // HospLv string `json:"hosp_lv"`
  2730. // } `json:"setlinfo"`
  2731. // Setldetail []struct {
  2732. // FundPayType string `json:"fund_pay_type"`
  2733. // FundPayamt float64 `json:"fund_payamt"`
  2734. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2735. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2736. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2737. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2738. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2739. // } `json:"setldetail"`
  2740. // } `json:"output"`
  2741. // Infcode int `json:"infcode"`
  2742. // WarnMsg interface{} `json:"warn_msg"`
  2743. // Cainfo interface{} `json:"cainfo"`
  2744. // ErrMsg interface{} `json:"err_msg"`
  2745. // RefmsgTime string `json:"refmsg_time"`
  2746. // Signtype interface{} `json:"signtype"`
  2747. // RespondTime string `json:"respond_time"`
  2748. // InfRefmsgid string `json:"inf_refmsgid"`
  2749. //}
  2750. type ResultEleven struct {
  2751. Cainfo string `json:"cainfo"`
  2752. ErrMsg string `json:"err_msg"`
  2753. InfRefmsgid string `json:"inf_refmsgid"`
  2754. Infcode int64 `json:"infcode"`
  2755. Output struct {
  2756. Setlinfo struct {
  2757. SetlTime string `json:"setl_time"`
  2758. CvlservPay float64 `json:"cvlserv_pay"`
  2759. Year string `json:"year"`
  2760. MedType string `json:"med_type"`
  2761. PsnPay float64 `json:"psn_pay"`
  2762. OpterID string `json:"opter_id"`
  2763. Begndate string `json:"begndate"`
  2764. FlxempeFlag string `json:"flxempe_flag"`
  2765. HifmiPay float64 `json:"hifmi_pay"`
  2766. PsnNo string `json:"psn_no"`
  2767. ActPayDedc float64 `json:"act_pay_dedc"`
  2768. MedinsSetlID interface{} `json:"medins_setl_id"`
  2769. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2770. ClrWay string `json:"clr_way"`
  2771. OthPay float64 `json:"oth_pay"`
  2772. Gend string `json:"gend"`
  2773. MdtrtID string `json:"mdtrt_id"`
  2774. AcctPay float64 `json:"acct_pay"`
  2775. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2776. Insutype string `json:"insutype"`
  2777. Invono interface{} `json:"invono"`
  2778. Enddate string `json:"enddate"`
  2779. CashPayamt float64 `json:"cash_payamt"`
  2780. PsnType string `json:"psn_type"`
  2781. FixmedinsName string `json:"fixmedins_name"`
  2782. HifpPay float64 `json:"hifp_pay"`
  2783. NewFlag interface{} `json:"new_flag"`
  2784. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2785. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2786. PayLoc string `json:"pay_loc"`
  2787. ClrType string `json:"clr_type"`
  2788. RefdSetlFlag string `json:"refd_setl_flag"`
  2789. CvlservFlag string `json:"cvlserv_flag"`
  2790. EmpName string `json:"emp_name"`
  2791. Brdy string `json:"brdy"`
  2792. Naty string `json:"naty"`
  2793. Certno string `json:"certno"`
  2794. DiseCode string `json:"dise_code"`
  2795. FixmedinsCode string `json:"fixmedins_code"`
  2796. DedcHospLv string `json:"dedc_hosp_lv"`
  2797. OpterName string `json:"opter_name"`
  2798. Balc float64 `json:"balc"`
  2799. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2800. PsnCertType string `json:"psn_cert_type"`
  2801. HifobPay float64 `json:"hifob_pay"`
  2802. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2803. HifesPay float64 `json:"hifes_pay"`
  2804. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2805. OptTime string `json:"opt_time"`
  2806. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2807. SetlID string `json:"setl_id"`
  2808. MafPay float64 `json:"maf_pay"`
  2809. PsnName string `json:"psn_name"`
  2810. InsuOptins interface{} `json:"insu_optins"`
  2811. PrefFundPay interface{} `json:"pref_fund_pay"`
  2812. ClrOptins string `json:"clr_optins"`
  2813. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2814. DiseName string `json:"dise_name"`
  2815. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2816. Age float64 `json:"age"`
  2817. DtrtCertType string `json:"dtrt_cert_type"`
  2818. HospLv string `json:"hosp_lv"`
  2819. } `json:"setlinfo"`
  2820. } `json:"output"`
  2821. RefmsgTime string `json:"refmsg_time"`
  2822. RespondTime string `json:"respond_time"`
  2823. Signtype interface{} `json:"signtype"`
  2824. WarnMsg interface{} `json:"warn_msg"`
  2825. }
  2826. type ResultEleven10265 struct {
  2827. Cainfo string `json:"cainfo"`
  2828. ErrMsg string `json:"err_msg"`
  2829. InfRefmsgid string `json:"inf_refmsgid"`
  2830. Infcode string `json:"infcode"`
  2831. Output struct {
  2832. Setlinfo struct {
  2833. SetlTime string `json:"setl_time"`
  2834. CvlservPay float64 `json:"cvlserv_pay"`
  2835. Year string `json:"year"`
  2836. MedType string `json:"med_type"`
  2837. PsnPay float64 `json:"psn_pay"`
  2838. OpterID string `json:"opter_id"`
  2839. Begndate string `json:"begndate"`
  2840. FlxempeFlag string `json:"flxempe_flag"`
  2841. HifmiPay float64 `json:"hifmi_pay"`
  2842. PsnNo string `json:"psn_no"`
  2843. ActPayDedc float64 `json:"act_pay_dedc"`
  2844. MedinsSetlID interface{} `json:"medins_setl_id"`
  2845. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2846. ClrWay string `json:"clr_way"`
  2847. OthPay float64 `json:"oth_pay"`
  2848. Gend string `json:"gend"`
  2849. MdtrtID string `json:"mdtrt_id"`
  2850. AcctPay float64 `json:"acct_pay"`
  2851. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2852. Insutype string `json:"insutype"`
  2853. Invono interface{} `json:"invono"`
  2854. Enddate string `json:"enddate"`
  2855. CashPayamt float64 `json:"cash_payamt"`
  2856. PsnType string `json:"psn_type"`
  2857. FixmedinsName string `json:"fixmedins_name"`
  2858. HifpPay float64 `json:"hifp_pay"`
  2859. NewFlag interface{} `json:"new_flag"`
  2860. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2861. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2862. PayLoc string `json:"pay_loc"`
  2863. ClrType string `json:"clr_type"`
  2864. RefdSetlFlag string `json:"refd_setl_flag"`
  2865. CvlservFlag string `json:"cvlserv_flag"`
  2866. EmpName string `json:"emp_name"`
  2867. Brdy string `json:"brdy"`
  2868. Naty string `json:"naty"`
  2869. Certno string `json:"certno"`
  2870. DiseCode string `json:"dise_code"`
  2871. FixmedinsCode string `json:"fixmedins_code"`
  2872. DedcHospLv string `json:"dedc_hosp_lv"`
  2873. OpterName string `json:"opter_name"`
  2874. Balc float64 `json:"balc"`
  2875. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2876. PsnCertType string `json:"psn_cert_type"`
  2877. HifobPay float64 `json:"hifob_pay"`
  2878. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2879. HifesPay float64 `json:"hifes_pay"`
  2880. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2881. OptTime string `json:"opt_time"`
  2882. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2883. SetlID string `json:"setl_id"`
  2884. MafPay float64 `json:"maf_pay"`
  2885. PsnName string `json:"psn_name"`
  2886. InsuOptins interface{} `json:"insu_optins"`
  2887. PrefFundPay interface{} `json:"pref_fund_pay"`
  2888. ClrOptins string `json:"clr_optins"`
  2889. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2890. DiseName string `json:"dise_name"`
  2891. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2892. Age float64 `json:"age"`
  2893. DtrtCertType string `json:"dtrt_cert_type"`
  2894. HospLv string `json:"hosp_lv"`
  2895. } `json:"setlinfo"`
  2896. } `json:"output"`
  2897. RefmsgTime string `json:"refmsg_time"`
  2898. RespondTime string `json:"respond_time"`
  2899. Signtype interface{} `json:"signtype"`
  2900. WarnMsg interface{} `json:"warn_msg"`
  2901. }
  2902. type ResultTwelve struct {
  2903. Cainfo string `json:"cainfo"`
  2904. ErrMsg string `json:"err_msg"`
  2905. InfRefmsgid string `json:"inf_refmsgid"`
  2906. Infcode int64 `json:"infcode"`
  2907. Output struct {
  2908. MdtrtId string `json:"mdtrt_id"`
  2909. ChrgBchno string `json:"chrg_bchno"`
  2910. PsnNo string `json:"psn_no"`
  2911. } `json:"output"`
  2912. RefmsgTime string `json:"refmsg_time"`
  2913. RespondTime string `json:"respond_time"`
  2914. Signtype interface{} `json:"signtype"`
  2915. WarnMsg interface{} `json:"warn_msg"`
  2916. }
  2917. type ResultThirteen struct {
  2918. ErrMsg string `json:"err_msg"`
  2919. InfRefmsgid string `json:"inf_refmsgid"`
  2920. Infcode int64 `json:"infcode"`
  2921. Output struct {
  2922. Result struct {
  2923. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2924. } `json:"result"`
  2925. } `json:"output"`
  2926. RefmsgTime string `json:"refmsg_time"`
  2927. RespondTime string `json:"respond_time"`
  2928. Signtype interface{} `json:"signtype"`
  2929. WarnInfo interface{} `json:"warn_info"`
  2930. }
  2931. type ResultThirteen10265 struct {
  2932. ErrMsg string `json:"err_msg"`
  2933. InfRefmsgid string `json:"inf_refmsgid"`
  2934. Infcode string `json:"infcode"`
  2935. Output struct {
  2936. Result struct {
  2937. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2938. } `json:"result"`
  2939. } `json:"output"`
  2940. RefmsgTime string `json:"refmsg_time"`
  2941. RespondTime string `json:"respond_time"`
  2942. Signtype interface{} `json:"signtype"`
  2943. WarnInfo interface{} `json:"warn_info"`
  2944. }
  2945. type ResultFourteen struct {
  2946. ErrMsg string `json:"err_msg"`
  2947. InfRefmsgid string `json:"inf_refmsgid"`
  2948. Infcode int64 `json:"infcode"`
  2949. Output struct {
  2950. } `json:"output"`
  2951. RefmsgTime string `json:"refmsg_time"`
  2952. RespondTime string `json:"respond_time"`
  2953. Signtype interface{} `json:"signtype"`
  2954. WarnInfo interface{} `json:"warn_info"`
  2955. }
  2956. type ResultFourteen10265 struct {
  2957. ErrMsg string `json:"err_msg"`
  2958. InfRefmsgid string `json:"inf_refmsgid"`
  2959. Infcode string `json:"infcode"`
  2960. Output struct {
  2961. } `json:"output"`
  2962. RefmsgTime string `json:"refmsg_time"`
  2963. RespondTime string `json:"respond_time"`
  2964. Signtype interface{} `json:"signtype"`
  2965. WarnInfo interface{} `json:"warn_info"`
  2966. }
  2967. type ResultSixteen struct {
  2968. Cainfo string `json:"cainfo"`
  2969. ErrMsg string `json:"err_msg"`
  2970. InfRefmsgid string `json:"inf_refmsgid"`
  2971. Infcode int64 `json:"infcode"`
  2972. Output struct {
  2973. Setldetail []interface{} `json:"setldetail"`
  2974. Setlinfo struct {
  2975. MdtrtID string `json:"mdtrt_id"`
  2976. SetlID string `json:"setl_id"`
  2977. ClrOptins string `json:"clr_optins"`
  2978. SetlTime string `json:"setl_time"`
  2979. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2980. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2981. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2982. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2983. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2984. ActPayDedc float64 `json:"act_pay_dedc"`
  2985. HifpPay float64 `json:"hifp_pay"`
  2986. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2987. Lfpay float64 `json:"selfpay"`
  2988. CvlservPay float64 `json:"cvlserv_pay"`
  2989. HifesPay float64 `json:"hifes_pay"`
  2990. HifmiPay float64 `json:"hifmi_pay"`
  2991. HifobPay float64 `json:"hifob_pay"`
  2992. MafPay float64 `json:"maf_pay"`
  2993. OthPay float64 `json:"oth_pay"`
  2994. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2995. PsnPartAmt float64 `json:"psn_part_amt"`
  2996. AcctPay float64 `json:"acct_pay"`
  2997. Balc float64 `json:"balc"`
  2998. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2999. HospPartAmt float64 `json:"hosp_part_amt"`
  3000. MedinsSetlID string `json:"medins_setl_id"`
  3001. PdnCashPay string `json:"pdn_cash_pay"`
  3002. } `json:"setlinfo"`
  3003. } `json:"output"`
  3004. RefmsgTime string `json:"refmsg_time"`
  3005. RespondTime string `json:"respond_time"`
  3006. Signtype interface{} `json:"signtype"`
  3007. WarnMsg interface{} `json:"warn_msg"`
  3008. }
  3009. type ResultSixteen10265 struct {
  3010. Cainfo string `json:"cainfo"`
  3011. ErrMsg string `json:"err_msg"`
  3012. InfRefmsgid string `json:"inf_refmsgid"`
  3013. Infcode string `json:"infcode"`
  3014. Output struct {
  3015. Setldetail []interface{} `json:"setldetail"`
  3016. Setlinfo struct {
  3017. MdtrtID string `json:"mdtrt_id"`
  3018. SetlID string `json:"setl_id"`
  3019. ClrOptins string `json:"clr_optins"`
  3020. SetlTime string `json:"setl_time"`
  3021. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3022. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3023. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3024. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3025. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3026. ActPayDedc float64 `json:"act_pay_dedc"`
  3027. HifpPay float64 `json:"hifp_pay"`
  3028. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3029. Lfpay float64 `json:"selfpay"`
  3030. CvlservPay float64 `json:"cvlserv_pay"`
  3031. HifesPay float64 `json:"hifes_pay"`
  3032. HifmiPay float64 `json:"hifmi_pay"`
  3033. HifobPay float64 `json:"hifob_pay"`
  3034. MafPay float64 `json:"maf_pay"`
  3035. OthPay float64 `json:"oth_pay"`
  3036. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3037. PsnPartAmt float64 `json:"psn_part_amt"`
  3038. AcctPay float64 `json:"acct_pay"`
  3039. Balc float64 `json:"balc"`
  3040. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3041. HospPartAmt float64 `json:"hosp_part_amt"`
  3042. MedinsSetlID string `json:"medins_setl_id"`
  3043. PdnCashPay string `json:"pdn_cash_pay"`
  3044. } `json:"setlinfo"`
  3045. } `json:"output"`
  3046. RefmsgTime string `json:"refmsg_time"`
  3047. RespondTime string `json:"respond_time"`
  3048. Signtype interface{} `json:"signtype"`
  3049. WarnMsg interface{} `json:"warn_msg"`
  3050. }
  3051. type ResultSeventeen struct {
  3052. ErrMsg string `json:"err_msg"`
  3053. InfRefmsgid string `json:"inf_refmsgid"`
  3054. Infcode int64 `json:"infcode"`
  3055. Output struct {
  3056. SetlListId string `json:"setl_list_id"`
  3057. } `json:"output"`
  3058. RefmsgTime string `json:"refmsg_time"`
  3059. RespondTime string `json:"respond_time"`
  3060. Signtype string `json:"signtype"`
  3061. WarnInfo string `json:"warn_info"`
  3062. }
  3063. type Result90991 struct {
  3064. ErrMsg string `json:"err_msg"`
  3065. InfRefmsgid string `json:"inf_refmsgid"`
  3066. Infcode int64 `json:"infcode"`
  3067. Output struct {
  3068. Result struct {
  3069. PsnNo string `json:"psn_no"`
  3070. CardStat string `json:"card_stat"`
  3071. Certno string `json:"certno"`
  3072. PsnName string `json:"psn_name"`
  3073. CheckStat string `json:"check_stat"`
  3074. } `json:"result"`
  3075. } `json:"output"`
  3076. RefmsgTime string `json:"refmsg_time"`
  3077. RespondTime string `json:"respond_time"`
  3078. Signtype interface{} `json:"signtype"`
  3079. WarnInfo interface{} `json:"warn_info"`
  3080. }
  3081. type Result90100 struct {
  3082. ErrMsg string `json:"err_msg"`
  3083. InfRefmsgid string `json:"inf_refmsgid"`
  3084. Infcode int64 `json:"infcode"`
  3085. Output struct {
  3086. PoolareaNo string `json:"poolarea_no"`
  3087. PoolareaNoName string `json:"poolarea_no_name"`
  3088. Insutype string `json:"insutype"`
  3089. InsutypeName string `json:"insutype_name"`
  3090. ClctType string `json:"clct_type"`
  3091. ClctTypeName string `json:"clct_type_name"`
  3092. ClctFlag string `json:"clct_flag"`
  3093. ClctFlagName string `json:"clct_flag_name"`
  3094. AccrymBegn string `json:"accrym_begn"`
  3095. AccrymEnd string `json:"accrym_end"`
  3096. ClctTime string `json:"clct_time"`
  3097. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3098. } `json:"output"`
  3099. RefmsgTime string `json:"refmsg_time"`
  3100. RespondTime string `json:"respond_time"`
  3101. Signtype interface{} `json:"signtype"`
  3102. WarnInfo interface{} `json:"warn_info"`
  3103. }
  3104. type Custom struct {
  3105. DetItemFeeSumamt string
  3106. Cut string
  3107. FeedetlSn string
  3108. Price string
  3109. MedListCodg string
  3110. Type int64
  3111. AdviceId int64
  3112. ProjectId int64
  3113. ItemId int64
  3114. }
  3115. type Result5301 struct {
  3116. ErrMsg string `json:"err_msg"`
  3117. InfRefmsgid string `json:"inf_refmsgid"`
  3118. Infcode int64 `json:"infcode"`
  3119. Output struct {
  3120. Result []struct {
  3121. OpspDiseCode string `json:"opsp_dise_code"`
  3122. OpspDiseName string `json:"opsp_dise_name"`
  3123. Begndate string `json:"begndate"`
  3124. Enddate string `json:"enddate"`
  3125. } `json:"feedetail"`
  3126. } `json:"output"`
  3127. RefmsgTime string `json:"refmsg_time"`
  3128. RespondTime string `json:"respond_time"`
  3129. Signtype interface{} `json:"signtype"`
  3130. WarnInfo interface{} `json:"warn_info"`
  3131. }
  3132. type Result5301For10265 struct {
  3133. ErrMsg string `json:"err_msg"`
  3134. InfRefmsgid string `json:"inf_refmsgid"`
  3135. Infcode string `json:"infcode"`
  3136. Output struct {
  3137. Result []struct {
  3138. OpspDiseCode string `json:"opsp_dise_code"`
  3139. OpspDiseName string `json:"opsp_dise_name"`
  3140. Begndate string `json:"begndate"`
  3141. Enddate string `json:"enddate"`
  3142. } `json:"feedetail"`
  3143. } `json:"output"`
  3144. RefmsgTime string `json:"refmsg_time"`
  3145. RespondTime string `json:"respond_time"`
  3146. Signtype interface{} `json:"signtype"`
  3147. WarnInfo interface{} `json:"warn_info"`
  3148. }
  3149. //获取个人信息----挂号-----上传就诊信息
  3150. func (c *HisApiController) GetRegisterInfo() {
  3151. id, _ := c.GetInt64("id")
  3152. record_time := c.GetString("record_time")
  3153. settlementValue, _ := c.GetInt64("settlement_value")
  3154. medical_insurance_card := c.GetString("medical_insurance_card")
  3155. name := c.GetString("name")
  3156. id_card_type, _ := c.GetInt64("id_card_type")
  3157. certificates, _ := c.GetInt64("certificates")
  3158. medical_care, _ := c.GetInt64("medical_care")
  3159. birthday := c.GetString("birthday")
  3160. id_card := c.GetString("id_card")
  3161. register_type, _ := c.GetInt64("register")
  3162. doctor, _ := c.GetInt64("doctor")
  3163. department, _ := c.GetInt64("department")
  3164. gender, _ := c.GetInt64("sex")
  3165. registration_fee, _ := c.GetFloat("registration_fee")
  3166. medical_expenses, _ := c.GetFloat("medical_expenses")
  3167. social_type, _ := c.GetInt64("social_type")
  3168. med_type := c.GetString("social_type")
  3169. admin_user_id, _ := c.GetInt64("admin_user_id")
  3170. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3171. timeLayout := "2006-01-02"
  3172. loc, _ := time.LoadLocation("Local")
  3173. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3174. birthUnix := birthdays.Unix()
  3175. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3176. if err != nil {
  3177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3178. return
  3179. }
  3180. recordDateTime := theTime.Unix()
  3181. adminInfo := c.GetAdminUserInfo()
  3182. var patient service.Patients
  3183. if id == 0 {
  3184. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3185. } else {
  3186. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3187. }
  3188. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3189. if patientPrescription.ID == 0 {
  3190. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3191. }
  3192. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3193. if patient.ID == 0 {
  3194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3195. return
  3196. }
  3197. if len(patient.IdCardNo) == 0 {
  3198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3199. return
  3200. }
  3201. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3202. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3203. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3204. //就诊结算未完成,不能进行二次挂号
  3205. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3206. if len(his) >= 1 {
  3207. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3208. if len(his) >= 1 && order.ID == 0 {
  3209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3210. return
  3211. }
  3212. }
  3213. //var register_log string
  3214. if config.IsOpen == 1 {
  3215. var res ResultTwo
  3216. var res10265 ResultTwo10265
  3217. var PsnNo string
  3218. var PsnCertType string
  3219. var Certno string
  3220. var PsnName string
  3221. var Gend string
  3222. var Naty string
  3223. var Brdy string
  3224. var Age float64
  3225. var infoStr string
  3226. var idetinfoStr string
  3227. var infocode int64
  3228. var verify_number string
  3229. fmt.Println(verify_number)
  3230. if miConfig.MdtrtareaAdmvs == "421300" {
  3231. psn_info, _ := service.GetPsnByPatientId(id)
  3232. PsnNo = psn_info.PsnNo
  3233. PsnCertType = psn_info.PsnCertType
  3234. Certno = psn_info.Certno
  3235. PsnName = psn_info.PsnName
  3236. Gend = psn_info.Gend
  3237. Naty = psn_info.Naty
  3238. Brdy = psn_info.Brdy
  3239. Age = psn_info.Age
  3240. infoStr = psn_info.Insuinfo
  3241. idetinfoStr = psn_info.Idetinfo
  3242. infocode = 0
  3243. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3244. psn_info, _ := service.GetPsnByPatientId(id)
  3245. PsnNo = psn_info.PsnNo
  3246. PsnCertType = psn_info.PsnCertType
  3247. Certno = psn_info.Certno
  3248. PsnName = psn_info.PsnName
  3249. Gend = psn_info.Gend
  3250. Naty = psn_info.Naty
  3251. Brdy = psn_info.Brdy
  3252. Age = psn_info.Age
  3253. infoStr = psn_info.Insuinfo
  3254. idetinfoStr = psn_info.Idetinfo
  3255. infocode = 0
  3256. verify_number = psn_info.VerifyNumber
  3257. } else {
  3258. var result string
  3259. var requestLog string
  3260. if miConfig.UserOrgId == 10138 {
  3261. 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)
  3262. } else {
  3263. 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)
  3264. }
  3265. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3266. if miConfig.Code == "H15049901371" {
  3267. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3268. utils.ErrorLog("解析失败:%v", err)
  3269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3270. return
  3271. }
  3272. res.ErrMsg = res10265.ErrMsg
  3273. res.Output = res10265.Output
  3274. res.InfRefmsgid = res10265.InfRefmsgid
  3275. } else {
  3276. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3277. utils.ErrorLog("解析失败:%v", err)
  3278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3279. return
  3280. }
  3281. }
  3282. PsnNo = res.Output.Baseinfo.PsnNo
  3283. PsnCertType = res.Output.Baseinfo.PsnCertType
  3284. Certno = res.Output.Baseinfo.Certno
  3285. PsnName = res.Output.Baseinfo.PsnName
  3286. Gend = res.Output.Baseinfo.Gend
  3287. Naty = res.Output.Baseinfo.Naty
  3288. Brdy = res.Output.Baseinfo.Brdy
  3289. Age = res.Output.Baseinfo.Age
  3290. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3291. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3292. infoStr = string(Iinfos)
  3293. idetinfoStr = string(Idetinfos)
  3294. if miConfig.Code == "H15049901371" {
  3295. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3296. } else {
  3297. infocode = res.Infcode
  3298. }
  3299. }
  3300. if infocode == 0 {
  3301. his := models.VMHisPatient{
  3302. Name: name,
  3303. Gender: gender,
  3304. Birthday: birthUnix,
  3305. MedicalTreatmentType: medical_care,
  3306. IdType: certificates,
  3307. IdCardNo: id_card,
  3308. BalanceAccountsType: settlementValue,
  3309. SocialType: social_type,
  3310. MedicalInsuranceNumber: medical_insurance_card,
  3311. RegisterType: register_type,
  3312. RegisterCost: registration_fee,
  3313. TreatmentCost: medical_expenses,
  3314. Status: 1,
  3315. Ctime: time.Now().Unix(),
  3316. Mtime: time.Now().Unix(),
  3317. PsnNo: PsnNo,
  3318. PsnCertType: PsnCertType,
  3319. Certno: Certno,
  3320. PsnName: PsnName,
  3321. Gend: Gend,
  3322. Naty: Naty,
  3323. Brdy: Brdy,
  3324. Age: Age,
  3325. Iinfo: infoStr,
  3326. Idetinfo: idetinfoStr,
  3327. PatientId: patient.ID,
  3328. RecordDate: theTime.Unix(),
  3329. UserOrgId: adminInfo.CurrentOrgId,
  3330. AdminUserId: admin_user_id,
  3331. IsReturn: 1,
  3332. IdCardType: id_card_type,
  3333. Doctor: doctor,
  3334. Departments: department,
  3335. }
  3336. timestamp := time.Now().Unix()
  3337. tempTime := time.Unix(timestamp, 0)
  3338. timeFormat := tempTime.Format("20060102150405")
  3339. chrgBchno := rand.Intn(100000) + 10000
  3340. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3341. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3342. department, _ := service.GetDepartMentDetail(department)
  3343. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3344. IdCardNo := ""
  3345. if id_card_type == 1 {
  3346. // IdCardNo = medical_insurance_card
  3347. IdCardNo = patient.IdCardNo
  3348. } else {
  3349. IdCardNo = patient.IdCardNo
  3350. }
  3351. var rf []*ResultFive
  3352. json.Unmarshal([]byte(his.Iinfo), &rf)
  3353. var insutypes []*ResultFive
  3354. var insutype string
  3355. var insuplc_admdvs_temp string
  3356. var is390 int = 0
  3357. var is310 int = 0
  3358. for _, item := range rf {
  3359. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3360. insutypes = append(insutypes, item)
  3361. }
  3362. }
  3363. if len(insutypes) == 1 {
  3364. insutype = insutypes[0].Insutype
  3365. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3366. } else {
  3367. for _, i := range insutypes {
  3368. if i.Insutype == "390" {
  3369. is390 = 1
  3370. }
  3371. if i.Insutype == "310" {
  3372. is310 = 1
  3373. }
  3374. }
  3375. }
  3376. if is390 == 1 {
  3377. insutype = "390"
  3378. }
  3379. if is310 == 1 {
  3380. insutype = "310"
  3381. }
  3382. if len(insutypes) == 0 {
  3383. insutype = "310"
  3384. }
  3385. if len(insutypes) == 2 {
  3386. insutype = med_type
  3387. }
  3388. if len(med_type) > 0 {
  3389. insutype = med_type
  3390. }
  3391. //for _, item := range rf {
  3392. // if item.Insutype == insutype {
  3393. // insuplc_admdvs = item.InsuplcAdmdvs
  3394. // }
  3395. //}
  3396. var infocode int64
  3397. var resThree ResultThree
  3398. var resThree10265 ResultThree10265
  3399. if len(insuplc_admdvs) == 0 {
  3400. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3401. } else {
  3402. insuplc_admdvs_temp = insuplc_admdvs
  3403. }
  3404. if miConfig.MdtrtareaAdmvs == "421300" {
  3405. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3406. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3407. "&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
  3408. resp, requestErr := http.Get(api)
  3409. if requestErr != nil {
  3410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3411. return
  3412. }
  3413. body, ioErr := ioutil.ReadAll(resp.Body)
  3414. if ioErr != nil {
  3415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3417. return
  3418. }
  3419. var respJSON map[string]interface{}
  3420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3423. return
  3424. }
  3425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3426. result, _ := json.Marshal(respJSON)
  3427. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3428. utils.ErrorLog("解析失败:%v", err)
  3429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3430. return
  3431. }
  3432. infocode = resThree.Infcode
  3433. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3434. psn_info, _ := service.GetPsnByPatientId(id)
  3435. bas := strings.Split(psn_info.CardInfo, "|")
  3436. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3437. var api string
  3438. if miConfig.MdtrtareaAdmvs == "320921" {
  3439. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3440. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3441. "&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
  3442. } else {
  3443. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3444. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3445. "&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
  3446. }
  3447. resp, requestErr := http.Get(api)
  3448. if requestErr != nil {
  3449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3450. return
  3451. }
  3452. body, ioErr := ioutil.ReadAll(resp.Body)
  3453. if ioErr != nil {
  3454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3456. return
  3457. }
  3458. var respJSON map[string]interface{}
  3459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3465. result, _ := json.Marshal(respJSON)
  3466. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3467. utils.ErrorLog("解析失败:%v", err)
  3468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3469. return
  3470. }
  3471. resThree.ErrMsg = resThree10265.ErrMsg
  3472. resThree.Output = resThree10265.Output
  3473. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3474. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3475. } else {
  3476. 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)
  3477. saveLog(result, requestLog, "2201", "挂号")
  3478. if miConfig.Code == "H15049901371" {
  3479. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3480. utils.ErrorLog("解析失败:%v", err)
  3481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. return
  3483. }
  3484. resThree.ErrMsg = resThree10265.ErrMsg
  3485. resThree.Output = resThree10265.Output
  3486. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3487. } else {
  3488. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3489. utils.ErrorLog("解析失败:%v", err)
  3490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3491. return
  3492. }
  3493. }
  3494. if miConfig.Code == "H15049901371" {
  3495. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3496. } else {
  3497. infocode = resThree.Infcode
  3498. }
  3499. }
  3500. if infocode != 0 {
  3501. adminUser := c.GetAdminUserInfo()
  3502. errlog := &models.HisOrderError{
  3503. UserOrgId: adminUser.CurrentOrgId,
  3504. Ctime: time.Now().Unix(),
  3505. Mtime: time.Now().Unix(),
  3506. ErrMsg: resThree.ErrMsg,
  3507. Status: 1,
  3508. PatientId: id,
  3509. RecordTime: recordDateTime,
  3510. Stage: 2,
  3511. }
  3512. service.CreateErrMsgLog(errlog)
  3513. c.ServeSuccessJSON(map[string]interface{}{
  3514. "failed_code": -10,
  3515. "msg": resThree.ErrMsg,
  3516. })
  3517. return
  3518. }
  3519. his.Number = resThree.Output.Data.MdtrtID
  3520. his.PsnNo = resThree.Output.Data.PsnNo
  3521. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3522. his.IdCardNo = patient.IdCardNo
  3523. his.PhoneNumber = patient.Phone
  3524. his.UserOrgId = adminInfo.CurrentOrgId
  3525. his.Insutype = insutype
  3526. his.Ctime = time.Now().Unix()
  3527. his.Mtime = time.Now().Unix()
  3528. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3529. his.Status = 1
  3530. service.UpdateHisPatientStatus(&his)
  3531. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3532. c.ServeSuccessJSON(map[string]interface{}{
  3533. "his_info": his,
  3534. })
  3535. } else {
  3536. adminUser := c.GetAdminUserInfo()
  3537. errlog := &models.HisOrderError{
  3538. UserOrgId: adminUser.CurrentOrgId,
  3539. Ctime: time.Now().Unix(),
  3540. Mtime: time.Now().Unix(),
  3541. ErrMsg: res.ErrMsg,
  3542. Status: 1,
  3543. PatientId: id,
  3544. RecordTime: recordDateTime,
  3545. Stage: 1,
  3546. }
  3547. service.CreateErrMsgLog(errlog)
  3548. c.ServeSuccessJSON(map[string]interface{}{
  3549. "failed_code": -10,
  3550. "msg": res.ErrMsg,
  3551. })
  3552. return
  3553. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3554. }
  3555. }
  3556. }
  3557. //上传明细----预结算----确认订单
  3558. func (c *HisApiController) GetUploadInfo() {
  3559. id, _ := c.GetInt64("id")
  3560. record_time := c.GetString("record_time")
  3561. his_patient_id, _ := c.GetInt64("his_patient_id")
  3562. order_id, _ := c.GetInt64("order_id")
  3563. pay_way, _ := c.GetInt64("pay_way")
  3564. pay_price, _ := c.GetFloat("pay_price")
  3565. pay_card_no := c.GetString("pay_card_no")
  3566. discount_price, _ := c.GetFloat("discount_price")
  3567. preferential_price, _ := c.GetFloat("preferential_price")
  3568. reality_price, _ := c.GetFloat("reality_price")
  3569. found_price, _ := c.GetFloat("found_price")
  3570. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3571. private_price, _ := c.GetFloat("private_price")
  3572. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3573. admin_user_id, _ := c.GetInt64("admin_user_id")
  3574. fapiao_code := c.GetString("fapiao_code")
  3575. fapiao_number := c.GetString("fapiao_number")
  3576. diagnosis_id := c.GetString("diagnosis")
  3577. sick_type, _ := c.GetInt64("sick_type")
  3578. reg_type, _ := c.GetInt64("p_type")
  3579. begin_time := c.GetString("begin_time")
  3580. id_str := c.GetString("ids")
  3581. ids_arr := strings.Split(id_str, ",")
  3582. timeLayout := "2006-01-02"
  3583. loc, _ := time.LoadLocation("Local")
  3584. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3585. if err != nil {
  3586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3587. return
  3588. }
  3589. recordDateTime := theTime.Unix()
  3590. adminUser := c.GetAdminUserInfo()
  3591. var tempOrder models.HisOrder
  3592. tempOrder, _ = service.GetHisOrderByID(order_id)
  3593. var prescriptions []*models.HisPrescription
  3594. var start_time int64
  3595. var end_time int64
  3596. //if adminUser.CurrentOrgId == 10106{
  3597. // if len(fapiao_code) == 0{
  3598. // fapiao_code = "144072080589"
  3599. // }
  3600. // if len(fapiao_number) == 0{
  3601. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3602. // if order.ID == 0{
  3603. // fapiao_number = "00001520"
  3604. // }else{
  3605. // //fapiao_code = "00001520"
  3606. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3607. // var zero string
  3608. // if fpNumber >= 1000{
  3609. // zero = "0000" + strconv.Itoa(fpNumber)
  3610. // }else if fpNumber >= 10000{
  3611. // zero = "000" + strconv.Itoa(fpNumber)
  3612. // } else if fpNumber >= 100000{
  3613. // zero = "00" + strconv.Itoa(fpNumber)
  3614. // } else if fpNumber >= 1000000{
  3615. // zero = "0" + strconv.Itoa(fpNumber)
  3616. // }else {
  3617. // zero = strconv.Itoa(fpNumber)
  3618. // }
  3619. // fapiao_number = zero
  3620. // }
  3621. // }
  3622. //}
  3623. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3624. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3625. var patientPrescription models.HisPrescriptionInfo
  3626. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3627. if patientPrescription.ID == 0 {
  3628. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3629. }
  3630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3631. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3632. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3633. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3634. var config []*models.HisXtDiagnoseConfig
  3635. for _, item := range diagnosis_ids {
  3636. id, _ := strconv.ParseInt(item, 10, 64)
  3637. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3638. config = append(config, &diagnosisConfig)
  3639. }
  3640. sickConfig, _ := service.FindSickById(sick_type)
  3641. //if tempOrder.ID == 0 {
  3642. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3643. //}
  3644. if tempOrder.ID == 0 {
  3645. var result string
  3646. var requestLog string
  3647. var res2 ResultSix
  3648. var ressix10265 ResultSix10265
  3649. if miConfig.MdtrtareaAdmvs == "421300" {
  3650. data := make(map[string]interface{})
  3651. client := &http.Client{}
  3652. data["psn_no"] = his.PsnNo
  3653. data["mdtrt_id"] = his.Number
  3654. data["doctor"] = roles.UserName
  3655. data["department"] = department.Name
  3656. data["org_name"] = miConfig.OrgName
  3657. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3658. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3659. data["fixmedins_code"] = miConfig.Code
  3660. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3661. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3662. data["secret_key"] = miConfig.SecretKey
  3663. data["sick_code"] = sickConfig.CountryCode
  3664. data["sick_name"] = sickConfig.ClassName
  3665. data["dept"] = strconv.FormatInt(department.ID, 10)
  3666. data["config"] = config
  3667. data["begin_time"] = begin_time
  3668. bytesData, _ := json.Marshal(data)
  3669. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3670. resp, _ := client.Do(req)
  3671. defer resp.Body.Close()
  3672. body, ioErr := ioutil.ReadAll(resp.Body)
  3673. if ioErr != nil {
  3674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3676. return
  3677. }
  3678. var respJSON map[string]interface{}
  3679. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3682. return
  3683. }
  3684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3685. userJSONBytes, _ := json.Marshal(respJSON)
  3686. fmt.Println("log")
  3687. fmt.Println(string(userJSONBytes))
  3688. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3689. utils.ErrorLog("解析失败:%v", err)
  3690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3691. return
  3692. }
  3693. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3694. //江苏地区国家医保医疗类别
  3695. //职工透析:医疗类别选特殊情况门诊9933
  3696. //居民血透门慢: 医疗类别选门诊慢病1402
  3697. //var med_type string
  3698. //if his.Insutype == "310" {
  3699. // if reg_type == 14 {
  3700. // med_type = "9933"
  3701. // } else if reg_type == 11 {
  3702. // med_type = "11"
  3703. //
  3704. // }
  3705. //} else if his.Insutype == "390" {
  3706. // if reg_type == 14 {
  3707. // med_type = "1402"
  3708. // } else if reg_type == 11 {
  3709. // med_type = "11"
  3710. // }
  3711. //}
  3712. data := make(map[string]interface{})
  3713. client := &http.Client{}
  3714. data["psn_no"] = his.PsnNo
  3715. data["mdtrt_id"] = his.Number
  3716. data["doctor"] = roles.UserName
  3717. data["department"] = department.Name
  3718. data["org_name"] = miConfig.OrgName
  3719. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3720. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3721. data["fixmedins_code"] = miConfig.Code
  3722. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3723. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3724. data["secret_key"] = miConfig.SecretKey
  3725. data["sick_code"] = sickConfig.CountryCode
  3726. data["sick_name"] = sickConfig.ClassName
  3727. data["url"] = miConfig.Url
  3728. data["ak"] = miConfig.AccessKey
  3729. data["begin_time"] = begin_time
  3730. data["cainfo"] = miConfig.Cainfo
  3731. data["dept"] = strconv.FormatInt(department.ID, 10)
  3732. data["config"] = config
  3733. bytesData, _ := json.Marshal(data)
  3734. var req *http.Request
  3735. if miConfig.MdtrtareaAdmvs == "320921" {
  3736. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3737. //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 +
  3738. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3739. } else {
  3740. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3741. }
  3742. resp, _ := client.Do(req)
  3743. defer resp.Body.Close()
  3744. body, ioErr := ioutil.ReadAll(resp.Body)
  3745. if ioErr != nil {
  3746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3748. return
  3749. }
  3750. var respJSON map[string]interface{}
  3751. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3754. return
  3755. }
  3756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3757. userJSONBytes, _ := json.Marshal(respJSON)
  3758. fmt.Println("log")
  3759. fmt.Println(string(userJSONBytes))
  3760. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3761. utils.ErrorLog("解析失败:%v", err)
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. return
  3764. }
  3765. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3766. res2.Output = ressix10265.Output
  3767. res2.ErrMsg = ressix10265.ErrMsg
  3768. res2.Cainfo = ressix10265.Cainfo
  3769. res2.WarnMsg = ressix10265.WarnMsg
  3770. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3771. res2.Infcode = infocode
  3772. } else {
  3773. if miConfig.MdtrtareaAdmvs == "440781" { //
  3774. 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)
  3775. } else {
  3776. if miConfig.Code == "H15049901371" {
  3777. //赤峰地区国家医保医疗类别
  3778. //职工透析:医疗类别选特殊情况门诊990502
  3779. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3780. var med_type string
  3781. if his.Insutype == "390" {
  3782. if reg_type == 14 {
  3783. med_type = "9933"
  3784. } else if reg_type == 11 {
  3785. med_type = "11"
  3786. }
  3787. } else if his.Insutype == "310" {
  3788. if reg_type == 14 {
  3789. med_type = "990502"
  3790. } else if reg_type == 11 {
  3791. med_type = "11"
  3792. }
  3793. }
  3794. 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)
  3795. } else {
  3796. 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)
  3797. }
  3798. }
  3799. saveLog(result, requestLog, "2203", "上传就诊信息")
  3800. var respJSON2 map[string]interface{}
  3801. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3804. return
  3805. }
  3806. userJSONBytes2, _ := json.Marshal(respJSON2)
  3807. if miConfig.Code == "H15049901371" {
  3808. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3809. utils.ErrorLog("解析失败:%v", err)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3814. res2.Output = ressix10265.Output
  3815. res2.ErrMsg = ressix10265.ErrMsg
  3816. res2.Cainfo = ressix10265.Cainfo
  3817. res2.WarnMsg = ressix10265.WarnMsg
  3818. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3819. res2.Infcode = infocode
  3820. } else {
  3821. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3822. utils.ErrorLog("解析失败:%v", err)
  3823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3824. return
  3825. }
  3826. }
  3827. }
  3828. if res2.Infcode != 0 {
  3829. adminUser := c.GetAdminUserInfo()
  3830. errlog := &models.HisOrderError{
  3831. UserOrgId: adminUser.CurrentOrgId,
  3832. Ctime: time.Now().Unix(),
  3833. Mtime: time.Now().Unix(),
  3834. ErrMsg: res2.ErrMsg,
  3835. Status: 1,
  3836. PatientId: id,
  3837. RecordTime: recordDateTime,
  3838. Stage: 3,
  3839. }
  3840. service.CreateErrMsgLog(errlog)
  3841. c.ServeSuccessJSON(map[string]interface{}{
  3842. "failed_code": -10,
  3843. "msg": res2.ErrMsg,
  3844. })
  3845. return
  3846. } else {
  3847. his.Diagnosis = diagnosis_id
  3848. his.SickType = sickConfig.ID
  3849. var p_type int64
  3850. if reg_type == 1111 || reg_type == 1112 {
  3851. p_type = 11
  3852. }
  3853. his.PType = fmt.Sprintf("%d", p_type)
  3854. service.UpdateHisPatientThree(&his)
  3855. data := make(map[string]interface{})
  3856. if settle_accounts_type == 1 { //日结
  3857. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3858. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3859. } else {
  3860. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3861. }
  3862. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3863. data["pre"] = prescriptions
  3864. } else { //月结
  3865. start_time_str := c.GetString("start_time")
  3866. end_time_str := c.GetString("end_time")
  3867. timeLayout := "2006-01-02"
  3868. loc, _ := time.LoadLocation("Local")
  3869. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3870. if err != nil {
  3871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3872. return
  3873. }
  3874. recordStartTime := theStartTime.Unix()
  3875. start_time = recordStartTime
  3876. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3877. if err != nil {
  3878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3879. return
  3880. }
  3881. recordEndTime := theEndTime.Unix()
  3882. end_time = recordEndTime
  3883. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3884. data["pre"] = prescriptions
  3885. }
  3886. timestamp := time.Now().Unix()
  3887. tempTime := time.Unix(timestamp, 0)
  3888. timeFormat := tempTime.Format("20060102150405")
  3889. chrgBchno := rand.Intn(100000) + 10000
  3890. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3891. strconv.FormatInt(his.PatientId, 10)
  3892. client := &http.Client{}
  3893. data["psn_no"] = his.PsnNo
  3894. data["mdtrt_id"] = his.Number
  3895. data["chrg_bchno"] = chrg_bchno
  3896. data["org_name"] = miConfig.OrgName
  3897. data["doctor"] = roles.UserName
  3898. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3899. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3900. data["fixmedins_code"] = miConfig.Code
  3901. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3902. // data["dept_code"] = "15"
  3903. //} else {
  3904. data["dept_code"] = department.Number
  3905. //}
  3906. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3907. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3908. data["secret_key"] = miConfig.SecretKey
  3909. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3910. data["url"] = miConfig.Url
  3911. data["ak"] = miConfig.AccessKey
  3912. data["new_doctor_name"] = patientPrescription.Doctor
  3913. data["diag_code"] = sickConfig.CountryCode
  3914. data["cainfo"] = miConfig.Cainfo
  3915. var ids []int64
  3916. for _, item := range prescriptions {
  3917. ids = append(ids, item.ID)
  3918. }
  3919. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3920. if config.IsOpen == 1 { //对接了医保,走医保流程
  3921. var res ResultFour
  3922. var resFour10265 ResultFour10265
  3923. if miConfig.MdtrtareaAdmvs == "421300" {
  3924. bytesData, _ := json.Marshal(data)
  3925. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3926. resp, _ := client.Do(req)
  3927. defer resp.Body.Close()
  3928. body, ioErr := ioutil.ReadAll(resp.Body)
  3929. if ioErr != nil {
  3930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3932. return
  3933. }
  3934. var respJSON map[string]interface{}
  3935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3938. return
  3939. }
  3940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3941. userJSONBytes, _ := json.Marshal(respJSON)
  3942. fmt.Println("log")
  3943. fmt.Println(string(userJSONBytes))
  3944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3945. utils.ErrorLog("解析失败:%v", err)
  3946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. return
  3948. }
  3949. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3950. bytesData, _ := json.Marshal(data)
  3951. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3952. resp, _ := client.Do(req)
  3953. defer resp.Body.Close()
  3954. body, ioErr := ioutil.ReadAll(resp.Body)
  3955. if ioErr != nil {
  3956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. return
  3959. }
  3960. var respJSON map[string]interface{}
  3961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return
  3965. }
  3966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3967. userJSONBytes, _ := json.Marshal(respJSON)
  3968. fmt.Println("log")
  3969. fmt.Println(string(userJSONBytes))
  3970. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3971. utils.ErrorLog("解析失败:%v", err)
  3972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3973. return
  3974. }
  3975. res.InfRefmsgid = resFour10265.InfRefmsgid
  3976. res.Output = resFour10265.Output
  3977. res.ErrMsg = resFour10265.ErrMsg
  3978. res.Cainfo = resFour10265.Cainfo
  3979. res.WarnMsg = resFour10265.WarnMsg
  3980. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3981. res.Infcode = infocode
  3982. } else {
  3983. if miConfig.Code == "H15049901371" {
  3984. 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)
  3985. var dat map[string]interface{}
  3986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3987. fmt.Println(dat)
  3988. } else {
  3989. fmt.Println(err)
  3990. }
  3991. saveLog(result, request_log, "2204", "上传费用明细")
  3992. userJSONBytes, _ := json.Marshal(dat)
  3993. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3994. utils.ErrorLog("解析失败:%v", err)
  3995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3996. return
  3997. }
  3998. res.InfRefmsgid = resFour10265.InfRefmsgid
  3999. res.Output = resFour10265.Output
  4000. res.ErrMsg = resFour10265.ErrMsg
  4001. res.Cainfo = resFour10265.Cainfo
  4002. res.WarnMsg = resFour10265.WarnMsg
  4003. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4004. res.Infcode = infocode
  4005. } else {
  4006. 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)
  4007. var dat map[string]interface{}
  4008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4009. fmt.Println(dat)
  4010. } else {
  4011. fmt.Println(err)
  4012. }
  4013. saveLog(result, request_log, "2204", "上传费用明细")
  4014. userJSONBytes, _ := json.Marshal(dat)
  4015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4016. utils.ErrorLog("解析失败:%v", err)
  4017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4018. return
  4019. }
  4020. }
  4021. }
  4022. if res.Infcode == 0 {
  4023. order := &models.HisOrder{
  4024. UserOrgId: adminUser.CurrentOrgId,
  4025. HisPatientId: his.ID,
  4026. PatientId: his.PatientId,
  4027. SettleAccountsDate: recordDateTime,
  4028. MdtrtId: his.Number,
  4029. PsnNo: his.PsnNo,
  4030. MedType: strconv.FormatInt(reg_type, 10),
  4031. Ctime: time.Now().Unix(),
  4032. Mtime: time.Now().Unix(),
  4033. Status: 1,
  4034. Number: chrg_bchno,
  4035. Infcode: res.Infcode,
  4036. WarnMsg: res.WarnMsg,
  4037. Cainfo: res.Cainfo,
  4038. ErrMsg: res.ErrMsg,
  4039. RespondTime: res.RefmsgTime,
  4040. InfRefmsgid: res.InfRefmsgid,
  4041. OrderStatus: 1,
  4042. PayWay: pay_way,
  4043. PayPrice: pay_price,
  4044. PayCardNo: pay_card_no,
  4045. DiscountPrice: discount_price,
  4046. PreferentialPrice: preferential_price,
  4047. RealityPrice: reality_price,
  4048. FoundPrice: found_price,
  4049. MedicalInsurancePrice: medical_insurance_price,
  4050. PrivatePrice: private_price,
  4051. IsMedicineInsurance: 1,
  4052. SettleType: settle_accounts_type,
  4053. SettleStartTime: start_time,
  4054. SettleEndTime: end_time,
  4055. Creator: roles.AdminUserId,
  4056. Modify: roles.AdminUserId,
  4057. FaPiaoNumber: fapiao_number,
  4058. FaPiaoCode: fapiao_code,
  4059. PType: 2,
  4060. Diagnosis: diagnosis_id,
  4061. }
  4062. err = service.CreateOrder(order)
  4063. if err != nil {
  4064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4065. return
  4066. }
  4067. for _, item := range res.Output.Result {
  4068. temp := strings.Split(item.FeedetlSn, "-")
  4069. var advice_id int64 = 0
  4070. var project_id int64 = 0
  4071. var types int64 = 0
  4072. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4073. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4074. if temp[1] == "1" {
  4075. advice_id = id
  4076. project_id = 0
  4077. } else if temp[1] == "2" {
  4078. advice_id = 0
  4079. project_id = id
  4080. }
  4081. info := &models.HisOrderInfo{
  4082. OrderNumber: order.Number,
  4083. FeedetlSn: item.FeedetlSn,
  4084. UploadDate: time.Now().Unix(),
  4085. AdviceId: advice_id,
  4086. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4087. Cnt: item.Cnt,
  4088. Pric: float64(item.Pric),
  4089. PatientId: his.PatientId,
  4090. PricUplmtAmt: item.PricUplmtAmt,
  4091. SelfpayProp: item.SelfpayProp,
  4092. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4093. OverlmtAmt: item.OverlmtAmt,
  4094. PreselfpayAmt: item.PreselfpayAmt,
  4095. BasMednFlag: item.BasMednFlag,
  4096. MedChrgitmType: item.MedChrgitmType,
  4097. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4098. Status: 1,
  4099. Memo: item.Memo,
  4100. Mtime: time.Now().Unix(),
  4101. InscpScpAmt: item.InscpScpAmt,
  4102. DrtReimFlag: item.DrtReimFlag,
  4103. Ctime: time.Now().Unix(),
  4104. ListSpItemFlag: item.ListSpItemFlag,
  4105. ChldMedcFlag: item.ChldMedcFlag,
  4106. LmtUsedFlag: item.LmtUsedFlag,
  4107. ChrgitmLv: item.ChrgitmLv,
  4108. UserOrgId: adminUser.CurrentOrgId,
  4109. HisPatientId: his.ID,
  4110. OrderId: order.ID,
  4111. ProjectId: project_id,
  4112. Type: types,
  4113. }
  4114. service.CreateOrderInfo(info)
  4115. }
  4116. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4117. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4118. var total float64
  4119. for _, item := range prescriptions {
  4120. if item.Type == 1 { //药品
  4121. for _, subItem := range item.HisDoctorAdviceInfo {
  4122. total = total + (subItem.Price * subItem.PrescribingNumber)
  4123. }
  4124. }
  4125. if item.Type == 2 { //项目
  4126. for _, subItem := range item.HisPrescriptionProject {
  4127. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4128. total = total + (subItem.Price * cnt)
  4129. }
  4130. }
  4131. }
  4132. for _, item := range prescriptions {
  4133. for _, subItem := range item.HisAdditionalCharge {
  4134. total = total + (subItem.Price * float64(subItem.Count))
  4135. }
  4136. }
  4137. var allTotal string
  4138. if adminUser.CurrentOrgId == 9919 {
  4139. allTotal = fmt.Sprintf("%.4f", total)
  4140. } else {
  4141. allTotal = fmt.Sprintf("%.4f", total)
  4142. }
  4143. if res.Infcode == 0 {
  4144. var rf []*ResultFive
  4145. json.Unmarshal([]byte(his.Iinfo), &rf)
  4146. chrg_bchno := chrg_bchno
  4147. cert_no := his.Certno
  4148. var insutypes []string
  4149. var insutype string
  4150. var is390 int = 0
  4151. var is310 int = 0
  4152. for _, item := range rf {
  4153. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4154. insutypes = append(insutypes, item.Insutype)
  4155. }
  4156. }
  4157. if len(insutypes) == 1 {
  4158. insutype = insutypes[0]
  4159. } else {
  4160. for _, i := range insutypes {
  4161. if i == "390" {
  4162. is390 = 1
  4163. }
  4164. if i == "310" {
  4165. is310 = 1
  4166. }
  4167. }
  4168. }
  4169. if is390 == 1 {
  4170. insutype = "390"
  4171. }
  4172. if is310 == 1 {
  4173. insutype = "310"
  4174. }
  4175. if len(insutypes) == 0 {
  4176. insutype = "310"
  4177. }
  4178. if len(insutypes) == 2 {
  4179. insutype = strconv.FormatInt(his.SocialType, 10)
  4180. }
  4181. insutype = strconv.FormatInt(his.SocialType, 10)
  4182. //insutype = "390"
  4183. if his.IdCardType == 1 {
  4184. // cert_no = his.MedicalInsuranceNumber
  4185. cert_no = his.Certno
  4186. } else {
  4187. cert_no = his.Certno
  4188. }
  4189. var res ResultSeven
  4190. var resSeven10265 ResultSeven10265
  4191. var src_resquest string
  4192. var result2 string
  4193. var acct_used_flag string
  4194. fmt.Println("pay_way")
  4195. fmt.Println(pay_way)
  4196. fmt.Println("pay_way")
  4197. if pay_way == 4 {
  4198. acct_used_flag = "1"
  4199. } else {
  4200. acct_used_flag = "0"
  4201. }
  4202. if miConfig.MdtrtareaAdmvs == "421300" {
  4203. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4204. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4205. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4206. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4207. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4208. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4209. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4210. resp, requestErr := http.Get(api)
  4211. if requestErr != nil {
  4212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4213. return
  4214. }
  4215. body, ioErr := ioutil.ReadAll(resp.Body)
  4216. if ioErr != nil {
  4217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4219. return
  4220. }
  4221. var respJSON map[string]interface{}
  4222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4225. return
  4226. }
  4227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4228. result, _ := json.Marshal(respJSON)
  4229. if miConfig.Code == "H15049901371" {
  4230. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4231. utils.ErrorLog("解析失败:%v", err)
  4232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4233. return
  4234. }
  4235. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4236. res.Output = resSeven10265.Output
  4237. res.ErrMsg = resSeven10265.ErrMsg
  4238. res.Cainfo = resSeven10265.Cainfo
  4239. res.WarnMsg = resSeven10265.WarnMsg
  4240. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4241. res.Infcode = infocode
  4242. } else {
  4243. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4244. utils.ErrorLog("解析失败:%v", err)
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4246. return
  4247. }
  4248. }
  4249. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4250. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4251. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4252. //psn_info, _ := service.GetPsnByPatientId(id)
  4253. bas := strings.Split(psn_info.CardInfo, "|")
  4254. if his.IdCardType == 1 {
  4255. cert_no = bas[2]
  4256. } else {
  4257. cert_no = bas[1]
  4258. }
  4259. //江苏地区国家医保医疗类别
  4260. //职工透析:医疗类别选特殊情况门诊9933
  4261. //居民血透门慢: 医疗类别选门诊慢病1402
  4262. //var med_type string
  4263. //if his.Insutype == "310" {
  4264. // if reg_type == 14 {
  4265. // med_type = "9933"
  4266. // } else if reg_type == 11 {
  4267. // med_type = "11"
  4268. //
  4269. // }
  4270. //} else if his.Insutype == "390" {
  4271. // if reg_type == 14 {
  4272. // med_type = "1402"
  4273. // } else if reg_type == 11 {
  4274. // med_type = "11"
  4275. // }
  4276. //}
  4277. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4278. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4279. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4280. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4282. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4283. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4284. "&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
  4285. resp, requestErr := http.Get(api)
  4286. if requestErr != nil {
  4287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4288. return
  4289. }
  4290. body, ioErr := ioutil.ReadAll(resp.Body)
  4291. if ioErr != nil {
  4292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4294. return
  4295. }
  4296. var respJSON map[string]interface{}
  4297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4300. return
  4301. }
  4302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4303. result, _ := json.Marshal(respJSON)
  4304. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4305. utils.ErrorLog("解析失败:%v", err)
  4306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4307. return
  4308. }
  4309. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4310. res.Output = resSeven10265.Output
  4311. res.ErrMsg = resSeven10265.ErrMsg
  4312. res.Cainfo = resSeven10265.Cainfo
  4313. res.WarnMsg = resSeven10265.WarnMsg
  4314. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4315. res.Infcode = infocode
  4316. } else {
  4317. if miConfig.Code == "H15049901371" {
  4318. //赤峰地区国家医保医疗类别
  4319. //职工透析:医疗类别选特殊情况门诊990502
  4320. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4321. var med_type string
  4322. if his.Insutype == "390" {
  4323. if reg_type == 14 {
  4324. med_type = "9933"
  4325. } else if reg_type == 11 {
  4326. med_type = "11"
  4327. }
  4328. } else if his.Insutype == "310" {
  4329. if reg_type == 14 {
  4330. med_type = "990502"
  4331. } else if reg_type == 11 {
  4332. med_type = "11"
  4333. }
  4334. }
  4335. 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)
  4336. } else {
  4337. 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)
  4338. }
  4339. //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)
  4340. var dat map[string]interface{}
  4341. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4342. fmt.Println(dat)
  4343. } else {
  4344. fmt.Println(err)
  4345. }
  4346. saveLog(result2, src_resquest, "2207", "结算")
  4347. userJSONBytes, _ := json.Marshal(dat)
  4348. if miConfig.Code == "H15049901371" {
  4349. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4350. utils.ErrorLog("解析失败:%v", err)
  4351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4352. return
  4353. }
  4354. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4355. res.Output = resSeven10265.Output
  4356. res.ErrMsg = resSeven10265.ErrMsg
  4357. res.Cainfo = resSeven10265.Cainfo
  4358. res.WarnMsg = resSeven10265.WarnMsg
  4359. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4360. res.Infcode = infocode
  4361. } else {
  4362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4363. utils.ErrorLog("解析失败:%v", err)
  4364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4365. return
  4366. }
  4367. }
  4368. }
  4369. if res.Infcode != 0 {
  4370. errlog := &models.HisOrderError{
  4371. UserOrgId: adminUser.CurrentOrgId,
  4372. Ctime: time.Now().Unix(),
  4373. Mtime: time.Now().Unix(),
  4374. Number: chrg_bchno,
  4375. ErrMsg: res.ErrMsg,
  4376. Status: 1,
  4377. PatientId: id,
  4378. RecordTime: recordDateTime,
  4379. Stage: 6,
  4380. }
  4381. service.CreateErrMsgLog(errlog)
  4382. c.ServeSuccessJSON(map[string]interface{}{
  4383. "failed_code": -10,
  4384. "msg": res.ErrMsg,
  4385. })
  4386. return
  4387. } else {
  4388. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4389. order.OrderStatus = 2
  4390. order.Status = 1
  4391. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4392. order.SetlId = res.Output.Setlinfo.SetlID
  4393. order.PsnNo = res.Output.Setlinfo.PsnNo
  4394. order.PsnName = res.Output.Setlinfo.PsnName
  4395. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4396. order.Certno = res.Output.Setlinfo.Certno
  4397. order.Gend = res.Output.Setlinfo.Gend
  4398. order.Naty = res.Output.Setlinfo.Naty
  4399. order.Age = res.Output.Setlinfo.Age
  4400. order.Insutype = res.Output.Setlinfo.Insutype
  4401. order.PsnType = res.Output.Setlinfo.PsnType
  4402. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4403. order.SetlTime = res.Output.Setlinfo.SetlTime
  4404. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4405. if res.Output.Setlinfo.MedType == "140101" {
  4406. order.MedType = "14"
  4407. } else {
  4408. order.MedType = res.Output.Setlinfo.MedType
  4409. }
  4410. if reg_type == 1112 {
  4411. order.MedType = "1112"
  4412. }
  4413. if reg_type == 1111 {
  4414. order.MedType = "1111"
  4415. }
  4416. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4417. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4418. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4419. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4420. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4421. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4422. order.HifpPay = res.Output.Setlinfo.HifpPay
  4423. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4424. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4425. order.HifesPay = res.Output.Setlinfo.HifesPay
  4426. order.HifobPay = res.Output.Setlinfo.HifobPay
  4427. order.MafPay = res.Output.Setlinfo.MafPay
  4428. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4429. order.OthPay = res.Output.Setlinfo.OthPay
  4430. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4431. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4432. order.AcctPay = res.Output.Setlinfo.AcctPay
  4433. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4434. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4435. order.Balc = res.Output.Setlinfo.Balc
  4436. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4437. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4438. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4439. order.ClrType = res.Output.Setlinfo.ClrType
  4440. order.ClrWay = res.Output.Setlinfo.ClrWay
  4441. order.Creator = order.Creator
  4442. order.Modify = roles.AdminUserId
  4443. order.RequestLog = src_resquest
  4444. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4445. detailStr := string(setlDetail)
  4446. order.SetlDetail = detailStr
  4447. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4448. err = service.UpDateOrder(order)
  4449. if err == nil {
  4450. c.ServeSuccessJSON(map[string]interface{}{
  4451. "msg": "结算成功",
  4452. })
  4453. } else {
  4454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4455. return
  4456. }
  4457. }
  4458. } else {
  4459. adminUser := c.GetAdminUserInfo()
  4460. errlog := &models.HisOrderError{
  4461. UserOrgId: adminUser.CurrentOrgId,
  4462. Ctime: time.Now().Unix(),
  4463. Mtime: time.Now().Unix(),
  4464. ErrMsg: res.ErrMsg,
  4465. Status: 1,
  4466. PatientId: id,
  4467. RecordTime: recordDateTime,
  4468. Stage: 4,
  4469. }
  4470. service.CreateErrMsgLog(errlog)
  4471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4472. return
  4473. }
  4474. } else {
  4475. adminUser := c.GetAdminUserInfo()
  4476. errlog := &models.HisOrderError{
  4477. UserOrgId: adminUser.CurrentOrgId,
  4478. Ctime: time.Now().Unix(),
  4479. Mtime: time.Now().Unix(),
  4480. ErrMsg: res.ErrMsg,
  4481. Status: 1,
  4482. PatientId: id,
  4483. RecordTime: recordDateTime,
  4484. Stage: 4,
  4485. }
  4486. service.CreateErrMsgLog(errlog)
  4487. c.ServeSuccessJSON(map[string]interface{}{
  4488. "failed_code": -10,
  4489. "msg": res.ErrMsg,
  4490. })
  4491. return
  4492. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4493. //return
  4494. }
  4495. }
  4496. }
  4497. } else if tempOrder.ID > 0 {
  4498. if tempOrder.IsPre == 1 {
  4499. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4500. var rf []*ResultFive
  4501. json.Unmarshal([]byte(his.Iinfo), &rf)
  4502. chrg_bchno := tempOrder.Number
  4503. cert_no := his.Certno
  4504. var insutypes []string
  4505. var insutype string
  4506. var is390 int = 0
  4507. var is310 int = 0
  4508. for _, item := range rf {
  4509. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4510. insutypes = append(insutypes, item.Insutype)
  4511. }
  4512. }
  4513. if len(insutypes) == 1 {
  4514. insutype = insutypes[0]
  4515. } else {
  4516. for _, i := range insutypes {
  4517. if i == "390" {
  4518. is390 = 1
  4519. }
  4520. if i == "310" {
  4521. is310 = 1
  4522. }
  4523. }
  4524. }
  4525. if is390 == 1 {
  4526. insutype = "390"
  4527. }
  4528. if is310 == 1 {
  4529. insutype = "310"
  4530. }
  4531. if len(insutypes) == 0 {
  4532. insutype = "310"
  4533. }
  4534. if len(insutypes) == 2 {
  4535. insutype = strconv.FormatInt(his.SocialType, 64)
  4536. }
  4537. //insutype = "390"
  4538. if his.IdCardType == 1 {
  4539. // cert_no = his.MedicalInsuranceNumber
  4540. cert_no = his.Certno
  4541. } else {
  4542. cert_no = his.Certno
  4543. }
  4544. var res ResultSeven
  4545. var resSeven10265 ResultSeven10265
  4546. var src_resquest string
  4547. var result2 string
  4548. var acct_used_flag string
  4549. fmt.Println("pay_way")
  4550. fmt.Println(pay_way)
  4551. fmt.Println("pay_way")
  4552. if pay_way == 4 {
  4553. acct_used_flag = "1"
  4554. } else {
  4555. acct_used_flag = "0"
  4556. }
  4557. if miConfig.MdtrtareaAdmvs == "421300" {
  4558. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4559. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4560. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4561. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4562. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4563. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4564. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4565. resp, requestErr := http.Get(api)
  4566. if requestErr != nil {
  4567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4568. return
  4569. }
  4570. body, ioErr := ioutil.ReadAll(resp.Body)
  4571. if ioErr != nil {
  4572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4574. return
  4575. }
  4576. var respJSON map[string]interface{}
  4577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4580. return
  4581. }
  4582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4583. result, _ := json.Marshal(respJSON)
  4584. fmt.Println("log")
  4585. fmt.Println(string(result))
  4586. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4587. utils.ErrorLog("解析失败:%v", err)
  4588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4589. return
  4590. }
  4591. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4592. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4593. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4594. //psn_info, _ := service.GetPsnByPatientId(id)
  4595. bas := strings.Split(psn_info.CardInfo, "|")
  4596. if his.IdCardType == 1 {
  4597. cert_no = bas[2]
  4598. } else {
  4599. cert_no = bas[1]
  4600. }
  4601. //江苏地区国家医保医疗类别
  4602. //职工透析:医疗类别选特殊情况门诊9933
  4603. //居民血透门慢: 医疗类别选门诊慢病1402
  4604. //var med_type string
  4605. //if his.Insutype == "310" {
  4606. // if reg_type == 14 {
  4607. // med_type = "9933"
  4608. // } else if reg_type == 11 {
  4609. // med_type = "11"
  4610. //
  4611. // }
  4612. //} else if his.Insutype == "390" {
  4613. // if reg_type == 14 {
  4614. // med_type = "1402"
  4615. // } else if reg_type == 11 {
  4616. // med_type = "11"
  4617. // }
  4618. //}
  4619. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4620. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4621. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4622. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4623. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4624. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4625. "&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
  4626. resp, requestErr := http.Get(api)
  4627. if requestErr != nil {
  4628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4629. return
  4630. }
  4631. body, ioErr := ioutil.ReadAll(resp.Body)
  4632. if ioErr != nil {
  4633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4635. return
  4636. }
  4637. var respJSON map[string]interface{}
  4638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4641. return
  4642. }
  4643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4644. result, _ := json.Marshal(respJSON)
  4645. fmt.Println("log")
  4646. fmt.Println(string(result))
  4647. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4648. utils.ErrorLog("解析失败:%v", err)
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4650. return
  4651. }
  4652. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4653. res.Output = resSeven10265.Output
  4654. res.ErrMsg = resSeven10265.ErrMsg
  4655. res.Cainfo = resSeven10265.Cainfo
  4656. res.WarnMsg = resSeven10265.WarnMsg
  4657. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4658. res.Infcode = infocode
  4659. } else {
  4660. var src_resquest string
  4661. if miConfig.Code == "H15049901371" {
  4662. //赤峰地区国家医保医疗类别
  4663. //职工透析:医疗类别选特殊情况门诊990502
  4664. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4665. var med_type string
  4666. if his.Insutype == "390" {
  4667. if reg_type == 14 {
  4668. med_type = "9933"
  4669. } else if reg_type == 11 {
  4670. med_type = "11"
  4671. }
  4672. } else if his.Insutype == "310" {
  4673. if reg_type == 14 {
  4674. med_type = "990502"
  4675. } else if reg_type == 11 {
  4676. med_type = "11"
  4677. }
  4678. }
  4679. 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)
  4680. } else {
  4681. 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)
  4682. }
  4683. var dat map[string]interface{}
  4684. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4685. fmt.Println(dat)
  4686. } else {
  4687. fmt.Println(err)
  4688. }
  4689. saveLog(result2, src_resquest, "2207", "结算")
  4690. userJSONBytes, _ := json.Marshal(dat)
  4691. if miConfig.Code == "H15049901371" {
  4692. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4693. utils.ErrorLog("解析失败:%v", err)
  4694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4695. return
  4696. }
  4697. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4698. res.Output = resSeven10265.Output
  4699. res.ErrMsg = resSeven10265.ErrMsg
  4700. res.Cainfo = resSeven10265.Cainfo
  4701. res.WarnMsg = resSeven10265.WarnMsg
  4702. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4703. res.Infcode = infocode
  4704. } else {
  4705. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4706. utils.ErrorLog("解析失败:%v", err)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. }
  4711. }
  4712. if res.Infcode != 0 {
  4713. errlog := &models.HisOrderError{
  4714. UserOrgId: adminUser.CurrentOrgId,
  4715. Ctime: time.Now().Unix(),
  4716. Mtime: time.Now().Unix(),
  4717. Number: chrg_bchno,
  4718. ErrMsg: res.ErrMsg,
  4719. Status: 1,
  4720. PatientId: id,
  4721. RecordTime: recordDateTime,
  4722. Stage: 6,
  4723. }
  4724. service.CreateErrMsgLog(errlog)
  4725. c.ServeSuccessJSON(map[string]interface{}{
  4726. "failed_code": -10,
  4727. "msg": res.ErrMsg,
  4728. })
  4729. return
  4730. } else {
  4731. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4732. order.OrderStatus = 2
  4733. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4734. order.SetlId = res.Output.Setlinfo.SetlID
  4735. order.PsnNo = res.Output.Setlinfo.PsnNo
  4736. order.PsnName = res.Output.Setlinfo.PsnName
  4737. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4738. order.Certno = res.Output.Setlinfo.Certno
  4739. order.Gend = res.Output.Setlinfo.Gend
  4740. order.Naty = res.Output.Setlinfo.Naty
  4741. order.Age = res.Output.Setlinfo.Age
  4742. order.Insutype = res.Output.Setlinfo.Insutype
  4743. order.PsnType = res.Output.Setlinfo.PsnType
  4744. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4745. order.SetlTime = res.Output.Setlinfo.SetlTime
  4746. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4747. //order.MedType = res.Output.Setlinfo.MedType
  4748. if reg_type == 1112 {
  4749. order.MedType = "1112"
  4750. }
  4751. if reg_type == 1111 {
  4752. order.MedType = "1111"
  4753. }
  4754. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4755. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4756. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4757. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4758. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4759. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4760. order.HifpPay = res.Output.Setlinfo.HifpPay
  4761. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4762. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4763. order.HifesPay = res.Output.Setlinfo.HifesPay
  4764. order.HifobPay = res.Output.Setlinfo.HifobPay
  4765. order.MafPay = res.Output.Setlinfo.MafPay
  4766. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4767. order.OthPay = res.Output.Setlinfo.OthPay
  4768. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4769. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4770. order.AcctPay = res.Output.Setlinfo.AcctPay
  4771. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4772. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4773. order.Balc = res.Output.Setlinfo.Balc
  4774. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4775. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4776. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4777. order.ClrWay = res.Output.Setlinfo.ClrWay
  4778. order.Creator = order.Creator
  4779. order.Modify = roles.AdminUserId
  4780. order.RequestLog = src_resquest
  4781. order.Diagnosis = diagnosis_id
  4782. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4783. detailStr := string(setlDetail)
  4784. order.SetlDetail = detailStr
  4785. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4786. err = service.UpDateOrder(order)
  4787. if err == nil {
  4788. c.ServeSuccessJSON(map[string]interface{}{
  4789. "msg": "结算成功",
  4790. })
  4791. } else {
  4792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4793. return
  4794. }
  4795. }
  4796. }
  4797. }
  4798. }
  4799. //func (c *HisApiController) GetPreUploadInfo() {
  4800. // id, _ := c.GetInt64("id")
  4801. // record_time := c.GetString("record_time")
  4802. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4803. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4804. //
  4805. // timeLayout := "2006-01-02"
  4806. // loc, _ := time.LoadLocation("Local")
  4807. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4808. // if err != nil {
  4809. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4810. // return
  4811. // }
  4812. // recordDateTime := theTime.Unix()
  4813. // adminUser := c.GetAdminUserInfo()
  4814. //
  4815. // var prescriptions []*models.HisPrescription
  4816. //
  4817. // var start_time int64
  4818. // var end_time int64
  4819. //
  4820. // data := make(map[string]interface{})
  4821. // if settle_accounts_type == 1 { //日结
  4822. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4823. // data["pre"] = prescriptions
  4824. //
  4825. // } else { //月结
  4826. // start_time_str := c.GetString("start_time")
  4827. // end_time_str := c.GetString("end_time")
  4828. // timeLayout := "2006-01-02"
  4829. // loc, _ := time.LoadLocation("Local")
  4830. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4831. // if err != nil {
  4832. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4833. // return
  4834. // }
  4835. // recordStartTime := theStartTime.Unix()
  4836. // start_time = recordStartTime
  4837. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4838. // if err != nil {
  4839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4840. // return
  4841. // }
  4842. // recordEndTime := theEndTime.Unix()
  4843. // end_time = recordEndTime
  4844. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4845. // data["pre"] = prescriptions
  4846. //
  4847. // }
  4848. //
  4849. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4850. //
  4851. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4852. // timestamp := time.Now().Unix()
  4853. // tempTime := time.Unix(timestamp, 0)
  4854. // timeFormat := tempTime.Format("20060102150405")
  4855. // chrgBchno := rand.Intn(100000) + 10000
  4856. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4857. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4858. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4859. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4860. // strconv.FormatInt(his.PatientId, 10)
  4861. // client := &http.Client{}
  4862. // data["psn_no"] = his.PsnNo
  4863. // data["mdtrt_id"] = his.Number
  4864. // data["chrg_bchno"] = chrg_bchno
  4865. // data["org_name"] = miConfig.OrgName
  4866. // data["doctor"] = roles.UserName
  4867. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4868. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4869. // data["fixmedins_code"] = miConfig.Code
  4870. // data["dept_code"] = department.Number
  4871. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4872. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4873. // data["secret_key"] = miConfig.SecretKey
  4874. // var ids []int64
  4875. //
  4876. // for _, item := range prescriptions {
  4877. // ids = append(ids, item.ID)
  4878. // }
  4879. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4880. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4881. // bytesData, _ := json.Marshal(data)
  4882. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4883. // resp, _ := client.Do(req)
  4884. // defer resp.Body.Close()
  4885. // body, ioErr := ioutil.ReadAll(resp.Body)
  4886. // if ioErr != nil {
  4887. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4889. // return
  4890. // }
  4891. // var respJSON map[string]interface{}
  4892. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4893. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4895. // return
  4896. // }
  4897. //
  4898. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4899. // userJSONBytes, _ := json.Marshal(respJSON)
  4900. // var res ResultFour
  4901. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4902. // utils.ErrorLog("解析失败:%v", err)
  4903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4904. // return
  4905. // }
  4906. //
  4907. // if res.Infcode == 0 {
  4908. // order := &models.HisOrder{
  4909. // UserOrgId: adminUser.CurrentOrgId,
  4910. // HisPatientId: his.ID,
  4911. // PatientId: his.PatientId,
  4912. // SettleAccountsDate: recordDateTime,
  4913. // Ctime: time.Now().Unix(),
  4914. // Mtime: time.Now().Unix(),
  4915. // Status: 1,
  4916. // Number: chrg_bchno,
  4917. // Infcode: res.Infcode,
  4918. // WarnMsg: res.WarnMsg,
  4919. // Cainfo: res.Cainfo,
  4920. // ErrMsg: res.ErrMsg,
  4921. // RespondTime: res.RefmsgTime,
  4922. // InfRefmsgid: res.InfRefmsgid,
  4923. // OrderStatus: 1,
  4924. // IsMedicineInsurance: 1,
  4925. // SettleType: settle_accounts_type,
  4926. // SettleStartTime: start_time,
  4927. // SettleEndTime: end_time,
  4928. // Creator: roles.ID,
  4929. // Modify: roles.ID,
  4930. // PType: 2,
  4931. // }
  4932. // err = service.CreateOrder(order)
  4933. // if err != nil {
  4934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4935. // return
  4936. // }
  4937. //
  4938. // for _, item := range res.Output.Result {
  4939. // temp := strings.Split(item.FeedetlSn, "-")
  4940. // var advice_id int64 = 0
  4941. // var project_id int64 = 0
  4942. // var types int64 = 0
  4943. //
  4944. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4945. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4946. //
  4947. // if temp[1] == "1" {
  4948. // advice_id = id
  4949. // project_id = 0
  4950. // } else if temp[1] == "2" {
  4951. // advice_id = 0
  4952. // project_id = id
  4953. // }
  4954. //
  4955. // info := &models.HisOrderInfo{
  4956. // OrderNumber: order.Number,
  4957. // FeedetlSn: item.FeedetlSn,
  4958. // UploadDate: time.Now().Unix(),
  4959. // AdviceId: advice_id,
  4960. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4961. // Cnt: item.Cnt,
  4962. // Pric: float64(item.Pric),
  4963. // PatientId: his.PatientId,
  4964. // PricUplmtAmt: item.PricUplmtAmt,
  4965. // SelfpayProp: item.SelfpayProp,
  4966. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4967. // OverlmtAmt: item.OverlmtAmt,
  4968. // PreselfpayAmt: item.PreselfpayAmt,
  4969. // BasMednFlag: item.BasMednFlag,
  4970. // MedChrgitmType: item.MedChrgitmType,
  4971. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4972. // Status: 1,
  4973. // Memo: item.Memo,
  4974. // Mtime: time.Now().Unix(),
  4975. // InscpScpAmt: item.InscpScpAmt,
  4976. // DrtReimFlag: item.DrtReimFlag,
  4977. // Ctime: time.Now().Unix(),
  4978. // ListSpItemFlag: item.ListSpItemFlag,
  4979. // ChldMedcFlag: item.ChldMedcFlag,
  4980. // LmtUsedFlag: item.LmtUsedFlag,
  4981. // ChrgitmLv: item.ChrgitmLv,
  4982. // UserOrgId: adminUser.CurrentOrgId,
  4983. // HisPatientId: his.ID,
  4984. // OrderId: order.ID,
  4985. // ProjectId: project_id,
  4986. // Type: types,
  4987. // }
  4988. // service.CreateOrderInfo(info)
  4989. //
  4990. // }
  4991. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4992. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4993. //
  4994. // var total float64
  4995. // for _, item := range prescriptions {
  4996. // if item.Type == 1 { //药品
  4997. // for _, subItem := range item.HisDoctorAdviceInfo {
  4998. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4999. // }
  5000. // }
  5001. // if item.Type == 2 { //项目
  5002. // for _, subItem := range item.HisPrescriptionProject {
  5003. // total = total + (subItem.Price * float64(subItem.Count))
  5004. // }
  5005. // }
  5006. // }
  5007. //
  5008. // for _, item := range prescriptions {
  5009. // for _, subItem := range item.HisAdditionalCharge {
  5010. // total = total + (subItem.Price * float64(subItem.Count))
  5011. // }
  5012. // }
  5013. //
  5014. // allTotal := fmt.Sprintf("%.2f", total)
  5015. // if res.Infcode == 0 {
  5016. // var rf []*ResultFive
  5017. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5018. // psn_no := his.PsnNo
  5019. // mdtrt_id := his.Number
  5020. // chrg_bchno := chrg_bchno
  5021. // cert_no := his.Certno
  5022. // insutype := rf[0].Insutype
  5023. //
  5024. // if his.IdCardType == 1 {
  5025. // cert_no = his.MedicalInsuranceNumber
  5026. //
  5027. // } else {
  5028. //
  5029. // cert_no = his.Certno
  5030. //
  5031. // }
  5032. //
  5033. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5034. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5035. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5036. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5037. // resp, requestErr := http.Get(api)
  5038. // if requestErr != nil {
  5039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5040. // return
  5041. // }
  5042. // defer resp.Body.Close()
  5043. // body, ioErr := ioutil.ReadAll(resp.Body)
  5044. // if ioErr != nil {
  5045. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5047. // return
  5048. // }
  5049. // var respJSON map[string]interface{}
  5050. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5051. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5053. // return
  5054. // }
  5055. // fmt.Println(respJSON)
  5056. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5057. // userJSONBytes, _ := json.Marshal(respJSON)
  5058. // var res ResultSeven
  5059. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5060. // utils.ErrorLog("解析失败:%v", err)
  5061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5062. // return
  5063. // }
  5064. // if res.Infcode != 0 {
  5065. // errlog := &models.HisOrderError{
  5066. // UserOrgId: adminUser.CurrentOrgId,
  5067. // Ctime: time.Now().Unix(),
  5068. // Mtime: time.Now().Unix(),
  5069. // Number: chrg_bchno,
  5070. // ErrMsg: res.ErrMsg,
  5071. // Status: 1,
  5072. // PatientId: id,
  5073. // RecordTime: recordDateTime,
  5074. // Stage: 7,
  5075. // }
  5076. // service.CreateErrMsgLog(errlog)
  5077. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5078. // return
  5079. // } else {
  5080. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5081. // order.OrderStatus = 1
  5082. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5083. // order.SetlId = res.Output.Setlinfo.SetlID
  5084. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5085. // order.PsnName = res.Output.Setlinfo.PsnName
  5086. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5087. // order.Certno = res.Output.Setlinfo.Certno
  5088. // order.Gend = res.Output.Setlinfo.Gend
  5089. // order.Naty = res.Output.Setlinfo.Naty
  5090. // order.Age = res.Output.Setlinfo.Age
  5091. // order.Insutype = res.Output.Setlinfo.Insutype
  5092. // order.PsnType = res.Output.Setlinfo.PsnType
  5093. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5094. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5095. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5096. // order.MedType = res.Output.Setlinfo.MedType
  5097. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5098. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5099. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5100. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5101. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5102. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5103. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5104. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5105. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5106. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5107. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5108. // order.MafPay = res.Output.Setlinfo.MafPay
  5109. // order.OthPay = res.Output.Setlinfo.OthPay
  5110. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5111. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5112. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5113. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5114. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5115. // order.Balc = res.Output.Setlinfo.Balc
  5116. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5117. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5118. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5119. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5120. // order.Creator = order.Creator
  5121. // order.Modify = roles.ID
  5122. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5123. // detailStr := string(setlDetail)
  5124. // order.SetlDetail = detailStr
  5125. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5126. // err = service.UpDateOrder(order)
  5127. // if err == nil {
  5128. // c.ServeSuccessJSON(map[string]interface{}{
  5129. // "msg": "预结算成功",
  5130. // })
  5131. // } else {
  5132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5133. // return
  5134. // }
  5135. // }
  5136. // } else {
  5137. // adminUser := c.GetAdminUserInfo()
  5138. // errlog := &models.HisOrderError{
  5139. // UserOrgId: adminUser.CurrentOrgId,
  5140. // Ctime: time.Now().Unix(),
  5141. // Mtime: time.Now().Unix(),
  5142. // ErrMsg: res.ErrMsg,
  5143. // Status: 1,
  5144. // PatientId: id,
  5145. // RecordTime: recordDateTime,
  5146. // Stage: 4,
  5147. // }
  5148. // service.CreateErrMsgLog(errlog)
  5149. //
  5150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5151. // return
  5152. // }
  5153. // } else {
  5154. // adminUser := c.GetAdminUserInfo()
  5155. // errlog := &models.HisOrderError{
  5156. // UserOrgId: adminUser.CurrentOrgId,
  5157. // Ctime: time.Now().Unix(),
  5158. // Mtime: time.Now().Unix(),
  5159. // ErrMsg: res.ErrMsg,
  5160. // Status: 1,
  5161. // PatientId: id,
  5162. // RecordTime: recordDateTime,
  5163. // Stage: 4,
  5164. // }
  5165. // service.CreateErrMsgLog(errlog)
  5166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5167. // return
  5168. // }
  5169. //
  5170. // } else {
  5171. // var total float64
  5172. // for _, item := range prescriptions {
  5173. // if item.Type == 1 { //药品
  5174. // for _, subItem := range item.HisDoctorAdviceInfo {
  5175. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5176. // }
  5177. // }
  5178. // if item.Type == 2 { //项目
  5179. // for _, subItem := range item.HisPrescriptionProject {
  5180. // total = total + (subItem.Price * float64(subItem.Count))
  5181. // }
  5182. // }
  5183. //
  5184. // for _, subItem := range item.HisAdditionalCharge {
  5185. // total = total + (subItem.Price * float64(subItem.Count))
  5186. // }
  5187. // }
  5188. //
  5189. // allTotal := fmt.Sprintf("%.2f", total)
  5190. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5191. // order := &models.HisOrder{
  5192. // UserOrgId: adminUser.CurrentOrgId,
  5193. // HisPatientId: his.ID,
  5194. // PatientId: id,
  5195. // SettleAccountsDate: recordDateTime,
  5196. // Ctime: time.Now().Unix(),
  5197. // Mtime: time.Now().Unix(),
  5198. // Status: 1,
  5199. // OrderStatus: 2,
  5200. // Number: chrg_bchno,
  5201. // MedfeeSumamt: totals,
  5202. // }
  5203. // err = service.CreateOrder(order)
  5204. // if err != nil {
  5205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5206. // return
  5207. // }
  5208. //
  5209. // var customs []*Custom
  5210. // for _, item := range prescriptions {
  5211. //
  5212. // if item.Type == 1 { //药品
  5213. // for _, subItem := range item.HisDoctorAdviceInfo {
  5214. // cus := &Custom{
  5215. // AdviceId: subItem.ID,
  5216. // ProjectId: 0,
  5217. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5218. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5219. // FeedetlSn: subItem.FeedetlSn,
  5220. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5221. // MedListCodg: subItem.MedListCodg,
  5222. // Type: 1,
  5223. // }
  5224. // customs = append(customs, cus)
  5225. // }
  5226. // }
  5227. //
  5228. // if item.Type == 2 { //项目
  5229. // for _, subItem := range item.HisPrescriptionProject {
  5230. //
  5231. // cus := &Custom{
  5232. // AdviceId: 0,
  5233. // ProjectId: subItem.ID,
  5234. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5235. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5236. // FeedetlSn: subItem.FeedetlSn,
  5237. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5238. // MedListCodg: subItem.MedListCodg,
  5239. // Type: 2,
  5240. // }
  5241. //
  5242. // customs = append(customs, cus)
  5243. // }
  5244. // }
  5245. //
  5246. // for _, item := range item.HisAdditionalCharge {
  5247. // cus := &Custom{
  5248. // ItemId: item.ID,
  5249. // AdviceId: 0,
  5250. // ProjectId: 0,
  5251. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5252. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5253. // FeedetlSn: item.FeedetlSn,
  5254. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5255. // MedListCodg: item.XtHisAddtionConfig.Code,
  5256. // Type: 3,
  5257. // }
  5258. //
  5259. // customs = append(customs, cus)
  5260. // }
  5261. //
  5262. // }
  5263. //
  5264. // for _, item := range customs {
  5265. // var advice_id int64 = 0
  5266. // var project_id int64 = 0
  5267. // var item_id int64 = 0
  5268. //
  5269. // var types int64 = 0
  5270. //
  5271. // if item.Type == 1 {
  5272. // advice_id = item.AdviceId
  5273. // project_id = 0
  5274. // item_id = 0
  5275. // } else if item.Type == 2 {
  5276. // advice_id = 0
  5277. // item_id = 0
  5278. //
  5279. // project_id = item.ProjectId
  5280. // } else if item.Type == 3 {
  5281. // advice_id = 0
  5282. // item_id = item.ItemId
  5283. // project_id = 0
  5284. // }
  5285. //
  5286. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5287. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5288. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5289. //
  5290. // info := &models.HisOrderInfo{
  5291. // OrderNumber: order.Number,
  5292. // UploadDate: time.Now().Unix(),
  5293. // AdviceId: advice_id,
  5294. // DetItemFeeSumamt: detItemFeeSumamt,
  5295. // Cnt: cut,
  5296. // Pric: pric,
  5297. // PatientId: id,
  5298. // Status: 1,
  5299. // Mtime: time.Now().Unix(),
  5300. // Ctime: time.Now().Unix(),
  5301. // UserOrgId: adminUser.CurrentOrgId,
  5302. // HisPatientId: his.ID,
  5303. // OrderId: order.ID,
  5304. // ProjectId: project_id,
  5305. // Type: types,
  5306. // ItemId: item_id,
  5307. // }
  5308. // service.CreateOrderInfo(info)
  5309. // }
  5310. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5311. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5312. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5313. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5314. // if err == nil {
  5315. // c.ServeSuccessJSON(map[string]interface{}{
  5316. // "msg": "结算成功",
  5317. // })
  5318. // } else {
  5319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5320. // return
  5321. // }
  5322. // }
  5323. //}
  5324. //上传明细-预结算-
  5325. func (c *HisApiController) GetPreUploadInfo() {
  5326. id, _ := c.GetInt64("id")
  5327. record_time := c.GetString("record_time")
  5328. his_patient_id, _ := c.GetInt64("his_patient_id")
  5329. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5330. admin_user_id, _ := c.GetInt64("admin_user_id")
  5331. diagnosis_id := c.GetString("diagnosis")
  5332. sick_type, _ := c.GetInt64("sick_type")
  5333. reg_type, _ := c.GetInt64("p_type")
  5334. begin_time := c.GetString("begin_time")
  5335. id_str := c.GetString("ids")
  5336. ids_arr := strings.Split(id_str, ",")
  5337. timeLayout := "2006-01-02"
  5338. loc, _ := time.LoadLocation("Local")
  5339. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5340. if err != nil {
  5341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5342. return
  5343. }
  5344. recordDateTime := theTime.Unix()
  5345. adminUser := c.GetAdminUserInfo()
  5346. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5347. var config []*models.HisXtDiagnoseConfig
  5348. for _, item := range diagnosis_ids {
  5349. id, _ := strconv.ParseInt(item, 10, 64)
  5350. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5351. config = append(config, &diagnosisConfig)
  5352. }
  5353. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5354. sickConfig, _ := service.FindSickById(sick_type)
  5355. var prescriptions []*models.HisPrescription
  5356. var start_time int64
  5357. var end_time int64
  5358. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5359. fmt.Println(his_patient_id)
  5360. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5361. timestamp := time.Now().Unix()
  5362. tempTime := time.Unix(timestamp, 0)
  5363. timeFormat := tempTime.Format("20060102150405")
  5364. chrgBchno := rand.Intn(100000) + 10000
  5365. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5366. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5367. var patientPrescription models.HisPrescriptionInfo
  5368. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5369. if patientPrescription.ID == 0 {
  5370. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5371. }
  5372. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5373. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5374. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5375. strconv.FormatInt(his.PatientId, 10)
  5376. var res2 ResultSix
  5377. var resSix10265 ResultSix10265
  5378. var time_stamp string
  5379. if miConfig.MdtrtareaAdmvs == "421300" {
  5380. data := make(map[string]interface{})
  5381. client := &http.Client{}
  5382. data["psn_no"] = his.PsnNo
  5383. data["mdtrt_id"] = his.Number
  5384. data["doctor"] = roles.UserName
  5385. data["department"] = department.Name
  5386. data["org_name"] = miConfig.OrgName
  5387. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5388. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5389. data["fixmedins_code"] = miConfig.Code
  5390. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5391. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5392. data["secret_key"] = miConfig.SecretKey
  5393. data["sick_code"] = sickConfig.CountryCode
  5394. data["sick_name"] = sickConfig.ClassName
  5395. data["begin_time"] = begin_time
  5396. data["dept"] = strconv.FormatInt(department.ID, 10)
  5397. data["config"] = config
  5398. fmt.Println(data)
  5399. bytesData, _ := json.Marshal(data)
  5400. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5401. resp, _ := client.Do(req)
  5402. defer resp.Body.Close()
  5403. body, ioErr := ioutil.ReadAll(resp.Body)
  5404. if ioErr != nil {
  5405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5407. return
  5408. }
  5409. var respJSON map[string]interface{}
  5410. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5413. return
  5414. }
  5415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5416. userJSONBytes, _ := json.Marshal(respJSON)
  5417. fmt.Println("log")
  5418. fmt.Println(string(userJSONBytes))
  5419. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5420. utils.ErrorLog("解析失败:%v", err)
  5421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5422. return
  5423. }
  5424. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5425. //江苏地区国家医保医疗类别
  5426. //职工透析:医疗类别选特殊情况门诊9933
  5427. //居民血透门慢: 医疗类别选门诊慢病1402
  5428. //var med_type string
  5429. //if his.Insutype == "310" {
  5430. // if reg_type == 14 {
  5431. // med_type = "9933"
  5432. // } else if reg_type == 11 {
  5433. // med_type = "11"
  5434. //
  5435. // }
  5436. //} else if his.Insutype == "390" {
  5437. // if reg_type == 14 {
  5438. // med_type = "1402"
  5439. // } else if reg_type == 11 {
  5440. // med_type = "11"
  5441. // }
  5442. //}
  5443. data := make(map[string]interface{})
  5444. client := &http.Client{}
  5445. data["psn_no"] = his.PsnNo
  5446. data["mdtrt_id"] = his.Number
  5447. data["doctor"] = roles.UserName
  5448. data["department"] = department.Name
  5449. data["org_name"] = miConfig.OrgName
  5450. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5451. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5452. data["fixmedins_code"] = miConfig.Code
  5453. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5454. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5455. data["secret_key"] = miConfig.SecretKey
  5456. data["sick_code"] = sickConfig.CountryCode
  5457. data["sick_name"] = sickConfig.ClassName
  5458. data["begin_time"] = begin_time
  5459. data["dept"] = strconv.FormatInt(department.ID, 10)
  5460. data["config"] = config
  5461. data["url"] = miConfig.Url
  5462. data["ak"] = miConfig.AccessKey
  5463. data["cainfo"] = miConfig.Cainfo
  5464. bytesData, _ := json.Marshal(data)
  5465. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5466. resp, _ := client.Do(req)
  5467. defer resp.Body.Close()
  5468. body, ioErr := ioutil.ReadAll(resp.Body)
  5469. if ioErr != nil {
  5470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5472. return
  5473. }
  5474. var respJSON map[string]interface{}
  5475. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5478. return
  5479. }
  5480. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5481. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5482. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5483. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5484. userJSONBytes, _ := json.Marshal(respJSON)
  5485. fmt.Println("log")
  5486. fmt.Println(string(userJSONBytes))
  5487. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5488. utils.ErrorLog("解析失败:%v", err)
  5489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5490. return
  5491. }
  5492. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5493. res2.Output = resSix10265.Output
  5494. res2.ErrMsg = resSix10265.ErrMsg
  5495. res2.Cainfo = resSix10265.Cainfo
  5496. res2.WarnMsg = resSix10265.WarnMsg
  5497. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5498. res2.Infcode = infocode
  5499. } else {
  5500. var result string
  5501. var requestLog string
  5502. if miConfig.MdtrtareaAdmvs == "440781" { //
  5503. 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)
  5504. } else {
  5505. if miConfig.Code == "H15049901371" {
  5506. //赤峰地区国家医保医疗类别
  5507. //职工透析:医疗类别选特殊情况门诊990502
  5508. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5509. var med_type string
  5510. if his.Insutype == "390" {
  5511. if reg_type == 14 {
  5512. med_type = "9933"
  5513. } else if reg_type == 11 {
  5514. med_type = "11"
  5515. }
  5516. } else if his.Insutype == "310" {
  5517. if reg_type == 14 {
  5518. med_type = "990502"
  5519. } else if reg_type == 11 {
  5520. med_type = "11"
  5521. }
  5522. }
  5523. 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)
  5524. } else {
  5525. 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)
  5526. }
  5527. saveLog(result, requestLog, "2203", "上传就诊信息")
  5528. var respJSON2 map[string]interface{}
  5529. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5532. return
  5533. }
  5534. userJSONBytes2, _ := json.Marshal(respJSON2)
  5535. if miConfig.Code == "H15049901371" {
  5536. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5537. utils.ErrorLog("解析失败:%v", err)
  5538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5539. return
  5540. }
  5541. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5542. res2.Output = resSix10265.Output
  5543. res2.ErrMsg = resSix10265.ErrMsg
  5544. res2.Cainfo = resSix10265.Cainfo
  5545. res2.WarnMsg = resSix10265.WarnMsg
  5546. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5547. res2.Infcode = infocode
  5548. } else {
  5549. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5550. utils.ErrorLog("解析失败:%v", err)
  5551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5552. return
  5553. }
  5554. }
  5555. }
  5556. }
  5557. if res2.Infcode != 0 {
  5558. adminUser := c.GetAdminUserInfo()
  5559. errlog := &models.HisOrderError{
  5560. UserOrgId: adminUser.CurrentOrgId,
  5561. Ctime: time.Now().Unix(),
  5562. Mtime: time.Now().Unix(),
  5563. ErrMsg: res2.ErrMsg,
  5564. Status: 1,
  5565. PatientId: id,
  5566. RecordTime: recordDateTime,
  5567. Stage: 3,
  5568. }
  5569. service.CreateErrMsgLog(errlog)
  5570. c.ServeSuccessJSON(map[string]interface{}{
  5571. "failed_code": -10,
  5572. "msg": res2.ErrMsg,
  5573. })
  5574. return
  5575. } else {
  5576. his.Diagnosis = diagnosis_id
  5577. his.SickType = sickConfig.ID
  5578. his.PType = fmt.Sprintf("%d", reg_type)
  5579. service.UpdateHisPatientThree(&his)
  5580. data := make(map[string]interface{})
  5581. if settle_accounts_type == 1 { //日结
  5582. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5583. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5584. } else {
  5585. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5586. }
  5587. data["pre"] = prescriptions
  5588. } else { //月结
  5589. start_time_str := c.GetString("start_time")
  5590. end_time_str := c.GetString("end_time")
  5591. timeLayout := "2006-01-02"
  5592. loc, _ := time.LoadLocation("Local")
  5593. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5594. if err != nil {
  5595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5596. return
  5597. }
  5598. recordStartTime := theStartTime.Unix()
  5599. start_time = recordStartTime
  5600. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5601. if err != nil {
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5603. return
  5604. }
  5605. recordEndTime := theEndTime.Unix()
  5606. end_time = recordEndTime
  5607. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5608. data["pre"] = prescriptions
  5609. }
  5610. client := &http.Client{}
  5611. data["psn_no"] = his.PsnNo
  5612. data["mdtrt_id"] = his.Number
  5613. data["chrg_bchno"] = chrg_bchno
  5614. data["org_name"] = miConfig.OrgName
  5615. data["doctor"] = roles.UserName
  5616. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5617. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5618. data["fixmedins_code"] = miConfig.Code
  5619. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5620. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5621. data["dept_code"] = "15"
  5622. } else {
  5623. data["dept_code"] = department.Number
  5624. }
  5625. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5626. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5627. data["secret_key"] = miConfig.SecretKey
  5628. data["url"] = miConfig.Url
  5629. data["ak"] = miConfig.AccessKey
  5630. data["new_doctor_name"] = patientPrescription.Doctor
  5631. data["diag_code"] = sickConfig.CountryCode
  5632. data["time_stamp"] = time_stamp
  5633. data["cainfo"] = miConfig.Cainfo
  5634. var ids []int64
  5635. for _, item := range prescriptions {
  5636. ids = append(ids, item.ID)
  5637. }
  5638. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5639. if config.IsOpen == 1 { //对接了医保,走医保流程
  5640. var res ResultFour
  5641. var resFour10265 ResultFour10265
  5642. if miConfig.MdtrtareaAdmvs == "421300" {
  5643. bytesData, _ := json.Marshal(data)
  5644. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5645. resp, _ := client.Do(req)
  5646. defer resp.Body.Close()
  5647. body, ioErr := ioutil.ReadAll(resp.Body)
  5648. if ioErr != nil {
  5649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5651. return
  5652. }
  5653. var respJSON map[string]interface{}
  5654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5657. return
  5658. }
  5659. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5660. userJSONBytes, _ := json.Marshal(respJSON)
  5661. fmt.Println("log")
  5662. fmt.Println(string(userJSONBytes))
  5663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5664. utils.ErrorLog("解析失败:%v", err)
  5665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5666. return
  5667. }
  5668. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5669. bytesData, _ := json.Marshal(data)
  5670. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5671. resp, _ := client.Do(req)
  5672. defer resp.Body.Close()
  5673. body, ioErr := ioutil.ReadAll(resp.Body)
  5674. if ioErr != nil {
  5675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. return
  5678. }
  5679. var respJSON map[string]interface{}
  5680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return
  5684. }
  5685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5686. userJSONBytes, _ := json.Marshal(respJSON)
  5687. fmt.Println("log")
  5688. fmt.Println(string(userJSONBytes))
  5689. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5690. utils.ErrorLog("解析失败:%v", err)
  5691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5692. return
  5693. }
  5694. res.InfRefmsgid = resFour10265.InfRefmsgid
  5695. res.Output = resFour10265.Output
  5696. res.ErrMsg = resFour10265.ErrMsg
  5697. res.Cainfo = resFour10265.Cainfo
  5698. res.WarnMsg = resFour10265.WarnMsg
  5699. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5700. res.Infcode = infocode
  5701. } else {
  5702. if miConfig.Code == "H15049901371" {
  5703. 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)
  5704. var dat map[string]interface{}
  5705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5706. fmt.Println(dat)
  5707. } else {
  5708. fmt.Println(err)
  5709. }
  5710. saveLog(result, request_log, "2204", "上传费用明细")
  5711. userJSONBytes, _ := json.Marshal(dat)
  5712. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5713. utils.ErrorLog("解析失败:%v", err)
  5714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5715. return
  5716. }
  5717. res.InfRefmsgid = resFour10265.InfRefmsgid
  5718. res.Output = resFour10265.Output
  5719. res.ErrMsg = resFour10265.ErrMsg
  5720. res.Cainfo = resFour10265.Cainfo
  5721. res.WarnMsg = resFour10265.WarnMsg
  5722. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5723. res.Infcode = infocode
  5724. } else {
  5725. 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)
  5726. var dat map[string]interface{}
  5727. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5728. fmt.Println(dat)
  5729. } else {
  5730. fmt.Println(err)
  5731. }
  5732. saveLog(result, request_log, "2204", "上传费用明细")
  5733. userJSONBytes, _ := json.Marshal(dat)
  5734. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5735. utils.ErrorLog("解析失败:%v", err)
  5736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5737. return
  5738. }
  5739. }
  5740. }
  5741. if res.Infcode == 0 {
  5742. order := &models.HisOrder{
  5743. UserOrgId: adminUser.CurrentOrgId,
  5744. HisPatientId: his.ID,
  5745. PatientId: his.PatientId,
  5746. SettleAccountsDate: recordDateTime,
  5747. Ctime: time.Now().Unix(),
  5748. Mtime: time.Now().Unix(),
  5749. MdtrtId: his.Number,
  5750. PsnNo: his.PsnNo,
  5751. MedType: strconv.FormatInt(reg_type, 10),
  5752. Status: 1,
  5753. Number: chrg_bchno,
  5754. Infcode: res.Infcode,
  5755. WarnMsg: res.WarnMsg,
  5756. Cainfo: res.Cainfo,
  5757. ErrMsg: res.ErrMsg,
  5758. RespondTime: res.RefmsgTime,
  5759. InfRefmsgid: res.InfRefmsgid,
  5760. OrderStatus: 1,
  5761. IsMedicineInsurance: 1,
  5762. SettleType: settle_accounts_type,
  5763. SettleStartTime: start_time,
  5764. SettleEndTime: end_time,
  5765. Creator: roles.AdminUserId,
  5766. Modify: roles.AdminUserId,
  5767. PType: 2,
  5768. Diagnosis: diagnosis_id,
  5769. }
  5770. err = service.CreateOrder(order)
  5771. if err != nil {
  5772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5773. return
  5774. }
  5775. for _, item := range res.Output.Result {
  5776. temp := strings.Split(item.FeedetlSn, "-")
  5777. var advice_id int64 = 0
  5778. var project_id int64 = 0
  5779. var types int64 = 0
  5780. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5781. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5782. if temp[1] == "1" {
  5783. advice_id = id
  5784. project_id = 0
  5785. } else if temp[1] == "2" {
  5786. advice_id = 0
  5787. project_id = id
  5788. }
  5789. info := &models.HisOrderInfo{
  5790. OrderNumber: order.Number,
  5791. FeedetlSn: item.FeedetlSn,
  5792. UploadDate: time.Now().Unix(),
  5793. AdviceId: advice_id,
  5794. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5795. Cnt: item.Cnt,
  5796. Pric: float64(item.Pric),
  5797. PatientId: his.PatientId,
  5798. PricUplmtAmt: item.PricUplmtAmt,
  5799. SelfpayProp: item.SelfpayProp,
  5800. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5801. OverlmtAmt: item.OverlmtAmt,
  5802. PreselfpayAmt: item.PreselfpayAmt,
  5803. BasMednFlag: item.BasMednFlag,
  5804. MedChrgitmType: item.MedChrgitmType,
  5805. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5806. Status: 1,
  5807. Memo: item.Memo,
  5808. Mtime: time.Now().Unix(),
  5809. InscpScpAmt: item.InscpScpAmt,
  5810. DrtReimFlag: item.DrtReimFlag,
  5811. Ctime: time.Now().Unix(),
  5812. ListSpItemFlag: item.ListSpItemFlag,
  5813. ChldMedcFlag: item.ChldMedcFlag,
  5814. LmtUsedFlag: item.LmtUsedFlag,
  5815. ChrgitmLv: item.ChrgitmLv,
  5816. UserOrgId: adminUser.CurrentOrgId,
  5817. HisPatientId: his.ID,
  5818. OrderId: order.ID,
  5819. ProjectId: project_id,
  5820. Type: types,
  5821. }
  5822. service.CreateOrderInfo(info)
  5823. }
  5824. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5825. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5826. var total float64
  5827. for _, item := range prescriptions {
  5828. if item.Type == 1 { //药品
  5829. for _, subItem := range item.HisDoctorAdviceInfo {
  5830. total = total + (subItem.Price * subItem.PrescribingNumber)
  5831. }
  5832. }
  5833. if item.Type == 2 { //项目
  5834. for _, subItem := range item.HisPrescriptionProject {
  5835. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5836. total = total + (subItem.Price * cnt)
  5837. }
  5838. }
  5839. }
  5840. for _, item := range prescriptions {
  5841. for _, subItem := range item.HisAdditionalCharge {
  5842. total = total + (subItem.Price * float64(subItem.Count))
  5843. }
  5844. }
  5845. allTotal := fmt.Sprintf("%.4f", total)
  5846. if res.Infcode == 0 {
  5847. var rf []*ResultFive
  5848. json.Unmarshal([]byte(his.Iinfo), &rf)
  5849. chrg_bchno := chrg_bchno
  5850. cert_no := his.Certno
  5851. var insutypes []string
  5852. var insutype string
  5853. var is390 int = 0
  5854. var is310 int = 0
  5855. for _, item := range rf {
  5856. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5857. insutypes = append(insutypes, item.Insutype)
  5858. }
  5859. }
  5860. if len(insutypes) == 1 {
  5861. insutype = insutypes[0]
  5862. } else {
  5863. for _, i := range insutypes {
  5864. if i == "390" {
  5865. is390 = 1
  5866. }
  5867. if i == "310" {
  5868. is310 = 1
  5869. }
  5870. }
  5871. }
  5872. if is390 == 1 {
  5873. insutype = "390"
  5874. }
  5875. if is310 == 1 {
  5876. insutype = "310"
  5877. }
  5878. if len(insutypes) == 0 {
  5879. insutype = "310"
  5880. }
  5881. if len(insutypes) == 2 {
  5882. insutype = strconv.FormatInt(his.SocialType, 64)
  5883. }
  5884. //insutype = "390"
  5885. if his.IdCardType == 1 {
  5886. cert_no = his.MedicalInsuranceNumber
  5887. } else {
  5888. cert_no = his.Certno
  5889. }
  5890. var res ResultSeven
  5891. var resSeven10265 ResultSeven10265
  5892. if miConfig.MdtrtareaAdmvs == "421300" {
  5893. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5894. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5895. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5896. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5897. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5898. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5899. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5900. resp, requestErr := http.Get(api)
  5901. if requestErr != nil {
  5902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5903. return
  5904. }
  5905. body, ioErr := ioutil.ReadAll(resp.Body)
  5906. if ioErr != nil {
  5907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5909. return
  5910. }
  5911. var respJSON map[string]interface{}
  5912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5918. result, _ := json.Marshal(respJSON)
  5919. fmt.Println("log")
  5920. fmt.Println(string(result))
  5921. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5922. utils.ErrorLog("解析失败:%v", err)
  5923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5924. return
  5925. }
  5926. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5927. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5928. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5929. bas := strings.Split(psn_info.CardInfo, "|")
  5930. if his.IdCardType == 1 {
  5931. cert_no = bas[2]
  5932. } else {
  5933. cert_no = bas[1]
  5934. }
  5935. //江苏地区国家医保医疗类别
  5936. //职工透析:医疗类别选特殊情况门诊9933
  5937. //居民血透门慢: 医疗类别选门诊慢病1402
  5938. //var med_type string
  5939. //if his.Insutype == "310" {
  5940. // if reg_type == 14 {
  5941. // med_type = "9933"
  5942. // } else if reg_type == 11 {
  5943. // med_type = "11"
  5944. //
  5945. // }
  5946. //} else if his.Insutype == "390" {
  5947. // if reg_type == 14 {
  5948. // med_type = "1402"
  5949. // } else if reg_type == 11 {
  5950. // med_type = "11"
  5951. // }
  5952. //}
  5953. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5954. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5955. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5957. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5958. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5959. "&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
  5960. resp, requestErr := http.Get(api)
  5961. if requestErr != nil {
  5962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5963. return
  5964. }
  5965. body, ioErr := ioutil.ReadAll(resp.Body)
  5966. if ioErr != nil {
  5967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5969. return
  5970. }
  5971. var respJSON map[string]interface{}
  5972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5975. return
  5976. }
  5977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5978. result, _ := json.Marshal(respJSON)
  5979. fmt.Println("log")
  5980. fmt.Println(string(result))
  5981. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5982. utils.ErrorLog("解析失败:%v", err)
  5983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5984. return
  5985. }
  5986. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5987. res.Output = resSeven10265.Output
  5988. res.ErrMsg = resSeven10265.ErrMsg
  5989. res.Cainfo = resSeven10265.Cainfo
  5990. res.WarnMsg = resSeven10265.WarnMsg
  5991. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5992. res.Infcode = infocode
  5993. } else {
  5994. var result string
  5995. var request_log string
  5996. if miConfig.Code == "H15049901371" {
  5997. //赤峰地区国家医保医疗类别
  5998. //职工透析:医疗类别选特殊情况门诊990502
  5999. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6000. var med_type string
  6001. if his.Insutype == "390" {
  6002. if reg_type == 14 {
  6003. med_type = "9933"
  6004. } else if reg_type == 11 {
  6005. med_type = "11"
  6006. }
  6007. } else if his.Insutype == "310" {
  6008. if reg_type == 14 {
  6009. med_type = "990502"
  6010. } else if reg_type == 11 {
  6011. med_type = "11"
  6012. }
  6013. }
  6014. 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)
  6015. } else {
  6016. 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)
  6017. }
  6018. var dat map[string]interface{}
  6019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6020. fmt.Println(dat)
  6021. } else {
  6022. fmt.Println(err)
  6023. }
  6024. saveLog(result, request_log, "2206", "预结算")
  6025. //userJSONBytes, _ := json.Marshal(dat)
  6026. //
  6027. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6028. // utils.ErrorLog("解析失败:%v", err)
  6029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6030. // return
  6031. //}
  6032. userJSONBytes, _ := json.Marshal(dat)
  6033. if miConfig.Code == "H15049901371" {
  6034. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6035. utils.ErrorLog("解析失败:%v", err)
  6036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6037. return
  6038. }
  6039. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6040. res.Output = resSeven10265.Output
  6041. res.ErrMsg = resSeven10265.ErrMsg
  6042. res.Cainfo = resSeven10265.Cainfo
  6043. res.WarnMsg = resSeven10265.WarnMsg
  6044. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6045. res.Infcode = infocode
  6046. } else {
  6047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6048. utils.ErrorLog("解析失败:%v", err)
  6049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6050. return
  6051. }
  6052. }
  6053. }
  6054. if res.Infcode != 0 {
  6055. errlog := &models.HisOrderError{
  6056. UserOrgId: adminUser.CurrentOrgId,
  6057. Ctime: time.Now().Unix(),
  6058. Mtime: time.Now().Unix(),
  6059. Number: chrg_bchno,
  6060. ErrMsg: res.ErrMsg,
  6061. Status: 1,
  6062. PatientId: id,
  6063. RecordTime: recordDateTime,
  6064. Stage: 20,
  6065. }
  6066. service.CreateErrMsgLog(errlog)
  6067. c.ServeSuccessJSON(map[string]interface{}{
  6068. "failed_code": -10,
  6069. "msg": res.ErrMsg,
  6070. })
  6071. return
  6072. } else {
  6073. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6074. order.OrderStatus = 1
  6075. order.IsPre = 1
  6076. order.Status = 1
  6077. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6078. order.SetlId = res.Output.Setlinfo.SetlID
  6079. order.PsnNo = res.Output.Setlinfo.PsnNo
  6080. order.PsnName = res.Output.Setlinfo.PsnName
  6081. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6082. order.Certno = res.Output.Setlinfo.Certno
  6083. order.Gend = res.Output.Setlinfo.Gend
  6084. order.Naty = res.Output.Setlinfo.Naty
  6085. order.Age = res.Output.Setlinfo.Age
  6086. order.Insutype = res.Output.Setlinfo.Insutype
  6087. order.PsnType = res.Output.Setlinfo.PsnType
  6088. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6089. order.SetlTime = res.Output.Setlinfo.SetlTime
  6090. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6091. if res.Output.Setlinfo.MedType == "140101" {
  6092. order.MedType = "14"
  6093. } else {
  6094. order.MedType = res.Output.Setlinfo.MedType
  6095. }
  6096. if reg_type == 1112 {
  6097. order.MedType = "1112"
  6098. }
  6099. if reg_type == 1111 {
  6100. order.MedType = "1111"
  6101. }
  6102. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6103. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6104. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6105. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6106. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6107. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6108. order.HifpPay = res.Output.Setlinfo.HifpPay
  6109. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6110. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6111. order.HifesPay = res.Output.Setlinfo.HifesPay
  6112. order.HifobPay = res.Output.Setlinfo.HifobPay
  6113. order.MafPay = res.Output.Setlinfo.MafPay
  6114. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6115. order.OthPay = res.Output.Setlinfo.OthPay
  6116. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6117. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6118. order.AcctPay = res.Output.Setlinfo.AcctPay
  6119. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6120. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6121. order.Balc = res.Output.Setlinfo.Balc
  6122. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6123. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6124. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6125. order.ClrWay = res.Output.Setlinfo.ClrWay
  6126. order.Creator = order.Creator
  6127. order.Modify = roles.AdminUserId
  6128. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6129. detailStr := string(setlDetail)
  6130. order.SetlDetail = detailStr
  6131. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6132. err = service.UpDateOrder(order)
  6133. if err == nil {
  6134. c.ServeSuccessJSON(map[string]interface{}{
  6135. "msg": "预结算成功",
  6136. })
  6137. } else {
  6138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6139. return
  6140. }
  6141. }
  6142. } else {
  6143. adminUser := c.GetAdminUserInfo()
  6144. errlog := &models.HisOrderError{
  6145. UserOrgId: adminUser.CurrentOrgId,
  6146. Ctime: time.Now().Unix(),
  6147. Mtime: time.Now().Unix(),
  6148. ErrMsg: res.ErrMsg,
  6149. Status: 1,
  6150. PatientId: id,
  6151. RecordTime: recordDateTime,
  6152. Stage: 4,
  6153. }
  6154. service.CreateErrMsgLog(errlog)
  6155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6156. return
  6157. }
  6158. } else {
  6159. adminUser := c.GetAdminUserInfo()
  6160. errlog := &models.HisOrderError{
  6161. UserOrgId: adminUser.CurrentOrgId,
  6162. Ctime: time.Now().Unix(),
  6163. Mtime: time.Now().Unix(),
  6164. ErrMsg: res.ErrMsg,
  6165. Status: 1,
  6166. PatientId: id,
  6167. RecordTime: recordDateTime,
  6168. Stage: 4,
  6169. }
  6170. service.CreateErrMsgLog(errlog)
  6171. c.ServeSuccessJSON(map[string]interface{}{
  6172. "failed_code": -10,
  6173. "msg": res.ErrMsg,
  6174. })
  6175. return
  6176. }
  6177. }
  6178. }
  6179. }
  6180. //func (c *HisApiController) GetSettleInfo() {
  6181. // id, _ := c.GetInt64("id")
  6182. // order_id, _ := c.GetInt64("order_id")
  6183. //
  6184. // record_time := c.GetString("record_time")
  6185. // pay_way, _ := c.GetInt64("pay_way")
  6186. // pay_price, _ := c.GetFloat("pay_price")
  6187. // pay_card_no := c.GetString("pay_card_no")
  6188. // discount_price, _ := c.GetFloat("discount_price")
  6189. // preferential_price, _ := c.GetFloat("preferential_price")
  6190. // reality_price, _ := c.GetFloat("reality_price")
  6191. // found_price, _ := c.GetFloat("found_price")
  6192. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6193. // private_price, _ := c.GetFloat("private_price")
  6194. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6195. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6196. //
  6197. // timeLayout := "2006-01-02"
  6198. // loc, _ := time.LoadLocation("Local")
  6199. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6200. // if err != nil {
  6201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6202. // return
  6203. // }
  6204. // recordDateTime := theTime.Unix()
  6205. // adminUser := c.GetAdminUserInfo()
  6206. //
  6207. // var prescriptions []*models.HisPrescription
  6208. //
  6209. // data := make(map[string]interface{})
  6210. // if settle_accounts_type == 1 { //日结
  6211. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6212. // data["pre"] = prescriptions
  6213. //
  6214. // } else { //月结
  6215. // start_time_str := c.GetString("start_time")
  6216. // end_time_str := c.GetString("end_time")
  6217. // timeLayout := "2006-01-02"
  6218. // loc, _ := time.LoadLocation("Local")
  6219. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6220. // if err != nil {
  6221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6222. // return
  6223. // }
  6224. // recordStartTime := theStartTime.Unix()
  6225. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6226. // if err != nil {
  6227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6228. // return
  6229. // }
  6230. // recordEndTime := theEndTime.Unix()
  6231. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6232. // data["pre"] = prescriptions
  6233. //
  6234. // }
  6235. //
  6236. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6237. //
  6238. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6239. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6240. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6241. // strconv.FormatInt(his.PatientId, 10)
  6242. //
  6243. // order_src, _ := service.GetHisOrderByID(order_id)
  6244. //
  6245. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6246. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6247. //
  6248. // var total float64
  6249. // for _, item := range prescriptions {
  6250. // if item.Type == 1 { //药品
  6251. // for _, subItem := range item.HisDoctorAdviceInfo {
  6252. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6253. // }
  6254. // }
  6255. // if item.Type == 2 { //项目
  6256. // for _, subItem := range item.HisPrescriptionProject {
  6257. // total = total + (subItem.Price * float64(subItem.Count))
  6258. // }
  6259. // }
  6260. // }
  6261. //
  6262. // for _, item := range prescriptions {
  6263. // for _, subItem := range item.HisAdditionalCharge {
  6264. // total = total + (subItem.Price * float64(subItem.Count))
  6265. // }
  6266. // }
  6267. //
  6268. // allTotal := fmt.Sprintf("%.2f", total)
  6269. // var rf []*ResultFive
  6270. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6271. // psn_no := order_src.PsnNo
  6272. // mdtrt_id := order_src.MdtrtId
  6273. // chrg_bchno := order_src.Number
  6274. // cert_no := order_src.Certno
  6275. // insutype := rf[0].Insutype
  6276. //
  6277. // if his.IdCardType == 1 {
  6278. // cert_no = his.MedicalInsuranceNumber
  6279. // } else {
  6280. // cert_no = his.Certno
  6281. // }
  6282. //
  6283. // 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)
  6284. // var dat map[string]interface{}
  6285. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6286. // fmt.Println(dat)
  6287. // } else {
  6288. // fmt.Println(err)
  6289. // }
  6290. //
  6291. // userJSONBytes, _ := json.Marshal(dat)
  6292. //
  6293. //
  6294. //
  6295. // var res ResultSeven
  6296. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6297. // utils.ErrorLog("解析失败:%v", err)
  6298. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6299. // return
  6300. // }
  6301. // if res.Infcode == -1 {
  6302. // errlog := &models.HisOrderError{
  6303. // UserOrgId: adminUser.CurrentOrgId,
  6304. // Ctime: time.Now().Unix(),
  6305. // Mtime: time.Now().Unix(),
  6306. // Number: chrg_bchno,
  6307. // ErrMsg: res.ErrMsg,
  6308. // Status: 1,
  6309. // PatientId: id,
  6310. // RecordTime: recordDateTime,
  6311. // Stage: 6,
  6312. // }
  6313. // service.CreateErrMsgLog(errlog)
  6314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6315. // return
  6316. // } else {
  6317. // order_src.OrderStatus = 2
  6318. // order_src.PayWay = pay_way
  6319. // order_src.PayPrice = pay_price
  6320. // order_src.PayCardNo = pay_card_no
  6321. // order_src.DiscountPrice = discount_price
  6322. // order_src.PreferentialPrice = preferential_price
  6323. // order_src.RealityPrice = reality_price
  6324. // order_src.FoundPrice = found_price
  6325. // order_src.MedicalInsurancePrice = medical_insurance_price
  6326. // order_src.PrivatePrice = private_price
  6327. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6328. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6329. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6330. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6331. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6332. // order_src.Certno = res.Output.Setlinfo.Certno
  6333. // order_src.Gend = res.Output.Setlinfo.Gend
  6334. // order_src.Naty = res.Output.Setlinfo.Naty
  6335. // order_src.Age = res.Output.Setlinfo.Age
  6336. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6337. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6338. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6339. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6340. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6341. // order_src.MedType = res.Output.Setlinfo.MedType
  6342. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6343. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6344. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6345. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6346. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6347. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6348. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6349. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6350. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6351. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6352. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6353. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6354. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6355. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6356. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6357. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6358. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6359. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6360. // order_src.Balc = res.Output.Setlinfo.Balc
  6361. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6362. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6363. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6364. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6365. // order_src.Creator = order_src.Creator
  6366. // order_src.Modify = roles.ID
  6367. // order_src.RequestLog = src_resquest
  6368. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6369. // detailStr := string(setlDetail)
  6370. // order_src.SetlDetail = detailStr
  6371. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6372. // err = service.UpDateOrder(order_src)
  6373. //
  6374. // if err == nil {
  6375. // c.ServeSuccessJSON(map[string]interface{}{
  6376. // "msg": "结算成功",
  6377. // })
  6378. // } else {
  6379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6380. // return
  6381. // }
  6382. // }
  6383. // }
  6384. //}
  6385. //退款
  6386. func (c *HisApiController) Refund() {
  6387. order_id, _ := c.GetInt64("order_id")
  6388. admin_user_id, _ := c.GetInt64("admin_user_id")
  6389. adminUser := c.GetAdminUserInfo()
  6390. var order models.HisOrder
  6391. order, _ = service.GetHisOrderByID(order_id)
  6392. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6393. if order.ID == 0 {
  6394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6395. return
  6396. }
  6397. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6398. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6399. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6400. if config.IsOpen == 1 { //对接了医保,走医保流程
  6401. var res ResultSixteen
  6402. var resSixteen10265 ResultSixteen10265
  6403. var src_resquest string
  6404. var result string
  6405. if miConfig.MdtrtareaAdmvs == "421300" {
  6406. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6407. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6408. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6409. resp3, requestErr3 := http.Get(api3)
  6410. if requestErr3 != nil {
  6411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6412. return
  6413. }
  6414. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6415. if ioErr3 != nil {
  6416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6418. return
  6419. }
  6420. var respJSON3 map[string]interface{}
  6421. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6424. return
  6425. }
  6426. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6427. userJSONBytes3, _ := json.Marshal(respJSON3)
  6428. fmt.Println("log")
  6429. fmt.Println(string(userJSONBytes3))
  6430. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6431. utils.ErrorLog("解析失败:%v", err)
  6432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6433. return
  6434. }
  6435. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6436. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6437. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6438. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6439. resp3, requestErr3 := http.Get(api3)
  6440. if requestErr3 != nil {
  6441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6442. return
  6443. }
  6444. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6445. if ioErr3 != nil {
  6446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6448. return
  6449. }
  6450. var respJSON3 map[string]interface{}
  6451. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6454. return
  6455. }
  6456. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6457. userJSONBytes3, _ := json.Marshal(respJSON3)
  6458. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6459. utils.ErrorLog("解析失败:%v", err)
  6460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6461. return
  6462. }
  6463. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6464. res.Output = resSixteen10265.Output
  6465. res.ErrMsg = resSixteen10265.ErrMsg
  6466. res.Cainfo = resSixteen10265.Cainfo
  6467. res.WarnMsg = resSixteen10265.WarnMsg
  6468. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6469. res.Infcode = infocode
  6470. } else {
  6471. if miConfig.Code == "H15049901371" {
  6472. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6473. var dat map[string]interface{}
  6474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6475. fmt.Println(dat)
  6476. } else {
  6477. fmt.Println(err)
  6478. }
  6479. saveLog(result, src_resquest, "2208", "退费")
  6480. userJSONBytes, _ := json.Marshal(dat)
  6481. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6482. utils.ErrorLog("解析失败:%v", err)
  6483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6484. return
  6485. }
  6486. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6487. res.Output = resSixteen10265.Output
  6488. res.ErrMsg = resSixteen10265.ErrMsg
  6489. res.Cainfo = resSixteen10265.Cainfo
  6490. res.WarnMsg = resSixteen10265.WarnMsg
  6491. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6492. res.Infcode = infocode
  6493. } else {
  6494. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6495. var dat map[string]interface{}
  6496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6497. fmt.Println(dat)
  6498. } else {
  6499. fmt.Println(err)
  6500. }
  6501. saveLog(result, src_resquest, "2208", "退费")
  6502. userJSONBytes, _ := json.Marshal(dat)
  6503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6504. utils.ErrorLog("解析失败:%v", err)
  6505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6506. return
  6507. }
  6508. }
  6509. }
  6510. if res.Infcode == 0 {
  6511. var res2 ResultSix
  6512. var resSix10265 ResultSix10265
  6513. if miConfig.MdtrtareaAdmvs == "421300" {
  6514. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6515. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6516. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6517. resp3, requestErr3 := http.Get(api3)
  6518. if requestErr3 != nil {
  6519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6520. return
  6521. }
  6522. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6523. if ioErr3 != nil {
  6524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. return
  6527. }
  6528. var respJSON3 map[string]interface{}
  6529. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6532. return
  6533. }
  6534. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6535. userJSONBytes3, _ := json.Marshal(respJSON3)
  6536. fmt.Println("log")
  6537. fmt.Println(string(userJSONBytes3))
  6538. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6539. utils.ErrorLog("解析失败:%v", err)
  6540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6541. return
  6542. }
  6543. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6544. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6545. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6547. resp3, requestErr3 := http.Get(api3)
  6548. if requestErr3 != nil {
  6549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6550. return
  6551. }
  6552. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6553. if ioErr3 != nil {
  6554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6556. return
  6557. }
  6558. var respJSON3 map[string]interface{}
  6559. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6562. return
  6563. }
  6564. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6565. userJSONBytes3, _ := json.Marshal(respJSON3)
  6566. fmt.Println("log")
  6567. fmt.Println(string(userJSONBytes3))
  6568. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6569. utils.ErrorLog("解析失败:%v", err)
  6570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. return
  6572. }
  6573. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6574. res2.Output = resSix10265.Output
  6575. res2.ErrMsg = resSix10265.ErrMsg
  6576. res2.Cainfo = resSix10265.Cainfo
  6577. res2.WarnMsg = resSix10265.WarnMsg
  6578. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6579. res2.Infcode = infocode
  6580. } else {
  6581. if miConfig.Code == "H15049901371" {
  6582. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6583. var dat map[string]interface{}
  6584. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6585. fmt.Println(dat)
  6586. } else {
  6587. fmt.Println(err)
  6588. }
  6589. saveLog(result2, src_request, "2205", "撤销明细")
  6590. userJSONBytes, _ := json.Marshal(dat)
  6591. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6592. utils.ErrorLog("解析失败:%v", err)
  6593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6594. return
  6595. }
  6596. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6597. res2.Output = resSix10265.Output
  6598. res2.ErrMsg = resSix10265.ErrMsg
  6599. res2.Cainfo = resSix10265.Cainfo
  6600. res2.WarnMsg = resSix10265.WarnMsg
  6601. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6602. res2.Infcode = infocode
  6603. } else {
  6604. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6605. var dat map[string]interface{}
  6606. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6607. fmt.Println(dat)
  6608. } else {
  6609. fmt.Println(err)
  6610. }
  6611. saveLog(result2, src_request, "2205", "撤销明细")
  6612. userJSONBytes, _ := json.Marshal(dat)
  6613. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6614. utils.ErrorLog("解析失败:%v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. return
  6617. }
  6618. }
  6619. }
  6620. if res2.Infcode == 0 {
  6621. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6622. if err == nil {
  6623. c.ServeSuccessJSON(map[string]interface{}{
  6624. "msg": "退费成功",
  6625. })
  6626. } else {
  6627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6628. return
  6629. }
  6630. } else {
  6631. c.ServeSuccessJSON(map[string]interface{}{
  6632. "code": -10,
  6633. "msg": res2.ErrMsg,
  6634. })
  6635. }
  6636. } else {
  6637. c.ServeSuccessJSON(map[string]interface{}{
  6638. "code": -10,
  6639. "msg": res.ErrMsg,
  6640. })
  6641. }
  6642. }
  6643. }
  6644. func (c *HisApiController) RefundNumber() {
  6645. record_time := c.GetString("record_time")
  6646. //patient_id, _ := c.GetInt64("patient_id")
  6647. admin_user_id, _ := c.GetInt64("admin_user_id")
  6648. his_patient_id, _ := c.GetInt64("id")
  6649. timeLayout := "2006-01-02"
  6650. loc, _ := time.LoadLocation("Local")
  6651. adminUser := c.GetAdminUserInfo()
  6652. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6653. fmt.Println(err)
  6654. if err != nil {
  6655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6656. return
  6657. }
  6658. recordDateTime := theTime.Unix()
  6659. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6660. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6661. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6662. //order, _ := service.GetHisOrderByID(order_id)
  6663. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6664. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6665. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6666. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6667. if count > 0 {
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6669. return
  6670. }
  6671. if config.IsOpen == 1 { //对接了医保,走医保流程
  6672. var res2 ResultSix
  6673. var resSix10265 ResultSix10265
  6674. if miConfig.MdtrtareaAdmvs == "421300" {
  6675. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6676. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6677. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6678. resp3, requestErr3 := http.Get(api3)
  6679. if requestErr3 != nil {
  6680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6681. return
  6682. }
  6683. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6684. if ioErr3 != nil {
  6685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6687. return
  6688. }
  6689. var respJSON3 map[string]interface{}
  6690. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6693. return
  6694. }
  6695. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6696. userJSONBytes3, _ := json.Marshal(respJSON3)
  6697. fmt.Println("log")
  6698. fmt.Println(string(userJSONBytes3))
  6699. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6700. utils.ErrorLog("解析失败:%v", err)
  6701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6702. return
  6703. }
  6704. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6705. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6706. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6707. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6708. resp3, requestErr3 := http.Get(api3)
  6709. if requestErr3 != nil {
  6710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6711. return
  6712. }
  6713. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6714. if ioErr3 != nil {
  6715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. return
  6718. }
  6719. var respJSON3 map[string]interface{}
  6720. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. return
  6724. }
  6725. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6726. userJSONBytes3, _ := json.Marshal(respJSON3)
  6727. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6728. utils.ErrorLog("解析失败:%v", err)
  6729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6730. return
  6731. }
  6732. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6733. res2.Output = resSix10265.Output
  6734. res2.ErrMsg = resSix10265.ErrMsg
  6735. res2.Cainfo = resSix10265.Cainfo
  6736. res2.WarnMsg = resSix10265.WarnMsg
  6737. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6738. res2.Infcode = infocode
  6739. } else {
  6740. var api3 string
  6741. if miConfig.Code == "H15049901371" {
  6742. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6743. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6745. } else {
  6746. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6747. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6749. }
  6750. resp3, requestErr3 := http.Get(api3)
  6751. if requestErr3 != nil {
  6752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6753. return
  6754. }
  6755. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6756. if ioErr3 != nil {
  6757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6759. return
  6760. }
  6761. var respJSON3 map[string]interface{}
  6762. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6765. return
  6766. }
  6767. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6768. userJSONBytes3, _ := json.Marshal(respJSON3)
  6769. if miConfig.Code == "H15049901371" {
  6770. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6771. utils.ErrorLog("解析失败:%v", err)
  6772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6773. return
  6774. }
  6775. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6776. res2.Output = resSix10265.Output
  6777. res2.ErrMsg = resSix10265.ErrMsg
  6778. res2.Cainfo = resSix10265.Cainfo
  6779. res2.WarnMsg = resSix10265.WarnMsg
  6780. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6781. res2.Infcode = infocode
  6782. } else {
  6783. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6784. utils.ErrorLog("解析失败:%v", err)
  6785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6786. return
  6787. }
  6788. }
  6789. }
  6790. if res2.Infcode == 0 {
  6791. if err == nil {
  6792. c.ServeSuccessJSON(map[string]interface{}{
  6793. "msg": "退号成功",
  6794. })
  6795. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6796. } else {
  6797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6798. return
  6799. }
  6800. } else {
  6801. c.ServeSuccessJSON(map[string]interface{}{
  6802. "code": -10,
  6803. "msg": res2.ErrMsg,
  6804. })
  6805. }
  6806. } else {
  6807. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6808. //if err == nil {
  6809. // c.ServeSuccessJSON(map[string]interface{}{
  6810. // "msg": "退费成功",
  6811. // })
  6812. //} else {
  6813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6814. // return
  6815. //}
  6816. }
  6817. }
  6818. func (c *HisApiController) RefundDetail() {
  6819. order_id, _ := c.GetInt64("order_id")
  6820. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6821. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6822. number := c.GetString("number")
  6823. record_time := c.GetString("record_time")
  6824. patient_id, _ := c.GetInt64("patient_id")
  6825. timeLayout := "2006-01-02"
  6826. loc, _ := time.LoadLocation("Local")
  6827. adminUser := c.GetAdminUserInfo()
  6828. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6829. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6830. fmt.Println(err)
  6831. if err != nil {
  6832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6833. return
  6834. }
  6835. recordDateTime := theTime.Unix()
  6836. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6837. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6838. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6839. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6840. var order models.HisOrder
  6841. order, _ = service.GetHisOrderByID(order_id)
  6842. if order.ID == 0 {
  6843. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6844. }
  6845. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6846. if config.IsOpen == 1 { //对接了医保,走医保流程
  6847. var res2 ResultSix
  6848. if miConfig.MdtrtareaAdmvs == "421300" {
  6849. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6850. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6851. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6852. resp3, requestErr3 := http.Get(api3)
  6853. if requestErr3 != nil {
  6854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6855. return
  6856. }
  6857. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6858. if ioErr3 != nil {
  6859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6861. return
  6862. }
  6863. var respJSON3 map[string]interface{}
  6864. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6867. return
  6868. }
  6869. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6870. userJSONBytes3, _ := json.Marshal(respJSON3)
  6871. fmt.Println("log")
  6872. fmt.Println(string(userJSONBytes3))
  6873. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6874. utils.ErrorLog("解析失败:%v", err)
  6875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6876. return
  6877. }
  6878. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6879. if err == nil {
  6880. c.ServeSuccessJSON(map[string]interface{}{
  6881. "msg": "撤销明细成功",
  6882. })
  6883. return
  6884. } else {
  6885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6886. return
  6887. }
  6888. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6889. var resSix10265 ResultSix10265
  6890. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6891. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6892. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6893. resp3, requestErr3 := http.Get(api3)
  6894. if requestErr3 != nil {
  6895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6896. return
  6897. }
  6898. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6899. if ioErr3 != nil {
  6900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. return
  6903. }
  6904. var respJSON3 map[string]interface{}
  6905. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. return
  6909. }
  6910. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6911. userJSONBytes3, _ := json.Marshal(respJSON3)
  6912. fmt.Println("log")
  6913. fmt.Println(string(userJSONBytes3))
  6914. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6915. utils.ErrorLog("解析失败:%v", err)
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. return
  6918. }
  6919. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6920. res2.Output = resSix10265.Output
  6921. res2.ErrMsg = resSix10265.ErrMsg
  6922. res2.Cainfo = resSix10265.Cainfo
  6923. res2.WarnMsg = resSix10265.WarnMsg
  6924. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6925. res2.Infcode = infocode
  6926. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6927. if err == nil {
  6928. c.ServeSuccessJSON(map[string]interface{}{
  6929. "msg": "撤销明细成功",
  6930. })
  6931. return
  6932. } else {
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. return
  6935. }
  6936. } else {
  6937. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6938. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6939. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6940. resp2, requestErr2 := http.Get(api2)
  6941. if requestErr2 != nil {
  6942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6943. return
  6944. }
  6945. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6946. if ioErr2 != nil {
  6947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. return
  6950. }
  6951. var respJSON2 map[string]interface{}
  6952. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6958. if err == nil {
  6959. c.ServeSuccessJSON(map[string]interface{}{
  6960. "msg": "撤销明细成功",
  6961. })
  6962. return
  6963. } else {
  6964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. return
  6966. }
  6967. }
  6968. } else {
  6969. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6970. if err == nil {
  6971. c.ServeSuccessJSON(map[string]interface{}{
  6972. "msg": "退费成功",
  6973. })
  6974. } else {
  6975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6976. return
  6977. }
  6978. }
  6979. }
  6980. //对账
  6981. func (c *HisApiController) GetCheckAccount() {
  6982. start_time := c.GetString("start_time")
  6983. end_time := c.GetString("end_time")
  6984. insutype := c.GetString("insutype")
  6985. clr_type := c.GetString("clr_type")
  6986. clr_org := c.GetString("clr_optins")
  6987. admin_user_id, _ := c.GetInt64("admin_user_id")
  6988. adminUser := c.GetAdminUserInfo()
  6989. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6990. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6991. if len(clr_org) == 0 {
  6992. clr_org = miConfig.MdtrtareaAdmvs
  6993. }
  6994. timeLayout := "2006-01-02"
  6995. loc, _ := time.LoadLocation("Local")
  6996. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6997. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6998. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6999. fixmedins_setl_cnt := int64(len(orders))
  7000. var medfee_sumamt float64
  7001. var acct_pay float64
  7002. var fund_pay_sumamt float64
  7003. for _, item := range orders {
  7004. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7005. acct_pay = acct_pay + item.AcctPay
  7006. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7007. }
  7008. var user_name string
  7009. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7010. if role.ID == 0 {
  7011. user_name = "xxx"
  7012. } else {
  7013. user_name = role.UserName
  7014. }
  7015. var res ResultEight
  7016. var res10188 ResultEightFor10188
  7017. if config.IsOpen == 1 {
  7018. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7019. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7020. "insutype=" + insutype +
  7021. "&clr_type=" + "11" +
  7022. "&setl_optins=" + clr_org +
  7023. "&stmt_begndate=" + start_time +
  7024. "&stm_enddate=" + end_time +
  7025. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7026. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7027. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7028. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7029. "&fixmedins_code=" + miConfig.Code +
  7030. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7031. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7032. "&secret_key=" + miConfig.SecretKey +
  7033. "&org_name=" + miConfig.OrgName +
  7034. "&doctor=" + user_name +
  7035. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7036. fmt.Println(api)
  7037. resp, requestErr := http.Get(api)
  7038. if requestErr != nil {
  7039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7040. return
  7041. }
  7042. body, ioErr := ioutil.ReadAll(resp.Body)
  7043. fmt.Println(body)
  7044. if ioErr != nil {
  7045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. return
  7048. }
  7049. var respJSON map[string]interface{}
  7050. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7053. return
  7054. }
  7055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7056. userJSONBytes, _ := json.Marshal(respJSON)
  7057. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7058. utils.ErrorLog("解析失败:%v", err)
  7059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7060. return
  7061. }
  7062. res.InfRefmsgid = res10188.InfRefmsgid
  7063. res.Output = res10188.Output
  7064. res.ErrMsg = res10188.ErrMsg
  7065. res.Cainfo = res10188.Cainfo
  7066. res.WarnMsg = res10188.WarnMsg
  7067. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7068. res.Infcode = infocode
  7069. } else {
  7070. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7071. "insutype=" + insutype +
  7072. "&clr_type=" + clr_type +
  7073. "&setl_optins=" + clr_org +
  7074. "&stmt_begndate=" + start_time +
  7075. "&stm_enddate=" + end_time +
  7076. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7077. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7078. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7079. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7080. "&fixmedins_code=" + miConfig.Code +
  7081. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7082. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7083. "&secret_key=" + miConfig.SecretKey +
  7084. "&org_name=" + miConfig.OrgName +
  7085. "&doctor=" + user_name
  7086. fmt.Println(api)
  7087. resp, requestErr := http.Get(api)
  7088. if requestErr != nil {
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. return
  7091. }
  7092. body, ioErr := ioutil.ReadAll(resp.Body)
  7093. fmt.Println(body)
  7094. if ioErr != nil {
  7095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7097. return
  7098. }
  7099. var respJSON map[string]interface{}
  7100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7103. return
  7104. }
  7105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7106. userJSONBytes, _ := json.Marshal(respJSON)
  7107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7108. utils.ErrorLog("解析失败:%v", err)
  7109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7110. return
  7111. }
  7112. }
  7113. if res.Infcode == 0 {
  7114. if res.Output.Stmtinfo.StmtRslt == "0" {
  7115. micc := &models.MedicalInsuranceCostCompare{
  7116. StartTime: startime.Unix(),
  7117. EndTime: endtime.Unix(),
  7118. Insutype: insutype,
  7119. CheckType: 1,
  7120. Num: fixmedins_setl_cnt,
  7121. Mtime: time.Now().Unix(),
  7122. Status: 1,
  7123. UserOrgId: adminUser.CurrentOrgId,
  7124. CostTotal: medfee_sumamt,
  7125. FuncTotal: fund_pay_sumamt,
  7126. PsnPay: acct_pay,
  7127. Creator: admin_user_id,
  7128. Ctime: time.Now().Unix(),
  7129. }
  7130. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7131. if err == nil {
  7132. c.ServeSuccessJSON(map[string]interface{}{
  7133. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7134. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7135. })
  7136. } else {
  7137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7138. }
  7139. } else {
  7140. c.ServeSuccessJSON(map[string]interface{}{
  7141. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7142. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7143. })
  7144. }
  7145. } else {
  7146. c.ServeSuccessJSON(map[string]interface{}{
  7147. "code": -10,
  7148. "msg": res.ErrMsg,
  7149. })
  7150. }
  7151. }
  7152. }
  7153. func (c *HisApiController) Check310() {
  7154. adminUser := c.GetAdminUserInfo()
  7155. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7156. var user_name string
  7157. user_name = "高慧裕"
  7158. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7159. "insutype=" + "310" +
  7160. "&clr_type=" + "" +
  7161. "&setl_optins=" + "441202" +
  7162. "&stmt_begndate=" + "2022-03-01" +
  7163. "&stm_enddate=" + "2022-03-31" +
  7164. "&medfee_sumamt=" + "194930.12" +
  7165. "&fund_pay_sumamt=" + "188741.46" +
  7166. "&acct_pay=" + "0" +
  7167. "&fixmedins_setl_cnt=" + "452" +
  7168. "&fixmedins_code=" + miConfig.Code +
  7169. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7170. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7171. "&secret_key=" + miConfig.SecretKey +
  7172. "&org_name=" + miConfig.OrgName +
  7173. "&doctor=" + user_name
  7174. fmt.Println(api)
  7175. resp, requestErr := http.Get(api)
  7176. if requestErr != nil {
  7177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7178. return
  7179. }
  7180. body, ioErr := ioutil.ReadAll(resp.Body)
  7181. fmt.Println(body)
  7182. if ioErr != nil {
  7183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7185. return
  7186. }
  7187. var respJSON map[string]interface{}
  7188. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. return
  7192. }
  7193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7194. userJSONBytes, _ := json.Marshal(respJSON)
  7195. var res ResultEight
  7196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7197. utils.ErrorLog("解析失败:%v", err)
  7198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7199. return
  7200. }
  7201. }
  7202. func (c *HisApiController) Check390() {
  7203. adminUser := c.GetAdminUserInfo()
  7204. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7205. var user_name string
  7206. user_name = "高慧裕"
  7207. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7208. "insutype=" + "390" +
  7209. "&clr_type=" + "" +
  7210. "&setl_optins=" + "441202" +
  7211. "&stmt_begndate=" + "2022-03-01" +
  7212. "&stm_enddate=" + "2022-03-31" +
  7213. "&medfee_sumamt=" + "1068448.89" +
  7214. "&fund_pay_sumamt=" + "1014677.62" +
  7215. "&acct_pay=" + "0" +
  7216. "&fixmedins_setl_cnt=" + "1950" +
  7217. "&fixmedins_code=" + miConfig.Code +
  7218. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7219. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7220. "&secret_key=" + miConfig.SecretKey +
  7221. "&org_name=" + miConfig.OrgName +
  7222. "&doctor=" + user_name
  7223. fmt.Println(api)
  7224. resp, requestErr := http.Get(api)
  7225. if requestErr != nil {
  7226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7227. return
  7228. }
  7229. body, ioErr := ioutil.ReadAll(resp.Body)
  7230. fmt.Println(body)
  7231. if ioErr != nil {
  7232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7234. return
  7235. }
  7236. var respJSON map[string]interface{}
  7237. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7240. return
  7241. }
  7242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7243. userJSONBytes, _ := json.Marshal(respJSON)
  7244. var res ResultEight
  7245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7246. utils.ErrorLog("解析失败:%v", err)
  7247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7248. return
  7249. }
  7250. }
  7251. //对账明细
  7252. func (c *HisApiController) GetCheckDetailAccount() {
  7253. start_time := c.GetString("start_time")
  7254. end_time := c.GetString("end_time")
  7255. admin_user_id, _ := c.GetInt64("admin_user_id")
  7256. adminUser := c.GetAdminUserInfo()
  7257. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7258. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7259. timeLayout := "2006-01-02"
  7260. loc, _ := time.LoadLocation("Local")
  7261. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7262. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7263. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7264. Mkdir(miConfig.OrgName)
  7265. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7266. file_name := file + ".txt"
  7267. zip_name := file + ".zip"
  7268. zip_path := miConfig.OrgName + "/" + zip_name
  7269. file_path := miConfig.OrgName + "/" + file_name
  7270. decimal.DivisionPrecision = 2
  7271. var medfee_sumamt float64
  7272. var psn_cash_pay float64
  7273. var fund_pay_sumamt float64
  7274. fixmedins_setl_cnt := int64(len(orders))
  7275. for _, item := range orders {
  7276. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7277. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7278. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7279. }
  7280. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7281. defer f.Close()
  7282. if err != nil {
  7283. fmt.Println(err.Error())
  7284. } else {
  7285. for _, item := range orders {
  7286. var refd_setl_flag string
  7287. if item.OrderStatus == 2 {
  7288. refd_setl_flag = "0"
  7289. var str string
  7290. str = item.SetlId + " " +
  7291. item.MdtrtId + " " +
  7292. item.PsnNo + " " +
  7293. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7294. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7295. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7296. _, err = f.Write([]byte(str))
  7297. }
  7298. if item.OrderStatus == 3 {
  7299. var str string
  7300. str = item.SetlId + " " +
  7301. item.MdtrtId + " " +
  7302. item.PsnNo + " " +
  7303. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7304. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7305. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7306. _, err = f.Write([]byte(str))
  7307. var str2 string
  7308. str2 = item.SetlId + " " +
  7309. item.MdtrtId + " " +
  7310. item.PsnNo + " " +
  7311. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7312. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7313. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7314. _, err = f.Write([]byte(str2))
  7315. }
  7316. }
  7317. }
  7318. Zip(file_path, zip_path)
  7319. fmt.Println(ReadFile(zip_path))
  7320. fmt.Println(string(ReadFile(zip_path)))
  7321. if config.IsOpen == 1 {
  7322. var user_name string
  7323. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7324. if role.ID == 0 {
  7325. user_name = "管理员"
  7326. } else {
  7327. user_name = role.UserName
  7328. }
  7329. baseParams := models.BaseParams{
  7330. SecretKey: miConfig.SecretKey,
  7331. FixmedinsCode: miConfig.Code,
  7332. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7333. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7334. OrgName: miConfig.OrgName,
  7335. Doctor: user_name,
  7336. }
  7337. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7338. var dat map[string]interface{}
  7339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7340. fmt.Println(dat)
  7341. } else {
  7342. fmt.Println(err)
  7343. }
  7344. userJSONBytes, _ := json.Marshal(dat)
  7345. var res ResultNine
  7346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7347. utils.ErrorLog("解析失败:%v", err)
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. return
  7350. }
  7351. if res.Infcode == 0 {
  7352. fileNo := res.Output.FileQuryNo
  7353. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7354. "file_qury_no=" + fileNo +
  7355. "&setl_optins=" + "定点医保中心" +
  7356. "&stmt_begndate=" + start_time +
  7357. "&stm_enddate=" + end_time +
  7358. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7359. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7360. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7361. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7362. "&fixmedins_code=" + miConfig.Code +
  7363. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7364. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7365. "&secret_key=" + miConfig.SecretKey +
  7366. "&org_name=" + miConfig.OrgName +
  7367. "&doctor=" + user_name
  7368. resp, requestErr := http.Get(api)
  7369. if requestErr != nil {
  7370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. return
  7372. }
  7373. body, ioErr := ioutil.ReadAll(resp.Body)
  7374. if ioErr != nil {
  7375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. return
  7378. }
  7379. var respJSON map[string]interface{}
  7380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7383. return
  7384. }
  7385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7386. userJSONBytes, _ := json.Marshal(respJSON)
  7387. var res ResultTen
  7388. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7389. utils.ErrorLog("解析失败:%v", err)
  7390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7391. return
  7392. }
  7393. if res.Infcode == 0 {
  7394. service.Gdyb9102(baseParams, zip_name, fileNo)
  7395. micc := &models.MedicalInsuranceCostCompare{
  7396. StartTime: startime.Unix(),
  7397. EndTime: endtime.Unix(),
  7398. Insutype: "0",
  7399. CheckType: 2,
  7400. Num: fixmedins_setl_cnt,
  7401. Mtime: time.Now().Unix(),
  7402. Status: 1,
  7403. UserOrgId: adminUser.CurrentOrgId,
  7404. CostTotal: medfee_sumamt,
  7405. FuncTotal: fund_pay_sumamt,
  7406. PsnPay: psn_cash_pay,
  7407. Creator: admin_user_id,
  7408. Ctime: time.Now().Unix(),
  7409. }
  7410. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7411. c.ServeSuccessJSON(map[string]interface{}{
  7412. "msg": "明细对账成功",
  7413. })
  7414. }
  7415. } else {
  7416. }
  7417. }
  7418. }
  7419. type CustomOrderInfo struct {
  7420. Name string
  7421. Spec string
  7422. Unit string
  7423. Count float64
  7424. Price float64
  7425. Total float64
  7426. }
  7427. func (c *HisApiController) GetSettleAccounts() {
  7428. //id, _ := c.GetInt64("id")
  7429. //record_time := c.GetString("record_time")
  7430. order_id, _ := c.GetInt64("order_id")
  7431. admin_user_id, _ := c.GetInt64("admin_user_id")
  7432. //timeLayout := "2006-01-02"
  7433. //loc, _ := time.LoadLocation("Local")
  7434. //
  7435. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7436. //if err != nil {
  7437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7438. // return
  7439. //}
  7440. //recordDateTime := theTime.Unix()
  7441. adminUser := c.GetAdminUserInfo()
  7442. order, _ := service.GetHisOrderByID(order_id)
  7443. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7444. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7445. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7446. orderInfos = append(orderInfos, orderInfos_two...)
  7447. //his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7448. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7449. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7450. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7451. //var config []*models.HisXtDiagnoseConfig
  7452. var name string
  7453. for _, item := range diagnosis_ids {
  7454. id, _ := strconv.ParseInt(item, 10, 64)
  7455. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7456. if len(name) == 0 {
  7457. name = diagnosisConfig.ClassName
  7458. } else {
  7459. name = name + "," + diagnosisConfig.ClassName
  7460. }
  7461. }
  7462. var bedCostTotal float64 = 0 //床位总费
  7463. var bedCostSelfTotal float64 = 0 //床位自费
  7464. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7465. var operationCostTotal float64 = 0 //手术费
  7466. var operationCostSelfTotal float64 = 0 //手术费
  7467. var operationCostPartSelfTotal float64 = 0 //手术费
  7468. var otherCostTotal float64 = 0 //其他费用
  7469. var otherCostSelfTotal float64 = 0 //其他费用
  7470. var otherCostPartSelfTotal float64 = 0 //其他费用
  7471. var materialCostTotal float64 = 0 //材料费
  7472. var materialCostSelfTotal float64 = 0 //材料费
  7473. var materialCostPartSelfTotal float64 = 0 //材料费
  7474. var westernMedicineCostTotal float64 = 0 //西药费
  7475. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7476. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7477. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7478. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7479. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7480. var checkCostTotal float64 = 0 //检查费
  7481. var checkCostSelfTotal float64 = 0 //检查费
  7482. var checkCostPartSelfTotal float64 = 0 //检查费
  7483. var laboratoryCostTotal float64 = 0 //化验费
  7484. var laboratoryCostSelfTotal float64 = 0 //化验费
  7485. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7486. var treatCostTotal float64 = 0 //治疗费用
  7487. var treatCostSelfTotal float64 = 0 //治疗费用
  7488. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7489. decimal.DivisionPrecision = 2
  7490. for _, item := range orderInfos {
  7491. if item.MedChrgitmType == "01" { //床位费
  7492. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7493. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7494. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7495. }
  7496. if item.MedChrgitmType == "03" { //检查费
  7497. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7498. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7499. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7500. }
  7501. if item.MedChrgitmType == "04" { //化验费
  7502. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7503. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7504. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7505. }
  7506. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7507. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7508. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7509. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7510. }
  7511. if item.MedChrgitmType == "06" { //手术费
  7512. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7513. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7514. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7515. }
  7516. if item.MedChrgitmType == "08" { //材料费
  7517. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7518. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7519. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7520. }
  7521. if item.MedChrgitmType == "09" { //西药费
  7522. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7523. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7524. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7525. }
  7526. if item.MedChrgitmType == "11" { //中成费
  7527. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7528. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7529. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7530. }
  7531. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7532. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7533. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7534. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7535. }
  7536. }
  7537. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7538. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7539. var user_name string
  7540. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7541. if role.ID == 0 {
  7542. user_name = "管理员"
  7543. } else {
  7544. user_name = role.UserName
  7545. }
  7546. baseParams := models.BaseParams{
  7547. SecretKey: miConfig.SecretKey,
  7548. FixmedinsCode: miConfig.Code,
  7549. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7550. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7551. OrgName: miConfig.OrgName,
  7552. Doctor: user_name,
  7553. }
  7554. businessParams := models.BusinessParams{
  7555. PsnNo: order.PsnNo,
  7556. MdtrtId: order.MdtrtId,
  7557. SetlId: order.SetlId,
  7558. }
  7559. var res ResultEleven
  7560. var resEleven10265 ResultEleven10265
  7561. if config.IsOpen == 1 {
  7562. if miConfig.MdtrtareaAdmvs == "421300" {
  7563. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7564. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7565. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7566. resp, requestErr := http.Get(api)
  7567. if requestErr != nil {
  7568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7569. return
  7570. }
  7571. body, ioErr := ioutil.ReadAll(resp.Body)
  7572. if ioErr != nil {
  7573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7575. return
  7576. }
  7577. var respJSON map[string]interface{}
  7578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7581. return
  7582. }
  7583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7584. result, _ := json.Marshal(respJSON)
  7585. fmt.Println("log")
  7586. fmt.Println(string(result))
  7587. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7588. utils.ErrorLog("解析失败:%v", err)
  7589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7590. return
  7591. }
  7592. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7593. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7594. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7595. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7596. resp, requestErr := http.Get(api)
  7597. if requestErr != nil {
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. return
  7600. }
  7601. body, ioErr := ioutil.ReadAll(resp.Body)
  7602. if ioErr != nil {
  7603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7605. return
  7606. }
  7607. var respJSON map[string]interface{}
  7608. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7611. return
  7612. }
  7613. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7614. result, _ := json.Marshal(respJSON)
  7615. fmt.Println("log")
  7616. fmt.Println(string(result))
  7617. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7618. utils.ErrorLog("解析失败:%v", err)
  7619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7620. return
  7621. }
  7622. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7623. res.Output = resEleven10265.Output
  7624. res.ErrMsg = resEleven10265.ErrMsg
  7625. res.Cainfo = resEleven10265.Cainfo
  7626. res.WarnMsg = resEleven10265.WarnMsg
  7627. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7628. res.Infcode = infocode
  7629. } else {
  7630. result2 := service.Gdyb5204(baseParams, businessParams)
  7631. saveLog(result2, "", "5204", "查询")
  7632. result := service.Gdyb5203(baseParams, businessParams)
  7633. var dat map[string]interface{}
  7634. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7635. fmt.Println(dat)
  7636. } else {
  7637. fmt.Println(err)
  7638. }
  7639. userJSONBytes, _ := json.Marshal(dat)
  7640. if miConfig.Code == "H15049901371" {
  7641. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7642. utils.ErrorLog("解析失败:%v", err)
  7643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7644. return
  7645. }
  7646. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7647. res.Output = resEleven10265.Output
  7648. res.ErrMsg = resEleven10265.ErrMsg
  7649. res.Cainfo = resEleven10265.Cainfo
  7650. res.WarnMsg = resEleven10265.WarnMsg
  7651. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7652. res.Infcode = infocode
  7653. } else {
  7654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7655. utils.ErrorLog("解析失败:%v", err)
  7656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7657. return
  7658. }
  7659. }
  7660. }
  7661. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7662. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7663. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7664. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7665. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7666. var doctor_name string
  7667. if roles.ID == 0 {
  7668. doctor_name = "管理员"
  7669. } else {
  7670. doctor_name = roles.UserName
  7671. }
  7672. yiliao_leibie := ""
  7673. switch order.MedType {
  7674. case "11":
  7675. yiliao_leibie = "普通门诊"
  7676. break
  7677. case "12":
  7678. yiliao_leibie = "门诊挂号"
  7679. break
  7680. case "13":
  7681. yiliao_leibie = "急诊"
  7682. break
  7683. case "14":
  7684. yiliao_leibie = "门诊特殊病"
  7685. break
  7686. case "15":
  7687. yiliao_leibie = "门诊统筹"
  7688. break
  7689. case "16":
  7690. yiliao_leibie = "门诊慢性病"
  7691. break
  7692. case "21":
  7693. yiliao_leibie = "普通住院"
  7694. break
  7695. }
  7696. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7697. if res.Infcode == 0 {
  7698. c.ServeSuccessJSON(map[string]interface{}{
  7699. "diagnosis": name,
  7700. "order_infos": orderInfos,
  7701. "number": order.MdtrtId,
  7702. "date": order.SettleAccountsDate,
  7703. "charge_admin": charge_admin,
  7704. "printor_admin": printor_admin,
  7705. "info": res.Output.Setlinfo,
  7706. "bedCostTotal": bedCostTotal,
  7707. "bedCostSelfTotal": bedCostSelfTotal,
  7708. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7709. "operationCostTotal": operationCostTotal,
  7710. "operationCostSelfTotal": operationCostSelfTotal,
  7711. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7712. "otherCostTotal": otherCostTotal,
  7713. "otherCostSelfTotal": otherCostSelfTotal,
  7714. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7715. "materialCostTotal": materialCostTotal,
  7716. "materialCostSelfTotal": materialCostSelfTotal,
  7717. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7718. "westernMedicineCostTotal": westernMedicineCostTotal,
  7719. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7720. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7721. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7722. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7723. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7724. "checkCostTotal": checkCostTotal,
  7725. "checkCostSelfTotal": checkCostSelfTotal,
  7726. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7727. "laboratoryCostTotal": laboratoryCostTotal,
  7728. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7729. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7730. "treatCostTotal": treatCostTotal,
  7731. "treatCostSelfTotal": treatCostSelfTotal,
  7732. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7733. "doctor_code": adminRole_two.DoctorCode,
  7734. "doctor_name": doctor_name,
  7735. "health_card_no": order.PsnNo,
  7736. "department": departments.Name,
  7737. "yiliao_leibie": yiliao_leibie,
  7738. "after_money": order.AccountPrice,
  7739. "patient": patient,
  7740. "org_name": miConfig.OrgName,
  7741. "org_code": miConfig.Code,
  7742. "order_number": order.Number,
  7743. //"his": his_hospital,
  7744. //"check_order_info": cus_slice,
  7745. })
  7746. }
  7747. }
  7748. }
  7749. func (c *HisApiController) CheckTreatment() {
  7750. patient_id, _ := c.GetInt64("patient_id")
  7751. id_card_no := c.GetString("id_card_no")
  7752. insutype := c.GetString("insutype")
  7753. med_type := c.GetString("med_type")
  7754. admin_user_id, _ := c.GetInt64("admin_user_id")
  7755. adminUser := c.GetAdminUserInfo()
  7756. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7757. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7758. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7759. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7760. if miConfig.MdtrtareaAdmvs == "421300" {
  7761. var res ResultTwo
  7762. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7763. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7764. "&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)
  7765. resp, requestErr := http.Get(api)
  7766. if requestErr != nil {
  7767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7768. return
  7769. }
  7770. body, ioErr := ioutil.ReadAll(resp.Body)
  7771. if ioErr != nil {
  7772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7774. return
  7775. }
  7776. var respJSON map[string]interface{}
  7777. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7780. return
  7781. }
  7782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7783. result, _ := json.Marshal(respJSON)
  7784. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7785. utils.ErrorLog("解析失败:%v", err)
  7786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7787. return
  7788. }
  7789. if res.Infcode == 0 {
  7790. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7791. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7792. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7793. resp, requestErr := http.Get(api)
  7794. if requestErr != nil {
  7795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7796. return
  7797. }
  7798. body, ioErr := ioutil.ReadAll(resp.Body)
  7799. if ioErr != nil {
  7800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7802. return
  7803. }
  7804. var respJSON map[string]interface{}
  7805. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7808. return
  7809. }
  7810. var res Result2001
  7811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7812. result2, _ := json.Marshal(respJSON)
  7813. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7814. utils.ErrorLog("解析失败:%v", err)
  7815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7816. return
  7817. }
  7818. if res.Infcode == 0 {
  7819. c.ServeSuccessJSON(map[string]interface{}{
  7820. "msg": res.Output.Trtinfo,
  7821. })
  7822. }
  7823. } else {
  7824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7825. return
  7826. }
  7827. } else {
  7828. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7829. var dat map[string]interface{}
  7830. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7831. fmt.Println(dat)
  7832. } else {
  7833. fmt.Println(err)
  7834. }
  7835. userJSONBytes, _ := json.Marshal(dat)
  7836. var res ResultTwo
  7837. var res10265 ResultTwo10265
  7838. if miConfig.Code == "H15049901371" {
  7839. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7840. utils.ErrorLog("解析失败:%v", err)
  7841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7842. return
  7843. }
  7844. res.ErrMsg = res10265.ErrMsg
  7845. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7846. res.Infcode = infocode
  7847. res.Output = res10265.Output
  7848. res.InfRefmsgid = res10265.InfRefmsgid
  7849. } else {
  7850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7851. utils.ErrorLog("解析失败:%v", err)
  7852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7853. return
  7854. }
  7855. }
  7856. var user_name string
  7857. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7858. if role.ID == 0 {
  7859. user_name = "xxx"
  7860. } else {
  7861. user_name = role.UserName
  7862. }
  7863. baseParams := models.BaseParams{
  7864. SecretKey: miConfig.SecretKey,
  7865. FixmedinsCode: miConfig.Code,
  7866. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7867. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7868. OrgName: miConfig.OrgName,
  7869. Doctor: user_name,
  7870. }
  7871. if config.IsOpen == 1 {
  7872. if miConfig.Code == "H15049901371" {
  7873. if med_type == "14" {
  7874. if insutype == "390" {
  7875. med_type = "9933"
  7876. } else if insutype == "310" {
  7877. med_type = "990502"
  7878. }
  7879. } else if med_type == "11" {
  7880. med_type = "11"
  7881. }
  7882. }
  7883. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7884. var dat map[string]interface{}
  7885. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7886. fmt.Println(dat)
  7887. } else {
  7888. fmt.Println(err)
  7889. }
  7890. var res Result2001
  7891. var res10265 Result2001Org10265
  7892. if miConfig.Code == "H15049901371" {
  7893. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7894. utils.ErrorLog("解析失败:%v", err)
  7895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. return
  7897. }
  7898. res.ErrMsg = res10265.ErrMsg
  7899. res.Output = res10265.Output
  7900. res.InfRefmsgid = res10265.InfRefmsgid
  7901. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7902. res.Infcode = infocode
  7903. } else {
  7904. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7905. utils.ErrorLog("解析失败:%v", err)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. }
  7910. if res.Infcode == 0 {
  7911. c.ServeSuccessJSON(map[string]interface{}{
  7912. "msg": res.Output.Trtinfo,
  7913. })
  7914. }
  7915. }
  7916. }
  7917. }
  7918. //func (c *HisApiController) PutRecord() {
  7919. // id, _ := c.GetInt64("id")
  7920. // record_time := c.GetString("record_time")
  7921. // timeLayout := "2006-01-02"
  7922. // loc, _ := time.LoadLocation("Local")
  7923. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7924. // if err != nil {
  7925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7926. // return
  7927. // }
  7928. // recordDateTime := theTime.Unix()
  7929. //
  7930. // adminInfo := c.GetAdminUserInfo()
  7931. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7932. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7933. //
  7934. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7935. //
  7936. // fmt.Println(miConfig.SecretKey)
  7937. //
  7938. // if patient == nil {
  7939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7940. // return
  7941. // }
  7942. // if len(patient.IdCardNo) == 0 {
  7943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7944. // return
  7945. // }
  7946. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7947. // if config.IsOpen == 1 {
  7948. // 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
  7949. // resp, requestErr := http.Get(api)
  7950. // if requestErr != nil {
  7951. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7952. // return
  7953. // }
  7954. // defer resp.Body.Close()
  7955. // body, ioErr := ioutil.ReadAll(resp.Body)
  7956. // if ioErr != nil {
  7957. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7959. // return
  7960. // }
  7961. // var respJSON map[string]interface{}
  7962. //
  7963. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7964. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7965. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7966. // return
  7967. // }
  7968. //
  7969. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7970. // userJSONBytes, _ := json.Marshal(userJSON)
  7971. // var res ResultTwo
  7972. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7973. // utils.ErrorLog("解析失败:%v", err)
  7974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7975. // return
  7976. // }
  7977. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7978. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7979. // infoStr := string(Iinfos)
  7980. // idetinfoStr := string(Idetinfos)
  7981. //
  7982. // if res.Infcode == 0 {
  7983. // his := models.VMHisPatient{
  7984. // Status: 1,
  7985. // Ctime: time.Now().Unix(),
  7986. // Mtime: time.Now().Unix(),
  7987. // PsnNo: res.Output.Baseinfo.PsnNo,
  7988. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7989. // Certno: res.Output.Baseinfo.Certno,
  7990. // PsnName: res.Output.Baseinfo.PsnName,
  7991. // Gend: res.Output.Baseinfo.Gend,
  7992. // Naty: res.Output.Baseinfo.Naty,
  7993. // Brdy: res.Output.Baseinfo.Brdy,
  7994. // Age: res.Output.Baseinfo.Age,
  7995. // Iinfo: infoStr,
  7996. // Idetinfo: idetinfoStr,
  7997. // PatientId: patient.ID,
  7998. // RecordDate: theTime.Unix(),
  7999. // UserOrgId: adminInfo.CurrentOrgId,
  8000. // AdminUserId: adminInfo.AdminUser.Id,
  8001. // IsReturn: 1,
  8002. // }
  8003. //
  8004. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8005. // //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")
  8006. // //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")
  8007. //
  8008. // //var dat map[string]interface{}
  8009. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8010. // // fmt.Println(dat)
  8011. // //} else {
  8012. // // fmt.Println(err)
  8013. // //}
  8014. //
  8015. // var dat2 map[string]interface{}
  8016. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8017. // fmt.Println(dat2)
  8018. // } else {
  8019. // fmt.Println(err)
  8020. // }
  8021. //
  8022. // } else {
  8023. // adminUser := c.GetAdminUserInfo()
  8024. // errlog := &models.HisOrderError{
  8025. // UserOrgId: adminUser.CurrentOrgId,
  8026. // Ctime: time.Now().Unix(),
  8027. // Mtime: time.Now().Unix(),
  8028. // ErrMsg: res.ErrMsg,
  8029. // Status: 1,
  8030. // PatientId: id,
  8031. // RecordTime: recordDateTime,
  8032. // Stage: 1,
  8033. // }
  8034. // service.CreateErrMsgLog(errlog)
  8035. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8036. // return
  8037. // }
  8038. // }
  8039. //
  8040. //}
  8041. //func (c *HisApiController) GetUploadDiag() {
  8042. // id, _ := c.GetInt64("id")
  8043. // record_time := c.GetString("record_time")
  8044. //
  8045. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8046. // sick_type, _ := c.GetInt64("sick_type")
  8047. // reg_type, _ := c.GetInt64("reg_type")
  8048. //
  8049. // timeLayout := "2006-01-02"
  8050. // loc, _ := time.LoadLocation("Local")
  8051. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8052. // if err != nil {
  8053. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8054. // return
  8055. // }
  8056. //
  8057. // var patientPrescription models.HisPrescriptionInfo
  8058. // recordDateTime := theTime.Unix()
  8059. // adminInfo := c.GetAdminUserInfo()
  8060. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8061. //
  8062. // if patientPrescription.ID == 0 {
  8063. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8064. // }
  8065. //
  8066. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8067. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8068. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8069. // sickConfig, _ := service.FindSickById(sick_type)
  8070. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8071. //
  8072. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8073. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8074. // "&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 +
  8075. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8076. // resp2, requestErr2 := http.Get(api2)
  8077. // if requestErr2 != nil {
  8078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8079. // return
  8080. // }
  8081. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8082. // if ioErr2 != nil {
  8083. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8085. // return
  8086. // }
  8087. // var respJSON2 map[string]interface{}
  8088. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8089. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8091. // return
  8092. // }
  8093. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8094. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8095. //
  8096. // var res2 ResultSix
  8097. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8098. // utils.ErrorLog("解析失败:%v", err)
  8099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. // return
  8101. // }
  8102. // if res2.Infcode != 0 {
  8103. // adminUser := c.GetAdminUserInfo()
  8104. // errlog := &models.HisOrderError{
  8105. // UserOrgId: adminUser.CurrentOrgId,
  8106. // Ctime: time.Now().Unix(),
  8107. // Mtime: time.Now().Unix(),
  8108. // ErrMsg: res2.ErrMsg,
  8109. // Status: 1,
  8110. // PatientId: id,
  8111. // RecordTime: recordDateTime,
  8112. // Stage: 3,
  8113. // }
  8114. // service.CreateErrMsgLog(errlog)
  8115. //
  8116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8117. // return
  8118. // }
  8119. //
  8120. // c.ServeSuccessJSON(map[string]interface{}{
  8121. // "msg": "上传成功",
  8122. // })
  8123. //
  8124. //}
  8125. type QueryResult struct {
  8126. ID int64
  8127. Name string
  8128. Code string
  8129. List_type_code string
  8130. }
  8131. func (c *HisApiController) GetCheckCode() {
  8132. ids_str := c.GetString("ids")
  8133. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8134. ids_arr := strings.Split(ids_str, ",")
  8135. var queryResult []QueryResult
  8136. ids := make([]int64, 0)
  8137. for _, item := range ids_arr {
  8138. id, _ := strconv.ParseInt(item, 10, 64)
  8139. ids = append(ids, id)
  8140. }
  8141. if record_type == 1 {
  8142. drugs, _ := service.GetBatchDrugList(ids)
  8143. for _, item := range drugs {
  8144. result := QueryResult{
  8145. ID: item.ID,
  8146. Name: item.DrugName,
  8147. Code: item.MedicalInsuranceNumber,
  8148. List_type_code: "101",
  8149. }
  8150. queryResult = append(queryResult, result)
  8151. }
  8152. } else if record_type == 2 {
  8153. goods, _ := service.GetBatchGoodInformationList(ids)
  8154. for _, item := range goods {
  8155. result := QueryResult{
  8156. ID: item.ID,
  8157. Name: item.GoodName,
  8158. Code: item.MedicalInsuranceNumber,
  8159. List_type_code: "301",
  8160. }
  8161. queryResult = append(queryResult, result)
  8162. }
  8163. } else if record_type == 3 {
  8164. projects, _ := service.GetBathchMyPorjecgList(ids)
  8165. for _, item := range projects {
  8166. result := QueryResult{
  8167. ID: item.ID,
  8168. Name: item.ProjectName,
  8169. Code: item.MedicalCode,
  8170. List_type_code: "201",
  8171. }
  8172. queryResult = append(queryResult, result)
  8173. }
  8174. }
  8175. admin_user_id, _ := c.GetInt64("admin_user_id")
  8176. adminUser := c.GetAdminUserInfo()
  8177. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8178. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8179. var user_name string
  8180. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8181. if role.ID == 0 {
  8182. user_name = "xxx"
  8183. } else {
  8184. user_name = role.UserName
  8185. }
  8186. baseParams := &models.BaseParams{
  8187. SecretKey: miConfig.SecretKey,
  8188. FixmedinsCode: miConfig.Code,
  8189. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8190. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8191. OrgName: miConfig.OrgName,
  8192. Doctor: user_name,
  8193. }
  8194. if config.IsOpen == 1 {
  8195. for _, item := range queryResult {
  8196. var result string
  8197. if record_type == 1 {
  8198. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8199. } else if record_type == 2 {
  8200. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8201. } else if record_type == 3 {
  8202. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8203. }
  8204. var dat map[string]interface{}
  8205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8206. fmt.Println(dat)
  8207. } else {
  8208. fmt.Println(err)
  8209. }
  8210. userJSONBytes, _ := json.Marshal(dat)
  8211. var res ResultSix
  8212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8213. utils.ErrorLog("解析失败:%v", err)
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. if res.Infcode == 0 {
  8218. if record_type == 1 {
  8219. service.UpdateBaseDrugById(item.ID)
  8220. } else if record_type == 2 {
  8221. service.UpdateGoodInformaitonByDetail(item.ID)
  8222. } else if record_type == 3 {
  8223. service.UpdateProjectById(item.ID)
  8224. }
  8225. c.ServeSuccessJSON(map[string]interface{}{
  8226. "failed_code": 0,
  8227. "msg": "目录对照成功",
  8228. })
  8229. } else {
  8230. c.ServeSuccessJSON(map[string]interface{}{
  8231. "failed_code": -10,
  8232. "msg": res.ErrMsg,
  8233. })
  8234. }
  8235. }
  8236. }
  8237. }
  8238. func (c *HisApiController) UnCheckCode() {
  8239. ids_str := c.GetString("ids")
  8240. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8241. admin_user_id, _ := c.GetInt64("admin_user_id")
  8242. ids_arr := strings.Split(ids_str, ",")
  8243. var queryResult []QueryResult
  8244. ids := make([]int64, 0)
  8245. for _, item := range ids_arr {
  8246. id, _ := strconv.ParseInt(item, 10, 64)
  8247. ids = append(ids, id)
  8248. }
  8249. if record_type == 1 {
  8250. drugs, _ := service.GetBatchDrugList(ids)
  8251. for _, item := range drugs {
  8252. result := QueryResult{
  8253. ID: item.ID,
  8254. Name: item.DrugName,
  8255. Code: item.MedicalInsuranceNumber,
  8256. List_type_code: "101",
  8257. }
  8258. queryResult = append(queryResult, result)
  8259. }
  8260. } else if record_type == 2 {
  8261. goods, _ := service.GetBatchGoodInformationList(ids)
  8262. for _, item := range goods {
  8263. result := QueryResult{
  8264. ID: item.ID,
  8265. Name: item.GoodName,
  8266. Code: item.MedicalInsuranceNumber,
  8267. List_type_code: "301",
  8268. }
  8269. queryResult = append(queryResult, result)
  8270. }
  8271. } else if record_type == 3 {
  8272. projects, _ := service.GetBathchMyPorjecgList(ids)
  8273. for _, item := range projects {
  8274. result := QueryResult{
  8275. ID: item.ID,
  8276. Name: item.ProjectName,
  8277. Code: item.MedicalCode,
  8278. List_type_code: "201",
  8279. }
  8280. queryResult = append(queryResult, result)
  8281. }
  8282. }
  8283. adminUser := c.GetAdminUserInfo()
  8284. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8285. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8286. var user_name string
  8287. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8288. if role.ID == 0 {
  8289. user_name = "xxx"
  8290. } else {
  8291. user_name = role.UserName
  8292. }
  8293. baseParams := &models.BaseParams{
  8294. SecretKey: miConfig.SecretKey,
  8295. FixmedinsCode: miConfig.Code,
  8296. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8297. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8298. OrgName: miConfig.OrgName,
  8299. Doctor: user_name,
  8300. }
  8301. if config.IsOpen == 1 {
  8302. for _, item := range queryResult {
  8303. var result string
  8304. if record_type == 1 {
  8305. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8306. } else if record_type == 2 {
  8307. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8308. } else if record_type == 3 {
  8309. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8310. }
  8311. var dat2 map[string]interface{}
  8312. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8313. fmt.Println(dat2)
  8314. } else {
  8315. fmt.Println(err)
  8316. }
  8317. userJSONBytes, _ := json.Marshal(dat2)
  8318. var res ResultSix
  8319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8320. utils.ErrorLog("解析失败:%v", err)
  8321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8322. return
  8323. }
  8324. if res.Infcode == 0 {
  8325. if record_type == 1 {
  8326. service.UpdateDrugByIdDetail(item.ID)
  8327. } else if record_type == 2 {
  8328. service.UpdateGoodInfoById(item.ID)
  8329. } else if record_type == 3 {
  8330. service.UpdateMyProjectById(item.ID)
  8331. }
  8332. c.ServeSuccessJSON(map[string]interface{}{
  8333. "failed_code": 0,
  8334. "msg": "撤销目录对照成功",
  8335. })
  8336. } else {
  8337. c.ServeSuccessJSON(map[string]interface{}{
  8338. "failed_code": -10,
  8339. "msg": res.ErrMsg,
  8340. })
  8341. }
  8342. }
  8343. }
  8344. }
  8345. func (c *HisApiController) GetPatientInfo() {
  8346. id_card_no := c.GetString("id_card_no")
  8347. admin_user_id, _ := c.GetInt64("admin_user_id")
  8348. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8349. if patient.ID == 0 {
  8350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8351. return
  8352. }
  8353. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8354. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8355. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8356. if config.IsOpen == 1 {
  8357. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8358. var dat map[string]interface{}
  8359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8360. fmt.Println(dat)
  8361. } else {
  8362. fmt.Println(err)
  8363. }
  8364. userJSONBytes, _ := json.Marshal(dat)
  8365. var res ResultTwo
  8366. var res10265 ResultTwo10265
  8367. if miConfig.Code == "H15049901371" {
  8368. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8369. utils.ErrorLog("解析失败:%v", err)
  8370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8371. return
  8372. }
  8373. res.ErrMsg = res10265.ErrMsg
  8374. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8375. res.Infcode = infocode
  8376. res.Output = res10265.Output
  8377. res.InfRefmsgid = res10265.InfRefmsgid
  8378. } else {
  8379. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8380. utils.ErrorLog("解析失败:%v", err)
  8381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8382. return
  8383. }
  8384. }
  8385. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8386. // utils.ErrorLog("解析失败:%v", err)
  8387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8388. // return
  8389. //}
  8390. if res.Infcode != 0 {
  8391. c.ServeSuccessJSON(map[string]interface{}{
  8392. "failed_code": -10,
  8393. "msg": res.ErrMsg,
  8394. })
  8395. } else {
  8396. c.ServeSuccessJSON(map[string]interface{}{
  8397. "failed_code": 0,
  8398. "info": res,
  8399. })
  8400. }
  8401. }
  8402. }
  8403. func (c *HisApiController) PsnPutOnRecord() {
  8404. record_type, _ := c.GetInt64("type")
  8405. patient_id, _ := c.GetInt64("patient_id")
  8406. admin_user_id, _ := c.GetInt64("admin_user_id")
  8407. start_time := c.GetString("start_time")
  8408. end_time := c.GetString("end_time")
  8409. adminUser := c.GetAdminUserInfo()
  8410. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8411. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8412. var patients []*models.Patients
  8413. if record_type == 1 { //全部备案
  8414. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8415. patients = append(patients, patient...)
  8416. } else { //单个备案
  8417. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8418. patients = append(patients, patient)
  8419. }
  8420. var user_name string
  8421. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8422. if role.ID == 0 {
  8423. user_name = "xxx"
  8424. } else {
  8425. user_name = role.UserName
  8426. }
  8427. if config.IsOpen == 1 {
  8428. for _, item := range patients {
  8429. 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
  8430. resp, requestErr := http.Get(api)
  8431. if requestErr != nil {
  8432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8433. return
  8434. }
  8435. defer resp.Body.Close()
  8436. body, ioErr := ioutil.ReadAll(resp.Body)
  8437. if ioErr != nil {
  8438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8440. return
  8441. }
  8442. var respJSON map[string]interface{}
  8443. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8446. return
  8447. }
  8448. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8449. userJSONBytes, _ := json.Marshal(userJSON)
  8450. var res ResultTwo
  8451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8452. utils.ErrorLog("解析失败:%v", err)
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8454. return
  8455. }
  8456. if res.Infcode == 0 {
  8457. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8458. var dat map[string]interface{}
  8459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8460. fmt.Println(dat)
  8461. } else {
  8462. fmt.Println(err)
  8463. }
  8464. userJSONBytes, _ := json.Marshal(dat)
  8465. var res2 ResultThirteen
  8466. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8467. utils.ErrorLog("解析失败:%v", err)
  8468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8469. return
  8470. }
  8471. if res2.Infcode == 0 {
  8472. psnResult := &models.GdybPsnRecord{
  8473. UserOrgId: adminUser.CurrentOrgId,
  8474. PatientId: item.ID,
  8475. PsnNo: res.Output.Baseinfo.PsnNo,
  8476. Ctime: time.Now().Unix(),
  8477. Mtime: time.Now().Unix(),
  8478. Status: 1,
  8479. IsCancel: 1,
  8480. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8481. }
  8482. service.CreatePsnRecord(psnResult)
  8483. } else {
  8484. c.ServeSuccessJSON(map[string]interface{}{
  8485. "failed_code": -10,
  8486. "msg": res2.ErrMsg,
  8487. })
  8488. return
  8489. }
  8490. }
  8491. }
  8492. }
  8493. }
  8494. func (c *HisApiController) PsnUnPutOnRecord() {
  8495. id, _ := c.GetInt64("id")
  8496. //record_type, _ := c.GetInt64("type")
  8497. admin_user_id, _ := c.GetInt64("admin_user_id")
  8498. adminUser := c.GetAdminUserInfo()
  8499. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8500. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8501. var user_name string
  8502. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8503. if role.ID == 0 {
  8504. user_name = "xxx"
  8505. } else {
  8506. user_name = role.UserName
  8507. }
  8508. psn_record, _ := service.GetPsnRecordById(id)
  8509. if psn_record.ID == 0 {
  8510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8511. return
  8512. }
  8513. if config.IsOpen == 1 {
  8514. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8515. var dat map[string]interface{}
  8516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8517. fmt.Println(dat)
  8518. } else {
  8519. fmt.Println(err)
  8520. }
  8521. userJSONBytes, _ := json.Marshal(dat)
  8522. var res ResultFourteen
  8523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8524. utils.ErrorLog("解析失败:%v", err)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. if res.Infcode == 0 {
  8529. psn_record.IsCancel = 2
  8530. service.CreatePsnRecord(&psn_record)
  8531. } else {
  8532. c.ServeSuccessJSON(map[string]interface{}{
  8533. "failed_code": -10,
  8534. "msg": res.ErrMsg,
  8535. })
  8536. return
  8537. }
  8538. }
  8539. }
  8540. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8541. patient_id, _ := c.GetInt64("patient_id")
  8542. insutype_two := c.GetString("insutype")
  8543. psn_no := c.GetString("psn_no")
  8544. doctor_id, _ := c.GetInt64("doctor_id")
  8545. sick_id, _ := c.GetInt64("sick_id")
  8546. department_id, _ := c.GetInt64("department_id")
  8547. start_time := c.GetString("start_time")
  8548. end_time := c.GetString("end_time")
  8549. check_time := c.GetString("check_time")
  8550. adminUser := c.GetAdminUserInfo()
  8551. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8552. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8553. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8554. sick, _ := service.FindSickById(sick_id)
  8555. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8556. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8557. var res ResultTwo
  8558. var res10265 ResultTwo10265
  8559. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8560. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8561. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8562. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8563. "&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
  8564. resp, requestErr := http.Get(api)
  8565. if requestErr != nil {
  8566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8567. return
  8568. }
  8569. body, ioErr := ioutil.ReadAll(resp.Body)
  8570. if ioErr != nil {
  8571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8573. return
  8574. }
  8575. var respJSON map[string]interface{}
  8576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8579. return
  8580. }
  8581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8582. result, _ := json.Marshal(respJSON)
  8583. fmt.Println("log")
  8584. fmt.Println(string(result))
  8585. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8586. utils.ErrorLog("解析失败:%v", err)
  8587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8588. return
  8589. }
  8590. res.ErrMsg = res10265.ErrMsg
  8591. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8592. res.Infcode = infocode
  8593. res.Output = res10265.Output
  8594. res.InfRefmsgid = res10265.InfRefmsgid
  8595. } else {
  8596. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8597. if miConfig.Code == "H15049901371" {
  8598. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8599. utils.ErrorLog("解析失败:%v", err)
  8600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8601. return
  8602. }
  8603. res.ErrMsg = res10265.ErrMsg
  8604. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8605. res.Infcode = infocode
  8606. res.Output = res10265.Output
  8607. res.InfRefmsgid = res10265.InfRefmsgid
  8608. } else {
  8609. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8610. utils.ErrorLog("解析失败:%v", err)
  8611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8612. return
  8613. }
  8614. }
  8615. }
  8616. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8617. infoStr := string(Iinfos)
  8618. var rf []*ResultFive
  8619. json.Unmarshal([]byte(infoStr), &rf)
  8620. var insuplc_admdvs string
  8621. var insutype string
  8622. var is390 int = 0
  8623. var is310 int = 0
  8624. var insutypes []*ResultFive
  8625. for _, item := range rf {
  8626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8627. insutypes = append(insutypes, item)
  8628. }
  8629. }
  8630. if len(insutypes) == 1 {
  8631. insutype = insutypes[0].Insutype
  8632. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8633. } else {
  8634. for _, i := range insutypes {
  8635. if i.Insutype == "390" {
  8636. is390 = 1
  8637. }
  8638. if i.Insutype == "310" {
  8639. is310 = 1
  8640. }
  8641. }
  8642. }
  8643. if is390 == 1 {
  8644. insutype = "390"
  8645. }
  8646. if is310 == 1 {
  8647. insutype = "310"
  8648. }
  8649. if len(insutypes) == 2 {
  8650. insutype = insutype_two
  8651. }
  8652. if len(insutypes) == 0 {
  8653. insutype = "310"
  8654. }
  8655. insutype = insutype_two
  8656. fmt.Println(insutype)
  8657. for _, item := range rf {
  8658. fmt.Println(item.Insutype)
  8659. fmt.Println(insutype)
  8660. if item.Insutype == insutype {
  8661. fmt.Println(item.Insutype)
  8662. fmt.Println(insutype)
  8663. insuplc_admdvs = item.InsuplcAdmdvs
  8664. }
  8665. }
  8666. fmt.Println(insuplc_admdvs)
  8667. var res2 ResultThirteen
  8668. var res10265_2 ResultThirteen10265
  8669. if config.IsOpen == 1 {
  8670. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8671. } else {
  8672. 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)
  8673. var dat map[string]interface{}
  8674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8675. fmt.Println(dat)
  8676. } else {
  8677. fmt.Println(err)
  8678. }
  8679. userJSONBytes, _ := json.Marshal(dat)
  8680. if miConfig.Code == "H15049901371" {
  8681. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8682. utils.ErrorLog("解析失败:%v", err)
  8683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8684. return
  8685. }
  8686. res2.ErrMsg = res10265_2.ErrMsg
  8687. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8688. res2.Infcode = infocode
  8689. res2.Output = res10265_2.Output
  8690. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8691. } else {
  8692. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8693. utils.ErrorLog("解析失败:%v", err)
  8694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8695. return
  8696. }
  8697. }
  8698. }
  8699. if res2.Infcode == 0 {
  8700. psnResult := &models.GdybPsnNcdsRecord{
  8701. UserOrgId: adminUser.CurrentOrgId,
  8702. PatientId: patient.ID,
  8703. PsnNo: psn_no,
  8704. DoctorId: doctor.AdminUserId,
  8705. DepartmentId: department_id,
  8706. SickType: sick_id,
  8707. Insutype: insutype,
  8708. Ctime: time.Now().Unix(),
  8709. Mtime: time.Now().Unix(),
  8710. Status: 1,
  8711. IsCancel: 1,
  8712. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8713. }
  8714. service.CreatePsnNCDSRecord(psnResult)
  8715. c.ServeSuccessJSON(map[string]interface{}{
  8716. "failed_code": 0,
  8717. "msg": "备案成功",
  8718. "result": psnResult,
  8719. })
  8720. } else {
  8721. c.ServeSuccessJSON(map[string]interface{}{
  8722. "failed_code": -10,
  8723. "msg": res2.ErrMsg,
  8724. })
  8725. return
  8726. }
  8727. }
  8728. }
  8729. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8730. id, _ := c.GetInt64("id")
  8731. admin_user_id, _ := c.GetInt64("admin_user_id")
  8732. adminUser := c.GetAdminUserInfo()
  8733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8734. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8735. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8736. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8737. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8738. //var user_name string
  8739. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8740. //if role.ID == 0 {
  8741. // user_name = "xxx"
  8742. //} else {
  8743. // user_name = role.UserName
  8744. //}
  8745. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8746. if psn_record.ID == 0 {
  8747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8748. return
  8749. }
  8750. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8751. var res ResultTwo
  8752. var res10265 ResultTwo10265
  8753. if miConfig.Code == "H15049901371" {
  8754. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8755. utils.ErrorLog("解析失败:%v", err)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. res.ErrMsg = res10265.ErrMsg
  8760. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8761. res.Infcode = infocode
  8762. res.Output = res10265.Output
  8763. res.InfRefmsgid = res10265.InfRefmsgid
  8764. } else {
  8765. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8766. utils.ErrorLog("解析失败:%v", err)
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8768. return
  8769. }
  8770. }
  8771. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8772. infoStr := string(Iinfos)
  8773. var rf []*ResultFive
  8774. json.Unmarshal([]byte(infoStr), &rf)
  8775. var insuplc_admdvs string
  8776. var insutype string
  8777. var is390 int = 0
  8778. var is310 int = 0
  8779. var insutypes []*ResultFive
  8780. for _, item := range rf {
  8781. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8782. insutypes = append(insutypes, item)
  8783. }
  8784. }
  8785. if len(insutypes) == 1 {
  8786. insutype = insutypes[0].Insutype
  8787. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8788. } else {
  8789. for _, i := range insutypes {
  8790. if i.Insutype == "390" {
  8791. is390 = 1
  8792. }
  8793. if i.Insutype == "310" {
  8794. is310 = 1
  8795. }
  8796. }
  8797. }
  8798. if is390 == 1 {
  8799. insutype = "390"
  8800. }
  8801. if is310 == 1 {
  8802. insutype = "310"
  8803. }
  8804. if len(insutypes) == 0 {
  8805. insutype = "310"
  8806. }
  8807. insutype = psn_record.Insutype
  8808. for _, item := range rf {
  8809. if item.Insutype == insutype {
  8810. insuplc_admdvs = item.InsuplcAdmdvs
  8811. }
  8812. }
  8813. if config.IsOpen == 1 {
  8814. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8815. var dat map[string]interface{}
  8816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8817. fmt.Println(dat)
  8818. } else {
  8819. fmt.Println(err)
  8820. }
  8821. userJSONBytes, _ := json.Marshal(dat)
  8822. var res ResultFourteen
  8823. var res10265 ResultFourteen10265
  8824. if miConfig.Code == "H15049901371" {
  8825. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8826. utils.ErrorLog("解析失败:%v", err)
  8827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8828. return
  8829. }
  8830. res.ErrMsg = res10265.ErrMsg
  8831. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8832. res.Infcode = infocode
  8833. res.Output = res10265.Output
  8834. res.InfRefmsgid = res10265.InfRefmsgid
  8835. } else {
  8836. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8837. utils.ErrorLog("解析失败:%v", err)
  8838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8839. return
  8840. }
  8841. }
  8842. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8843. // utils.ErrorLog("解析失败:%v", err)
  8844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8845. // return
  8846. //}
  8847. if res.Infcode == 0 {
  8848. psn_record.IsCancel = 2
  8849. service.CreatePsnNCDSRecord(&psn_record)
  8850. c.ServeSuccessJSON(map[string]interface{}{
  8851. "failed_code": 0,
  8852. "msg": "撤销备案成功",
  8853. })
  8854. } else {
  8855. c.ServeSuccessJSON(map[string]interface{}{
  8856. "failed_code": -10,
  8857. "msg": res.ErrMsg,
  8858. })
  8859. return
  8860. }
  8861. }
  8862. }
  8863. func (c *HisApiController) TestTest() {
  8864. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8865. fmt.Println(patient.Iinfo)
  8866. }
  8867. type CustomData struct {
  8868. MsgId string
  8869. PsnNo string
  8870. Info string
  8871. }
  8872. func (c *HisApiController) ReversalData() {
  8873. var customData []*CustomData
  8874. custom := &CustomData{
  8875. MsgId: "H44022900158202103301714472004",
  8876. PsnNo: "44020000001101329945",
  8877. Info: "2207",
  8878. }
  8879. customData = append(customData, custom)
  8880. custom1 := &CustomData{
  8881. MsgId: "H4402290015820210330172057803",
  8882. PsnNo: "44020000001101161813",
  8883. Info: "2207",
  8884. }
  8885. customData = append(customData, custom1)
  8886. custom2 := &CustomData{
  8887. MsgId: "H44022900158202103301705198813",
  8888. PsnNo: "44190000133097375417",
  8889. Info: "2207",
  8890. }
  8891. customData = append(customData, custom2)
  8892. custom3 := &CustomData{
  8893. MsgId: "H44022900158202103301715524756",
  8894. PsnNo: "44020000001100187221",
  8895. Info: "2207",
  8896. }
  8897. customData = append(customData, custom3)
  8898. custom4 := &CustomData{
  8899. MsgId: "H44022900158202103301730376224",
  8900. PsnNo: "44020000001101959155",
  8901. Info: "2207",
  8902. }
  8903. customData = append(customData, custom4)
  8904. custom5 := &CustomData{
  8905. MsgId: "H44022900158202103301748008725",
  8906. PsnNo: "44020000001104246641",
  8907. Info: "2207",
  8908. }
  8909. customData = append(customData, custom5)
  8910. custom6 := &CustomData{
  8911. MsgId: "H44022900158202103301718096755",
  8912. PsnNo: "44020000001102211860",
  8913. Info: "2207",
  8914. }
  8915. customData = append(customData, custom6)
  8916. custom7 := &CustomData{
  8917. MsgId: "H44022900158202103301736551640",
  8918. PsnNo: "44020000001102687718",
  8919. Info: "2207",
  8920. }
  8921. customData = append(customData, custom7)
  8922. custom8 := &CustomData{
  8923. MsgId: "H44022900158202103301743097676",
  8924. PsnNo: "44020000001102127785",
  8925. Info: "2207",
  8926. }
  8927. customData = append(customData, custom8)
  8928. custom9 := &CustomData{
  8929. MsgId: "H44022900158202103301712304203",
  8930. PsnNo: "44020000001101518097",
  8931. Info: "2207",
  8932. }
  8933. customData = append(customData, custom9)
  8934. custom10 := &CustomData{
  8935. MsgId: "H44022900158202103301738448785",
  8936. PsnNo: "44020000001100500813",
  8937. Info: "2207",
  8938. }
  8939. customData = append(customData, custom10)
  8940. custom11 := &CustomData{
  8941. MsgId: "H44022900158202103301732455843",
  8942. PsnNo: "44020000001102690557",
  8943. Info: "2207",
  8944. }
  8945. customData = append(customData, custom11)
  8946. custom12 := &CustomData{
  8947. MsgId: "H44022900158202103301745421708",
  8948. PsnNo: "44020000001102211928",
  8949. Info: "2207",
  8950. }
  8951. customData = append(customData, custom12)
  8952. custom1212 := &CustomData{
  8953. MsgId: "H440229001582021033017351627",
  8954. PsnNo: "44020000001102481733",
  8955. Info: "2207",
  8956. }
  8957. customData = append(customData, custom1212)
  8958. custom13 := &CustomData{
  8959. MsgId: "H44022900158202103301740327951",
  8960. PsnNo: "44020000001103174866",
  8961. Info: "2207",
  8962. }
  8963. customData = append(customData, custom13)
  8964. custom14 := &CustomData{
  8965. MsgId: "H4402290015820210330174922668",
  8966. PsnNo: "44020000001102927272",
  8967. Info: "2207",
  8968. }
  8969. customData = append(customData, custom14)
  8970. custom15 := &CustomData{
  8971. MsgId: "H44022900158202103301752362273",
  8972. PsnNo: "44020000001102942890",
  8973. Info: "2207",
  8974. }
  8975. customData = append(customData, custom15)
  8976. custom16 := &CustomData{
  8977. MsgId: "H44022900158202103301751082917",
  8978. PsnNo: "44020000001101662162",
  8979. Info: "2207",
  8980. }
  8981. customData = append(customData, custom16)
  8982. custom17 := &CustomData{
  8983. MsgId: "H44022900158202103301754147728",
  8984. PsnNo: "44020000000229014511",
  8985. Info: "2207",
  8986. }
  8987. customData = append(customData, custom17)
  8988. adminUser := c.GetAdminUserInfo()
  8989. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8990. for _, item := range customData {
  8991. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8992. fmt.Println(result)
  8993. }
  8994. }
  8995. func (c *HisApiController) GetAllopatry() {
  8996. year := c.GetString("year")
  8997. month := c.GetString("month")
  8998. admin_user_id, _ := c.GetInt64("admin_user_id")
  8999. adminUser := c.GetAdminUserInfo()
  9000. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9001. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9002. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9003. var dat map[string]interface{}
  9004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9005. fmt.Println(dat)
  9006. } else {
  9007. fmt.Println(err)
  9008. }
  9009. userJSONBytes, _ := json.Marshal(dat)
  9010. var res models.Result9001
  9011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9012. utils.ErrorLog("解析失败:%v", err)
  9013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9014. return
  9015. }
  9016. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9017. var dat2 map[string]interface{}
  9018. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9019. fmt.Println(dat)
  9020. } else {
  9021. fmt.Println(err)
  9022. }
  9023. userJSONBytes2, _ := json.Marshal(dat2)
  9024. var res2 models.Result3260
  9025. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9026. utils.ErrorLog("解析失败:%v", err)
  9027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9028. return
  9029. }
  9030. if res2.Infcode == 0 {
  9031. c.ServeSuccessJSON(map[string]interface{}{
  9032. "list": res2.Output.Data,
  9033. })
  9034. return
  9035. } else {
  9036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9037. return
  9038. }
  9039. }
  9040. func (c *HisApiController) ComfirmAllopatry() {
  9041. year := c.GetString("year")
  9042. month := c.GetString("month")
  9043. admin_user_id, _ := c.GetInt64("admin_user_id")
  9044. adminUser := c.GetAdminUserInfo()
  9045. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9046. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9047. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9048. var dat map[string]interface{}
  9049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9050. fmt.Println(dat)
  9051. } else {
  9052. fmt.Println(err)
  9053. }
  9054. userJSONBytes, _ := json.Marshal(dat)
  9055. var res models.Result9001
  9056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9057. utils.ErrorLog("解析失败:%v", err)
  9058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9059. return
  9060. }
  9061. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9062. var dat2 map[string]interface{}
  9063. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9064. fmt.Println(dat)
  9065. } else {
  9066. fmt.Println(err)
  9067. }
  9068. userJSONBytes2, _ := json.Marshal(dat2)
  9069. var res2 models.Result3260
  9070. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9071. utils.ErrorLog("解析失败:%v", err)
  9072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9073. return
  9074. }
  9075. if res2.Infcode == 0 {
  9076. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9077. var dat map[string]interface{}
  9078. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9079. fmt.Println(dat)
  9080. } else {
  9081. fmt.Println(err)
  9082. }
  9083. userJSONBytes, _ := json.Marshal(dat)
  9084. var res3 models.Result3261
  9085. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9086. utils.ErrorLog("解析失败:%v", err)
  9087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9088. return
  9089. }
  9090. if res3.Infcode == 0 {
  9091. record := &models.HisYidiClearRecord{
  9092. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9093. Ctime: time.Now().Unix(),
  9094. Mtime: time.Now().Unix(),
  9095. Status: 1,
  9096. MsgId: msgId,
  9097. }
  9098. service.SaveClearRecord(record)
  9099. c.ServeSuccessJSON(map[string]interface{}{
  9100. "msg": "提取成功",
  9101. })
  9102. }
  9103. }
  9104. }
  9105. func (c *HisApiController) RefundAllopatry() {
  9106. year := c.GetString("year")
  9107. month := c.GetString("month")
  9108. id, _ := c.GetInt64("id")
  9109. admin_user_id, _ := c.GetInt64("admin_user_id")
  9110. adminUser := c.GetAdminUserInfo()
  9111. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9112. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9113. record, _ := service.GetClearRecordById(id)
  9114. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9115. var dat map[string]interface{}
  9116. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9117. fmt.Println(dat)
  9118. } else {
  9119. fmt.Println(err)
  9120. }
  9121. userJSONBytes, _ := json.Marshal(dat)
  9122. var empty ResultFourteen
  9123. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9124. utils.ErrorLog("解析失败:%v", err)
  9125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9126. return
  9127. }
  9128. if empty.Infcode == 0 {
  9129. c.ServeSuccessJSON(map[string]interface{}{
  9130. "msg": "撤销成功",
  9131. })
  9132. return
  9133. }
  9134. }
  9135. func (c *HisApiController) ReversalOtherData() {
  9136. var customData []*CustomData
  9137. custom := &CustomData{
  9138. MsgId: "H44022900158202103301714472004",
  9139. PsnNo: "44020000001101329945",
  9140. Info: "2208",
  9141. }
  9142. customData = append(customData, custom)
  9143. custom1 := &CustomData{
  9144. MsgId: "H4402290015820210330172057803",
  9145. PsnNo: "44020000001101161813",
  9146. Info: "2208",
  9147. }
  9148. customData = append(customData, custom1)
  9149. custom2 := &CustomData{
  9150. MsgId: "H44022900158202103301705198813",
  9151. PsnNo: "44190000133097375417",
  9152. Info: "2208",
  9153. }
  9154. customData = append(customData, custom2)
  9155. custom3 := &CustomData{
  9156. MsgId: "H44022900158202103301715524756",
  9157. PsnNo: "44020000001100187221",
  9158. Info: "2208",
  9159. }
  9160. customData = append(customData, custom3)
  9161. custom4 := &CustomData{
  9162. MsgId: "H44022900158202103301730376224",
  9163. PsnNo: "44020000001101959155",
  9164. Info: "2208",
  9165. }
  9166. customData = append(customData, custom4)
  9167. custom5 := &CustomData{
  9168. MsgId: "H44022900158202103301748008725",
  9169. PsnNo: "44020000001104246641",
  9170. Info: "2208",
  9171. }
  9172. customData = append(customData, custom5)
  9173. custom6 := &CustomData{
  9174. MsgId: "H44022900158202103301718096755",
  9175. PsnNo: "44020000001102211860",
  9176. Info: "2208",
  9177. }
  9178. customData = append(customData, custom6)
  9179. custom7 := &CustomData{
  9180. MsgId: "H44022900158202103301736551640",
  9181. PsnNo: "44020000001102687718",
  9182. Info: "2208",
  9183. }
  9184. customData = append(customData, custom7)
  9185. custom8 := &CustomData{
  9186. MsgId: "H44022900158202103301743097676",
  9187. PsnNo: "44020000001102127785",
  9188. Info: "2208",
  9189. }
  9190. customData = append(customData, custom8)
  9191. custom9 := &CustomData{
  9192. MsgId: "H44022900158202103301712304203",
  9193. PsnNo: "44020000001101518097",
  9194. Info: "2208",
  9195. }
  9196. customData = append(customData, custom9)
  9197. custom10 := &CustomData{
  9198. MsgId: "H44022900158202103301738448785",
  9199. PsnNo: "44020000001100500813",
  9200. Info: "2208",
  9201. }
  9202. customData = append(customData, custom10)
  9203. custom11 := &CustomData{
  9204. MsgId: "H44022900158202103301732455843",
  9205. PsnNo: "44020000001102690557",
  9206. Info: "2208",
  9207. }
  9208. customData = append(customData, custom11)
  9209. custom12 := &CustomData{
  9210. MsgId: "H44022900158202103301745421708",
  9211. PsnNo: "44020000001102211928",
  9212. Info: "2208",
  9213. }
  9214. customData = append(customData, custom12)
  9215. custom1212 := &CustomData{
  9216. MsgId: "H440229001582021033017351627",
  9217. PsnNo: "44020000001102481733",
  9218. Info: "2208",
  9219. }
  9220. customData = append(customData, custom1212)
  9221. custom13 := &CustomData{
  9222. MsgId: "H44022900158202103301740327951",
  9223. PsnNo: "44020000001103174866",
  9224. Info: "2208",
  9225. }
  9226. customData = append(customData, custom13)
  9227. custom14 := &CustomData{
  9228. MsgId: "H4402290015820210330174922668",
  9229. PsnNo: "44020000001102927272",
  9230. Info: "2208",
  9231. }
  9232. customData = append(customData, custom14)
  9233. custom15 := &CustomData{
  9234. MsgId: "H44022900158202103301752362273",
  9235. PsnNo: "44020000001102942890",
  9236. Info: "2208",
  9237. }
  9238. customData = append(customData, custom15)
  9239. custom16 := &CustomData{
  9240. MsgId: "H44022900158202103301751082917",
  9241. PsnNo: "44020000001101662162",
  9242. Info: "2208",
  9243. }
  9244. customData = append(customData, custom16)
  9245. custom17 := &CustomData{
  9246. MsgId: "H44022900158202103301754147728",
  9247. PsnNo: "44020000000229014511",
  9248. Info: "2208",
  9249. }
  9250. customData = append(customData, custom17)
  9251. adminUser := c.GetAdminUserInfo()
  9252. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9253. for _, item := range customData {
  9254. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9255. fmt.Println(result)
  9256. }
  9257. }
  9258. func PathExists(path string) (bool, error) {
  9259. _, err := os.Stat(path)
  9260. if err == nil {
  9261. return true, nil
  9262. }
  9263. if os.IsNotExist(err) {
  9264. return false, nil
  9265. }
  9266. return false, err
  9267. }
  9268. //创建文件夹
  9269. func Mkdir(dir string) {
  9270. // 创建文件夹
  9271. exist, err := PathExists(dir)
  9272. if err != nil {
  9273. fmt.Println(err.Error())
  9274. } else {
  9275. if exist {
  9276. fmt.Println(dir + "文件夹已存在!")
  9277. } else {
  9278. // 文件夹名称,权限
  9279. err := os.Mkdir(dir, os.ModePerm)
  9280. if err != nil {
  9281. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9282. } else {
  9283. fmt.Println(dir + "文件夹创建成功!")
  9284. }
  9285. }
  9286. }
  9287. }
  9288. //压缩文件
  9289. func Zip(srcFile string, destZip string) error {
  9290. zipfile, err := os.Create(destZip)
  9291. if err != nil {
  9292. return err
  9293. }
  9294. defer zipfile.Close()
  9295. archive := zip.NewWriter(zipfile)
  9296. defer archive.Close()
  9297. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9298. if err != nil {
  9299. return err
  9300. }
  9301. header, err := zip.FileInfoHeader(info)
  9302. if err != nil {
  9303. return err
  9304. }
  9305. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9306. // header.Name = path
  9307. if info.IsDir() {
  9308. header.Name += "/"
  9309. } else {
  9310. header.Method = zip.Deflate
  9311. }
  9312. writer, err := archive.CreateHeader(header)
  9313. if err != nil {
  9314. return err
  9315. }
  9316. if !info.IsDir() {
  9317. file, err := os.Open(path)
  9318. if err != nil {
  9319. return err
  9320. }
  9321. defer file.Close()
  9322. _, err = io.Copy(writer, file)
  9323. }
  9324. return err
  9325. })
  9326. return err
  9327. }
  9328. func ReadFile(filePath string) []byte {
  9329. f, err := os.Open(filePath)
  9330. if err != nil {
  9331. fmt.Println("read file fail", err)
  9332. return nil
  9333. }
  9334. defer f.Close()
  9335. fd, err := ioutil.ReadAll(f)
  9336. if err != nil {
  9337. fmt.Println("read to fd fail", err)
  9338. return nil
  9339. }
  9340. return fd
  9341. }
  9342. func saveLog(result string, request string, infno string, desc string) {
  9343. org_id, _ := beego.AppConfig.Int64("org_id")
  9344. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9345. dir := miConfig.OrgName + "日志"
  9346. utils.Mkdir(dir)
  9347. month := time.Unix(1557042972, 0).Format("1")
  9348. year := time.Now().Format("2006")
  9349. month = time.Now().Format("01")
  9350. day := time.Now().Format("02")
  9351. hour := time.Now().Format("15")
  9352. min := time.Now().Format("04")
  9353. sec := time.Now().Format("05")
  9354. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9355. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9356. file_name := file + ".txt"
  9357. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9358. exist, _ := utils.PathExists(file_path)
  9359. if exist { //存在
  9360. fmt.Println("存在")
  9361. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9362. if err != nil {
  9363. fmt.Println("read fail")
  9364. }
  9365. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9366. n, _ := f.Seek(0, 2)
  9367. _, err = f.WriteAt([]byte(content), n)
  9368. } else { //不存在
  9369. fmt.Println("文件不存在,创建文件")
  9370. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9371. defer f.Close()
  9372. if err != nil {
  9373. } else {
  9374. _, err = f.Write([]byte("记录日志"))
  9375. }
  9376. }
  9377. }
  9378. type Charset string
  9379. const (
  9380. UTF8 = Charset("UTF-8")
  9381. GB18030 = Charset("GB18030")
  9382. )
  9383. func ConvertToString(src string, srcCode string, tagCode string) string {
  9384. srcCoder := mahonia.NewDecoder(srcCode)
  9385. srcResult := srcCoder.ConvertString(src)
  9386. tagCoder := mahonia.NewDecoder(tagCode)
  9387. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9388. result := string(cdata)
  9389. return result
  9390. }