his_api_controller.go 288KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107
  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. 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)
  2946. }
  2947. saveLog(result, requestLog, "2203", "上传就诊信息")
  2948. var respJSON2 map[string]interface{}
  2949. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2952. return
  2953. }
  2954. userJSONBytes2, _ := json.Marshal(respJSON2)
  2955. if miConfig.Code == "H15049901371" {
  2956. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  2957. utils.ErrorLog("解析失败:%v", err)
  2958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2959. return
  2960. }
  2961. res2.InfRefmsgid = ressix10265.InfRefmsgid
  2962. res2.Output = ressix10265.Output
  2963. res2.ErrMsg = ressix10265.ErrMsg
  2964. res2.Cainfo = ressix10265.Cainfo
  2965. res2.WarnMsg = ressix10265.WarnMsg
  2966. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  2967. res2.Infcode = infocode
  2968. } else {
  2969. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2970. utils.ErrorLog("解析失败:%v", err)
  2971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2972. return
  2973. }
  2974. }
  2975. }
  2976. if res2.Infcode != 0 {
  2977. adminUser := c.GetAdminUserInfo()
  2978. errlog := &models.HisOrderError{
  2979. UserOrgId: adminUser.CurrentOrgId,
  2980. Ctime: time.Now().Unix(),
  2981. Mtime: time.Now().Unix(),
  2982. ErrMsg: res2.ErrMsg,
  2983. Status: 1,
  2984. PatientId: id,
  2985. RecordTime: recordDateTime,
  2986. Stage: 3,
  2987. }
  2988. service.CreateErrMsgLog(errlog)
  2989. c.ServeSuccessJSON(map[string]interface{}{
  2990. "failed_code": -10,
  2991. "msg": res2.ErrMsg,
  2992. })
  2993. return
  2994. } else {
  2995. his.Diagnosis = diagnosis_id
  2996. his.SickType = sickConfig.ID
  2997. var p_type int64
  2998. if reg_type == 1111 || reg_type == 1112 {
  2999. p_type = 11
  3000. }
  3001. his.PType = fmt.Sprintf("%d", p_type)
  3002. service.UpdateHisPatientThree(&his)
  3003. data := make(map[string]interface{})
  3004. if settle_accounts_type == 1 { //日结
  3005. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3006. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3007. } else {
  3008. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3009. }
  3010. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3011. data["pre"] = prescriptions
  3012. } else { //月结
  3013. start_time_str := c.GetString("start_time")
  3014. end_time_str := c.GetString("end_time")
  3015. timeLayout := "2006-01-02"
  3016. loc, _ := time.LoadLocation("Local")
  3017. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3018. if err != nil {
  3019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3020. return
  3021. }
  3022. recordStartTime := theStartTime.Unix()
  3023. start_time = recordStartTime
  3024. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3025. if err != nil {
  3026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3027. return
  3028. }
  3029. recordEndTime := theEndTime.Unix()
  3030. end_time = recordEndTime
  3031. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3032. data["pre"] = prescriptions
  3033. }
  3034. timestamp := time.Now().Unix()
  3035. tempTime := time.Unix(timestamp, 0)
  3036. timeFormat := tempTime.Format("20060102150405")
  3037. chrgBchno := rand.Intn(100000) + 10000
  3038. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3039. strconv.FormatInt(his.PatientId, 10)
  3040. client := &http.Client{}
  3041. data["psn_no"] = his.PsnNo
  3042. data["mdtrt_id"] = his.Number
  3043. data["chrg_bchno"] = chrg_bchno
  3044. data["org_name"] = miConfig.OrgName
  3045. data["doctor"] = roles.UserName
  3046. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3047. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3048. data["fixmedins_code"] = miConfig.Code
  3049. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3050. data["dept_code"] = "15"
  3051. } else {
  3052. data["dept_code"] = department.Number
  3053. }
  3054. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3055. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3056. data["secret_key"] = miConfig.SecretKey
  3057. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3058. var ids []int64
  3059. for _, item := range prescriptions {
  3060. ids = append(ids, item.ID)
  3061. }
  3062. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3063. if config.IsOpen == 1 { //对接了医保,走医保流程
  3064. var res ResultFour
  3065. var resFour10265 ResultFour10265
  3066. if miConfig.MdtrtareaAdmvs == "421300" {
  3067. bytesData, _ := json.Marshal(data)
  3068. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3069. resp, _ := client.Do(req)
  3070. defer resp.Body.Close()
  3071. body, ioErr := ioutil.ReadAll(resp.Body)
  3072. if ioErr != nil {
  3073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3075. return
  3076. }
  3077. var respJSON map[string]interface{}
  3078. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3081. return
  3082. }
  3083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3084. userJSONBytes, _ := json.Marshal(respJSON)
  3085. fmt.Println("log")
  3086. fmt.Println(string(userJSONBytes))
  3087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3088. utils.ErrorLog("解析失败:%v", err)
  3089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3090. return
  3091. }
  3092. } else {
  3093. 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))
  3094. var dat map[string]interface{}
  3095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3096. fmt.Println(dat)
  3097. } else {
  3098. fmt.Println(err)
  3099. }
  3100. saveLog(result, request_log, "2204", "上传费用明细")
  3101. userJSONBytes, _ := json.Marshal(dat)
  3102. if miConfig.Code == "H15049901371" {
  3103. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3104. utils.ErrorLog("解析失败:%v", err)
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. return
  3107. }
  3108. res.InfRefmsgid = resFour10265.InfRefmsgid
  3109. res.Output = resFour10265.Output
  3110. res.ErrMsg = resFour10265.ErrMsg
  3111. res.Cainfo = resFour10265.Cainfo
  3112. res.WarnMsg = resFour10265.WarnMsg
  3113. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3114. res.Infcode = infocode
  3115. } else {
  3116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3117. utils.ErrorLog("解析失败:%v", err)
  3118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3119. return
  3120. }
  3121. }
  3122. }
  3123. if res.Infcode == 0 {
  3124. order := &models.HisOrder{
  3125. UserOrgId: adminUser.CurrentOrgId,
  3126. HisPatientId: his.ID,
  3127. PatientId: his.PatientId,
  3128. SettleAccountsDate: recordDateTime,
  3129. Ctime: time.Now().Unix(),
  3130. Mtime: time.Now().Unix(),
  3131. Status: 1,
  3132. Number: chrg_bchno,
  3133. Infcode: res.Infcode,
  3134. WarnMsg: res.WarnMsg,
  3135. Cainfo: res.Cainfo,
  3136. ErrMsg: res.ErrMsg,
  3137. RespondTime: res.RefmsgTime,
  3138. InfRefmsgid: res.InfRefmsgid,
  3139. OrderStatus: 1,
  3140. PayWay: pay_way,
  3141. PayPrice: pay_price,
  3142. PayCardNo: pay_card_no,
  3143. DiscountPrice: discount_price,
  3144. PreferentialPrice: preferential_price,
  3145. RealityPrice: reality_price,
  3146. FoundPrice: found_price,
  3147. MedicalInsurancePrice: medical_insurance_price,
  3148. PrivatePrice: private_price,
  3149. IsMedicineInsurance: 1,
  3150. SettleType: settle_accounts_type,
  3151. SettleStartTime: start_time,
  3152. SettleEndTime: end_time,
  3153. Creator: roles.AdminUserId,
  3154. Modify: roles.AdminUserId,
  3155. FaPiaoNumber: fapiao_number,
  3156. FaPiaoCode: fapiao_code,
  3157. PType: 2,
  3158. Diagnosis: diagnosis_id,
  3159. }
  3160. err = service.CreateOrder(order)
  3161. if err != nil {
  3162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3163. return
  3164. }
  3165. for _, item := range res.Output.Result {
  3166. temp := strings.Split(item.FeedetlSn, "-")
  3167. var advice_id int64 = 0
  3168. var project_id int64 = 0
  3169. var types int64 = 0
  3170. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3171. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3172. if temp[1] == "1" {
  3173. advice_id = id
  3174. project_id = 0
  3175. } else if temp[1] == "2" {
  3176. advice_id = 0
  3177. project_id = id
  3178. }
  3179. info := &models.HisOrderInfo{
  3180. OrderNumber: order.Number,
  3181. FeedetlSn: item.FeedetlSn,
  3182. UploadDate: time.Now().Unix(),
  3183. AdviceId: advice_id,
  3184. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3185. Cnt: item.Cnt,
  3186. Pric: float64(item.Pric),
  3187. PatientId: his.PatientId,
  3188. PricUplmtAmt: item.PricUplmtAmt,
  3189. SelfpayProp: item.SelfpayProp,
  3190. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3191. OverlmtAmt: item.OverlmtAmt,
  3192. PreselfpayAmt: item.PreselfpayAmt,
  3193. BasMednFlag: item.BasMednFlag,
  3194. MedChrgitmType: item.MedChrgitmType,
  3195. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3196. Status: 1,
  3197. Memo: item.Memo,
  3198. Mtime: time.Now().Unix(),
  3199. InscpScpAmt: item.InscpScpAmt,
  3200. DrtReimFlag: item.DrtReimFlag,
  3201. Ctime: time.Now().Unix(),
  3202. ListSpItemFlag: item.ListSpItemFlag,
  3203. ChldMedcFlag: item.ChldMedcFlag,
  3204. LmtUsedFlag: item.LmtUsedFlag,
  3205. ChrgitmLv: item.ChrgitmLv,
  3206. UserOrgId: adminUser.CurrentOrgId,
  3207. HisPatientId: his.ID,
  3208. OrderId: order.ID,
  3209. ProjectId: project_id,
  3210. Type: types,
  3211. }
  3212. service.CreateOrderInfo(info)
  3213. }
  3214. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3215. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3216. var total float64
  3217. for _, item := range prescriptions {
  3218. if item.Type == 1 { //药品
  3219. for _, subItem := range item.HisDoctorAdviceInfo {
  3220. total = total + (subItem.Price * subItem.PrescribingNumber)
  3221. }
  3222. }
  3223. if item.Type == 2 { //项目
  3224. for _, subItem := range item.HisPrescriptionProject {
  3225. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3226. total = total + (subItem.Price * cnt)
  3227. }
  3228. }
  3229. }
  3230. for _, item := range prescriptions {
  3231. for _, subItem := range item.HisAdditionalCharge {
  3232. total = total + (subItem.Price * float64(subItem.Count))
  3233. }
  3234. }
  3235. var allTotal string
  3236. if adminUser.CurrentOrgId == 9919 {
  3237. allTotal = fmt.Sprintf("%.2f", total)
  3238. } else {
  3239. allTotal = fmt.Sprintf("%.4f", total)
  3240. }
  3241. if res.Infcode == 0 {
  3242. var rf []*ResultFive
  3243. json.Unmarshal([]byte(his.Iinfo), &rf)
  3244. chrg_bchno := chrg_bchno
  3245. cert_no := his.Certno
  3246. var insutypes []string
  3247. var insutype string
  3248. var is390 int = 0
  3249. var is310 int = 0
  3250. for _, item := range rf {
  3251. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3252. insutypes = append(insutypes, item.Insutype)
  3253. }
  3254. }
  3255. if len(insutypes) == 1 {
  3256. insutype = insutypes[0]
  3257. } else {
  3258. for _, i := range insutypes {
  3259. if i == "390" {
  3260. is390 = 1
  3261. }
  3262. if i == "310" {
  3263. is310 = 1
  3264. }
  3265. }
  3266. }
  3267. if is390 == 1 {
  3268. insutype = "390"
  3269. }
  3270. if is310 == 1 {
  3271. insutype = "310"
  3272. }
  3273. if len(insutypes) == 0 {
  3274. insutype = "310"
  3275. }
  3276. if len(insutypes) == 2 {
  3277. insutype = strconv.FormatInt(his.SocialType, 10)
  3278. }
  3279. //insutype = "390"
  3280. if his.IdCardType == 1 {
  3281. // cert_no = his.MedicalInsuranceNumber
  3282. cert_no = his.Certno
  3283. } else {
  3284. cert_no = his.Certno
  3285. }
  3286. var res ResultSeven
  3287. var resSeven10265 ResultSeven10265
  3288. var src_resquest string
  3289. var result2 string
  3290. var acct_used_flag string
  3291. fmt.Println("pay_way")
  3292. fmt.Println(pay_way)
  3293. fmt.Println("pay_way")
  3294. if pay_way == 4 {
  3295. acct_used_flag = "1"
  3296. } else {
  3297. acct_used_flag = "0"
  3298. }
  3299. if miConfig.MdtrtareaAdmvs == "421300" {
  3300. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3301. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3302. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3303. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3304. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3305. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3306. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3307. resp, requestErr := http.Get(api)
  3308. if requestErr != nil {
  3309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3310. return
  3311. }
  3312. body, ioErr := ioutil.ReadAll(resp.Body)
  3313. if ioErr != nil {
  3314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3316. return
  3317. }
  3318. var respJSON map[string]interface{}
  3319. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3322. return
  3323. }
  3324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3325. result, _ := json.Marshal(respJSON)
  3326. if miConfig.Code == "H15049901371" {
  3327. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3328. utils.ErrorLog("解析失败:%v", err)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3330. return
  3331. }
  3332. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3333. res.Output = resSeven10265.Output
  3334. res.ErrMsg = resSeven10265.ErrMsg
  3335. res.Cainfo = resSeven10265.Cainfo
  3336. res.WarnMsg = resSeven10265.WarnMsg
  3337. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3338. res.Infcode = infocode
  3339. } else {
  3340. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3341. utils.ErrorLog("解析失败:%v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. }
  3346. } else {
  3347. 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)
  3348. var dat map[string]interface{}
  3349. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3350. fmt.Println(dat)
  3351. } else {
  3352. fmt.Println(err)
  3353. }
  3354. saveLog(result2, src_resquest, "2207", "结算")
  3355. userJSONBytes, _ := json.Marshal(dat)
  3356. if miConfig.Code == "H15049901371" {
  3357. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3358. utils.ErrorLog("解析失败:%v", err)
  3359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3360. return
  3361. }
  3362. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3363. res.Output = resSeven10265.Output
  3364. res.ErrMsg = resSeven10265.ErrMsg
  3365. res.Cainfo = resSeven10265.Cainfo
  3366. res.WarnMsg = resSeven10265.WarnMsg
  3367. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3368. res.Infcode = infocode
  3369. } else {
  3370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3371. utils.ErrorLog("解析失败:%v", err)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. }
  3376. }
  3377. if res.Infcode != 0 {
  3378. errlog := &models.HisOrderError{
  3379. UserOrgId: adminUser.CurrentOrgId,
  3380. Ctime: time.Now().Unix(),
  3381. Mtime: time.Now().Unix(),
  3382. Number: chrg_bchno,
  3383. ErrMsg: res.ErrMsg,
  3384. Status: 1,
  3385. PatientId: id,
  3386. RecordTime: recordDateTime,
  3387. Stage: 6,
  3388. }
  3389. service.CreateErrMsgLog(errlog)
  3390. c.ServeSuccessJSON(map[string]interface{}{
  3391. "failed_code": -10,
  3392. "msg": res.ErrMsg,
  3393. })
  3394. return
  3395. } else {
  3396. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3397. order.OrderStatus = 2
  3398. order.Status = 1
  3399. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3400. order.SetlId = res.Output.Setlinfo.SetlID
  3401. order.PsnNo = res.Output.Setlinfo.PsnNo
  3402. order.PsnName = res.Output.Setlinfo.PsnName
  3403. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3404. order.Certno = res.Output.Setlinfo.Certno
  3405. order.Gend = res.Output.Setlinfo.Gend
  3406. order.Naty = res.Output.Setlinfo.Naty
  3407. order.Age = res.Output.Setlinfo.Age
  3408. order.Insutype = res.Output.Setlinfo.Insutype
  3409. order.PsnType = res.Output.Setlinfo.PsnType
  3410. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3411. order.SetlTime = res.Output.Setlinfo.SetlTime
  3412. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3413. if res.Output.Setlinfo.MedType == "140101" {
  3414. order.MedType = "14"
  3415. } else {
  3416. order.MedType = res.Output.Setlinfo.MedType
  3417. }
  3418. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3419. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3420. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3421. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3422. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3423. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3424. order.HifpPay = res.Output.Setlinfo.HifpPay
  3425. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3426. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3427. order.HifesPay = res.Output.Setlinfo.HifesPay
  3428. order.HifobPay = res.Output.Setlinfo.HifobPay
  3429. order.MafPay = res.Output.Setlinfo.MafPay
  3430. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3431. order.OthPay = res.Output.Setlinfo.OthPay
  3432. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3433. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3434. order.AcctPay = res.Output.Setlinfo.AcctPay
  3435. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3436. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3437. order.Balc = res.Output.Setlinfo.Balc
  3438. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3439. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3440. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3441. order.ClrWay = res.Output.Setlinfo.ClrWay
  3442. order.Creator = order.Creator
  3443. order.Modify = roles.AdminUserId
  3444. order.RequestLog = src_resquest
  3445. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3446. detailStr := string(setlDetail)
  3447. order.SetlDetail = detailStr
  3448. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3449. err = service.UpDateOrder(order)
  3450. if err == nil {
  3451. c.ServeSuccessJSON(map[string]interface{}{
  3452. "msg": "结算成功",
  3453. })
  3454. } else {
  3455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3456. return
  3457. }
  3458. }
  3459. } else {
  3460. adminUser := c.GetAdminUserInfo()
  3461. errlog := &models.HisOrderError{
  3462. UserOrgId: adminUser.CurrentOrgId,
  3463. Ctime: time.Now().Unix(),
  3464. Mtime: time.Now().Unix(),
  3465. ErrMsg: res.ErrMsg,
  3466. Status: 1,
  3467. PatientId: id,
  3468. RecordTime: recordDateTime,
  3469. Stage: 4,
  3470. }
  3471. service.CreateErrMsgLog(errlog)
  3472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3473. return
  3474. }
  3475. } else {
  3476. adminUser := c.GetAdminUserInfo()
  3477. errlog := &models.HisOrderError{
  3478. UserOrgId: adminUser.CurrentOrgId,
  3479. Ctime: time.Now().Unix(),
  3480. Mtime: time.Now().Unix(),
  3481. ErrMsg: res.ErrMsg,
  3482. Status: 1,
  3483. PatientId: id,
  3484. RecordTime: recordDateTime,
  3485. Stage: 4,
  3486. }
  3487. service.CreateErrMsgLog(errlog)
  3488. c.ServeSuccessJSON(map[string]interface{}{
  3489. "failed_code": -10,
  3490. "msg": res.ErrMsg,
  3491. })
  3492. return
  3493. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3494. //return
  3495. }
  3496. }
  3497. }
  3498. } else if tempOrder.ID > 0 {
  3499. if tempOrder.IsPre == 1 {
  3500. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3501. var rf []*ResultFive
  3502. json.Unmarshal([]byte(his.Iinfo), &rf)
  3503. chrg_bchno := tempOrder.Number
  3504. cert_no := his.Certno
  3505. var insutypes []string
  3506. var insutype string
  3507. var is390 int = 0
  3508. var is310 int = 0
  3509. for _, item := range rf {
  3510. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3511. insutypes = append(insutypes, item.Insutype)
  3512. }
  3513. }
  3514. if len(insutypes) == 1 {
  3515. insutype = insutypes[0]
  3516. } else {
  3517. for _, i := range insutypes {
  3518. if i == "390" {
  3519. is390 = 1
  3520. }
  3521. if i == "310" {
  3522. is310 = 1
  3523. }
  3524. }
  3525. }
  3526. if is390 == 1 {
  3527. insutype = "390"
  3528. }
  3529. if is310 == 1 {
  3530. insutype = "310"
  3531. }
  3532. if len(insutypes) == 0 {
  3533. insutype = "310"
  3534. }
  3535. if len(insutypes) == 2 {
  3536. insutype = strconv.FormatInt(his.SocialType, 64)
  3537. }
  3538. //insutype = "390"
  3539. if his.IdCardType == 1 {
  3540. // cert_no = his.MedicalInsuranceNumber
  3541. cert_no = his.Certno
  3542. } else {
  3543. cert_no = his.Certno
  3544. }
  3545. var res ResultSeven
  3546. var resSeven10265 ResultSeven10265
  3547. var src_resquest string
  3548. var result2 string
  3549. var acct_used_flag string
  3550. fmt.Println("pay_way")
  3551. fmt.Println(pay_way)
  3552. fmt.Println("pay_way")
  3553. if pay_way == 4 {
  3554. acct_used_flag = "1"
  3555. } else {
  3556. acct_used_flag = "0"
  3557. }
  3558. if miConfig.MdtrtareaAdmvs == "421300" {
  3559. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3560. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3561. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3562. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3563. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3564. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3565. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3566. resp, requestErr := http.Get(api)
  3567. if requestErr != nil {
  3568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3569. return
  3570. }
  3571. body, ioErr := ioutil.ReadAll(resp.Body)
  3572. if ioErr != nil {
  3573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3575. return
  3576. }
  3577. var respJSON map[string]interface{}
  3578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3581. return
  3582. }
  3583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3584. result, _ := json.Marshal(respJSON)
  3585. fmt.Println("log")
  3586. fmt.Println(string(result))
  3587. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3588. utils.ErrorLog("解析失败:%v", err)
  3589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3590. return
  3591. }
  3592. } else {
  3593. 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)
  3594. var dat map[string]interface{}
  3595. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3596. fmt.Println(dat)
  3597. } else {
  3598. fmt.Println(err)
  3599. }
  3600. saveLog(result2, src_resquest, "2207", "结算")
  3601. userJSONBytes, _ := json.Marshal(dat)
  3602. if miConfig.Code == "H15049901371" {
  3603. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3604. utils.ErrorLog("解析失败:%v", err)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3609. res.Output = resSeven10265.Output
  3610. res.ErrMsg = resSeven10265.ErrMsg
  3611. res.Cainfo = resSeven10265.Cainfo
  3612. res.WarnMsg = resSeven10265.WarnMsg
  3613. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3614. res.Infcode = infocode
  3615. } else {
  3616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3617. utils.ErrorLog("解析失败:%v", err)
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. }
  3622. }
  3623. if res.Infcode != 0 {
  3624. errlog := &models.HisOrderError{
  3625. UserOrgId: adminUser.CurrentOrgId,
  3626. Ctime: time.Now().Unix(),
  3627. Mtime: time.Now().Unix(),
  3628. Number: chrg_bchno,
  3629. ErrMsg: res.ErrMsg,
  3630. Status: 1,
  3631. PatientId: id,
  3632. RecordTime: recordDateTime,
  3633. Stage: 6,
  3634. }
  3635. service.CreateErrMsgLog(errlog)
  3636. c.ServeSuccessJSON(map[string]interface{}{
  3637. "failed_code": -10,
  3638. "msg": res.ErrMsg,
  3639. })
  3640. return
  3641. } else {
  3642. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3643. order.OrderStatus = 2
  3644. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3645. order.SetlId = res.Output.Setlinfo.SetlID
  3646. order.PsnNo = res.Output.Setlinfo.PsnNo
  3647. order.PsnName = res.Output.Setlinfo.PsnName
  3648. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3649. order.Certno = res.Output.Setlinfo.Certno
  3650. order.Gend = res.Output.Setlinfo.Gend
  3651. order.Naty = res.Output.Setlinfo.Naty
  3652. order.Age = res.Output.Setlinfo.Age
  3653. order.Insutype = res.Output.Setlinfo.Insutype
  3654. order.PsnType = res.Output.Setlinfo.PsnType
  3655. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3656. order.SetlTime = res.Output.Setlinfo.SetlTime
  3657. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3658. order.MedType = res.Output.Setlinfo.MedType
  3659. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3660. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3661. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3662. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3663. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3664. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3665. order.HifpPay = res.Output.Setlinfo.HifpPay
  3666. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3667. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3668. order.HifesPay = res.Output.Setlinfo.HifesPay
  3669. order.HifobPay = res.Output.Setlinfo.HifobPay
  3670. order.MafPay = res.Output.Setlinfo.MafPay
  3671. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3672. order.OthPay = res.Output.Setlinfo.OthPay
  3673. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3674. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3675. order.AcctPay = res.Output.Setlinfo.AcctPay
  3676. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3677. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3678. order.Balc = res.Output.Setlinfo.Balc
  3679. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3680. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3681. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3682. order.ClrWay = res.Output.Setlinfo.ClrWay
  3683. order.Creator = order.Creator
  3684. order.Modify = roles.AdminUserId
  3685. order.RequestLog = src_resquest
  3686. order.Diagnosis = diagnosis_id
  3687. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3688. detailStr := string(setlDetail)
  3689. order.SetlDetail = detailStr
  3690. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3691. err = service.UpDateOrder(order)
  3692. if err == nil {
  3693. c.ServeSuccessJSON(map[string]interface{}{
  3694. "msg": "结算成功",
  3695. })
  3696. } else {
  3697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3698. return
  3699. }
  3700. }
  3701. }
  3702. }
  3703. }
  3704. //func (c *HisApiController) GetPreUploadInfo() {
  3705. // id, _ := c.GetInt64("id")
  3706. // record_time := c.GetString("record_time")
  3707. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3708. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3709. //
  3710. // timeLayout := "2006-01-02"
  3711. // loc, _ := time.LoadLocation("Local")
  3712. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3713. // if err != nil {
  3714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3715. // return
  3716. // }
  3717. // recordDateTime := theTime.Unix()
  3718. // adminUser := c.GetAdminUserInfo()
  3719. //
  3720. // var prescriptions []*models.HisPrescription
  3721. //
  3722. // var start_time int64
  3723. // var end_time int64
  3724. //
  3725. // data := make(map[string]interface{})
  3726. // if settle_accounts_type == 1 { //日结
  3727. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3728. // data["pre"] = prescriptions
  3729. //
  3730. // } else { //月结
  3731. // start_time_str := c.GetString("start_time")
  3732. // end_time_str := c.GetString("end_time")
  3733. // timeLayout := "2006-01-02"
  3734. // loc, _ := time.LoadLocation("Local")
  3735. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3736. // if err != nil {
  3737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3738. // return
  3739. // }
  3740. // recordStartTime := theStartTime.Unix()
  3741. // start_time = recordStartTime
  3742. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3743. // if err != nil {
  3744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3745. // return
  3746. // }
  3747. // recordEndTime := theEndTime.Unix()
  3748. // end_time = recordEndTime
  3749. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3750. // data["pre"] = prescriptions
  3751. //
  3752. // }
  3753. //
  3754. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3755. //
  3756. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3757. // timestamp := time.Now().Unix()
  3758. // tempTime := time.Unix(timestamp, 0)
  3759. // timeFormat := tempTime.Format("20060102150405")
  3760. // chrgBchno := rand.Intn(100000) + 10000
  3761. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3762. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3763. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3764. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3765. // strconv.FormatInt(his.PatientId, 10)
  3766. // client := &http.Client{}
  3767. // data["psn_no"] = his.PsnNo
  3768. // data["mdtrt_id"] = his.Number
  3769. // data["chrg_bchno"] = chrg_bchno
  3770. // data["org_name"] = miConfig.OrgName
  3771. // data["doctor"] = roles.UserName
  3772. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3773. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3774. // data["fixmedins_code"] = miConfig.Code
  3775. // data["dept_code"] = department.Number
  3776. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3777. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3778. // data["secret_key"] = miConfig.SecretKey
  3779. // var ids []int64
  3780. //
  3781. // for _, item := range prescriptions {
  3782. // ids = append(ids, item.ID)
  3783. // }
  3784. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3785. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3786. // bytesData, _ := json.Marshal(data)
  3787. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3788. // resp, _ := client.Do(req)
  3789. // defer resp.Body.Close()
  3790. // body, ioErr := ioutil.ReadAll(resp.Body)
  3791. // if ioErr != nil {
  3792. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3794. // return
  3795. // }
  3796. // var respJSON map[string]interface{}
  3797. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3798. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3800. // return
  3801. // }
  3802. //
  3803. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3804. // userJSONBytes, _ := json.Marshal(respJSON)
  3805. // var res ResultFour
  3806. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3807. // utils.ErrorLog("解析失败:%v", err)
  3808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3809. // return
  3810. // }
  3811. //
  3812. // if res.Infcode == 0 {
  3813. // order := &models.HisOrder{
  3814. // UserOrgId: adminUser.CurrentOrgId,
  3815. // HisPatientId: his.ID,
  3816. // PatientId: his.PatientId,
  3817. // SettleAccountsDate: recordDateTime,
  3818. // Ctime: time.Now().Unix(),
  3819. // Mtime: time.Now().Unix(),
  3820. // Status: 1,
  3821. // Number: chrg_bchno,
  3822. // Infcode: res.Infcode,
  3823. // WarnMsg: res.WarnMsg,
  3824. // Cainfo: res.Cainfo,
  3825. // ErrMsg: res.ErrMsg,
  3826. // RespondTime: res.RefmsgTime,
  3827. // InfRefmsgid: res.InfRefmsgid,
  3828. // OrderStatus: 1,
  3829. // IsMedicineInsurance: 1,
  3830. // SettleType: settle_accounts_type,
  3831. // SettleStartTime: start_time,
  3832. // SettleEndTime: end_time,
  3833. // Creator: roles.ID,
  3834. // Modify: roles.ID,
  3835. // PType: 2,
  3836. // }
  3837. // err = service.CreateOrder(order)
  3838. // if err != nil {
  3839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3840. // return
  3841. // }
  3842. //
  3843. // for _, item := range res.Output.Result {
  3844. // temp := strings.Split(item.FeedetlSn, "-")
  3845. // var advice_id int64 = 0
  3846. // var project_id int64 = 0
  3847. // var types int64 = 0
  3848. //
  3849. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  3850. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  3851. //
  3852. // if temp[1] == "1" {
  3853. // advice_id = id
  3854. // project_id = 0
  3855. // } else if temp[1] == "2" {
  3856. // advice_id = 0
  3857. // project_id = id
  3858. // }
  3859. //
  3860. // info := &models.HisOrderInfo{
  3861. // OrderNumber: order.Number,
  3862. // FeedetlSn: item.FeedetlSn,
  3863. // UploadDate: time.Now().Unix(),
  3864. // AdviceId: advice_id,
  3865. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  3866. // Cnt: item.Cnt,
  3867. // Pric: float64(item.Pric),
  3868. // PatientId: his.PatientId,
  3869. // PricUplmtAmt: item.PricUplmtAmt,
  3870. // SelfpayProp: item.SelfpayProp,
  3871. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3872. // OverlmtAmt: item.OverlmtAmt,
  3873. // PreselfpayAmt: item.PreselfpayAmt,
  3874. // BasMednFlag: item.BasMednFlag,
  3875. // MedChrgitmType: item.MedChrgitmType,
  3876. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  3877. // Status: 1,
  3878. // Memo: item.Memo,
  3879. // Mtime: time.Now().Unix(),
  3880. // InscpScpAmt: item.InscpScpAmt,
  3881. // DrtReimFlag: item.DrtReimFlag,
  3882. // Ctime: time.Now().Unix(),
  3883. // ListSpItemFlag: item.ListSpItemFlag,
  3884. // ChldMedcFlag: item.ChldMedcFlag,
  3885. // LmtUsedFlag: item.LmtUsedFlag,
  3886. // ChrgitmLv: item.ChrgitmLv,
  3887. // UserOrgId: adminUser.CurrentOrgId,
  3888. // HisPatientId: his.ID,
  3889. // OrderId: order.ID,
  3890. // ProjectId: project_id,
  3891. // Type: types,
  3892. // }
  3893. // service.CreateOrderInfo(info)
  3894. //
  3895. // }
  3896. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3897. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  3898. //
  3899. // var total float64
  3900. // for _, item := range prescriptions {
  3901. // if item.Type == 1 { //药品
  3902. // for _, subItem := range item.HisDoctorAdviceInfo {
  3903. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3904. // }
  3905. // }
  3906. // if item.Type == 2 { //项目
  3907. // for _, subItem := range item.HisPrescriptionProject {
  3908. // total = total + (subItem.Price * float64(subItem.Count))
  3909. // }
  3910. // }
  3911. // }
  3912. //
  3913. // for _, item := range prescriptions {
  3914. // for _, subItem := range item.HisAdditionalCharge {
  3915. // total = total + (subItem.Price * float64(subItem.Count))
  3916. // }
  3917. // }
  3918. //
  3919. // allTotal := fmt.Sprintf("%.2f", total)
  3920. // if res.Infcode == 0 {
  3921. // var rf []*ResultFive
  3922. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3923. // psn_no := his.PsnNo
  3924. // mdtrt_id := his.Number
  3925. // chrg_bchno := chrg_bchno
  3926. // cert_no := his.Certno
  3927. // insutype := rf[0].Insutype
  3928. //
  3929. // if his.IdCardType == 1 {
  3930. // cert_no = his.MedicalInsuranceNumber
  3931. //
  3932. // } else {
  3933. //
  3934. // cert_no = his.Certno
  3935. //
  3936. // }
  3937. //
  3938. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  3939. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  3940. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  3941. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  3942. // resp, requestErr := http.Get(api)
  3943. // if requestErr != nil {
  3944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3945. // return
  3946. // }
  3947. // defer resp.Body.Close()
  3948. // body, ioErr := ioutil.ReadAll(resp.Body)
  3949. // if ioErr != nil {
  3950. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3951. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3952. // return
  3953. // }
  3954. // var respJSON map[string]interface{}
  3955. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3956. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. // return
  3959. // }
  3960. // fmt.Println(respJSON)
  3961. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3962. // userJSONBytes, _ := json.Marshal(respJSON)
  3963. // var res ResultSeven
  3964. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3965. // utils.ErrorLog("解析失败:%v", err)
  3966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3967. // return
  3968. // }
  3969. // if res.Infcode != 0 {
  3970. // errlog := &models.HisOrderError{
  3971. // UserOrgId: adminUser.CurrentOrgId,
  3972. // Ctime: time.Now().Unix(),
  3973. // Mtime: time.Now().Unix(),
  3974. // Number: chrg_bchno,
  3975. // ErrMsg: res.ErrMsg,
  3976. // Status: 1,
  3977. // PatientId: id,
  3978. // RecordTime: recordDateTime,
  3979. // Stage: 7,
  3980. // }
  3981. // service.CreateErrMsgLog(errlog)
  3982. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3983. // return
  3984. // } else {
  3985. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3986. // order.OrderStatus = 1
  3987. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3988. // order.SetlId = res.Output.Setlinfo.SetlID
  3989. // order.PsnNo = res.Output.Setlinfo.PsnNo
  3990. // order.PsnName = res.Output.Setlinfo.PsnName
  3991. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3992. // order.Certno = res.Output.Setlinfo.Certno
  3993. // order.Gend = res.Output.Setlinfo.Gend
  3994. // order.Naty = res.Output.Setlinfo.Naty
  3995. // order.Age = res.Output.Setlinfo.Age
  3996. // order.Insutype = res.Output.Setlinfo.Insutype
  3997. // order.PsnType = res.Output.Setlinfo.PsnType
  3998. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3999. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4000. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4001. // order.MedType = res.Output.Setlinfo.MedType
  4002. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4003. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4004. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4005. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4006. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4007. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4008. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4009. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4010. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4011. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4012. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4013. // order.MafPay = res.Output.Setlinfo.MafPay
  4014. // order.OthPay = res.Output.Setlinfo.OthPay
  4015. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4016. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4017. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4018. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4019. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4020. // order.Balc = res.Output.Setlinfo.Balc
  4021. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4022. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4023. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4024. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4025. // order.Creator = order.Creator
  4026. // order.Modify = roles.ID
  4027. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4028. // detailStr := string(setlDetail)
  4029. // order.SetlDetail = detailStr
  4030. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4031. // err = service.UpDateOrder(order)
  4032. // if err == nil {
  4033. // c.ServeSuccessJSON(map[string]interface{}{
  4034. // "msg": "预结算成功",
  4035. // })
  4036. // } else {
  4037. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4038. // return
  4039. // }
  4040. // }
  4041. // } else {
  4042. // adminUser := c.GetAdminUserInfo()
  4043. // errlog := &models.HisOrderError{
  4044. // UserOrgId: adminUser.CurrentOrgId,
  4045. // Ctime: time.Now().Unix(),
  4046. // Mtime: time.Now().Unix(),
  4047. // ErrMsg: res.ErrMsg,
  4048. // Status: 1,
  4049. // PatientId: id,
  4050. // RecordTime: recordDateTime,
  4051. // Stage: 4,
  4052. // }
  4053. // service.CreateErrMsgLog(errlog)
  4054. //
  4055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4056. // return
  4057. // }
  4058. // } else {
  4059. // adminUser := c.GetAdminUserInfo()
  4060. // errlog := &models.HisOrderError{
  4061. // UserOrgId: adminUser.CurrentOrgId,
  4062. // Ctime: time.Now().Unix(),
  4063. // Mtime: time.Now().Unix(),
  4064. // ErrMsg: res.ErrMsg,
  4065. // Status: 1,
  4066. // PatientId: id,
  4067. // RecordTime: recordDateTime,
  4068. // Stage: 4,
  4069. // }
  4070. // service.CreateErrMsgLog(errlog)
  4071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4072. // return
  4073. // }
  4074. //
  4075. // } else {
  4076. // var total float64
  4077. // for _, item := range prescriptions {
  4078. // if item.Type == 1 { //药品
  4079. // for _, subItem := range item.HisDoctorAdviceInfo {
  4080. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4081. // }
  4082. // }
  4083. // if item.Type == 2 { //项目
  4084. // for _, subItem := range item.HisPrescriptionProject {
  4085. // total = total + (subItem.Price * float64(subItem.Count))
  4086. // }
  4087. // }
  4088. //
  4089. // for _, subItem := range item.HisAdditionalCharge {
  4090. // total = total + (subItem.Price * float64(subItem.Count))
  4091. // }
  4092. // }
  4093. //
  4094. // allTotal := fmt.Sprintf("%.2f", total)
  4095. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4096. // order := &models.HisOrder{
  4097. // UserOrgId: adminUser.CurrentOrgId,
  4098. // HisPatientId: his.ID,
  4099. // PatientId: id,
  4100. // SettleAccountsDate: recordDateTime,
  4101. // Ctime: time.Now().Unix(),
  4102. // Mtime: time.Now().Unix(),
  4103. // Status: 1,
  4104. // OrderStatus: 2,
  4105. // Number: chrg_bchno,
  4106. // MedfeeSumamt: totals,
  4107. // }
  4108. // err = service.CreateOrder(order)
  4109. // if err != nil {
  4110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4111. // return
  4112. // }
  4113. //
  4114. // var customs []*Custom
  4115. // for _, item := range prescriptions {
  4116. //
  4117. // if item.Type == 1 { //药品
  4118. // for _, subItem := range item.HisDoctorAdviceInfo {
  4119. // cus := &Custom{
  4120. // AdviceId: subItem.ID,
  4121. // ProjectId: 0,
  4122. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4123. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4124. // FeedetlSn: subItem.FeedetlSn,
  4125. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4126. // MedListCodg: subItem.MedListCodg,
  4127. // Type: 1,
  4128. // }
  4129. // customs = append(customs, cus)
  4130. // }
  4131. // }
  4132. //
  4133. // if item.Type == 2 { //项目
  4134. // for _, subItem := range item.HisPrescriptionProject {
  4135. //
  4136. // cus := &Custom{
  4137. // AdviceId: 0,
  4138. // ProjectId: subItem.ID,
  4139. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4140. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4141. // FeedetlSn: subItem.FeedetlSn,
  4142. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4143. // MedListCodg: subItem.MedListCodg,
  4144. // Type: 2,
  4145. // }
  4146. //
  4147. // customs = append(customs, cus)
  4148. // }
  4149. // }
  4150. //
  4151. // for _, item := range item.HisAdditionalCharge {
  4152. // cus := &Custom{
  4153. // ItemId: item.ID,
  4154. // AdviceId: 0,
  4155. // ProjectId: 0,
  4156. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4157. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4158. // FeedetlSn: item.FeedetlSn,
  4159. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4160. // MedListCodg: item.XtHisAddtionConfig.Code,
  4161. // Type: 3,
  4162. // }
  4163. //
  4164. // customs = append(customs, cus)
  4165. // }
  4166. //
  4167. // }
  4168. //
  4169. // for _, item := range customs {
  4170. // var advice_id int64 = 0
  4171. // var project_id int64 = 0
  4172. // var item_id int64 = 0
  4173. //
  4174. // var types int64 = 0
  4175. //
  4176. // if item.Type == 1 {
  4177. // advice_id = item.AdviceId
  4178. // project_id = 0
  4179. // item_id = 0
  4180. // } else if item.Type == 2 {
  4181. // advice_id = 0
  4182. // item_id = 0
  4183. //
  4184. // project_id = item.ProjectId
  4185. // } else if item.Type == 3 {
  4186. // advice_id = 0
  4187. // item_id = item.ItemId
  4188. // project_id = 0
  4189. // }
  4190. //
  4191. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4192. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4193. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4194. //
  4195. // info := &models.HisOrderInfo{
  4196. // OrderNumber: order.Number,
  4197. // UploadDate: time.Now().Unix(),
  4198. // AdviceId: advice_id,
  4199. // DetItemFeeSumamt: detItemFeeSumamt,
  4200. // Cnt: cut,
  4201. // Pric: pric,
  4202. // PatientId: id,
  4203. // Status: 1,
  4204. // Mtime: time.Now().Unix(),
  4205. // Ctime: time.Now().Unix(),
  4206. // UserOrgId: adminUser.CurrentOrgId,
  4207. // HisPatientId: his.ID,
  4208. // OrderId: order.ID,
  4209. // ProjectId: project_id,
  4210. // Type: types,
  4211. // ItemId: item_id,
  4212. // }
  4213. // service.CreateOrderInfo(info)
  4214. // }
  4215. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4216. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4217. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4218. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4219. // if err == nil {
  4220. // c.ServeSuccessJSON(map[string]interface{}{
  4221. // "msg": "结算成功",
  4222. // })
  4223. // } else {
  4224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4225. // return
  4226. // }
  4227. // }
  4228. //}
  4229. //上传明细-预结算-
  4230. func (c *HisApiController) GetPreUploadInfo() {
  4231. id, _ := c.GetInt64("id")
  4232. record_time := c.GetString("record_time")
  4233. his_patient_id, _ := c.GetInt64("his_patient_id")
  4234. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4235. admin_user_id, _ := c.GetInt64("admin_user_id")
  4236. diagnosis_id := c.GetString("diagnosis")
  4237. sick_type, _ := c.GetInt64("sick_type")
  4238. reg_type, _ := c.GetInt64("p_type")
  4239. id_str := c.GetString("ids")
  4240. ids_arr := strings.Split(id_str, ",")
  4241. timeLayout := "2006-01-02"
  4242. loc, _ := time.LoadLocation("Local")
  4243. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4244. if err != nil {
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4246. return
  4247. }
  4248. recordDateTime := theTime.Unix()
  4249. adminUser := c.GetAdminUserInfo()
  4250. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4251. var config []*models.HisXtDiagnoseConfig
  4252. for _, item := range diagnosis_ids {
  4253. id, _ := strconv.ParseInt(item, 10, 64)
  4254. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4255. config = append(config, &diagnosisConfig)
  4256. }
  4257. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4258. sickConfig, _ := service.FindSickById(sick_type)
  4259. var prescriptions []*models.HisPrescription
  4260. var start_time int64
  4261. var end_time int64
  4262. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4263. fmt.Println(his_patient_id)
  4264. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4265. timestamp := time.Now().Unix()
  4266. tempTime := time.Unix(timestamp, 0)
  4267. timeFormat := tempTime.Format("20060102150405")
  4268. chrgBchno := rand.Intn(100000) + 10000
  4269. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4270. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4271. var patientPrescription models.HisPrescriptionInfo
  4272. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4273. if patientPrescription.ID == 0 {
  4274. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4275. }
  4276. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4277. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4278. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4279. strconv.FormatInt(his.PatientId, 10)
  4280. var res2 ResultSix
  4281. var resSix10265 ResultSix10265
  4282. if miConfig.InsuplcAdmdvs == "421300" {
  4283. data := make(map[string]interface{})
  4284. client := &http.Client{}
  4285. data["psn_no"] = his.PsnNo
  4286. data["mdtrt_id"] = his.Number
  4287. data["doctor"] = roles.UserName
  4288. data["department"] = department.Name
  4289. data["org_name"] = miConfig.OrgName
  4290. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4291. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4292. data["fixmedins_code"] = miConfig.Code
  4293. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4294. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4295. data["secret_key"] = miConfig.SecretKey
  4296. data["sick_code"] = sickConfig.CountryCode
  4297. data["sick_name"] = sickConfig.ClassName
  4298. data["dept"] = strconv.FormatInt(department.ID, 10)
  4299. data["config"] = config
  4300. fmt.Println(data)
  4301. bytesData, _ := json.Marshal(data)
  4302. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4303. resp, _ := client.Do(req)
  4304. defer resp.Body.Close()
  4305. body, ioErr := ioutil.ReadAll(resp.Body)
  4306. if ioErr != nil {
  4307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. return
  4310. }
  4311. var respJSON map[string]interface{}
  4312. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4315. return
  4316. }
  4317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4318. userJSONBytes, _ := json.Marshal(respJSON)
  4319. fmt.Println("log")
  4320. fmt.Println(string(userJSONBytes))
  4321. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4322. utils.ErrorLog("解析失败:%v", err)
  4323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4324. return
  4325. }
  4326. } else {
  4327. var result string
  4328. var requestLog string
  4329. if miConfig.InsuplcAdmdvs == "440781" { //
  4330. 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)
  4331. } else {
  4332. 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)
  4333. saveLog(result, requestLog, "2203", "上传就诊信息")
  4334. var respJSON2 map[string]interface{}
  4335. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. //userJSONBytes2, _ := json.Marshal(respJSON2)
  4341. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4342. // utils.ErrorLog("解析失败:%v", err)
  4343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. // return
  4345. //}
  4346. userJSONBytes2, _ := json.Marshal(respJSON2)
  4347. if miConfig.Code == "H15049901371" {
  4348. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4349. utils.ErrorLog("解析失败:%v", err)
  4350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4351. return
  4352. }
  4353. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4354. res2.Output = resSix10265.Output
  4355. res2.ErrMsg = resSix10265.ErrMsg
  4356. res2.Cainfo = resSix10265.Cainfo
  4357. res2.WarnMsg = resSix10265.WarnMsg
  4358. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4359. res2.Infcode = infocode
  4360. } else {
  4361. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4362. utils.ErrorLog("解析失败:%v", err)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. }
  4367. }
  4368. }
  4369. if res2.Infcode != 0 {
  4370. adminUser := c.GetAdminUserInfo()
  4371. errlog := &models.HisOrderError{
  4372. UserOrgId: adminUser.CurrentOrgId,
  4373. Ctime: time.Now().Unix(),
  4374. Mtime: time.Now().Unix(),
  4375. ErrMsg: res2.ErrMsg,
  4376. Status: 1,
  4377. PatientId: id,
  4378. RecordTime: recordDateTime,
  4379. Stage: 3,
  4380. }
  4381. service.CreateErrMsgLog(errlog)
  4382. c.ServeSuccessJSON(map[string]interface{}{
  4383. "failed_code": -10,
  4384. "msg": res2.ErrMsg,
  4385. })
  4386. return
  4387. } else {
  4388. his.Diagnosis = diagnosis_id
  4389. his.SickType = sickConfig.ID
  4390. his.PType = fmt.Sprintf("%d", reg_type)
  4391. service.UpdateHisPatientThree(&his)
  4392. data := make(map[string]interface{})
  4393. if settle_accounts_type == 1 { //日结
  4394. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4395. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4396. } else {
  4397. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4398. }
  4399. data["pre"] = prescriptions
  4400. } else { //月结
  4401. start_time_str := c.GetString("start_time")
  4402. end_time_str := c.GetString("end_time")
  4403. timeLayout := "2006-01-02"
  4404. loc, _ := time.LoadLocation("Local")
  4405. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4406. if err != nil {
  4407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4408. return
  4409. }
  4410. recordStartTime := theStartTime.Unix()
  4411. start_time = recordStartTime
  4412. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4413. if err != nil {
  4414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4415. return
  4416. }
  4417. recordEndTime := theEndTime.Unix()
  4418. end_time = recordEndTime
  4419. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4420. data["pre"] = prescriptions
  4421. }
  4422. client := &http.Client{}
  4423. data["psn_no"] = his.PsnNo
  4424. data["mdtrt_id"] = his.Number
  4425. data["chrg_bchno"] = chrg_bchno
  4426. data["org_name"] = miConfig.OrgName
  4427. data["doctor"] = roles.UserName
  4428. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4429. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4430. data["fixmedins_code"] = miConfig.Code
  4431. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4432. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4433. data["dept_code"] = "15"
  4434. } else {
  4435. data["dept_code"] = department.Number
  4436. }
  4437. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4438. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4439. data["secret_key"] = miConfig.SecretKey
  4440. var ids []int64
  4441. for _, item := range prescriptions {
  4442. ids = append(ids, item.ID)
  4443. }
  4444. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4445. if config.IsOpen == 1 { //对接了医保,走医保流程
  4446. var res ResultFour
  4447. var resFour10265 ResultFour10265
  4448. if miConfig.MdtrtareaAdmvs == "421300" {
  4449. bytesData, _ := json.Marshal(data)
  4450. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4451. resp, _ := client.Do(req)
  4452. defer resp.Body.Close()
  4453. body, ioErr := ioutil.ReadAll(resp.Body)
  4454. if ioErr != nil {
  4455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4457. return
  4458. }
  4459. var respJSON map[string]interface{}
  4460. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4463. return
  4464. }
  4465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4466. userJSONBytes, _ := json.Marshal(respJSON)
  4467. fmt.Println("log")
  4468. fmt.Println(string(userJSONBytes))
  4469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4470. utils.ErrorLog("解析失败:%v", err)
  4471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4472. return
  4473. }
  4474. } else {
  4475. 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))
  4476. var dat map[string]interface{}
  4477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4478. fmt.Println(dat)
  4479. } else {
  4480. fmt.Println(err)
  4481. }
  4482. saveLog(result, request_log, "2204", "上传费用明细")
  4483. userJSONBytes, _ := json.Marshal(dat)
  4484. if miConfig.Code == "H15049901371" {
  4485. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4486. utils.ErrorLog("解析失败:%v", err)
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4488. return
  4489. }
  4490. res.InfRefmsgid = resFour10265.InfRefmsgid
  4491. res.Output = resFour10265.Output
  4492. res.ErrMsg = resFour10265.ErrMsg
  4493. res.Cainfo = resFour10265.Cainfo
  4494. res.WarnMsg = resFour10265.WarnMsg
  4495. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4496. res.Infcode = infocode
  4497. } else {
  4498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4499. utils.ErrorLog("解析失败:%v", err)
  4500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4501. return
  4502. }
  4503. }
  4504. }
  4505. if res.Infcode == 0 {
  4506. order := &models.HisOrder{
  4507. UserOrgId: adminUser.CurrentOrgId,
  4508. HisPatientId: his.ID,
  4509. PatientId: his.PatientId,
  4510. SettleAccountsDate: recordDateTime,
  4511. Ctime: time.Now().Unix(),
  4512. Mtime: time.Now().Unix(),
  4513. Status: 1,
  4514. Number: chrg_bchno,
  4515. Infcode: res.Infcode,
  4516. WarnMsg: res.WarnMsg,
  4517. Cainfo: res.Cainfo,
  4518. ErrMsg: res.ErrMsg,
  4519. RespondTime: res.RefmsgTime,
  4520. InfRefmsgid: res.InfRefmsgid,
  4521. OrderStatus: 1,
  4522. IsMedicineInsurance: 1,
  4523. SettleType: settle_accounts_type,
  4524. SettleStartTime: start_time,
  4525. SettleEndTime: end_time,
  4526. Creator: roles.AdminUserId,
  4527. Modify: roles.AdminUserId,
  4528. PType: 2,
  4529. Diagnosis: diagnosis_id,
  4530. }
  4531. err = service.CreateOrder(order)
  4532. if err != nil {
  4533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4534. return
  4535. }
  4536. for _, item := range res.Output.Result {
  4537. temp := strings.Split(item.FeedetlSn, "-")
  4538. var advice_id int64 = 0
  4539. var project_id int64 = 0
  4540. var types int64 = 0
  4541. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4542. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4543. if temp[1] == "1" {
  4544. advice_id = id
  4545. project_id = 0
  4546. } else if temp[1] == "2" {
  4547. advice_id = 0
  4548. project_id = id
  4549. }
  4550. info := &models.HisOrderInfo{
  4551. OrderNumber: order.Number,
  4552. FeedetlSn: item.FeedetlSn,
  4553. UploadDate: time.Now().Unix(),
  4554. AdviceId: advice_id,
  4555. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4556. Cnt: item.Cnt,
  4557. Pric: float64(item.Pric),
  4558. PatientId: his.PatientId,
  4559. PricUplmtAmt: item.PricUplmtAmt,
  4560. SelfpayProp: item.SelfpayProp,
  4561. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4562. OverlmtAmt: item.OverlmtAmt,
  4563. PreselfpayAmt: item.PreselfpayAmt,
  4564. BasMednFlag: item.BasMednFlag,
  4565. MedChrgitmType: item.MedChrgitmType,
  4566. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4567. Status: 1,
  4568. Memo: item.Memo,
  4569. Mtime: time.Now().Unix(),
  4570. InscpScpAmt: item.InscpScpAmt,
  4571. DrtReimFlag: item.DrtReimFlag,
  4572. Ctime: time.Now().Unix(),
  4573. ListSpItemFlag: item.ListSpItemFlag,
  4574. ChldMedcFlag: item.ChldMedcFlag,
  4575. LmtUsedFlag: item.LmtUsedFlag,
  4576. ChrgitmLv: item.ChrgitmLv,
  4577. UserOrgId: adminUser.CurrentOrgId,
  4578. HisPatientId: his.ID,
  4579. OrderId: order.ID,
  4580. ProjectId: project_id,
  4581. Type: types,
  4582. }
  4583. service.CreateOrderInfo(info)
  4584. }
  4585. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4586. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4587. var total float64
  4588. for _, item := range prescriptions {
  4589. if item.Type == 1 { //药品
  4590. for _, subItem := range item.HisDoctorAdviceInfo {
  4591. total = total + (subItem.Price * subItem.PrescribingNumber)
  4592. }
  4593. }
  4594. if item.Type == 2 { //项目
  4595. for _, subItem := range item.HisPrescriptionProject {
  4596. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4597. total = total + (subItem.Price * cnt)
  4598. }
  4599. }
  4600. }
  4601. for _, item := range prescriptions {
  4602. for _, subItem := range item.HisAdditionalCharge {
  4603. total = total + (subItem.Price * float64(subItem.Count))
  4604. }
  4605. }
  4606. allTotal := fmt.Sprintf("%.4f", total)
  4607. if res.Infcode == 0 {
  4608. var rf []*ResultFive
  4609. json.Unmarshal([]byte(his.Iinfo), &rf)
  4610. chrg_bchno := chrg_bchno
  4611. cert_no := his.Certno
  4612. var insutypes []string
  4613. var insutype string
  4614. var is390 int = 0
  4615. var is310 int = 0
  4616. for _, item := range rf {
  4617. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4618. insutypes = append(insutypes, item.Insutype)
  4619. }
  4620. }
  4621. if len(insutypes) == 1 {
  4622. insutype = insutypes[0]
  4623. } else {
  4624. for _, i := range insutypes {
  4625. if i == "390" {
  4626. is390 = 1
  4627. }
  4628. if i == "310" {
  4629. is310 = 1
  4630. }
  4631. }
  4632. }
  4633. if is390 == 1 {
  4634. insutype = "390"
  4635. }
  4636. if is310 == 1 {
  4637. insutype = "310"
  4638. }
  4639. if len(insutypes) == 0 {
  4640. insutype = "310"
  4641. }
  4642. if len(insutypes) == 2 {
  4643. insutype = strconv.FormatInt(his.SocialType, 64)
  4644. }
  4645. //insutype = "390"
  4646. if his.IdCardType == 1 {
  4647. cert_no = his.MedicalInsuranceNumber
  4648. } else {
  4649. cert_no = his.Certno
  4650. }
  4651. var res ResultSeven
  4652. var resSeven10265 ResultSeven10265
  4653. if miConfig.MdtrtareaAdmvs == "421300" {
  4654. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4655. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4656. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4657. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4658. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4659. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4660. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  4661. resp, requestErr := http.Get(api)
  4662. if requestErr != nil {
  4663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4664. return
  4665. }
  4666. body, ioErr := ioutil.ReadAll(resp.Body)
  4667. if ioErr != nil {
  4668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4670. return
  4671. }
  4672. var respJSON map[string]interface{}
  4673. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4679. result, _ := json.Marshal(respJSON)
  4680. fmt.Println("log")
  4681. fmt.Println(string(result))
  4682. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4683. utils.ErrorLog("解析失败:%v", err)
  4684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4685. return
  4686. }
  4687. } else {
  4688. 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)
  4689. var dat map[string]interface{}
  4690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4691. fmt.Println(dat)
  4692. } else {
  4693. fmt.Println(err)
  4694. }
  4695. saveLog(result, request_log, "2206", "预结算")
  4696. //userJSONBytes, _ := json.Marshal(dat)
  4697. //
  4698. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4699. // utils.ErrorLog("解析失败:%v", err)
  4700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4701. // return
  4702. //}
  4703. userJSONBytes, _ := json.Marshal(dat)
  4704. if miConfig.Code == "H15049901371" {
  4705. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4706. utils.ErrorLog("解析失败:%v", err)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4711. res.Output = resSeven10265.Output
  4712. res.ErrMsg = resSeven10265.ErrMsg
  4713. res.Cainfo = resSeven10265.Cainfo
  4714. res.WarnMsg = resSeven10265.WarnMsg
  4715. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4716. res.Infcode = infocode
  4717. } else {
  4718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4719. utils.ErrorLog("解析失败:%v", err)
  4720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4721. return
  4722. }
  4723. }
  4724. }
  4725. if res.Infcode != 0 {
  4726. errlog := &models.HisOrderError{
  4727. UserOrgId: adminUser.CurrentOrgId,
  4728. Ctime: time.Now().Unix(),
  4729. Mtime: time.Now().Unix(),
  4730. Number: chrg_bchno,
  4731. ErrMsg: res.ErrMsg,
  4732. Status: 1,
  4733. PatientId: id,
  4734. RecordTime: recordDateTime,
  4735. Stage: 20,
  4736. }
  4737. service.CreateErrMsgLog(errlog)
  4738. c.ServeSuccessJSON(map[string]interface{}{
  4739. "failed_code": -10,
  4740. "msg": res.ErrMsg,
  4741. })
  4742. return
  4743. } else {
  4744. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4745. order.OrderStatus = 1
  4746. order.IsPre = 1
  4747. order.Status = 1
  4748. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4749. order.SetlId = res.Output.Setlinfo.SetlID
  4750. order.PsnNo = res.Output.Setlinfo.PsnNo
  4751. order.PsnName = res.Output.Setlinfo.PsnName
  4752. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4753. order.Certno = res.Output.Setlinfo.Certno
  4754. order.Gend = res.Output.Setlinfo.Gend
  4755. order.Naty = res.Output.Setlinfo.Naty
  4756. order.Age = res.Output.Setlinfo.Age
  4757. order.Insutype = res.Output.Setlinfo.Insutype
  4758. order.PsnType = res.Output.Setlinfo.PsnType
  4759. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4760. order.SetlTime = res.Output.Setlinfo.SetlTime
  4761. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4762. if res.Output.Setlinfo.MedType == "140101" {
  4763. order.MedType = "14"
  4764. } else {
  4765. order.MedType = res.Output.Setlinfo.MedType
  4766. }
  4767. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4768. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4769. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4770. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4771. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4772. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4773. order.HifpPay = res.Output.Setlinfo.HifpPay
  4774. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4775. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4776. order.HifesPay = res.Output.Setlinfo.HifesPay
  4777. order.HifobPay = res.Output.Setlinfo.HifobPay
  4778. order.MafPay = res.Output.Setlinfo.MafPay
  4779. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4780. order.OthPay = res.Output.Setlinfo.OthPay
  4781. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4782. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4783. order.AcctPay = res.Output.Setlinfo.AcctPay
  4784. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4785. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4786. order.Balc = res.Output.Setlinfo.Balc
  4787. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4788. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4789. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4790. order.ClrWay = res.Output.Setlinfo.ClrWay
  4791. order.Creator = order.Creator
  4792. order.Modify = roles.AdminUserId
  4793. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4794. detailStr := string(setlDetail)
  4795. order.SetlDetail = detailStr
  4796. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4797. err = service.UpDateOrder(order)
  4798. if err == nil {
  4799. c.ServeSuccessJSON(map[string]interface{}{
  4800. "msg": "预结算成功",
  4801. })
  4802. } else {
  4803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4804. return
  4805. }
  4806. }
  4807. } else {
  4808. adminUser := c.GetAdminUserInfo()
  4809. errlog := &models.HisOrderError{
  4810. UserOrgId: adminUser.CurrentOrgId,
  4811. Ctime: time.Now().Unix(),
  4812. Mtime: time.Now().Unix(),
  4813. ErrMsg: res.ErrMsg,
  4814. Status: 1,
  4815. PatientId: id,
  4816. RecordTime: recordDateTime,
  4817. Stage: 4,
  4818. }
  4819. service.CreateErrMsgLog(errlog)
  4820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4821. return
  4822. }
  4823. } else {
  4824. adminUser := c.GetAdminUserInfo()
  4825. errlog := &models.HisOrderError{
  4826. UserOrgId: adminUser.CurrentOrgId,
  4827. Ctime: time.Now().Unix(),
  4828. Mtime: time.Now().Unix(),
  4829. ErrMsg: res.ErrMsg,
  4830. Status: 1,
  4831. PatientId: id,
  4832. RecordTime: recordDateTime,
  4833. Stage: 4,
  4834. }
  4835. service.CreateErrMsgLog(errlog)
  4836. c.ServeSuccessJSON(map[string]interface{}{
  4837. "failed_code": -10,
  4838. "msg": res.ErrMsg,
  4839. })
  4840. return
  4841. }
  4842. }
  4843. }
  4844. }
  4845. //func (c *HisApiController) GetSettleInfo() {
  4846. // id, _ := c.GetInt64("id")
  4847. // order_id, _ := c.GetInt64("order_id")
  4848. //
  4849. // record_time := c.GetString("record_time")
  4850. // pay_way, _ := c.GetInt64("pay_way")
  4851. // pay_price, _ := c.GetFloat("pay_price")
  4852. // pay_card_no := c.GetString("pay_card_no")
  4853. // discount_price, _ := c.GetFloat("discount_price")
  4854. // preferential_price, _ := c.GetFloat("preferential_price")
  4855. // reality_price, _ := c.GetFloat("reality_price")
  4856. // found_price, _ := c.GetFloat("found_price")
  4857. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4858. // private_price, _ := c.GetFloat("private_price")
  4859. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4860. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4861. //
  4862. // timeLayout := "2006-01-02"
  4863. // loc, _ := time.LoadLocation("Local")
  4864. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4865. // if err != nil {
  4866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4867. // return
  4868. // }
  4869. // recordDateTime := theTime.Unix()
  4870. // adminUser := c.GetAdminUserInfo()
  4871. //
  4872. // var prescriptions []*models.HisPrescription
  4873. //
  4874. // data := make(map[string]interface{})
  4875. // if settle_accounts_type == 1 { //日结
  4876. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4877. // data["pre"] = prescriptions
  4878. //
  4879. // } else { //月结
  4880. // start_time_str := c.GetString("start_time")
  4881. // end_time_str := c.GetString("end_time")
  4882. // timeLayout := "2006-01-02"
  4883. // loc, _ := time.LoadLocation("Local")
  4884. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4885. // if err != nil {
  4886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4887. // return
  4888. // }
  4889. // recordStartTime := theStartTime.Unix()
  4890. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4891. // if err != nil {
  4892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4893. // return
  4894. // }
  4895. // recordEndTime := theEndTime.Unix()
  4896. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4897. // data["pre"] = prescriptions
  4898. //
  4899. // }
  4900. //
  4901. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4902. //
  4903. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4904. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4905. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4906. // strconv.FormatInt(his.PatientId, 10)
  4907. //
  4908. // order_src, _ := service.GetHisOrderByID(order_id)
  4909. //
  4910. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4911. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4912. //
  4913. // var total float64
  4914. // for _, item := range prescriptions {
  4915. // if item.Type == 1 { //药品
  4916. // for _, subItem := range item.HisDoctorAdviceInfo {
  4917. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4918. // }
  4919. // }
  4920. // if item.Type == 2 { //项目
  4921. // for _, subItem := range item.HisPrescriptionProject {
  4922. // total = total + (subItem.Price * float64(subItem.Count))
  4923. // }
  4924. // }
  4925. // }
  4926. //
  4927. // for _, item := range prescriptions {
  4928. // for _, subItem := range item.HisAdditionalCharge {
  4929. // total = total + (subItem.Price * float64(subItem.Count))
  4930. // }
  4931. // }
  4932. //
  4933. // allTotal := fmt.Sprintf("%.2f", total)
  4934. // var rf []*ResultFive
  4935. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4936. // psn_no := order_src.PsnNo
  4937. // mdtrt_id := order_src.MdtrtId
  4938. // chrg_bchno := order_src.Number
  4939. // cert_no := order_src.Certno
  4940. // insutype := rf[0].Insutype
  4941. //
  4942. // if his.IdCardType == 1 {
  4943. // cert_no = his.MedicalInsuranceNumber
  4944. // } else {
  4945. // cert_no = his.Certno
  4946. // }
  4947. //
  4948. // 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)
  4949. // var dat map[string]interface{}
  4950. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4951. // fmt.Println(dat)
  4952. // } else {
  4953. // fmt.Println(err)
  4954. // }
  4955. //
  4956. // userJSONBytes, _ := json.Marshal(dat)
  4957. //
  4958. //
  4959. //
  4960. // var res ResultSeven
  4961. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4962. // utils.ErrorLog("解析失败:%v", err)
  4963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4964. // return
  4965. // }
  4966. // if res.Infcode == -1 {
  4967. // errlog := &models.HisOrderError{
  4968. // UserOrgId: adminUser.CurrentOrgId,
  4969. // Ctime: time.Now().Unix(),
  4970. // Mtime: time.Now().Unix(),
  4971. // Number: chrg_bchno,
  4972. // ErrMsg: res.ErrMsg,
  4973. // Status: 1,
  4974. // PatientId: id,
  4975. // RecordTime: recordDateTime,
  4976. // Stage: 6,
  4977. // }
  4978. // service.CreateErrMsgLog(errlog)
  4979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4980. // return
  4981. // } else {
  4982. // order_src.OrderStatus = 2
  4983. // order_src.PayWay = pay_way
  4984. // order_src.PayPrice = pay_price
  4985. // order_src.PayCardNo = pay_card_no
  4986. // order_src.DiscountPrice = discount_price
  4987. // order_src.PreferentialPrice = preferential_price
  4988. // order_src.RealityPrice = reality_price
  4989. // order_src.FoundPrice = found_price
  4990. // order_src.MedicalInsurancePrice = medical_insurance_price
  4991. // order_src.PrivatePrice = private_price
  4992. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  4993. // order_src.SetlId = res.Output.Setlinfo.SetlID
  4994. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  4995. // order_src.PsnName = res.Output.Setlinfo.PsnName
  4996. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  4997. // order_src.Certno = res.Output.Setlinfo.Certno
  4998. // order_src.Gend = res.Output.Setlinfo.Gend
  4999. // order_src.Naty = res.Output.Setlinfo.Naty
  5000. // order_src.Age = res.Output.Setlinfo.Age
  5001. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5002. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5003. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5004. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5005. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5006. // order_src.MedType = res.Output.Setlinfo.MedType
  5007. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5008. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5009. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5010. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5011. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5012. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5013. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5014. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5015. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5016. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5017. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5018. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5019. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5020. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5021. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5022. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5023. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5024. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5025. // order_src.Balc = res.Output.Setlinfo.Balc
  5026. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5027. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5028. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5029. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5030. // order_src.Creator = order_src.Creator
  5031. // order_src.Modify = roles.ID
  5032. // order_src.RequestLog = src_resquest
  5033. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5034. // detailStr := string(setlDetail)
  5035. // order_src.SetlDetail = detailStr
  5036. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5037. // err = service.UpDateOrder(order_src)
  5038. //
  5039. // if err == nil {
  5040. // c.ServeSuccessJSON(map[string]interface{}{
  5041. // "msg": "结算成功",
  5042. // })
  5043. // } else {
  5044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5045. // return
  5046. // }
  5047. // }
  5048. // }
  5049. //}
  5050. //退款
  5051. func (c *HisApiController) Refund() {
  5052. order_id, _ := c.GetInt64("order_id")
  5053. admin_user_id, _ := c.GetInt64("admin_user_id")
  5054. //record_time := c.GetString("record_time")
  5055. //patient_id, _ := c.GetInt64("patient_id")
  5056. //timeLayout := "2006-01-02"
  5057. //loc, _ := time.LoadLocation("Local")
  5058. adminUser := c.GetAdminUserInfo()
  5059. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5060. //if err != nil {
  5061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5062. // return
  5063. //}
  5064. //recordDateTime := theTime.Unix()
  5065. var order models.HisOrder
  5066. order, _ = service.GetHisOrderByID(order_id)
  5067. //his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5068. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5069. if order.ID == 0 {
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5071. return
  5072. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5073. }
  5074. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5075. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5076. if config.IsOpen == 1 { //对接了医保,走医保流程
  5077. var res ResultSixteen
  5078. var resSixteen10265 ResultSixteen10265
  5079. var src_resquest string
  5080. var result string
  5081. if miConfig.MdtrtareaAdmvs == "421300" {
  5082. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5083. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5084. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5085. resp3, requestErr3 := http.Get(api3)
  5086. if requestErr3 != nil {
  5087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5088. return
  5089. }
  5090. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5091. if ioErr3 != nil {
  5092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5094. return
  5095. }
  5096. var respJSON3 map[string]interface{}
  5097. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5100. return
  5101. }
  5102. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5103. userJSONBytes3, _ := json.Marshal(respJSON3)
  5104. fmt.Println("log")
  5105. fmt.Println(string(userJSONBytes3))
  5106. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5107. utils.ErrorLog("解析失败:%v", err)
  5108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5109. return
  5110. }
  5111. } else {
  5112. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5113. var dat map[string]interface{}
  5114. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5115. fmt.Println(dat)
  5116. } else {
  5117. fmt.Println(err)
  5118. }
  5119. saveLog(result, src_resquest, "2208", "退费")
  5120. userJSONBytes, _ := json.Marshal(dat)
  5121. if miConfig.Code == "H15049901371" {
  5122. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5123. utils.ErrorLog("解析失败:%v", err)
  5124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5125. return
  5126. }
  5127. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5128. res.Output = resSixteen10265.Output
  5129. res.ErrMsg = resSixteen10265.ErrMsg
  5130. res.Cainfo = resSixteen10265.Cainfo
  5131. res.WarnMsg = resSixteen10265.WarnMsg
  5132. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5133. res.Infcode = infocode
  5134. } else {
  5135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5136. utils.ErrorLog("解析失败:%v", err)
  5137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5138. return
  5139. }
  5140. }
  5141. }
  5142. if res.Infcode == 0 {
  5143. var res2 ResultSix
  5144. var resSix10265 ResultSix10265
  5145. if miConfig.MdtrtareaAdmvs == "421300" {
  5146. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5147. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5148. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5149. resp3, requestErr3 := http.Get(api3)
  5150. if requestErr3 != nil {
  5151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5152. return
  5153. }
  5154. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5155. if ioErr3 != nil {
  5156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5158. return
  5159. }
  5160. var respJSON3 map[string]interface{}
  5161. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5164. return
  5165. }
  5166. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5167. userJSONBytes3, _ := json.Marshal(respJSON3)
  5168. fmt.Println("log")
  5169. fmt.Println(string(userJSONBytes3))
  5170. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5171. utils.ErrorLog("解析失败:%v", err)
  5172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5173. return
  5174. }
  5175. } else {
  5176. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5177. var dat map[string]interface{}
  5178. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5179. fmt.Println(dat)
  5180. } else {
  5181. fmt.Println(err)
  5182. }
  5183. saveLog(result2, src_request, "2205", "撤销明细")
  5184. userJSONBytes, _ := json.Marshal(dat)
  5185. if miConfig.Code == "H15049901371" {
  5186. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5187. utils.ErrorLog("解析失败:%v", err)
  5188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5189. return
  5190. }
  5191. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5192. res2.Output = resSix10265.Output
  5193. res2.ErrMsg = resSix10265.ErrMsg
  5194. res2.Cainfo = resSix10265.Cainfo
  5195. res2.WarnMsg = resSix10265.WarnMsg
  5196. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5197. res2.Infcode = infocode
  5198. } else {
  5199. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5200. utils.ErrorLog("解析失败:%v", err)
  5201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5202. return
  5203. }
  5204. }
  5205. }
  5206. if res2.Infcode == 0 {
  5207. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5208. if err == nil {
  5209. c.ServeSuccessJSON(map[string]interface{}{
  5210. "msg": "退费成功",
  5211. })
  5212. } else {
  5213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5214. return
  5215. }
  5216. } else {
  5217. c.ServeSuccessJSON(map[string]interface{}{
  5218. "code": -10,
  5219. "msg": res2.ErrMsg,
  5220. })
  5221. }
  5222. } else {
  5223. c.ServeSuccessJSON(map[string]interface{}{
  5224. "code": -10,
  5225. "msg": res.ErrMsg,
  5226. })
  5227. }
  5228. }
  5229. }
  5230. func (c *HisApiController) RefundNumber() {
  5231. record_time := c.GetString("record_time")
  5232. //patient_id, _ := c.GetInt64("patient_id")
  5233. admin_user_id, _ := c.GetInt64("admin_user_id")
  5234. his_patient_id, _ := c.GetInt64("id")
  5235. timeLayout := "2006-01-02"
  5236. loc, _ := time.LoadLocation("Local")
  5237. adminUser := c.GetAdminUserInfo()
  5238. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5239. fmt.Println(err)
  5240. if err != nil {
  5241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5242. return
  5243. }
  5244. recordDateTime := theTime.Unix()
  5245. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5246. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5247. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5248. //order, _ := service.GetHisOrderByID(order_id)
  5249. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5250. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5251. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5252. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5253. if count > 0 {
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5255. return
  5256. }
  5257. if config.IsOpen == 1 { //对接了医保,走医保流程
  5258. var res2 ResultSix
  5259. var resSix10265 ResultSix10265
  5260. if miConfig.MdtrtareaAdmvs == "421300" {
  5261. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5262. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5263. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5264. resp3, requestErr3 := http.Get(api3)
  5265. if requestErr3 != nil {
  5266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5267. return
  5268. }
  5269. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5270. if ioErr3 != nil {
  5271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5273. return
  5274. }
  5275. var respJSON3 map[string]interface{}
  5276. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5279. return
  5280. }
  5281. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5282. userJSONBytes3, _ := json.Marshal(respJSON3)
  5283. fmt.Println("log")
  5284. fmt.Println(string(userJSONBytes3))
  5285. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5286. utils.ErrorLog("解析失败:%v", err)
  5287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5288. return
  5289. }
  5290. } else {
  5291. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5292. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5293. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5294. resp3, requestErr3 := http.Get(api3)
  5295. if requestErr3 != nil {
  5296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5297. return
  5298. }
  5299. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5300. if ioErr3 != nil {
  5301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5303. return
  5304. }
  5305. var respJSON3 map[string]interface{}
  5306. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5309. return
  5310. }
  5311. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5312. userJSONBytes3, _ := json.Marshal(respJSON3)
  5313. if miConfig.Code == "H15049901371" {
  5314. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5315. utils.ErrorLog("解析失败:%v", err)
  5316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5317. return
  5318. }
  5319. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5320. res2.Output = resSix10265.Output
  5321. res2.ErrMsg = resSix10265.ErrMsg
  5322. res2.Cainfo = resSix10265.Cainfo
  5323. res2.WarnMsg = resSix10265.WarnMsg
  5324. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5325. res2.Infcode = infocode
  5326. } else {
  5327. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5328. utils.ErrorLog("解析失败:%v", err)
  5329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5330. return
  5331. }
  5332. }
  5333. }
  5334. if res2.Infcode == 0 {
  5335. if err == nil {
  5336. c.ServeSuccessJSON(map[string]interface{}{
  5337. "msg": "退号成功",
  5338. })
  5339. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  5340. } else {
  5341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5342. return
  5343. }
  5344. } else {
  5345. c.ServeSuccessJSON(map[string]interface{}{
  5346. "code": -10,
  5347. "msg": res2.ErrMsg,
  5348. })
  5349. }
  5350. } else {
  5351. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  5352. //if err == nil {
  5353. // c.ServeSuccessJSON(map[string]interface{}{
  5354. // "msg": "退费成功",
  5355. // })
  5356. //} else {
  5357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5358. // return
  5359. //}
  5360. }
  5361. }
  5362. func (c *HisApiController) RefundDetail() {
  5363. order_id, _ := c.GetInt64("order_id")
  5364. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5365. number := c.GetString("number")
  5366. record_time := c.GetString("record_time")
  5367. patient_id, _ := c.GetInt64("patient_id")
  5368. timeLayout := "2006-01-02"
  5369. loc, _ := time.LoadLocation("Local")
  5370. adminUser := c.GetAdminUserInfo()
  5371. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5372. fmt.Println(err)
  5373. if err != nil {
  5374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5375. return
  5376. }
  5377. recordDateTime := theTime.Unix()
  5378. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5379. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5380. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5381. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5382. var order models.HisOrder
  5383. order, _ = service.GetHisOrderByID(order_id)
  5384. if order.ID == 0 {
  5385. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5386. }
  5387. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5388. if config.IsOpen == 1 { //对接了医保,走医保流程
  5389. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  5390. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5391. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5392. resp2, requestErr2 := http.Get(api2)
  5393. if requestErr2 != nil {
  5394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5395. return
  5396. }
  5397. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5398. if ioErr2 != nil {
  5399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5401. return
  5402. }
  5403. var respJSON2 map[string]interface{}
  5404. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  5405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5407. return
  5408. }
  5409. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5410. if err == nil {
  5411. c.ServeSuccessJSON(map[string]interface{}{
  5412. "msg": "退费成功",
  5413. })
  5414. } else {
  5415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5416. return
  5417. }
  5418. } else {
  5419. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5420. if err == nil {
  5421. c.ServeSuccessJSON(map[string]interface{}{
  5422. "msg": "退费成功",
  5423. })
  5424. } else {
  5425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5426. return
  5427. }
  5428. }
  5429. }
  5430. //对账
  5431. func (c *HisApiController) GetCheckAccount() {
  5432. start_time := c.GetString("start_time")
  5433. end_time := c.GetString("end_time")
  5434. insutype := c.GetString("insutype")
  5435. clr_type := c.GetString("clr_type")
  5436. admin_user_id, _ := c.GetInt64("admin_user_id")
  5437. adminUser := c.GetAdminUserInfo()
  5438. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5439. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5440. timeLayout := "2006-01-02"
  5441. loc, _ := time.LoadLocation("Local")
  5442. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5443. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5444. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5445. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5446. fixmedins_setl_cnt := int64(len(orders))
  5447. //
  5448. ////撤销的算2条数据为一笔
  5449. //for _, item := range orders_two {
  5450. // if item.OrderStatus == 3 {
  5451. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  5452. // }
  5453. //}
  5454. var medfee_sumamt float64
  5455. var acct_pay float64
  5456. var fund_pay_sumamt float64
  5457. for _, item := range orders {
  5458. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5459. acct_pay = acct_pay + item.AcctPay
  5460. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5461. }
  5462. var user_name string
  5463. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5464. if role.ID == 0 {
  5465. user_name = "xxx"
  5466. } else {
  5467. user_name = role.UserName
  5468. }
  5469. if config.IsOpen == 1 {
  5470. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5471. "insutype=" + insutype +
  5472. "&clr_type=" + clr_type +
  5473. "&setl_optins=" + "定点医保中心" +
  5474. "&stmt_begndate=" + start_time +
  5475. "&stm_enddate=" + end_time +
  5476. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5477. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5478. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  5479. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5480. "&fixmedins_code=" + miConfig.Code +
  5481. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5482. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5483. "&secret_key=" + miConfig.SecretKey +
  5484. "&org_name=" + miConfig.OrgName +
  5485. "&doctor=" + user_name
  5486. fmt.Println(api)
  5487. resp, requestErr := http.Get(api)
  5488. if requestErr != nil {
  5489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5490. return
  5491. }
  5492. body, ioErr := ioutil.ReadAll(resp.Body)
  5493. fmt.Println(body)
  5494. if ioErr != nil {
  5495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5497. return
  5498. }
  5499. var respJSON map[string]interface{}
  5500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5503. return
  5504. }
  5505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5506. userJSONBytes, _ := json.Marshal(respJSON)
  5507. var res ResultEight
  5508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5509. utils.ErrorLog("解析失败:%v", err)
  5510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5511. return
  5512. }
  5513. if res.Infcode == 0 {
  5514. if res.Output.Stmtinfo.StmtRslt == "0" {
  5515. micc := &models.MedicalInsuranceCostCompare{
  5516. StartTime: startime.Unix(),
  5517. EndTime: endtime.Unix(),
  5518. Insutype: insutype,
  5519. CheckType: 1,
  5520. Num: fixmedins_setl_cnt,
  5521. Mtime: time.Now().Unix(),
  5522. Status: 1,
  5523. UserOrgId: adminUser.CurrentOrgId,
  5524. CostTotal: medfee_sumamt,
  5525. FuncTotal: fund_pay_sumamt,
  5526. PsnPay: acct_pay,
  5527. Creator: admin_user_id,
  5528. Ctime: time.Now().Unix(),
  5529. }
  5530. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  5531. if err == nil {
  5532. c.ServeSuccessJSON(map[string]interface{}{
  5533. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5534. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5535. })
  5536. } else {
  5537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5538. }
  5539. } else {
  5540. c.ServeSuccessJSON(map[string]interface{}{
  5541. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5542. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5543. })
  5544. }
  5545. } else {
  5546. c.ServeSuccessJSON(map[string]interface{}{
  5547. "code": -10,
  5548. "msg": res.ErrMsg,
  5549. })
  5550. }
  5551. }
  5552. }
  5553. func (c *HisApiController) Check310() {
  5554. adminUser := c.GetAdminUserInfo()
  5555. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5556. var user_name string
  5557. user_name = "xxx"
  5558. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5559. "insutype=" + "310" +
  5560. "&clr_type=" + "11" +
  5561. "&setl_optins=" + "定点医保中心" +
  5562. "&stmt_begndate=" + "2021-03-01" +
  5563. "&stm_enddate=" + "2021-03-31" +
  5564. "&medfee_sumamt=" + "11521" +
  5565. "&fund_pay_sumamt=" + "10166.66" +
  5566. "&acct_pay=" + "0" +
  5567. "&fixmedins_setl_cnt=" + "7" +
  5568. "&fixmedins_code=" + miConfig.Code +
  5569. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5570. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5571. "&secret_key=" + miConfig.SecretKey +
  5572. "&org_name=" + miConfig.OrgName +
  5573. "&doctor=" + user_name
  5574. fmt.Println(api)
  5575. resp, requestErr := http.Get(api)
  5576. if requestErr != nil {
  5577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5578. return
  5579. }
  5580. body, ioErr := ioutil.ReadAll(resp.Body)
  5581. fmt.Println(body)
  5582. if ioErr != nil {
  5583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5585. return
  5586. }
  5587. var respJSON map[string]interface{}
  5588. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5591. return
  5592. }
  5593. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5594. userJSONBytes, _ := json.Marshal(respJSON)
  5595. var res ResultEight
  5596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5597. utils.ErrorLog("解析失败:%v", err)
  5598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5599. return
  5600. }
  5601. }
  5602. func (c *HisApiController) Check390() {
  5603. adminUser := c.GetAdminUserInfo()
  5604. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5605. var user_name string
  5606. user_name = "张俊杰"
  5607. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5608. "insutype=" + "390" +
  5609. "&clr_type=" + "11" +
  5610. "&setl_optins=" + "定点医保中心" +
  5611. "&stmt_begndate=" + "2021-03-01" +
  5612. "&stm_enddate=" + "2021-03-31" +
  5613. "&medfee_sumamt=" + "209318.43" +
  5614. "&fund_pay_sumamt=" + "188029.12" +
  5615. "&acct_pay=" + "0" +
  5616. "&fixmedins_setl_cnt=" + "48" +
  5617. "&fixmedins_code=" + miConfig.Code +
  5618. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5619. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5620. "&secret_key=" + miConfig.SecretKey +
  5621. "&org_name=" + miConfig.OrgName +
  5622. "&doctor=" + user_name
  5623. fmt.Println(api)
  5624. resp, requestErr := http.Get(api)
  5625. if requestErr != nil {
  5626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5627. return
  5628. }
  5629. body, ioErr := ioutil.ReadAll(resp.Body)
  5630. fmt.Println(body)
  5631. if ioErr != nil {
  5632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5634. return
  5635. }
  5636. var respJSON map[string]interface{}
  5637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5640. return
  5641. }
  5642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5643. userJSONBytes, _ := json.Marshal(respJSON)
  5644. var res ResultEight
  5645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5646. utils.ErrorLog("解析失败:%v", err)
  5647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5648. return
  5649. }
  5650. }
  5651. //对账明细
  5652. func (c *HisApiController) GetCheckDetailAccount() {
  5653. start_time := c.GetString("start_time")
  5654. end_time := c.GetString("end_time")
  5655. admin_user_id, _ := c.GetInt64("admin_user_id")
  5656. adminUser := c.GetAdminUserInfo()
  5657. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5658. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5659. timeLayout := "2006-01-02"
  5660. loc, _ := time.LoadLocation("Local")
  5661. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5662. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5663. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  5664. Mkdir(miConfig.OrgName)
  5665. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  5666. file_name := file + ".txt"
  5667. zip_name := file + ".zip"
  5668. zip_path := miConfig.OrgName + "/" + zip_name
  5669. file_path := miConfig.OrgName + "/" + file_name
  5670. decimal.DivisionPrecision = 2
  5671. var medfee_sumamt float64
  5672. var psn_cash_pay float64
  5673. var fund_pay_sumamt float64
  5674. fixmedins_setl_cnt := int64(len(orders))
  5675. for _, item := range orders {
  5676. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5677. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  5678. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5679. }
  5680. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  5681. defer f.Close()
  5682. if err != nil {
  5683. fmt.Println(err.Error())
  5684. } else {
  5685. for _, item := range orders {
  5686. var refd_setl_flag string
  5687. if item.OrderStatus == 2 {
  5688. refd_setl_flag = "0"
  5689. var str string
  5690. str = item.SetlId + " " +
  5691. item.MdtrtId + " " +
  5692. item.PsnNo + " " +
  5693. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5694. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5695. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  5696. _, err = f.Write([]byte(str))
  5697. }
  5698. if item.OrderStatus == 3 {
  5699. var str string
  5700. str = item.SetlId + " " +
  5701. item.MdtrtId + " " +
  5702. item.PsnNo + " " +
  5703. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5704. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5705. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  5706. _, err = f.Write([]byte(str))
  5707. var str2 string
  5708. str2 = item.SetlId + " " +
  5709. item.MdtrtId + " " +
  5710. item.PsnNo + " " +
  5711. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  5712. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  5713. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  5714. _, err = f.Write([]byte(str2))
  5715. }
  5716. }
  5717. }
  5718. Zip(file_path, zip_path)
  5719. fmt.Println(ReadFile(zip_path))
  5720. fmt.Println(string(ReadFile(zip_path)))
  5721. if config.IsOpen == 1 {
  5722. var user_name string
  5723. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5724. if role.ID == 0 {
  5725. user_name = "管理员"
  5726. } else {
  5727. user_name = role.UserName
  5728. }
  5729. baseParams := models.BaseParams{
  5730. SecretKey: miConfig.SecretKey,
  5731. FixmedinsCode: miConfig.Code,
  5732. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5733. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5734. OrgName: miConfig.OrgName,
  5735. Doctor: user_name,
  5736. }
  5737. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  5738. var dat map[string]interface{}
  5739. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5740. fmt.Println(dat)
  5741. } else {
  5742. fmt.Println(err)
  5743. }
  5744. userJSONBytes, _ := json.Marshal(dat)
  5745. var res ResultNine
  5746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5747. utils.ErrorLog("解析失败:%v", err)
  5748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5749. return
  5750. }
  5751. if res.Infcode == 0 {
  5752. fileNo := res.Output.FileQuryNo
  5753. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  5754. "file_qury_no=" + fileNo +
  5755. "&setl_optins=" + "定点医保中心" +
  5756. "&stmt_begndate=" + start_time +
  5757. "&stm_enddate=" + end_time +
  5758. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5759. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5760. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  5761. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5762. "&fixmedins_code=" + miConfig.Code +
  5763. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5764. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5765. "&secret_key=" + miConfig.SecretKey +
  5766. "&org_name=" + miConfig.OrgName +
  5767. "&doctor=" + user_name
  5768. resp, requestErr := http.Get(api)
  5769. if requestErr != nil {
  5770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5771. return
  5772. }
  5773. body, ioErr := ioutil.ReadAll(resp.Body)
  5774. if ioErr != nil {
  5775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5777. return
  5778. }
  5779. var respJSON map[string]interface{}
  5780. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5783. return
  5784. }
  5785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5786. userJSONBytes, _ := json.Marshal(respJSON)
  5787. var res ResultTen
  5788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5789. utils.ErrorLog("解析失败:%v", err)
  5790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5791. return
  5792. }
  5793. if res.Infcode == 0 {
  5794. service.Gdyb9102(baseParams, zip_name, fileNo)
  5795. micc := &models.MedicalInsuranceCostCompare{
  5796. StartTime: startime.Unix(),
  5797. EndTime: endtime.Unix(),
  5798. Insutype: "0",
  5799. CheckType: 2,
  5800. Num: fixmedins_setl_cnt,
  5801. Mtime: time.Now().Unix(),
  5802. Status: 1,
  5803. UserOrgId: adminUser.CurrentOrgId,
  5804. CostTotal: medfee_sumamt,
  5805. FuncTotal: fund_pay_sumamt,
  5806. PsnPay: psn_cash_pay,
  5807. Creator: admin_user_id,
  5808. Ctime: time.Now().Unix(),
  5809. }
  5810. service.CreateMedicalInsuranceCostCompareRecord(micc)
  5811. c.ServeSuccessJSON(map[string]interface{}{
  5812. "msg": "明细对账成功",
  5813. })
  5814. }
  5815. } else {
  5816. }
  5817. }
  5818. }
  5819. type CustomOrderInfo struct {
  5820. Name string
  5821. Spec string
  5822. Unit string
  5823. Count float64
  5824. Price float64
  5825. Total float64
  5826. }
  5827. func (c *HisApiController) GetSettleAccounts() {
  5828. //id, _ := c.GetInt64("id")
  5829. //record_time := c.GetString("record_time")
  5830. order_id, _ := c.GetInt64("order_id")
  5831. admin_user_id, _ := c.GetInt64("admin_user_id")
  5832. //timeLayout := "2006-01-02"
  5833. //loc, _ := time.LoadLocation("Local")
  5834. //
  5835. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5836. //if err != nil {
  5837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5838. // return
  5839. //}
  5840. //recordDateTime := theTime.Unix()
  5841. adminUser := c.GetAdminUserInfo()
  5842. order, _ := service.GetHisOrderByID(order_id)
  5843. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5844. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  5845. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  5846. orderInfos = append(orderInfos, orderInfos_two...)
  5847. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  5848. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5849. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  5850. //var config []*models.HisXtDiagnoseConfig
  5851. var name string
  5852. for _, item := range diagnosis_ids {
  5853. id, _ := strconv.ParseInt(item, 10, 64)
  5854. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5855. if len(name) == 0 {
  5856. name = diagnosisConfig.ClassName
  5857. } else {
  5858. name = name + "," + diagnosisConfig.ClassName
  5859. }
  5860. }
  5861. var bedCostTotal float64 = 0 //床位总费
  5862. var bedCostSelfTotal float64 = 0 //床位自费
  5863. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5864. var operationCostTotal float64 = 0 //手术费
  5865. var operationCostSelfTotal float64 = 0 //手术费
  5866. var operationCostPartSelfTotal float64 = 0 //手术费
  5867. var otherCostTotal float64 = 0 //其他费用
  5868. var otherCostSelfTotal float64 = 0 //其他费用
  5869. var otherCostPartSelfTotal float64 = 0 //其他费用
  5870. var materialCostTotal float64 = 0 //材料费
  5871. var materialCostSelfTotal float64 = 0 //材料费
  5872. var materialCostPartSelfTotal float64 = 0 //材料费
  5873. var westernMedicineCostTotal float64 = 0 //西药费
  5874. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5875. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5876. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5877. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5878. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5879. var checkCostTotal float64 = 0 //检查费
  5880. var checkCostSelfTotal float64 = 0 //检查费
  5881. var checkCostPartSelfTotal float64 = 0 //检查费
  5882. var laboratoryCostTotal float64 = 0 //化验费
  5883. var laboratoryCostSelfTotal float64 = 0 //化验费
  5884. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5885. var treatCostTotal float64 = 0 //治疗费用
  5886. var treatCostSelfTotal float64 = 0 //治疗费用
  5887. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5888. decimal.DivisionPrecision = 2
  5889. for _, item := range orderInfos {
  5890. if item.MedChrgitmType == "01" { //床位费
  5891. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5892. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5893. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5894. }
  5895. if item.MedChrgitmType == "03" { //检查费
  5896. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5897. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5898. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5899. }
  5900. if item.MedChrgitmType == "04" { //化验费
  5901. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5902. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5903. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5904. }
  5905. if item.MedChrgitmType == "05" { //治疗费
  5906. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5907. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5908. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5909. }
  5910. if item.MedChrgitmType == "06" { //手术费
  5911. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5912. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5913. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5914. }
  5915. if item.MedChrgitmType == "08" { //材料费
  5916. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5917. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5918. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5919. }
  5920. if item.MedChrgitmType == "09" { //西药费
  5921. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5922. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5923. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5924. }
  5925. if item.MedChrgitmType == "11" { //中成费
  5926. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5927. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5928. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5929. }
  5930. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  5931. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5932. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5933. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5934. }
  5935. }
  5936. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5937. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5938. var user_name string
  5939. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5940. if role.ID == 0 {
  5941. user_name = "管理员"
  5942. } else {
  5943. user_name = role.UserName
  5944. }
  5945. baseParams := models.BaseParams{
  5946. SecretKey: miConfig.SecretKey,
  5947. FixmedinsCode: miConfig.Code,
  5948. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5949. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5950. OrgName: miConfig.OrgName,
  5951. Doctor: user_name,
  5952. }
  5953. businessParams := models.BusinessParams{
  5954. PsnNo: order.PsnNo,
  5955. MdtrtId: order.MdtrtId,
  5956. SetlId: order.SetlId,
  5957. }
  5958. var res ResultEleven
  5959. var resEleven10265 ResultEleven10265
  5960. if config.IsOpen == 1 {
  5961. if miConfig.MdtrtareaAdmvs == "421300" {
  5962. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  5963. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  5964. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5965. resp, requestErr := http.Get(api)
  5966. if requestErr != nil {
  5967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5968. return
  5969. }
  5970. body, ioErr := ioutil.ReadAll(resp.Body)
  5971. if ioErr != nil {
  5972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5974. return
  5975. }
  5976. var respJSON map[string]interface{}
  5977. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5980. return
  5981. }
  5982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5983. result, _ := json.Marshal(respJSON)
  5984. fmt.Println("log")
  5985. fmt.Println(string(result))
  5986. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5987. utils.ErrorLog("解析失败:%v", err)
  5988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5989. return
  5990. }
  5991. } else {
  5992. result := service.Gdyb5203(baseParams, businessParams)
  5993. var dat map[string]interface{}
  5994. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5995. fmt.Println(dat)
  5996. } else {
  5997. fmt.Println(err)
  5998. }
  5999. userJSONBytes, _ := json.Marshal(dat)
  6000. if miConfig.Code == "H15049901371" {
  6001. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6002. utils.ErrorLog("解析失败:%v", err)
  6003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6004. return
  6005. }
  6006. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6007. res.Output = resEleven10265.Output
  6008. res.ErrMsg = resEleven10265.ErrMsg
  6009. res.Cainfo = resEleven10265.Cainfo
  6010. res.WarnMsg = resEleven10265.WarnMsg
  6011. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6012. res.Infcode = infocode
  6013. } else {
  6014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6015. utils.ErrorLog("解析失败:%v", err)
  6016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6017. return
  6018. }
  6019. }
  6020. }
  6021. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6022. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6023. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6024. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6025. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6026. var doctor_name string
  6027. if roles.ID == 0 {
  6028. doctor_name = "管理员"
  6029. } else {
  6030. doctor_name = roles.UserName
  6031. }
  6032. yiliao_leibie := ""
  6033. switch order.MedType {
  6034. case "11":
  6035. yiliao_leibie = "普通门诊"
  6036. break
  6037. case "12":
  6038. yiliao_leibie = "门诊挂号"
  6039. break
  6040. case "13":
  6041. yiliao_leibie = "急诊"
  6042. break
  6043. case "14":
  6044. yiliao_leibie = "门诊特殊病"
  6045. break
  6046. case "15":
  6047. yiliao_leibie = "门诊统筹"
  6048. break
  6049. case "16":
  6050. yiliao_leibie = "门诊慢性病"
  6051. break
  6052. case "21":
  6053. yiliao_leibie = "普通住院"
  6054. break
  6055. }
  6056. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6057. if res.Infcode == 0 {
  6058. c.ServeSuccessJSON(map[string]interface{}{
  6059. "diagnosis": name,
  6060. "order_infos": orderInfos,
  6061. "number": order.MdtrtId,
  6062. "date": order.SettleAccountsDate,
  6063. "charge_admin": charge_admin,
  6064. "printor_admin": printor_admin,
  6065. "info": res.Output.Setlinfo,
  6066. "bedCostTotal": bedCostTotal,
  6067. "bedCostSelfTotal": bedCostSelfTotal,
  6068. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6069. "operationCostTotal": operationCostTotal,
  6070. "operationCostSelfTotal": operationCostSelfTotal,
  6071. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6072. "otherCostTotal": otherCostTotal,
  6073. "otherCostSelfTotal": otherCostSelfTotal,
  6074. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6075. "materialCostTotal": materialCostTotal,
  6076. "materialCostSelfTotal": materialCostSelfTotal,
  6077. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6078. "westernMedicineCostTotal": westernMedicineCostTotal,
  6079. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6080. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6081. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6082. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6083. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6084. "checkCostTotal": checkCostTotal,
  6085. "checkCostSelfTotal": checkCostSelfTotal,
  6086. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6087. "laboratoryCostTotal": laboratoryCostTotal,
  6088. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6089. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6090. "treatCostTotal": treatCostTotal,
  6091. "treatCostSelfTotal": treatCostSelfTotal,
  6092. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6093. "doctor_code": adminRole_two.DoctorCode,
  6094. "doctor_name": doctor_name,
  6095. "health_card_no": order.PsnNo,
  6096. "department": departments.Name,
  6097. "yiliao_leibie": yiliao_leibie,
  6098. "after_money": order.AccountPrice,
  6099. "patient": patient,
  6100. "org_name": miConfig.OrgName,
  6101. "org_code": miConfig.Code,
  6102. "order_number": order.Number,
  6103. //"check_order_info": cus_slice,
  6104. })
  6105. }
  6106. }
  6107. }
  6108. func (c *HisApiController) CheckTreatment() {
  6109. patient_id, _ := c.GetInt64("patient_id", 0)
  6110. record_time := c.GetString("record_time")
  6111. insutype := c.GetString("insutype")
  6112. timeLayout := "2006-01-02"
  6113. loc, _ := time.LoadLocation("Local")
  6114. adminUser := c.GetAdminUserInfo()
  6115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6116. fmt.Println(err)
  6117. if err != nil {
  6118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6119. return
  6120. }
  6121. recordDateTime := theTime.Unix()
  6122. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6123. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6124. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6125. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6126. var user_name string
  6127. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  6128. if role.ID == 0 {
  6129. user_name = "xxx"
  6130. } else {
  6131. user_name = role.UserName
  6132. }
  6133. baseParams := models.BaseParams{
  6134. SecretKey: miConfig.SecretKey,
  6135. FixmedinsCode: miConfig.Code,
  6136. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6137. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6138. OrgName: miConfig.OrgName,
  6139. Doctor: user_name,
  6140. }
  6141. if config.IsOpen == 1 {
  6142. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  6143. var dat map[string]interface{}
  6144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6145. fmt.Println(dat)
  6146. } else {
  6147. fmt.Println(err)
  6148. }
  6149. }
  6150. }
  6151. func (c *HisApiController) PutRecord() {
  6152. id, _ := c.GetInt64("id")
  6153. record_time := c.GetString("record_time")
  6154. timeLayout := "2006-01-02"
  6155. loc, _ := time.LoadLocation("Local")
  6156. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6157. if err != nil {
  6158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6159. return
  6160. }
  6161. recordDateTime := theTime.Unix()
  6162. adminInfo := c.GetAdminUserInfo()
  6163. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  6164. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6165. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6166. fmt.Println(miConfig.SecretKey)
  6167. if patient == nil {
  6168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6169. return
  6170. }
  6171. if len(patient.IdCardNo) == 0 {
  6172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6173. return
  6174. }
  6175. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6176. if config.IsOpen == 1 {
  6177. 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
  6178. resp, requestErr := http.Get(api)
  6179. if requestErr != nil {
  6180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6181. return
  6182. }
  6183. defer resp.Body.Close()
  6184. body, ioErr := ioutil.ReadAll(resp.Body)
  6185. if ioErr != nil {
  6186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6188. return
  6189. }
  6190. var respJSON map[string]interface{}
  6191. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6194. return
  6195. }
  6196. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6197. userJSONBytes, _ := json.Marshal(userJSON)
  6198. var res ResultTwo
  6199. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6200. utils.ErrorLog("解析失败:%v", err)
  6201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6202. return
  6203. }
  6204. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6205. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6206. infoStr := string(Iinfos)
  6207. idetinfoStr := string(Idetinfos)
  6208. if res.Infcode == 0 {
  6209. his := models.VMHisPatient{
  6210. Status: 1,
  6211. Ctime: time.Now().Unix(),
  6212. Mtime: time.Now().Unix(),
  6213. PsnNo: res.Output.Baseinfo.PsnNo,
  6214. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6215. Certno: res.Output.Baseinfo.Certno,
  6216. PsnName: res.Output.Baseinfo.PsnName,
  6217. Gend: res.Output.Baseinfo.Gend,
  6218. Naty: res.Output.Baseinfo.Naty,
  6219. Brdy: res.Output.Baseinfo.Brdy,
  6220. Age: res.Output.Baseinfo.Age,
  6221. Iinfo: infoStr,
  6222. Idetinfo: idetinfoStr,
  6223. PatientId: patient.ID,
  6224. RecordDate: theTime.Unix(),
  6225. UserOrgId: adminInfo.CurrentOrgId,
  6226. AdminUserId: adminInfo.AdminUser.Id,
  6227. IsReturn: 1,
  6228. }
  6229. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  6230. 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")
  6231. 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")
  6232. var dat map[string]interface{}
  6233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6234. fmt.Println(dat)
  6235. } else {
  6236. fmt.Println(err)
  6237. }
  6238. var dat2 map[string]interface{}
  6239. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  6240. fmt.Println(dat2)
  6241. } else {
  6242. fmt.Println(err)
  6243. }
  6244. } else {
  6245. adminUser := c.GetAdminUserInfo()
  6246. errlog := &models.HisOrderError{
  6247. UserOrgId: adminUser.CurrentOrgId,
  6248. Ctime: time.Now().Unix(),
  6249. Mtime: time.Now().Unix(),
  6250. ErrMsg: res.ErrMsg,
  6251. Status: 1,
  6252. PatientId: id,
  6253. RecordTime: recordDateTime,
  6254. Stage: 1,
  6255. }
  6256. service.CreateErrMsgLog(errlog)
  6257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  6258. return
  6259. }
  6260. }
  6261. }
  6262. func (c *HisApiController) GetUploadDiag() {
  6263. id, _ := c.GetInt64("id")
  6264. record_time := c.GetString("record_time")
  6265. diagnosis_id, _ := c.GetInt64("diagnosis")
  6266. sick_type, _ := c.GetInt64("sick_type")
  6267. reg_type, _ := c.GetInt64("reg_type")
  6268. timeLayout := "2006-01-02"
  6269. loc, _ := time.LoadLocation("Local")
  6270. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6271. if err != nil {
  6272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6273. return
  6274. }
  6275. var patientPrescription models.HisPrescriptionInfo
  6276. recordDateTime := theTime.Unix()
  6277. adminInfo := c.GetAdminUserInfo()
  6278. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6279. if patientPrescription.ID == 0 {
  6280. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6281. }
  6282. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6283. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6284. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6285. sickConfig, _ := service.FindSickById(sick_type)
  6286. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6287. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  6288. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  6289. "&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 +
  6290. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  6291. resp2, requestErr2 := http.Get(api2)
  6292. if requestErr2 != nil {
  6293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6294. return
  6295. }
  6296. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6297. if ioErr2 != nil {
  6298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6300. return
  6301. }
  6302. var respJSON2 map[string]interface{}
  6303. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6306. return
  6307. }
  6308. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6309. userJSONBytes2, _ := json.Marshal(respJSON2)
  6310. var res2 ResultSix
  6311. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6312. utils.ErrorLog("解析失败:%v", err)
  6313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6314. return
  6315. }
  6316. if res2.Infcode != 0 {
  6317. adminUser := c.GetAdminUserInfo()
  6318. errlog := &models.HisOrderError{
  6319. UserOrgId: adminUser.CurrentOrgId,
  6320. Ctime: time.Now().Unix(),
  6321. Mtime: time.Now().Unix(),
  6322. ErrMsg: res2.ErrMsg,
  6323. Status: 1,
  6324. PatientId: id,
  6325. RecordTime: recordDateTime,
  6326. Stage: 3,
  6327. }
  6328. service.CreateErrMsgLog(errlog)
  6329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  6330. return
  6331. }
  6332. c.ServeSuccessJSON(map[string]interface{}{
  6333. "msg": "上传成功",
  6334. })
  6335. }
  6336. type QueryResult struct {
  6337. ID int64
  6338. Name string
  6339. Code string
  6340. List_type_code string
  6341. }
  6342. func (c *HisApiController) GetCheckCode() {
  6343. ids_str := c.GetString("ids")
  6344. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6345. ids_arr := strings.Split(ids_str, ",")
  6346. var queryResult []QueryResult
  6347. ids := make([]int64, 0)
  6348. for _, item := range ids_arr {
  6349. id, _ := strconv.ParseInt(item, 10, 64)
  6350. ids = append(ids, id)
  6351. }
  6352. if record_type == 1 {
  6353. drugs, _ := service.GetBatchDrugList(ids)
  6354. for _, item := range drugs {
  6355. result := QueryResult{
  6356. ID: item.ID,
  6357. Name: item.DrugName,
  6358. Code: item.MedicalInsuranceNumber,
  6359. List_type_code: "101",
  6360. }
  6361. queryResult = append(queryResult, result)
  6362. }
  6363. } else if record_type == 2 {
  6364. goods, _ := service.GetBatchGoodInformationList(ids)
  6365. for _, item := range goods {
  6366. result := QueryResult{
  6367. ID: item.ID,
  6368. Name: item.GoodName,
  6369. Code: item.MedicalInsuranceNumber,
  6370. List_type_code: "301",
  6371. }
  6372. queryResult = append(queryResult, result)
  6373. }
  6374. } else if record_type == 3 {
  6375. projects, _ := service.GetBathchMyPorjecgList(ids)
  6376. for _, item := range projects {
  6377. result := QueryResult{
  6378. ID: item.ID,
  6379. Name: item.ProjectName,
  6380. Code: item.MedicalCode,
  6381. List_type_code: "201",
  6382. }
  6383. queryResult = append(queryResult, result)
  6384. }
  6385. }
  6386. admin_user_id, _ := c.GetInt64("admin_user_id")
  6387. adminUser := c.GetAdminUserInfo()
  6388. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6389. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6390. var user_name string
  6391. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6392. if role.ID == 0 {
  6393. user_name = "xxx"
  6394. } else {
  6395. user_name = role.UserName
  6396. }
  6397. baseParams := &models.BaseParams{
  6398. SecretKey: miConfig.SecretKey,
  6399. FixmedinsCode: miConfig.Code,
  6400. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6401. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6402. OrgName: miConfig.OrgName,
  6403. Doctor: user_name,
  6404. }
  6405. if config.IsOpen == 1 {
  6406. for _, item := range queryResult {
  6407. var result string
  6408. if record_type == 1 {
  6409. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6410. } else if record_type == 2 {
  6411. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6412. } else if record_type == 3 {
  6413. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6414. }
  6415. var dat map[string]interface{}
  6416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6417. fmt.Println(dat)
  6418. } else {
  6419. fmt.Println(err)
  6420. }
  6421. userJSONBytes, _ := json.Marshal(dat)
  6422. var res ResultSix
  6423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6424. utils.ErrorLog("解析失败:%v", err)
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6426. return
  6427. }
  6428. if res.Infcode == 0 {
  6429. if record_type == 1 {
  6430. service.UpdateBaseDrugById(item.ID)
  6431. } else if record_type == 2 {
  6432. service.UpdateGoodInformaitonByDetail(item.ID)
  6433. } else if record_type == 3 {
  6434. service.UpdateProjectById(item.ID)
  6435. }
  6436. c.ServeSuccessJSON(map[string]interface{}{
  6437. "failed_code": 0,
  6438. "msg": "目录对照成功",
  6439. })
  6440. } else {
  6441. c.ServeSuccessJSON(map[string]interface{}{
  6442. "failed_code": -10,
  6443. "msg": res.ErrMsg,
  6444. })
  6445. }
  6446. }
  6447. }
  6448. }
  6449. func (c *HisApiController) UnCheckCode() {
  6450. ids_str := c.GetString("ids")
  6451. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6452. admin_user_id, _ := c.GetInt64("admin_user_id")
  6453. ids_arr := strings.Split(ids_str, ",")
  6454. var queryResult []QueryResult
  6455. ids := make([]int64, 0)
  6456. for _, item := range ids_arr {
  6457. id, _ := strconv.ParseInt(item, 10, 64)
  6458. ids = append(ids, id)
  6459. }
  6460. if record_type == 1 {
  6461. drugs, _ := service.GetBatchDrugList(ids)
  6462. for _, item := range drugs {
  6463. result := QueryResult{
  6464. ID: item.ID,
  6465. Name: item.DrugName,
  6466. Code: item.MedicalInsuranceNumber,
  6467. List_type_code: "101",
  6468. }
  6469. queryResult = append(queryResult, result)
  6470. }
  6471. } else if record_type == 2 {
  6472. goods, _ := service.GetBatchGoodInformationList(ids)
  6473. for _, item := range goods {
  6474. result := QueryResult{
  6475. ID: item.ID,
  6476. Name: item.GoodName,
  6477. Code: item.MedicalInsuranceNumber,
  6478. List_type_code: "301",
  6479. }
  6480. queryResult = append(queryResult, result)
  6481. }
  6482. } else if record_type == 3 {
  6483. projects, _ := service.GetBathchMyPorjecgList(ids)
  6484. for _, item := range projects {
  6485. result := QueryResult{
  6486. ID: item.ID,
  6487. Name: item.ProjectName,
  6488. Code: item.MedicalCode,
  6489. List_type_code: "201",
  6490. }
  6491. queryResult = append(queryResult, result)
  6492. }
  6493. }
  6494. adminUser := c.GetAdminUserInfo()
  6495. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6496. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6497. var user_name string
  6498. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6499. if role.ID == 0 {
  6500. user_name = "xxx"
  6501. } else {
  6502. user_name = role.UserName
  6503. }
  6504. baseParams := &models.BaseParams{
  6505. SecretKey: miConfig.SecretKey,
  6506. FixmedinsCode: miConfig.Code,
  6507. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6508. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6509. OrgName: miConfig.OrgName,
  6510. Doctor: user_name,
  6511. }
  6512. if config.IsOpen == 1 {
  6513. for _, item := range queryResult {
  6514. var result string
  6515. if record_type == 1 {
  6516. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6517. } else if record_type == 2 {
  6518. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6519. } else if record_type == 3 {
  6520. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6521. }
  6522. var dat2 map[string]interface{}
  6523. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  6524. fmt.Println(dat2)
  6525. } else {
  6526. fmt.Println(err)
  6527. }
  6528. userJSONBytes, _ := json.Marshal(dat2)
  6529. var res ResultSix
  6530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6531. utils.ErrorLog("解析失败:%v", err)
  6532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6533. return
  6534. }
  6535. if res.Infcode == 0 {
  6536. if record_type == 1 {
  6537. service.UpdateDrugByIdDetail(item.ID)
  6538. } else if record_type == 2 {
  6539. service.UpdateGoodInfoById(item.ID)
  6540. } else if record_type == 3 {
  6541. service.UpdateMyProjectById(item.ID)
  6542. }
  6543. c.ServeSuccessJSON(map[string]interface{}{
  6544. "failed_code": 0,
  6545. "msg": "撤销目录对照成功",
  6546. })
  6547. } else {
  6548. c.ServeSuccessJSON(map[string]interface{}{
  6549. "failed_code": -10,
  6550. "msg": res.ErrMsg,
  6551. })
  6552. }
  6553. }
  6554. }
  6555. }
  6556. func (c *HisApiController) GetPatientInfo() {
  6557. id_card_no := c.GetString("id_card_no")
  6558. admin_user_id, _ := c.GetInt64("admin_user_id")
  6559. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6560. if patient.ID == 0 {
  6561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6562. return
  6563. }
  6564. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6565. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6566. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  6567. if config.IsOpen == 1 {
  6568. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6569. var dat map[string]interface{}
  6570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6571. fmt.Println(dat)
  6572. } else {
  6573. fmt.Println(err)
  6574. }
  6575. userJSONBytes, _ := json.Marshal(dat)
  6576. var res ResultTwo
  6577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6578. utils.ErrorLog("解析失败:%v", err)
  6579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6580. return
  6581. }
  6582. if res.Infcode != 0 {
  6583. c.ServeSuccessJSON(map[string]interface{}{
  6584. "failed_code": -10,
  6585. "msg": res.ErrMsg,
  6586. })
  6587. } else {
  6588. c.ServeSuccessJSON(map[string]interface{}{
  6589. "failed_code": 0,
  6590. "info": res,
  6591. })
  6592. }
  6593. }
  6594. }
  6595. func (c *HisApiController) PsnPutOnRecord() {
  6596. record_type, _ := c.GetInt64("type")
  6597. patient_id, _ := c.GetInt64("patient_id")
  6598. admin_user_id, _ := c.GetInt64("admin_user_id")
  6599. start_time := c.GetString("start_time")
  6600. end_time := c.GetString("end_time")
  6601. adminUser := c.GetAdminUserInfo()
  6602. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6603. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6604. var patients []*models.Patients
  6605. if record_type == 1 { //全部备案
  6606. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  6607. patients = append(patients, patient...)
  6608. } else { //单个备案
  6609. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6610. patients = append(patients, patient)
  6611. }
  6612. var user_name string
  6613. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6614. if role.ID == 0 {
  6615. user_name = "xxx"
  6616. } else {
  6617. user_name = role.UserName
  6618. }
  6619. if config.IsOpen == 1 {
  6620. for _, item := range patients {
  6621. 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
  6622. resp, requestErr := http.Get(api)
  6623. if requestErr != nil {
  6624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6625. return
  6626. }
  6627. defer resp.Body.Close()
  6628. body, ioErr := ioutil.ReadAll(resp.Body)
  6629. if ioErr != nil {
  6630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6632. return
  6633. }
  6634. var respJSON map[string]interface{}
  6635. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6638. return
  6639. }
  6640. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6641. userJSONBytes, _ := json.Marshal(userJSON)
  6642. var res ResultTwo
  6643. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6644. utils.ErrorLog("解析失败:%v", err)
  6645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6646. return
  6647. }
  6648. if res.Infcode == 0 {
  6649. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  6650. var dat map[string]interface{}
  6651. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6652. fmt.Println(dat)
  6653. } else {
  6654. fmt.Println(err)
  6655. }
  6656. userJSONBytes, _ := json.Marshal(dat)
  6657. var res2 ResultThirteen
  6658. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6659. utils.ErrorLog("解析失败:%v", err)
  6660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6661. return
  6662. }
  6663. if res2.Infcode == 0 {
  6664. psnResult := &models.GdybPsnRecord{
  6665. UserOrgId: adminUser.CurrentOrgId,
  6666. PatientId: item.ID,
  6667. PsnNo: res.Output.Baseinfo.PsnNo,
  6668. Ctime: time.Now().Unix(),
  6669. Mtime: time.Now().Unix(),
  6670. Status: 1,
  6671. IsCancel: 1,
  6672. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6673. }
  6674. service.CreatePsnRecord(psnResult)
  6675. } else {
  6676. c.ServeSuccessJSON(map[string]interface{}{
  6677. "failed_code": -10,
  6678. "msg": res2.ErrMsg,
  6679. })
  6680. return
  6681. }
  6682. }
  6683. }
  6684. }
  6685. }
  6686. func (c *HisApiController) PsnUnPutOnRecord() {
  6687. id, _ := c.GetInt64("id")
  6688. //record_type, _ := c.GetInt64("type")
  6689. admin_user_id, _ := c.GetInt64("admin_user_id")
  6690. adminUser := c.GetAdminUserInfo()
  6691. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6692. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6693. var user_name string
  6694. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6695. if role.ID == 0 {
  6696. user_name = "xxx"
  6697. } else {
  6698. user_name = role.UserName
  6699. }
  6700. psn_record, _ := service.GetPsnRecordById(id)
  6701. if psn_record.ID == 0 {
  6702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6703. return
  6704. }
  6705. if config.IsOpen == 1 {
  6706. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6707. var dat map[string]interface{}
  6708. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6709. fmt.Println(dat)
  6710. } else {
  6711. fmt.Println(err)
  6712. }
  6713. userJSONBytes, _ := json.Marshal(dat)
  6714. var res ResultFourteen
  6715. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6716. utils.ErrorLog("解析失败:%v", err)
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. return
  6719. }
  6720. if res.Infcode == 0 {
  6721. psn_record.IsCancel = 2
  6722. service.CreatePsnRecord(&psn_record)
  6723. } else {
  6724. c.ServeSuccessJSON(map[string]interface{}{
  6725. "failed_code": -10,
  6726. "msg": res.ErrMsg,
  6727. })
  6728. return
  6729. }
  6730. }
  6731. }
  6732. func (c *HisApiController) PsnPutNCDSOnRecord() {
  6733. patient_id, _ := c.GetInt64("patient_id")
  6734. insutype := c.GetString("insutype")
  6735. psn_no := c.GetString("psn_no")
  6736. doctor_id, _ := c.GetInt64("doctor_id")
  6737. sick_id, _ := c.GetInt64("sick_id")
  6738. department_id, _ := c.GetInt64("department_id")
  6739. adminUser := c.GetAdminUserInfo()
  6740. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6741. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6742. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6743. sick, _ := service.FindSickById(sick_id)
  6744. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6745. if config.IsOpen == 1 {
  6746. 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)
  6747. var dat map[string]interface{}
  6748. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6749. fmt.Println(dat)
  6750. } else {
  6751. fmt.Println(err)
  6752. }
  6753. userJSONBytes, _ := json.Marshal(dat)
  6754. var res2 ResultThirteen
  6755. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6756. utils.ErrorLog("解析失败:%v", err)
  6757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6758. return
  6759. }
  6760. if res2.Infcode == 0 {
  6761. psnResult := &models.GdybPsnNcdsRecord{
  6762. UserOrgId: adminUser.CurrentOrgId,
  6763. PatientId: patient.ID,
  6764. PsnNo: psn_no,
  6765. DoctorId: doctor.AdminUserId,
  6766. DepartmentId: department_id,
  6767. SickType: sick_id,
  6768. Insutype: insutype,
  6769. Ctime: time.Now().Unix(),
  6770. Mtime: time.Now().Unix(),
  6771. Status: 1,
  6772. IsCancel: 1,
  6773. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6774. }
  6775. service.CreatePsnNCDSRecord(psnResult)
  6776. c.ServeSuccessJSON(map[string]interface{}{
  6777. "failed_code": 0,
  6778. "msg": "备案成功",
  6779. "result": psnResult,
  6780. })
  6781. } else {
  6782. c.ServeSuccessJSON(map[string]interface{}{
  6783. "failed_code": -10,
  6784. "msg": res2.ErrMsg,
  6785. })
  6786. return
  6787. }
  6788. }
  6789. }
  6790. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  6791. id, _ := c.GetInt64("id")
  6792. admin_user_id, _ := c.GetInt64("admin_user_id")
  6793. adminUser := c.GetAdminUserInfo()
  6794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6795. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6796. var user_name string
  6797. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6798. if role.ID == 0 {
  6799. user_name = "xxx"
  6800. } else {
  6801. user_name = role.UserName
  6802. }
  6803. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6804. if psn_record.ID == 0 {
  6805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6806. return
  6807. }
  6808. if config.IsOpen == 1 {
  6809. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6810. var dat map[string]interface{}
  6811. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6812. fmt.Println(dat)
  6813. } else {
  6814. fmt.Println(err)
  6815. }
  6816. userJSONBytes, _ := json.Marshal(dat)
  6817. var res ResultFourteen
  6818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6819. utils.ErrorLog("解析失败:%v", err)
  6820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6821. return
  6822. }
  6823. if res.Infcode == 0 {
  6824. psn_record.IsCancel = 2
  6825. service.CreatePsnNCDSRecord(&psn_record)
  6826. c.ServeSuccessJSON(map[string]interface{}{
  6827. "failed_code": 0,
  6828. "msg": "撤销备案成功",
  6829. })
  6830. } else {
  6831. c.ServeSuccessJSON(map[string]interface{}{
  6832. "failed_code": -10,
  6833. "msg": res.ErrMsg,
  6834. })
  6835. return
  6836. }
  6837. }
  6838. }
  6839. func (c *HisApiController) TestTest() {
  6840. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  6841. fmt.Println(patient.Iinfo)
  6842. }
  6843. type CustomData struct {
  6844. MsgId string
  6845. PsnNo string
  6846. Info string
  6847. }
  6848. func (c *HisApiController) ReversalData() {
  6849. var customData []*CustomData
  6850. custom := &CustomData{
  6851. MsgId: "H44022900158202103301714472004",
  6852. PsnNo: "44020000001101329945",
  6853. Info: "2207",
  6854. }
  6855. customData = append(customData, custom)
  6856. custom1 := &CustomData{
  6857. MsgId: "H4402290015820210330172057803",
  6858. PsnNo: "44020000001101161813",
  6859. Info: "2207",
  6860. }
  6861. customData = append(customData, custom1)
  6862. custom2 := &CustomData{
  6863. MsgId: "H44022900158202103301705198813",
  6864. PsnNo: "44190000133097375417",
  6865. Info: "2207",
  6866. }
  6867. customData = append(customData, custom2)
  6868. custom3 := &CustomData{
  6869. MsgId: "H44022900158202103301715524756",
  6870. PsnNo: "44020000001100187221",
  6871. Info: "2207",
  6872. }
  6873. customData = append(customData, custom3)
  6874. custom4 := &CustomData{
  6875. MsgId: "H44022900158202103301730376224",
  6876. PsnNo: "44020000001101959155",
  6877. Info: "2207",
  6878. }
  6879. customData = append(customData, custom4)
  6880. custom5 := &CustomData{
  6881. MsgId: "H44022900158202103301748008725",
  6882. PsnNo: "44020000001104246641",
  6883. Info: "2207",
  6884. }
  6885. customData = append(customData, custom5)
  6886. custom6 := &CustomData{
  6887. MsgId: "H44022900158202103301718096755",
  6888. PsnNo: "44020000001102211860",
  6889. Info: "2207",
  6890. }
  6891. customData = append(customData, custom6)
  6892. custom7 := &CustomData{
  6893. MsgId: "H44022900158202103301736551640",
  6894. PsnNo: "44020000001102687718",
  6895. Info: "2207",
  6896. }
  6897. customData = append(customData, custom7)
  6898. custom8 := &CustomData{
  6899. MsgId: "H44022900158202103301743097676",
  6900. PsnNo: "44020000001102127785",
  6901. Info: "2207",
  6902. }
  6903. customData = append(customData, custom8)
  6904. custom9 := &CustomData{
  6905. MsgId: "H44022900158202103301712304203",
  6906. PsnNo: "44020000001101518097",
  6907. Info: "2207",
  6908. }
  6909. customData = append(customData, custom9)
  6910. custom10 := &CustomData{
  6911. MsgId: "H44022900158202103301738448785",
  6912. PsnNo: "44020000001100500813",
  6913. Info: "2207",
  6914. }
  6915. customData = append(customData, custom10)
  6916. custom11 := &CustomData{
  6917. MsgId: "H44022900158202103301732455843",
  6918. PsnNo: "44020000001102690557",
  6919. Info: "2207",
  6920. }
  6921. customData = append(customData, custom11)
  6922. custom12 := &CustomData{
  6923. MsgId: "H44022900158202103301745421708",
  6924. PsnNo: "44020000001102211928",
  6925. Info: "2207",
  6926. }
  6927. customData = append(customData, custom12)
  6928. custom1212 := &CustomData{
  6929. MsgId: "H440229001582021033017351627",
  6930. PsnNo: "44020000001102481733",
  6931. Info: "2207",
  6932. }
  6933. customData = append(customData, custom1212)
  6934. custom13 := &CustomData{
  6935. MsgId: "H44022900158202103301740327951",
  6936. PsnNo: "44020000001103174866",
  6937. Info: "2207",
  6938. }
  6939. customData = append(customData, custom13)
  6940. custom14 := &CustomData{
  6941. MsgId: "H4402290015820210330174922668",
  6942. PsnNo: "44020000001102927272",
  6943. Info: "2207",
  6944. }
  6945. customData = append(customData, custom14)
  6946. custom15 := &CustomData{
  6947. MsgId: "H44022900158202103301752362273",
  6948. PsnNo: "44020000001102942890",
  6949. Info: "2207",
  6950. }
  6951. customData = append(customData, custom15)
  6952. custom16 := &CustomData{
  6953. MsgId: "H44022900158202103301751082917",
  6954. PsnNo: "44020000001101662162",
  6955. Info: "2207",
  6956. }
  6957. customData = append(customData, custom16)
  6958. custom17 := &CustomData{
  6959. MsgId: "H44022900158202103301754147728",
  6960. PsnNo: "44020000000229014511",
  6961. Info: "2207",
  6962. }
  6963. customData = append(customData, custom17)
  6964. adminUser := c.GetAdminUserInfo()
  6965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6966. for _, item := range customData {
  6967. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6968. fmt.Println(result)
  6969. }
  6970. }
  6971. func (c *HisApiController) ReversalOtherData() {
  6972. var customData []*CustomData
  6973. custom := &CustomData{
  6974. MsgId: "H44022900158202103301714472004",
  6975. PsnNo: "44020000001101329945",
  6976. Info: "2208",
  6977. }
  6978. customData = append(customData, custom)
  6979. custom1 := &CustomData{
  6980. MsgId: "H4402290015820210330172057803",
  6981. PsnNo: "44020000001101161813",
  6982. Info: "2208",
  6983. }
  6984. customData = append(customData, custom1)
  6985. custom2 := &CustomData{
  6986. MsgId: "H44022900158202103301705198813",
  6987. PsnNo: "44190000133097375417",
  6988. Info: "2208",
  6989. }
  6990. customData = append(customData, custom2)
  6991. custom3 := &CustomData{
  6992. MsgId: "H44022900158202103301715524756",
  6993. PsnNo: "44020000001100187221",
  6994. Info: "2208",
  6995. }
  6996. customData = append(customData, custom3)
  6997. custom4 := &CustomData{
  6998. MsgId: "H44022900158202103301730376224",
  6999. PsnNo: "44020000001101959155",
  7000. Info: "2208",
  7001. }
  7002. customData = append(customData, custom4)
  7003. custom5 := &CustomData{
  7004. MsgId: "H44022900158202103301748008725",
  7005. PsnNo: "44020000001104246641",
  7006. Info: "2208",
  7007. }
  7008. customData = append(customData, custom5)
  7009. custom6 := &CustomData{
  7010. MsgId: "H44022900158202103301718096755",
  7011. PsnNo: "44020000001102211860",
  7012. Info: "2208",
  7013. }
  7014. customData = append(customData, custom6)
  7015. custom7 := &CustomData{
  7016. MsgId: "H44022900158202103301736551640",
  7017. PsnNo: "44020000001102687718",
  7018. Info: "2208",
  7019. }
  7020. customData = append(customData, custom7)
  7021. custom8 := &CustomData{
  7022. MsgId: "H44022900158202103301743097676",
  7023. PsnNo: "44020000001102127785",
  7024. Info: "2208",
  7025. }
  7026. customData = append(customData, custom8)
  7027. custom9 := &CustomData{
  7028. MsgId: "H44022900158202103301712304203",
  7029. PsnNo: "44020000001101518097",
  7030. Info: "2208",
  7031. }
  7032. customData = append(customData, custom9)
  7033. custom10 := &CustomData{
  7034. MsgId: "H44022900158202103301738448785",
  7035. PsnNo: "44020000001100500813",
  7036. Info: "2208",
  7037. }
  7038. customData = append(customData, custom10)
  7039. custom11 := &CustomData{
  7040. MsgId: "H44022900158202103301732455843",
  7041. PsnNo: "44020000001102690557",
  7042. Info: "2208",
  7043. }
  7044. customData = append(customData, custom11)
  7045. custom12 := &CustomData{
  7046. MsgId: "H44022900158202103301745421708",
  7047. PsnNo: "44020000001102211928",
  7048. Info: "2208",
  7049. }
  7050. customData = append(customData, custom12)
  7051. custom1212 := &CustomData{
  7052. MsgId: "H440229001582021033017351627",
  7053. PsnNo: "44020000001102481733",
  7054. Info: "2208",
  7055. }
  7056. customData = append(customData, custom1212)
  7057. custom13 := &CustomData{
  7058. MsgId: "H44022900158202103301740327951",
  7059. PsnNo: "44020000001103174866",
  7060. Info: "2208",
  7061. }
  7062. customData = append(customData, custom13)
  7063. custom14 := &CustomData{
  7064. MsgId: "H4402290015820210330174922668",
  7065. PsnNo: "44020000001102927272",
  7066. Info: "2208",
  7067. }
  7068. customData = append(customData, custom14)
  7069. custom15 := &CustomData{
  7070. MsgId: "H44022900158202103301752362273",
  7071. PsnNo: "44020000001102942890",
  7072. Info: "2208",
  7073. }
  7074. customData = append(customData, custom15)
  7075. custom16 := &CustomData{
  7076. MsgId: "H44022900158202103301751082917",
  7077. PsnNo: "44020000001101662162",
  7078. Info: "2208",
  7079. }
  7080. customData = append(customData, custom16)
  7081. custom17 := &CustomData{
  7082. MsgId: "H44022900158202103301754147728",
  7083. PsnNo: "44020000000229014511",
  7084. Info: "2208",
  7085. }
  7086. customData = append(customData, custom17)
  7087. adminUser := c.GetAdminUserInfo()
  7088. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7089. for _, item := range customData {
  7090. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7091. fmt.Println(result)
  7092. }
  7093. }
  7094. func PathExists(path string) (bool, error) {
  7095. _, err := os.Stat(path)
  7096. if err == nil {
  7097. return true, nil
  7098. }
  7099. if os.IsNotExist(err) {
  7100. return false, nil
  7101. }
  7102. return false, err
  7103. }
  7104. //创建文件夹
  7105. func Mkdir(dir string) {
  7106. // 创建文件夹
  7107. exist, err := PathExists(dir)
  7108. if err != nil {
  7109. fmt.Println(err.Error())
  7110. } else {
  7111. if exist {
  7112. fmt.Println(dir + "文件夹已存在!")
  7113. } else {
  7114. // 文件夹名称,权限
  7115. err := os.Mkdir(dir, os.ModePerm)
  7116. if err != nil {
  7117. fmt.Println(dir+"文件夹创建失败:", err.Error())
  7118. } else {
  7119. fmt.Println(dir + "文件夹创建成功!")
  7120. }
  7121. }
  7122. }
  7123. }
  7124. //压缩文件
  7125. func Zip(srcFile string, destZip string) error {
  7126. zipfile, err := os.Create(destZip)
  7127. if err != nil {
  7128. return err
  7129. }
  7130. defer zipfile.Close()
  7131. archive := zip.NewWriter(zipfile)
  7132. defer archive.Close()
  7133. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  7134. if err != nil {
  7135. return err
  7136. }
  7137. header, err := zip.FileInfoHeader(info)
  7138. if err != nil {
  7139. return err
  7140. }
  7141. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  7142. // header.Name = path
  7143. if info.IsDir() {
  7144. header.Name += "/"
  7145. } else {
  7146. header.Method = zip.Deflate
  7147. }
  7148. writer, err := archive.CreateHeader(header)
  7149. if err != nil {
  7150. return err
  7151. }
  7152. if !info.IsDir() {
  7153. file, err := os.Open(path)
  7154. if err != nil {
  7155. return err
  7156. }
  7157. defer file.Close()
  7158. _, err = io.Copy(writer, file)
  7159. }
  7160. return err
  7161. })
  7162. return err
  7163. }
  7164. func ReadFile(filePath string) []byte {
  7165. f, err := os.Open(filePath)
  7166. if err != nil {
  7167. fmt.Println("read file fail", err)
  7168. return nil
  7169. }
  7170. defer f.Close()
  7171. fd, err := ioutil.ReadAll(f)
  7172. if err != nil {
  7173. fmt.Println("read to fd fail", err)
  7174. return nil
  7175. }
  7176. return fd
  7177. }
  7178. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  7179. newArr = make([]*models.HisOrderInfo, 0)
  7180. for i := 0; i < len(arr); i++ {
  7181. repeat := false
  7182. for j := i + 1; j < len(arr); j++ {
  7183. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  7184. repeat = true
  7185. break
  7186. }
  7187. }
  7188. if !repeat {
  7189. newArr = append(newArr, arr[i])
  7190. }
  7191. }
  7192. return
  7193. }
  7194. func saveRegisterLog(result string) {
  7195. org_id, _ := beego.AppConfig.Int64("org_id")
  7196. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7197. dir := miConfig.OrgName + "日志"
  7198. utils.Mkdir(dir)
  7199. month := time.Unix(1557042972, 0).Format("1")
  7200. year := time.Now().Format("2006")
  7201. month = time.Now().Format("01")
  7202. day := time.Now().Format("02")
  7203. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7204. file_name := file + ".txt"
  7205. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7206. exist, _ := utils.PathExists(file_path)
  7207. if exist { //存在
  7208. fmt.Println("存在")
  7209. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7210. if err != nil {
  7211. fmt.Println("read fail")
  7212. }
  7213. content := "\r\n" + result
  7214. n, _ := f.Seek(0, 2)
  7215. _, err = f.WriteAt([]byte(content), n)
  7216. } else { //不存在
  7217. fmt.Println("文件不存在,创建文件")
  7218. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7219. defer f.Close()
  7220. if err != nil {
  7221. } else {
  7222. _, err = f.Write([]byte("记录日志"))
  7223. }
  7224. }
  7225. }
  7226. func saveLog(result string, request string, infno string, desc string) {
  7227. org_id, _ := beego.AppConfig.Int64("org_id")
  7228. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7229. dir := miConfig.OrgName + "日志"
  7230. utils.Mkdir(dir)
  7231. month := time.Unix(1557042972, 0).Format("1")
  7232. year := time.Now().Format("2006")
  7233. month = time.Now().Format("01")
  7234. day := time.Now().Format("02")
  7235. hour := time.Now().Format("15")
  7236. min := time.Now().Format("04")
  7237. sec := time.Now().Format("05")
  7238. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  7239. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7240. file_name := file + ".txt"
  7241. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7242. exist, _ := utils.PathExists(file_path)
  7243. if exist { //存在
  7244. fmt.Println("存在")
  7245. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7246. if err != nil {
  7247. fmt.Println("read fail")
  7248. }
  7249. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  7250. n, _ := f.Seek(0, 2)
  7251. _, err = f.WriteAt([]byte(content), n)
  7252. } else { //不存在
  7253. fmt.Println("文件不存在,创建文件")
  7254. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7255. defer f.Close()
  7256. if err != nil {
  7257. } else {
  7258. _, err = f.Write([]byte("记录日志"))
  7259. }
  7260. }
  7261. }
  7262. type Charset string
  7263. const (
  7264. UTF8 = Charset("UTF-8")
  7265. GB18030 = Charset("GB18030")
  7266. )
  7267. func ConvertToString(src string, srcCode string, tagCode string) string {
  7268. srcCoder := mahonia.NewDecoder(srcCode)
  7269. srcResult := srcCoder.ConvertString(src)
  7270. tagCoder := mahonia.NewDecoder(tagCode)
  7271. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  7272. result := string(cdata)
  7273. return result
  7274. }
  7275. //func (c *HisApiController)HandleCheckDetailAccount(){
  7276. // psn_no, _ := c.GetString("psn_no")
  7277. // psn_no, _ := c.GetString("psn_no")
  7278. // psn_no, _ := c.GetString("psn_no")
  7279. //
  7280. //
  7281. //
  7282. //}