his_api_controller.go 289KB

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