his_api_controller.go 313KB

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