his_api_controller.go 381KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  353. } else {
  354. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  356. }
  357. resp, requestErr := http.Get(api)
  358. if requestErr != nil {
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. body, ioErr := ioutil.ReadAll(resp.Body)
  363. if ioErr != nil {
  364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. var respJSON map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var status string
  375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  376. if status == "0" { //读卡成功
  377. var card_info string //卡信息
  378. var busi_card_info string
  379. var res ResultTwo //1101结果
  380. var res10265 ResultTwo10265 //1101结果
  381. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  382. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  383. fmt.Println(card_info)
  384. fmt.Println(busi_card_info)
  385. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  386. result, _ := json.Marshal(respJSON)
  387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  388. utils.ErrorLog("解析失败:%v", err)
  389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  390. return
  391. }
  392. res.ErrMsg = res10265.ErrMsg
  393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  394. res.Infcode = infocode
  395. res.Output = res10265.Output
  396. res.InfRefmsgid = res10265.InfRefmsgid
  397. if res.Infcode == 0 {
  398. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  399. if err == gorm.ErrRecordNotFound {
  400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  401. return
  402. } else if err != nil {
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  404. return
  405. } else {
  406. bas := strings.Split(card_info, "|")
  407. basNumber := bas[2]
  408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  410. infoStr := string(Iinfos)
  411. idetinfoStr := string(Idetinfos)
  412. psn := &models.HisPsn{
  413. PsnNo: res.Output.Baseinfo.PsnNo,
  414. Age: res.Output.Baseinfo.Age,
  415. PatientId: patient.ID,
  416. Certno: res.Output.Baseinfo.Certno,
  417. Brdy: res.Output.Baseinfo.Brdy,
  418. Gend: res.Output.Baseinfo.Gend,
  419. Naty: res.Output.Baseinfo.Naty,
  420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  421. PsnName: res.Output.Baseinfo.PsnName,
  422. Idetinfo: idetinfoStr,
  423. Insuinfo: infoStr,
  424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  425. CardInfo: card_info,
  426. VerifyNumber: busi_card_info,
  427. }
  428. service.CreateHisPsn(psn)
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "patient": patient,
  431. "number": basNumber,
  432. })
  433. }
  434. } else {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  436. return
  437. }
  438. } else { //读卡失败
  439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  440. return
  441. }
  442. } else {
  443. if initFlag == 0 {
  444. c.TestGetBasBaseInit()
  445. }
  446. basStr := c.GetBasBaseInfo()
  447. if len(basStr) == 0 {
  448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  449. return
  450. }
  451. fmt.Println(basStr)
  452. bas := strings.Split(basStr, "|")
  453. basNumber := bas[1]
  454. fmt.Println(basNumber)
  455. card_sn := bas[3]
  456. fmt.Println(card_sn)
  457. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  458. var dat map[string]interface{}
  459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  460. fmt.Println(dat)
  461. } else {
  462. fmt.Println(err)
  463. }
  464. userJSONBytes, _ := json.Marshal(dat)
  465. var res ResultTwo
  466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  467. utils.ErrorLog("解析失败:%v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. if res.Infcode == 0 {
  472. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  473. if err == gorm.ErrRecordNotFound {
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  475. return
  476. } else if err != nil {
  477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  478. return
  479. } else {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "patient": patient,
  482. "number": basNumber,
  483. })
  484. }
  485. } else {
  486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  487. return
  488. }
  489. break
  490. }
  491. case 2:
  492. SFZStr := c.GetSFZBaseInfo()
  493. id_card_str := strings.Split(SFZStr, "^")
  494. id_card_number := id_card_str[0]
  495. card_sn := ""
  496. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  497. var dat map[string]interface{}
  498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  499. fmt.Println(dat)
  500. } else {
  501. fmt.Println(err)
  502. }
  503. userJSONBytes, _ := json.Marshal(dat)
  504. var res ResultTwo
  505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == 0 {
  511. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  512. if err == gorm.ErrRecordNotFound {
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  514. return
  515. } else if err != nil {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  517. return
  518. } else {
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "patient": patient,
  521. "number": id_card_number,
  522. })
  523. }
  524. } else {
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  526. return
  527. }
  528. break
  529. case 3:
  530. break
  531. }
  532. }
  533. var initFlag int64 = 0
  534. func (c *HisApiController) TestGetBasBaseInit() {
  535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  536. Iinit := DllDef.MustFindProc("Init")
  537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  538. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  539. if ret != 0 {
  540. fmt.Println("SSCard的报错原因:", err)
  541. fmt.Println("SSCard的运算结果为:", ret)
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  543. return
  544. }
  545. result := int(ret)
  546. fmt.Println("SSCard的运算结果为1:", result)
  547. initFlag = 1
  548. return
  549. }
  550. func (c *HisApiController) GetSFZBaseInfo() string {
  551. DllDef := syscall.MustLoadDLL("SSCard.dll")
  552. readCard := DllDef.MustFindProc("ReadSFZ")
  553. if readCard == nil {
  554. fmt.Println("readcard is nil")
  555. readCard = DllDef.MustFindProc("ReadSFZ")
  556. }
  557. str := make([]byte, 256)
  558. str1 := make([]byte, 256)
  559. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  560. fmt.Println(r)
  561. return string(str)
  562. }
  563. func (c *HisApiController) GetBasBaseInfo() string {
  564. DllDef := syscall.MustLoadDLL("SSCard.dll")
  565. readCard := DllDef.MustFindProc("ReadCardBas")
  566. if readCard == nil {
  567. fmt.Println("readcard is nil")
  568. readCard = DllDef.MustFindProc("ReadCardBas")
  569. }
  570. str := make([]byte, 1024)
  571. str1 := make([]byte, 1024)
  572. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  573. fmt.Println(string(str1))
  574. fmt.Println(string(str))
  575. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  576. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  577. if ret2 != 0 {
  578. return ""
  579. }
  580. return string(str)
  581. }
  582. type CustomFundPay struct {
  583. FundPayType string `json:"fund_pay_type"`
  584. FundPayamt float64 `json:"fund_payamt"`
  585. }
  586. func (c *HisApiController) GetSettleList() {
  587. order_id, _ := c.GetInt64("order_id")
  588. admin_user_id, _ := c.GetInt64("admin_user_id")
  589. order, _ := service.GetHisOrderByIDTwo(order_id)
  590. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  591. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  592. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  593. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  594. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  596. if order.ID == 0 {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  598. return
  599. }
  600. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  601. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  602. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  603. fmt.Println(count)
  604. var zero string
  605. number := count + 1
  606. if number >= 1000 {
  607. zero = "0000" + strconv.FormatInt(number, 10)
  608. } else if number >= 10000 {
  609. zero = "000" + strconv.FormatInt(number, 10)
  610. } else if number >= 100000 {
  611. zero = "00" + strconv.FormatInt(number, 10)
  612. } else if number >= 1000000 {
  613. zero = "0" + strconv.FormatInt(number, 10)
  614. } else {
  615. zero = strconv.FormatInt(number, 10)
  616. }
  617. fmt.Println(zero)
  618. struct4101 := service.Struct4101{
  619. PsnNo: order.PsnNo,
  620. MdtrtId: order.MdtrtId,
  621. SetlId: order.SetlId,
  622. PsnName: order.PsnName,
  623. Gend: order.Gend,
  624. Brdy: his.Brdy,
  625. Age: his.Age,
  626. Naty: order.Naty,
  627. PatnCertType: "01",
  628. Certno: order.Certno,
  629. Prfs: "90",
  630. ConerName: roles[0].UserName,
  631. PatnRlts: "99",
  632. ConerAddr: miConfig.OrgName,
  633. ConerTel: admin.Mobile,
  634. HiType: order.Insutype,
  635. Insuplc: miConfig.InsuplcAdmdvs,
  636. MaindiagFlag: "1",
  637. BillCode: last_order.FaPiaoCode,
  638. BillNo: zero,
  639. BizSn: order.Number,
  640. PsnSelfPay: order.PsnPartAmt,
  641. PsnOwnPay: order.PsnPartAmt,
  642. AcctPay: order.AcctPay,
  643. PsnCashpay: order.PsnCashPay,
  644. HiPaymtd: "1",
  645. Hsorg: miConfig.InsuplcAdmdvs,
  646. HsorgOpter: miConfig.InsuplcAdmdvs,
  647. MedinsFillPsn: curRoles.UserName,
  648. MedinsFillDept: depart.Name,
  649. IptMedType: "2",
  650. }
  651. struct4101.SetlBegnDate = order.SetlTime
  652. struct4101.SetlEndDate = order.SetlTime
  653. time_arr := strings.Split(order.SetlTime, " ")
  654. struct4101.AdmTime = time_arr[0]
  655. struct4101.AdmEndTime = time_arr[0]
  656. var rf []CustomFundPay
  657. json.Unmarshal([]byte(order.SetlDetail), &rf)
  658. var tempFunPays []service.CustomStruct
  659. for _, item := range rf {
  660. var tempFunPay service.CustomStruct
  661. tempFunPay.FundPayamt = item.FundPayamt
  662. tempFunPay.FundPayType = item.FundPayType
  663. tempFunPays = append(tempFunPays, tempFunPay)
  664. }
  665. struct4101.CustomStruct = tempFunPays
  666. var tempDiaginfos []service.DiaginfoStructTwo
  667. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  668. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  669. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  670. var config []*models.HisXtDiagnoseConfig
  671. for _, item := range diagnosis_ids {
  672. id, _ := strconv.ParseInt(item, 10, 64)
  673. diagnosisConfig, _ := service.FindDiagnoseById(id)
  674. config = append(config, &diagnosisConfig)
  675. }
  676. for index, item := range config {
  677. if index == 0 {
  678. var tempDiaginfo service.DiaginfoStructTwo
  679. tempDiaginfo.DiagCode = item.CountryCode
  680. tempDiaginfo.DiagName = item.CountryContentName
  681. tempDiaginfo.DiagType = "1"
  682. tempDiaginfo.MaindiagFlag = "1"
  683. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  684. } else {
  685. var tempDiaginfo service.DiaginfoStructTwo
  686. tempDiaginfo.DiagCode = item.CountryCode
  687. tempDiaginfo.DiagName = item.CountryContentName
  688. tempDiaginfo.DiagType = "2"
  689. tempDiaginfo.MaindiagFlag = "0"
  690. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  691. }
  692. }
  693. struct4101.Diseinfo = tempDiaginfos
  694. sickConfigTwo, _ := service.FindSickById(his.SickType)
  695. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  696. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  697. tempOpspdiseinfo2.OprnOprtCode = ""
  698. tempOpspdiseinfo2.OprnOprtName = ""
  699. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  700. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  701. var iteminfo service.IteminfoStruct
  702. var bedCostTotal float64 = 0 //床位总费
  703. var bedCostSelfTotal float64 = 0 //床位自费
  704. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  705. var operationCostTotal float64 = 0 //手术费
  706. var operationCostSelfTotal float64 = 0 //手术费
  707. var operationCostPartSelfTotal float64 = 0 //手术费
  708. var otherCostTotal float64 = 0 //其他费用
  709. var otherCostSelfTotal float64 = 0 //其他费用
  710. var otherCostPartSelfTotal float64 = 0 //其他费用
  711. var materialCostTotal float64 = 0 //材料费
  712. var materialCostSelfTotal float64 = 0 //材料费
  713. var materialCostPartSelfTotal float64 = 0 //材料费
  714. var westernMedicineCostTotal float64 = 0 //西药费
  715. var westernMedicineCostSelfTotal float64 = 0 //西药费
  716. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  717. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  718. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  719. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  720. var checkCostTotal float64 = 0 //检查费
  721. var checkCostSelfTotal float64 = 0 //检查费
  722. var checkCostPartSelfTotal float64 = 0 //检查费
  723. var laboratoryCostTotal float64 = 0 //化验费
  724. var laboratoryCostSelfTotal float64 = 0 //化验费
  725. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  726. var treatCostTotal float64 = 0 //治疗费用
  727. var treatCostSelfTotal float64 = 0 //治疗费用
  728. var treatCostPartSelfTotal float64 = 0 //治疗费用
  729. decimal.DivisionPrecision = 2
  730. var bed_fulamt_ownpay_amt float64 = 0
  731. var operation_fulamt_ownpay_amt float64 = 0
  732. var other_fulamt_ownpay_amt float64 = 0
  733. var westernMedicine_fulamt_ownpay_amt float64 = 0
  734. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  735. var check_fulamt_ownpay_amt float64 = 0
  736. var material_fulamt_ownpay_amt float64 = 0
  737. var laboratory_fulamt_ownpay_amt float64 = 0
  738. var treat_fulamt_ownpay_amt float64 = 0
  739. var bed_claa_sunmfee float64 = 0
  740. var bed_clab_amt float64 = 0
  741. var bed_other_amt float64 = 0
  742. var operation_claa_sunmfee float64 = 0
  743. var operation_clab_amt float64 = 0
  744. var operation_other_amt float64 = 0
  745. var other_claa_sunmfee float64 = 0
  746. var other_clab_amt float64 = 0
  747. var other_other_amt float64 = 0
  748. var westernMedicine_claa_sunmfee float64 = 0
  749. var westernMedicine_clab_amt float64 = 0
  750. var westernMedicine_other_amt float64 = 0
  751. var chineseTraditional_claa_sunmfee float64 = 0
  752. var chineseTraditional_clab_amt float64 = 0
  753. var chineseTraditional_other_amt float64 = 0
  754. var check_claa_sunmfee float64 = 0
  755. var check_clab_amt float64 = 0
  756. var check_other_amt float64 = 0
  757. var material_claa_sunmfee float64 = 0
  758. var material_clab_amt float64 = 0
  759. var material_other_amt float64 = 0
  760. var laboratory_claa_sunmfee float64 = 0
  761. var laboratory_clab_amt float64 = 0
  762. var laboratory_other_amt float64 = 0
  763. var treat_claa_sunmfee float64 = 0
  764. var treat_clab_amt float64 = 0
  765. var treat_other_amt float64 = 0
  766. for _, item := range order.HisOrderInfo {
  767. if item.MedChrgitmType == "01" { //床位费
  768. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  769. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  770. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  771. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  772. if item.ChrgitmLv == "1" {
  773. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  774. }
  775. if item.ChrgitmLv == "2" {
  776. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  777. }
  778. if item.ChrgitmLv == "3" {
  779. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  780. }
  781. }
  782. if item.MedChrgitmType == "03" { //检查费
  783. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  784. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  785. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  786. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  787. if item.ChrgitmLv == "1" {
  788. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  789. }
  790. if item.ChrgitmLv == "2" {
  791. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  792. }
  793. if item.ChrgitmLv == "3" {
  794. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  795. }
  796. }
  797. if item.MedChrgitmType == "04" { //化验费
  798. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  799. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  800. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  801. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  802. if item.ChrgitmLv == "1" {
  803. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  804. }
  805. if item.ChrgitmLv == "2" {
  806. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  807. }
  808. if item.ChrgitmLv == "3" {
  809. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  810. }
  811. }
  812. if item.MedChrgitmType == "05" { //治疗费
  813. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  814. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  815. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  816. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  817. if item.ChrgitmLv == "1" {
  818. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  819. }
  820. if item.ChrgitmLv == "2" {
  821. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  822. }
  823. if item.ChrgitmLv == "3" {
  824. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  825. }
  826. }
  827. if item.MedChrgitmType == "06" { //手术费
  828. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  829. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  830. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  831. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  832. if item.ChrgitmLv == "1" {
  833. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  834. }
  835. if item.ChrgitmLv == "2" {
  836. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  837. }
  838. if item.ChrgitmLv == "3" {
  839. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  840. }
  841. }
  842. if item.MedChrgitmType == "08" { //材料费
  843. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  844. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  845. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  846. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  847. if item.ChrgitmLv == "1" {
  848. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  849. }
  850. if item.ChrgitmLv == "2" {
  851. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  852. }
  853. if item.ChrgitmLv == "3" {
  854. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  855. }
  856. }
  857. if item.MedChrgitmType == "09" { //西药费
  858. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  859. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  860. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  861. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  862. if item.ChrgitmLv == "1" {
  863. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  864. }
  865. if item.ChrgitmLv == "2" {
  866. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  867. }
  868. if item.ChrgitmLv == "3" {
  869. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  870. }
  871. }
  872. if item.MedChrgitmType == "11" { //中成费
  873. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  874. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  875. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  876. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  877. if item.ChrgitmLv == "1" {
  878. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  879. }
  880. if item.ChrgitmLv == "2" {
  881. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  882. }
  883. if item.ChrgitmLv == "3" {
  884. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  885. }
  886. }
  887. if item.MedChrgitmType == "14" { //其他费
  888. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  889. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  890. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  891. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  892. if item.ChrgitmLv == "1" {
  893. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  894. }
  895. if item.ChrgitmLv == "2" {
  896. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  897. }
  898. if item.ChrgitmLv == "3" {
  899. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  900. }
  901. }
  902. }
  903. var iteminfoStructs []service.IteminfoStruct
  904. if bedCostTotal != 0 {
  905. iteminfo.MedChrgitm = "01"
  906. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  907. iteminfo.Amt = bedCostTotal
  908. iteminfo.ClaaSumfee = bed_claa_sunmfee
  909. iteminfo.ClabAmt = bed_clab_amt
  910. iteminfo.OthAmt = bed_other_amt
  911. iteminfoStructs = append(iteminfoStructs, iteminfo)
  912. }
  913. if checkCostTotal != 0 {
  914. iteminfo.MedChrgitm = "03"
  915. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  916. iteminfo.Amt = checkCostTotal
  917. iteminfo.ClaaSumfee = check_claa_sunmfee
  918. iteminfo.ClabAmt = check_clab_amt
  919. iteminfo.OthAmt = check_other_amt
  920. iteminfoStructs = append(iteminfoStructs, iteminfo)
  921. }
  922. if laboratoryCostTotal != 0 {
  923. iteminfo.MedChrgitm = "04"
  924. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  925. iteminfo.Amt = laboratoryCostTotal
  926. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  927. iteminfo.ClabAmt = laboratory_clab_amt
  928. iteminfo.OthAmt = laboratory_other_amt
  929. iteminfoStructs = append(iteminfoStructs, iteminfo)
  930. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  931. }
  932. if treatCostTotal != 0 {
  933. iteminfo.MedChrgitm = "05"
  934. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  935. iteminfo.Amt = treatCostTotal
  936. iteminfo.ClaaSumfee = treat_claa_sunmfee
  937. iteminfo.ClabAmt = treat_clab_amt
  938. iteminfo.OthAmt = treat_other_amt
  939. iteminfoStructs = append(iteminfoStructs, iteminfo)
  940. //(struct4101.IteminfoStruct, iteminfo)
  941. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  942. }
  943. if operationCostTotal != 0 {
  944. iteminfo.MedChrgitm = "06"
  945. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  946. iteminfo.Amt = operationCostTotal
  947. iteminfo.ClaaSumfee = operation_claa_sunmfee
  948. iteminfo.ClabAmt = operation_clab_amt
  949. iteminfo.OthAmt = operation_other_amt
  950. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  951. iteminfoStructs = append(iteminfoStructs, iteminfo)
  952. }
  953. if materialCostTotal != 0 {
  954. iteminfo.MedChrgitm = "08"
  955. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  956. iteminfo.Amt = materialCostTotal
  957. iteminfo.ClaaSumfee = material_claa_sunmfee
  958. iteminfo.ClabAmt = material_clab_amt
  959. iteminfo.OthAmt = material_other_amt
  960. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  961. iteminfoStructs = append(iteminfoStructs, iteminfo)
  962. }
  963. if westernMedicineCostTotal != 0 {
  964. iteminfo.MedChrgitm = "09"
  965. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  966. iteminfo.Amt = westernMedicineCostTotal
  967. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  968. iteminfo.ClabAmt = westernMedicine_clab_amt
  969. iteminfo.OthAmt = westernMedicine_other_amt
  970. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  971. iteminfoStructs = append(iteminfoStructs, iteminfo)
  972. }
  973. if chineseTraditionalMedicineCostTotal != 0 {
  974. iteminfo.MedChrgitm = "11"
  975. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  976. iteminfo.Amt = westernMedicineCostTotal
  977. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  978. iteminfo.ClabAmt = westernMedicine_clab_amt
  979. iteminfo.OthAmt = westernMedicine_other_amt
  980. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  981. iteminfoStructs = append(iteminfoStructs, iteminfo)
  982. }
  983. if otherCostTotal != 0 {
  984. iteminfo.MedChrgitm = "14"
  985. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  986. iteminfo.Amt = otherCostTotal
  987. iteminfo.ClaaSumfee = other_claa_sunmfee
  988. iteminfo.ClabAmt = other_clab_amt
  989. iteminfo.OthAmt = other_other_amt
  990. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  991. iteminfoStructs = append(iteminfoStructs, iteminfo)
  992. }
  993. struct4101.IteminfoStruct = iteminfoStructs
  994. struct4101.Ntly = "中国"
  995. struct4101.AdmCaty = "A03.06"
  996. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  997. fmt.Println(result)
  998. var dat map[string]interface{}
  999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1000. fmt.Println(dat)
  1001. } else {
  1002. fmt.Println(err)
  1003. }
  1004. userJSONBytes, _ := json.Marshal(dat)
  1005. var res ResultSeventeen
  1006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1007. utils.ErrorLog("解析失败:%v", err)
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1009. return
  1010. }
  1011. if res.Infcode != 0 {
  1012. c.ServeSuccessJSON(map[string]interface{}{
  1013. "failed_code": -10,
  1014. "msg": res.ErrMsg,
  1015. })
  1016. return
  1017. } else {
  1018. order.FaPiaoNumber = zero
  1019. order.FaPiaoCode = last_order.FaPiaoCode
  1020. service.UpdateOrder(order)
  1021. hisFundSettleListResult := &models.HisFundSettleListResult{
  1022. Number: res.Output.SetlListId,
  1023. Status: 1,
  1024. Ctime: time.Now().Unix(),
  1025. Mtime: time.Now().Unix(),
  1026. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1027. IsUpload: 1,
  1028. OrderId: order_id,
  1029. }
  1030. service.CreateUploadRecord(hisFundSettleListResult)
  1031. c.ServeSuccessJSON(map[string]interface{}{
  1032. "msg": "上传成功",
  1033. "result": hisFundSettleListResult,
  1034. })
  1035. return
  1036. }
  1037. }
  1038. func (c *HisApiController) GetSettleListHospital() {
  1039. order_id, _ := c.GetInt64("order_id")
  1040. admin_user_id, _ := c.GetInt64("admin_user_id")
  1041. order, _ := service.GetHisOrderByIDTwo(order_id)
  1042. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1043. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1044. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1045. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1046. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1047. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1048. if order.ID == 0 {
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1050. return
  1051. }
  1052. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1053. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1054. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1055. fmt.Println(count)
  1056. var zero string
  1057. number := count + 1
  1058. if number >= 1000 {
  1059. zero = "0000" + strconv.FormatInt(number, 10)
  1060. } else if number >= 10000 {
  1061. zero = "000" + strconv.FormatInt(number, 10)
  1062. } else if number >= 100000 {
  1063. zero = "00" + strconv.FormatInt(number, 10)
  1064. } else if number >= 1000000 {
  1065. zero = "0" + strconv.FormatInt(number, 10)
  1066. } else {
  1067. zero = strconv.FormatInt(number, 10)
  1068. }
  1069. fmt.Println(zero)
  1070. struct4101 := service.Struct4101{
  1071. PsnNo: order.PsnNo,
  1072. MdtrtId: order.MdtrtId,
  1073. SetlId: order.SetlId,
  1074. PsnName: order.PsnName,
  1075. Gend: order.Gend,
  1076. Brdy: his.Brdy,
  1077. Age: int64(order.Age),
  1078. Naty: order.Naty,
  1079. PatnCertType: "01",
  1080. Certno: order.Certno,
  1081. Prfs: "90",
  1082. ConerName: roles[0].UserName,
  1083. PatnRlts: "99",
  1084. ConerAddr: miConfig.OrgName,
  1085. ConerTel: admin.Mobile,
  1086. HiType: order.Insutype,
  1087. Insuplc: miConfig.InsuplcAdmdvs,
  1088. MaindiagFlag: "1",
  1089. BillCode: last_order.FaPiaoCode,
  1090. BillNo: zero,
  1091. BizSn: order.Number,
  1092. PsnSelfPay: order.PsnPartAmt,
  1093. PsnOwnPay: order.PsnPartAmt,
  1094. AcctPay: order.AcctPay,
  1095. PsnCashpay: order.PsnCashPay,
  1096. HiPaymtd: "1",
  1097. Hsorg: miConfig.InsuplcAdmdvs,
  1098. HsorgOpter: miConfig.InsuplcAdmdvs,
  1099. MedinsFillPsn: curRoles.UserName,
  1100. MedinsFillDept: depart.Name,
  1101. IptMedType: "2",
  1102. AdmTime: his.InHosptialTime,
  1103. AdmEndTime: his.OutHosptialTime,
  1104. }
  1105. struct4101.SetlBegnDate = order.SetlTime
  1106. struct4101.SetlEndDate = order.SetlTime
  1107. var rf []CustomFundPay
  1108. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1109. var tempFunPays []service.CustomStruct
  1110. for _, item := range rf {
  1111. var tempFunPay service.CustomStruct
  1112. tempFunPay.FundPayamt = item.FundPayamt
  1113. tempFunPay.FundPayType = item.FundPayType
  1114. tempFunPays = append(tempFunPays, tempFunPay)
  1115. }
  1116. struct4101.CustomStruct = tempFunPays
  1117. var tempDiaginfos []service.DiaginfoStructTwo
  1118. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1119. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1120. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1121. var config []*models.HisXtDiagnoseConfig
  1122. for _, item := range diagnosis_ids {
  1123. id, _ := strconv.ParseInt(item, 10, 64)
  1124. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1125. config = append(config, &diagnosisConfig)
  1126. }
  1127. for index, item := range config {
  1128. if index == 0 {
  1129. var tempDiaginfo service.DiaginfoStructTwo
  1130. tempDiaginfo.DiagCode = item.CountryCode
  1131. tempDiaginfo.DiagName = item.CountryContentName
  1132. tempDiaginfo.DiagType = "1"
  1133. tempDiaginfo.MaindiagFlag = "1"
  1134. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1135. } else {
  1136. var tempDiaginfo service.DiaginfoStructTwo
  1137. tempDiaginfo.DiagCode = item.CountryCode
  1138. tempDiaginfo.DiagName = item.CountryContentName
  1139. tempDiaginfo.DiagType = "2"
  1140. tempDiaginfo.MaindiagFlag = "0"
  1141. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1142. }
  1143. }
  1144. struct4101.Diseinfo = tempDiaginfos
  1145. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1146. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1147. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1148. tempOpspdiseinfo2.OprnOprtCode = ""
  1149. tempOpspdiseinfo2.OprnOprtName = ""
  1150. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1151. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1152. var iteminfo service.IteminfoStruct
  1153. var bedCostTotal float64 = 0 //床位总费
  1154. var bedCostSelfTotal float64 = 0 //床位自费
  1155. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1156. var operationCostTotal float64 = 0 //手术费
  1157. var operationCostSelfTotal float64 = 0 //手术费
  1158. var operationCostPartSelfTotal float64 = 0 //手术费
  1159. var otherCostTotal float64 = 0 //其他费用
  1160. var otherCostSelfTotal float64 = 0 //其他费用
  1161. var otherCostPartSelfTotal float64 = 0 //其他费用
  1162. var materialCostTotal float64 = 0 //材料费
  1163. var materialCostSelfTotal float64 = 0 //材料费
  1164. var materialCostPartSelfTotal float64 = 0 //材料费
  1165. var westernMedicineCostTotal float64 = 0 //西药费
  1166. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1167. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1168. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1169. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1170. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1171. var checkCostTotal float64 = 0 //检查费
  1172. var checkCostSelfTotal float64 = 0 //检查费
  1173. var checkCostPartSelfTotal float64 = 0 //检查费
  1174. var laboratoryCostTotal float64 = 0 //化验费
  1175. var laboratoryCostSelfTotal float64 = 0 //化验费
  1176. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1177. var treatCostTotal float64 = 0 //治疗费用
  1178. var treatCostSelfTotal float64 = 0 //治疗费用
  1179. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1180. decimal.DivisionPrecision = 2
  1181. var bed_fulamt_ownpay_amt float64 = 0
  1182. var operation_fulamt_ownpay_amt float64 = 0
  1183. var other_fulamt_ownpay_amt float64 = 0
  1184. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1185. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1186. var check_fulamt_ownpay_amt float64 = 0
  1187. var material_fulamt_ownpay_amt float64 = 0
  1188. var laboratory_fulamt_ownpay_amt float64 = 0
  1189. var treat_fulamt_ownpay_amt float64 = 0
  1190. var bed_claa_sunmfee float64 = 0
  1191. var bed_clab_amt float64 = 0
  1192. var bed_other_amt float64 = 0
  1193. var operation_claa_sunmfee float64 = 0
  1194. var operation_clab_amt float64 = 0
  1195. var operation_other_amt float64 = 0
  1196. var other_claa_sunmfee float64 = 0
  1197. var other_clab_amt float64 = 0
  1198. var other_other_amt float64 = 0
  1199. var westernMedicine_claa_sunmfee float64 = 0
  1200. var westernMedicine_clab_amt float64 = 0
  1201. var westernMedicine_other_amt float64 = 0
  1202. var chineseTraditional_claa_sunmfee float64 = 0
  1203. var chineseTraditional_clab_amt float64 = 0
  1204. var chineseTraditional_other_amt float64 = 0
  1205. var check_claa_sunmfee float64 = 0
  1206. var check_clab_amt float64 = 0
  1207. var check_other_amt float64 = 0
  1208. var material_claa_sunmfee float64 = 0
  1209. var material_clab_amt float64 = 0
  1210. var material_other_amt float64 = 0
  1211. var laboratory_claa_sunmfee float64 = 0
  1212. var laboratory_clab_amt float64 = 0
  1213. var laboratory_other_amt float64 = 0
  1214. var treat_claa_sunmfee float64 = 0
  1215. var treat_clab_amt float64 = 0
  1216. var treat_other_amt float64 = 0
  1217. for _, item := range order.HisOrderInfo {
  1218. if item.MedChrgitmType == "01" { //床位费
  1219. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1220. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1221. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1222. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1223. if item.ChrgitmLv == "1" {
  1224. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1225. }
  1226. if item.ChrgitmLv == "2" {
  1227. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1228. }
  1229. if item.ChrgitmLv == "3" {
  1230. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1231. }
  1232. }
  1233. if item.MedChrgitmType == "03" { //检查费
  1234. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1235. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1236. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1237. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1238. if item.ChrgitmLv == "1" {
  1239. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1240. }
  1241. if item.ChrgitmLv == "2" {
  1242. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1243. }
  1244. if item.ChrgitmLv == "3" {
  1245. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1246. }
  1247. }
  1248. if item.MedChrgitmType == "04" { //化验费
  1249. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1250. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1251. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1252. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1253. if item.ChrgitmLv == "1" {
  1254. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1255. }
  1256. if item.ChrgitmLv == "2" {
  1257. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1258. }
  1259. if item.ChrgitmLv == "3" {
  1260. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1261. }
  1262. }
  1263. if item.MedChrgitmType == "05" { //治疗费
  1264. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1265. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1266. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1267. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1268. if item.ChrgitmLv == "1" {
  1269. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1270. }
  1271. if item.ChrgitmLv == "2" {
  1272. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1273. }
  1274. if item.ChrgitmLv == "3" {
  1275. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1276. }
  1277. }
  1278. if item.MedChrgitmType == "06" { //手术费
  1279. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1280. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1281. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1282. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1283. if item.ChrgitmLv == "1" {
  1284. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1285. }
  1286. if item.ChrgitmLv == "2" {
  1287. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1288. }
  1289. if item.ChrgitmLv == "3" {
  1290. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1291. }
  1292. }
  1293. if item.MedChrgitmType == "08" { //材料费
  1294. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1295. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1296. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1297. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1298. if item.ChrgitmLv == "1" {
  1299. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1300. }
  1301. if item.ChrgitmLv == "2" {
  1302. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1303. }
  1304. if item.ChrgitmLv == "3" {
  1305. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1306. }
  1307. }
  1308. if item.MedChrgitmType == "09" { //西药费
  1309. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1310. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1311. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1312. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1313. if item.ChrgitmLv == "1" {
  1314. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1315. }
  1316. if item.ChrgitmLv == "2" {
  1317. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1318. }
  1319. if item.ChrgitmLv == "3" {
  1320. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1321. }
  1322. }
  1323. if item.MedChrgitmType == "11" { //中成费
  1324. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1325. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1326. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1327. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1328. if item.ChrgitmLv == "1" {
  1329. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1330. }
  1331. if item.ChrgitmLv == "2" {
  1332. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1333. }
  1334. if item.ChrgitmLv == "3" {
  1335. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1336. }
  1337. }
  1338. if item.MedChrgitmType == "14" { //其他费
  1339. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1340. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1341. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1342. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1343. if item.ChrgitmLv == "1" {
  1344. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1345. }
  1346. if item.ChrgitmLv == "2" {
  1347. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1348. }
  1349. if item.ChrgitmLv == "3" {
  1350. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1351. }
  1352. }
  1353. }
  1354. var iteminfoStructs []service.IteminfoStruct
  1355. if bedCostTotal != 0 {
  1356. iteminfo.MedChrgitm = "01"
  1357. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1358. iteminfo.Amt = bedCostTotal
  1359. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1360. iteminfo.ClabAmt = bed_clab_amt
  1361. iteminfo.OthAmt = bed_other_amt
  1362. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1363. }
  1364. if checkCostTotal != 0 {
  1365. iteminfo.MedChrgitm = "03"
  1366. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1367. iteminfo.Amt = checkCostTotal
  1368. iteminfo.ClaaSumfee = check_claa_sunmfee
  1369. iteminfo.ClabAmt = check_clab_amt
  1370. iteminfo.OthAmt = check_other_amt
  1371. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1372. }
  1373. if laboratoryCostTotal != 0 {
  1374. iteminfo.MedChrgitm = "04"
  1375. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1376. iteminfo.Amt = laboratoryCostTotal
  1377. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1378. iteminfo.ClabAmt = laboratory_clab_amt
  1379. iteminfo.OthAmt = laboratory_other_amt
  1380. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1381. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1382. }
  1383. if treatCostTotal != 0 {
  1384. iteminfo.MedChrgitm = "05"
  1385. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1386. iteminfo.Amt = treatCostTotal
  1387. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1388. iteminfo.ClabAmt = treat_clab_amt
  1389. iteminfo.OthAmt = treat_other_amt
  1390. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1391. //(struct4101.IteminfoStruct, iteminfo)
  1392. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1393. }
  1394. if operationCostTotal != 0 {
  1395. iteminfo.MedChrgitm = "06"
  1396. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1397. iteminfo.Amt = operationCostTotal
  1398. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1399. iteminfo.ClabAmt = operation_clab_amt
  1400. iteminfo.OthAmt = operation_other_amt
  1401. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1402. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1403. }
  1404. if materialCostTotal != 0 {
  1405. iteminfo.MedChrgitm = "08"
  1406. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1407. iteminfo.Amt = materialCostTotal
  1408. iteminfo.ClaaSumfee = material_claa_sunmfee
  1409. iteminfo.ClabAmt = material_clab_amt
  1410. iteminfo.OthAmt = material_other_amt
  1411. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1412. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1413. }
  1414. if westernMedicineCostTotal != 0 {
  1415. iteminfo.MedChrgitm = "09"
  1416. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1417. iteminfo.Amt = westernMedicineCostTotal
  1418. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1419. iteminfo.ClabAmt = westernMedicine_clab_amt
  1420. iteminfo.OthAmt = westernMedicine_other_amt
  1421. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1422. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1423. }
  1424. if chineseTraditionalMedicineCostTotal != 0 {
  1425. iteminfo.MedChrgitm = "11"
  1426. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1427. iteminfo.Amt = westernMedicineCostTotal
  1428. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1429. iteminfo.ClabAmt = westernMedicine_clab_amt
  1430. iteminfo.OthAmt = westernMedicine_other_amt
  1431. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1432. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1433. }
  1434. if otherCostTotal != 0 {
  1435. iteminfo.MedChrgitm = "14"
  1436. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1437. iteminfo.Amt = otherCostTotal
  1438. iteminfo.ClaaSumfee = other_claa_sunmfee
  1439. iteminfo.ClabAmt = other_clab_amt
  1440. iteminfo.OthAmt = other_other_amt
  1441. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1442. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1443. }
  1444. struct4101.IteminfoStruct = iteminfoStructs
  1445. struct4101.Ntly = "中国"
  1446. struct4101.AdmCaty = "A03.06"
  1447. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1448. fmt.Println(result)
  1449. var dat map[string]interface{}
  1450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1451. fmt.Println(dat)
  1452. } else {
  1453. fmt.Println(err)
  1454. }
  1455. userJSONBytes, _ := json.Marshal(dat)
  1456. var res ResultSeventeen
  1457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1458. utils.ErrorLog("解析失败:%v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. return
  1461. }
  1462. if res.Infcode != 0 {
  1463. c.ServeSuccessJSON(map[string]interface{}{
  1464. "failed_code": -10,
  1465. "msg": res.ErrMsg,
  1466. })
  1467. return
  1468. } else {
  1469. order.FaPiaoNumber = zero
  1470. order.FaPiaoCode = last_order.FaPiaoCode
  1471. service.UpdateOrder(order)
  1472. hisFundSettleListResult := &models.HisFundSettleListResult{
  1473. Number: res.Output.SetlListId,
  1474. Status: 1,
  1475. Ctime: time.Now().Unix(),
  1476. Mtime: time.Now().Unix(),
  1477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1478. IsUpload: 1,
  1479. OrderId: order_id,
  1480. }
  1481. service.CreateUploadRecord(hisFundSettleListResult)
  1482. c.ServeSuccessJSON(map[string]interface{}{
  1483. "msg": "上传成功",
  1484. "result": hisFundSettleListResult,
  1485. })
  1486. return
  1487. }
  1488. }
  1489. func (c *HisApiController) GetBatchSettleList() {
  1490. orders, _ := service.GetAllHisOrderErr(9504, 9504)
  1491. for _, item := range orders {
  1492. order_id := item.PatientId
  1493. order, _ := service.GetHisOrderByIDTwo(order_id)
  1494. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1495. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1496. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1497. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2100)
  1498. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1499. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1500. if order.ID == 0 {
  1501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1502. return
  1503. }
  1504. if his.BalanceAccountsType == 2 {
  1505. continue
  1506. }
  1507. struct4101 := service.Struct4101{
  1508. PsnNo: order.PsnNo,
  1509. MdtrtId: order.MdtrtId,
  1510. SetlId: order.SetlId,
  1511. PsnName: order.PsnName,
  1512. Gend: order.Gend,
  1513. Brdy: his.Brdy,
  1514. Age: his.Age,
  1515. Naty: order.Naty,
  1516. PatnCertType: "01",
  1517. Certno: order.Certno,
  1518. Prfs: "90",
  1519. ConerName: roles[0].UserName,
  1520. PatnRlts: "99",
  1521. ConerAddr: miConfig.OrgName,
  1522. ConerTel: admin.Mobile,
  1523. HiType: order.Insutype,
  1524. Insuplc: his.InsuplcAdmdvs,
  1525. MaindiagFlag: "1",
  1526. BillCode: order.FaPiaoCode,
  1527. BillNo: order.FaPiaoNumber,
  1528. BizSn: order.Number,
  1529. PsnSelfPay: order.PsnPartAmt,
  1530. PsnOwnPay: order.PsnPartAmt,
  1531. AcctPay: order.AcctPay,
  1532. PsnCashpay: order.PsnCashPay,
  1533. HiPaymtd: "1",
  1534. Hsorg: his.InsuplcAdmdvs,
  1535. HsorgOpter: his.InsuplcAdmdvs,
  1536. MedinsFillPsn: curRoles.UserName,
  1537. MedinsFillDept: depart.Name,
  1538. IptMedType: "2",
  1539. }
  1540. struct4101.SetlBegnDate = order.SetlTime
  1541. struct4101.SetlEndDate = order.SetlTime
  1542. //if order.SettleType == 1 {
  1543. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1544. // dateStr := t.Format("2006-01-02")
  1545. // struct4101.SetlBegnDate = dateStr
  1546. // struct4101.SetlEndDate = dateStr
  1547. //} else {
  1548. // t := time.Unix(int64(order.SettleStartTime), 0)
  1549. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1550. // dateStartStr := t.Format("2006-01-02")
  1551. // dateEndStr := t2.Format("2006-01-02")
  1552. // struct4101.SetlBegnDate = dateStartStr
  1553. // struct4101.SetlEndDate = dateEndStr
  1554. //}
  1555. var rf []CustomFundPay
  1556. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1557. var tempFunPays []service.CustomStruct
  1558. var tempFunPay610100 service.CustomStruct
  1559. for _, item := range rf {
  1560. if item.FundPayType == "610100" {
  1561. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1562. tempFunPay610100.FundPayType = item.FundPayType
  1563. } else {
  1564. var tempFunPay service.CustomStruct
  1565. tempFunPay.FundPayamt = item.FundPayamt
  1566. tempFunPay.FundPayType = item.FundPayType
  1567. tempFunPays = append(tempFunPays, tempFunPay)
  1568. }
  1569. }
  1570. tempFunPays = append(tempFunPays, tempFunPay610100)
  1571. struct4101.CustomStruct = tempFunPays
  1572. var tempDiaginfos []service.DiaginfoStructTwo
  1573. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1574. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1575. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1576. var config []*models.HisXtDiagnoseConfig
  1577. for _, item := range diagnosis_ids {
  1578. id, _ := strconv.ParseInt(item, 10, 64)
  1579. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1580. config = append(config, &diagnosisConfig)
  1581. }
  1582. for index, item := range config {
  1583. if index == 0 {
  1584. var tempDiaginfo service.DiaginfoStructTwo
  1585. tempDiaginfo.DiagCode = item.CountryCode
  1586. tempDiaginfo.DiagName = item.CountryContentName
  1587. tempDiaginfo.DiagType = "1"
  1588. tempDiaginfo.MaindiagFlag = "1"
  1589. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1590. } else {
  1591. var tempDiaginfo service.DiaginfoStructTwo
  1592. tempDiaginfo.DiagCode = item.CountryCode
  1593. tempDiaginfo.DiagName = item.CountryContentName
  1594. tempDiaginfo.DiagType = "2"
  1595. tempDiaginfo.MaindiagFlag = "0"
  1596. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1597. }
  1598. }
  1599. struct4101.Diseinfo = tempDiaginfos
  1600. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1601. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1602. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1603. tempOpspdiseinfo2.OprnOprtCode = ""
  1604. tempOpspdiseinfo2.OprnOprtName = ""
  1605. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1606. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1607. var iteminfo service.IteminfoStruct
  1608. var bedCostTotal float64 = 0 //床位总费
  1609. var bedCostSelfTotal float64 = 0 //床位自费
  1610. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1611. var examineCostTotal float64 = 0 //诊查总费
  1612. var examineCostSelfTotal float64 = 0 //诊查自费
  1613. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1614. var nursingCostTotal float64 = 0 //护理总费
  1615. var nursingCostSelfTotal float64 = 0 //护理自费
  1616. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1617. var chineseMedicineCostTotal float64 = 0 //中成药
  1618. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1619. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1620. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1621. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1622. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1623. var registerCostTotal float64 = 0 //一般诊疗费
  1624. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1625. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1626. var operationCostTotal float64 = 0 //手术费
  1627. var operationCostSelfTotal float64 = 0 //手术费
  1628. var operationCostPartSelfTotal float64 = 0 //手术费
  1629. var otherCostTotal float64 = 0 //其他费用
  1630. var otherCostSelfTotal float64 = 0 //其他费用
  1631. var otherCostPartSelfTotal float64 = 0 //其他费用
  1632. var materialCostTotal float64 = 0 //材料费
  1633. var materialCostSelfTotal float64 = 0 //材料费
  1634. var materialCostPartSelfTotal float64 = 0 //材料费
  1635. var westernMedicineCostTotal float64 = 0 //西药费
  1636. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1637. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1638. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1639. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1640. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1641. var checkCostTotal float64 = 0 //检查费
  1642. var checkCostSelfTotal float64 = 0 //检查费
  1643. var checkCostPartSelfTotal float64 = 0 //检查费
  1644. var laboratoryCostTotal float64 = 0 //化验费
  1645. var laboratoryCostSelfTotal float64 = 0 //化验费
  1646. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1647. var treatCostTotal float64 = 0 //治疗费用
  1648. var treatCostSelfTotal float64 = 0 //治疗费用
  1649. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1650. decimal.DivisionPrecision = 2
  1651. var bed_fulamt_ownpay_amt float64 = 0
  1652. var examine_fulamt_ownpay_amt float64 = 0
  1653. var nursing_fulamt_ownpay_amt float64 = 0
  1654. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1655. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1656. var register_fulamt_ownpay_amt float64 = 0
  1657. var operation_fulamt_ownpay_amt float64 = 0
  1658. var other_fulamt_ownpay_amt float64 = 0
  1659. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1660. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1661. var check_fulamt_ownpay_amt float64 = 0
  1662. var material_fulamt_ownpay_amt float64 = 0
  1663. var laboratory_fulamt_ownpay_amt float64 = 0
  1664. var treat_fulamt_ownpay_amt float64 = 0
  1665. var bed_claa_sunmfee float64 = 0
  1666. var bed_clab_amt float64 = 0
  1667. var bed_other_amt float64 = 0
  1668. var examine_claa_sunmfee float64 = 0
  1669. var examine_clab_amt float64 = 0
  1670. var examine_other_amt float64 = 0
  1671. var nursing_claa_sunmfee float64 = 0
  1672. var nursing_clab_amt float64 = 0
  1673. var nursing_other_amt float64 = 0
  1674. var chinese_medicine_claa_sunmfee float64 = 0
  1675. var chinese_medicine_clab_amt float64 = 0
  1676. var chinese_medicine_other_amt float64 = 0
  1677. var commonly_treatment_claa_sunmfee float64 = 0
  1678. var commonly_treatment_clab_amt float64 = 0
  1679. var commonly_treatment_other_amt float64 = 0
  1680. var operation_claa_sunmfee float64 = 0
  1681. var operation_clab_amt float64 = 0
  1682. var operation_other_amt float64 = 0
  1683. var other_claa_sunmfee float64 = 0
  1684. var other_clab_amt float64 = 0
  1685. var other_other_amt float64 = 0
  1686. var westernMedicine_claa_sunmfee float64 = 0
  1687. var westernMedicine_clab_amt float64 = 0
  1688. var westernMedicine_other_amt float64 = 0
  1689. var chineseTraditional_claa_sunmfee float64 = 0
  1690. var chineseTraditional_clab_amt float64 = 0
  1691. var chineseTraditional_other_amt float64 = 0
  1692. var check_claa_sunmfee float64 = 0
  1693. var check_clab_amt float64 = 0
  1694. var check_other_amt float64 = 0
  1695. var material_claa_sunmfee float64 = 0
  1696. var material_clab_amt float64 = 0
  1697. var material_other_amt float64 = 0
  1698. var laboratory_claa_sunmfee float64 = 0
  1699. var laboratory_clab_amt float64 = 0
  1700. var laboratory_other_amt float64 = 0
  1701. var treat_claa_sunmfee float64 = 0
  1702. var treat_clab_amt float64 = 0
  1703. var treat_other_amt float64 = 0
  1704. var register_claa_sunmfee float64 = 0
  1705. var register_clab_amt float64 = 0
  1706. var register_other_amt float64 = 0
  1707. for _, item := range order.HisOrderInfo {
  1708. if item.MedChrgitmType == "01" { //床位费
  1709. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1710. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1711. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1712. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1713. if item.ChrgitmLv == "1" {
  1714. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1715. }
  1716. if item.ChrgitmLv == "2" {
  1717. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1718. }
  1719. if item.ChrgitmLv == "3" {
  1720. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1721. }
  1722. }
  1723. if item.MedChrgitmType == "02" { //诊查
  1724. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1725. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1726. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1727. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1728. if item.ChrgitmLv == "1" {
  1729. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1730. }
  1731. if item.ChrgitmLv == "2" {
  1732. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1733. }
  1734. if item.ChrgitmLv == "3" {
  1735. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1736. }
  1737. }
  1738. if item.MedChrgitmType == "03" { //检查费
  1739. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1740. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1741. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1742. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1743. if item.ChrgitmLv == "1" {
  1744. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1745. }
  1746. if item.ChrgitmLv == "2" {
  1747. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1748. }
  1749. if item.ChrgitmLv == "3" {
  1750. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1751. }
  1752. }
  1753. if item.MedChrgitmType == "04" { //化验费
  1754. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1755. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1756. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1757. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1758. if item.ChrgitmLv == "1" {
  1759. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1760. }
  1761. if item.ChrgitmLv == "2" {
  1762. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1763. }
  1764. if item.ChrgitmLv == "3" {
  1765. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1766. }
  1767. }
  1768. if item.MedChrgitmType == "05" { //治疗费
  1769. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1770. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1771. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1772. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1773. if item.ChrgitmLv == "1" {
  1774. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1775. }
  1776. if item.ChrgitmLv == "2" {
  1777. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1778. }
  1779. if item.ChrgitmLv == "3" {
  1780. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1781. }
  1782. }
  1783. if item.MedChrgitmType == "06" { //手术费
  1784. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1785. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1786. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1787. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1788. if item.ChrgitmLv == "1" {
  1789. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1790. }
  1791. if item.ChrgitmLv == "2" {
  1792. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1793. }
  1794. if item.ChrgitmLv == "3" {
  1795. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1796. }
  1797. }
  1798. if item.MedChrgitmType == "07" { //手术费
  1799. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1800. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1801. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1802. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1803. if item.ChrgitmLv == "1" {
  1804. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1805. }
  1806. if item.ChrgitmLv == "2" {
  1807. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1808. }
  1809. if item.ChrgitmLv == "3" {
  1810. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1811. }
  1812. }
  1813. if item.MedChrgitmType == "08" { //材料费
  1814. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1815. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1816. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1817. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1818. if item.ChrgitmLv == "1" {
  1819. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1820. }
  1821. if item.ChrgitmLv == "2" {
  1822. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1823. }
  1824. if item.ChrgitmLv == "3" {
  1825. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1826. }
  1827. }
  1828. if item.MedChrgitmType == "09" { //西药费
  1829. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1830. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1831. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1832. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1833. if item.ChrgitmLv == "1" {
  1834. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1835. }
  1836. if item.ChrgitmLv == "2" {
  1837. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1838. }
  1839. if item.ChrgitmLv == "3" {
  1840. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1841. }
  1842. }
  1843. if item.MedChrgitmType == "10" { //中药饮片
  1844. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1845. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1846. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1847. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1848. if item.ChrgitmLv == "1" {
  1849. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1850. }
  1851. if item.ChrgitmLv == "2" {
  1852. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1853. }
  1854. if item.ChrgitmLv == "3" {
  1855. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1856. }
  1857. }
  1858. if item.MedChrgitmType == "11" { //中成费
  1859. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1860. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1861. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1862. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1863. if item.ChrgitmLv == "1" {
  1864. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1865. }
  1866. if item.ChrgitmLv == "2" {
  1867. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1868. }
  1869. if item.ChrgitmLv == "3" {
  1870. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1871. }
  1872. }
  1873. if item.MedChrgitmType == "12" { //中成费
  1874. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1875. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1876. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1877. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1878. if item.ChrgitmLv == "1" {
  1879. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1880. }
  1881. if item.ChrgitmLv == "2" {
  1882. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1883. }
  1884. if item.ChrgitmLv == "3" {
  1885. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1886. }
  1887. }
  1888. if item.MedChrgitmType == "13" { //中成费
  1889. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1890. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1891. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1892. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1893. if item.ChrgitmLv == "1" {
  1894. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1895. }
  1896. if item.ChrgitmLv == "2" {
  1897. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1898. }
  1899. if item.ChrgitmLv == "3" {
  1900. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1901. }
  1902. }
  1903. if item.MedChrgitmType == "14" { //其他费
  1904. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1905. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1906. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1907. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1908. if item.ChrgitmLv == "1" {
  1909. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1910. }
  1911. if item.ChrgitmLv == "2" {
  1912. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1913. }
  1914. if item.ChrgitmLv == "3" {
  1915. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1916. }
  1917. }
  1918. }
  1919. var iteminfoStructs []service.IteminfoStruct
  1920. if bedCostTotal != 0 {
  1921. iteminfo.MedChrgitm = "01"
  1922. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1923. iteminfo.Amt = bedCostTotal
  1924. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1925. iteminfo.ClabAmt = bed_clab_amt
  1926. iteminfo.OthAmt = bed_other_amt
  1927. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1928. }
  1929. if examineCostTotal != 0 {
  1930. iteminfo.MedChrgitm = "02"
  1931. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1932. iteminfo.Amt = examineCostTotal
  1933. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1934. iteminfo.ClabAmt = examine_clab_amt
  1935. iteminfo.OthAmt = examine_other_amt
  1936. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1937. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1938. }
  1939. if checkCostTotal != 0 {
  1940. iteminfo.MedChrgitm = "03"
  1941. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1942. iteminfo.Amt = checkCostTotal
  1943. iteminfo.ClaaSumfee = check_claa_sunmfee
  1944. iteminfo.ClabAmt = check_clab_amt
  1945. iteminfo.OthAmt = check_other_amt
  1946. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1947. }
  1948. if laboratoryCostTotal != 0 {
  1949. iteminfo.MedChrgitm = "04"
  1950. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1951. iteminfo.Amt = laboratoryCostTotal
  1952. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1953. iteminfo.ClabAmt = laboratory_clab_amt
  1954. iteminfo.OthAmt = laboratory_other_amt
  1955. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1956. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1957. }
  1958. if treatCostTotal != 0 {
  1959. iteminfo.MedChrgitm = "05"
  1960. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1961. iteminfo.Amt = treatCostTotal
  1962. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1963. iteminfo.ClabAmt = treat_clab_amt
  1964. iteminfo.OthAmt = treat_other_amt
  1965. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1966. //(struct4101.IteminfoStruct, iteminfo)
  1967. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1968. }
  1969. if operationCostTotal != 0 {
  1970. iteminfo.MedChrgitm = "06"
  1971. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1972. iteminfo.Amt = operationCostTotal
  1973. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1974. iteminfo.ClabAmt = operation_clab_amt
  1975. iteminfo.OthAmt = operation_other_amt
  1976. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1977. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1978. }
  1979. if nursingCostTotal != 0 {
  1980. iteminfo.MedChrgitm = "07"
  1981. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1982. iteminfo.Amt = nursingCostTotal
  1983. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1984. iteminfo.ClabAmt = nursing_clab_amt
  1985. iteminfo.OthAmt = nursing_other_amt
  1986. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1987. }
  1988. if materialCostTotal != 0 {
  1989. iteminfo.MedChrgitm = "08"
  1990. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1991. iteminfo.Amt = materialCostTotal
  1992. iteminfo.ClaaSumfee = material_claa_sunmfee
  1993. iteminfo.ClabAmt = material_clab_amt
  1994. iteminfo.OthAmt = material_other_amt
  1995. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1996. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1997. }
  1998. if westernMedicineCostTotal != 0 {
  1999. iteminfo.MedChrgitm = "09"
  2000. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2001. iteminfo.Amt = westernMedicineCostTotal
  2002. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2003. iteminfo.ClabAmt = westernMedicine_clab_amt
  2004. iteminfo.OthAmt = westernMedicine_other_amt
  2005. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2006. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2007. }
  2008. if chineseMedicineCostTotal != 0 {
  2009. iteminfo.MedChrgitm = "10"
  2010. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2011. iteminfo.Amt = chineseMedicineCostTotal
  2012. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2013. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2014. iteminfo.OthAmt = chinese_medicine_other_amt
  2015. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2016. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2017. }
  2018. if chineseTraditionalMedicineCostTotal != 0 {
  2019. iteminfo.MedChrgitm = "11"
  2020. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2021. iteminfo.Amt = westernMedicineCostTotal
  2022. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2023. iteminfo.ClabAmt = westernMedicine_clab_amt
  2024. iteminfo.OthAmt = westernMedicine_other_amt
  2025. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2027. }
  2028. if commonlyTreatmentCostTotal != 0 {
  2029. iteminfo.MedChrgitm = "12"
  2030. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2031. iteminfo.Amt = commonlyTreatmentCostTotal
  2032. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2033. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2034. iteminfo.OthAmt = commonly_treatment_other_amt
  2035. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2036. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2037. }
  2038. if registerCostTotal != 0 {
  2039. iteminfo.MedChrgitm = "13"
  2040. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2041. iteminfo.Amt = registerCostTotal
  2042. iteminfo.ClaaSumfee = register_claa_sunmfee
  2043. iteminfo.ClabAmt = register_clab_amt
  2044. iteminfo.OthAmt = register_other_amt
  2045. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2046. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2047. }
  2048. if otherCostTotal != 0 {
  2049. iteminfo.MedChrgitm = "14"
  2050. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2051. iteminfo.Amt = otherCostTotal
  2052. iteminfo.ClaaSumfee = other_claa_sunmfee
  2053. iteminfo.ClabAmt = other_clab_amt
  2054. iteminfo.OthAmt = other_other_amt
  2055. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2056. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2057. }
  2058. struct4101.IteminfoStruct = iteminfoStructs
  2059. struct4101.Ntly = "中国"
  2060. struct4101.AdmCaty = "A03.06"
  2061. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2062. fmt.Println(result)
  2063. var dat map[string]interface{}
  2064. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2065. fmt.Println(dat)
  2066. } else {
  2067. fmt.Println(err)
  2068. }
  2069. userJSONBytes, _ := json.Marshal(dat)
  2070. var res ResultSeventeen
  2071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2072. utils.ErrorLog("解析失败:%v", err)
  2073. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2074. adminUser := c.GetAdminUserInfo()
  2075. errlog := &models.HisOrderError{
  2076. UserOrgId: adminUser.CurrentOrgId,
  2077. Ctime: time.Now().Unix(),
  2078. Mtime: time.Now().Unix(),
  2079. ErrMsg: res.ErrMsg + "解析失败",
  2080. Status: 1,
  2081. PatientId: order_id,
  2082. Stage: 2000,
  2083. }
  2084. service.CreateErrMsgLog(errlog)
  2085. continue
  2086. }
  2087. if res.Infcode != 0 {
  2088. adminUser := c.GetAdminUserInfo()
  2089. errlog := &models.HisOrderError{
  2090. UserOrgId: adminUser.CurrentOrgId,
  2091. Ctime: time.Now().Unix(),
  2092. Mtime: time.Now().Unix(),
  2093. ErrMsg: res.ErrMsg,
  2094. Status: 1,
  2095. PatientId: order_id,
  2096. Stage: 9505,
  2097. }
  2098. service.CreateErrMsgLog(errlog)
  2099. continue
  2100. } else {
  2101. hisFundSettleListResult := &models.HisFundSettleListResult{
  2102. Number: res.Output.SetlListId,
  2103. Status: 1,
  2104. Ctime: time.Now().Unix(),
  2105. Mtime: time.Now().Unix(),
  2106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2107. IsUpload: 1,
  2108. OrderId: order_id,
  2109. }
  2110. service.CreateUploadRecord(hisFundSettleListResult)
  2111. continue
  2112. }
  2113. }
  2114. }
  2115. func (c *HisApiController) GetOrgInfo() {
  2116. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2117. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2118. }
  2119. func (c *HisApiController) GetHisPatientInfo() {
  2120. medical_insurance_card := c.GetString("medical_insurance_card")
  2121. id_card_type, _ := c.GetInt64("id_card_type")
  2122. id_card := c.GetString("id_card")
  2123. adminInfo := c.GetAdminUserInfo()
  2124. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2125. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2126. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2127. IdCardNo := ""
  2128. if id_card_type == 1 {
  2129. IdCardNo = medical_insurance_card
  2130. } else if id_card_type == 2 {
  2131. IdCardNo = id_card
  2132. }
  2133. if config.IsOpen == 1 {
  2134. 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
  2135. resp, requestErr := http.Get(api)
  2136. if requestErr != nil {
  2137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2138. return
  2139. }
  2140. defer resp.Body.Close()
  2141. body, ioErr := ioutil.ReadAll(resp.Body)
  2142. if ioErr != nil {
  2143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2145. return
  2146. }
  2147. var respJSON map[string]interface{}
  2148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. return
  2152. }
  2153. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2154. userJSONBytes, _ := json.Marshal(userJSON)
  2155. var res ResultTwo
  2156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2157. utils.ErrorLog("解析失败:%v", err)
  2158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2159. return
  2160. }
  2161. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2162. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2163. infoStr := string(Iinfos)
  2164. idetinfoStr := string(Idetinfos)
  2165. if res.Infcode == 0 {
  2166. his := models.VMHisPatient{
  2167. Status: 1,
  2168. Ctime: time.Now().Unix(),
  2169. Mtime: time.Now().Unix(),
  2170. PsnNo: res.Output.Baseinfo.PsnNo,
  2171. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2172. Certno: res.Output.Baseinfo.Certno,
  2173. PsnName: res.Output.Baseinfo.PsnName,
  2174. Gend: res.Output.Baseinfo.Gend,
  2175. Naty: res.Output.Baseinfo.Naty,
  2176. Brdy: res.Output.Baseinfo.Brdy,
  2177. Age: res.Output.Baseinfo.Age,
  2178. Iinfo: infoStr,
  2179. Idetinfo: idetinfoStr,
  2180. UserOrgId: adminInfo.CurrentOrgId,
  2181. IsReturn: 1,
  2182. IdCardType: id_card_type,
  2183. }
  2184. c.ServeSuccessJSON(map[string]interface{}{
  2185. "info": his,
  2186. })
  2187. } else {
  2188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2189. return
  2190. }
  2191. }
  2192. }
  2193. //func GetBasBaseInfo() (jsonStr string, err error) {
  2194. //
  2195. // handle := syscall.NewLazyDLL("SSCard.dll")
  2196. // add := handle.NewProc("ReadCardBas")
  2197. // str := make([]byte, 1024)
  2198. // str1 := make([]byte, 1024)
  2199. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2200. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2201. //
  2202. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2203. //
  2204. // fmt.Println("> Add(4,5)的结果为:", ret)
  2205. // handle.Release()
  2206. //
  2207. // return "", nil
  2208. //
  2209. //}
  2210. //func GetQRBaseInfo() (jsonStr string, err error) {
  2211. // handle := syscall.LoadDLL("SSCard.dll")
  2212. // ReadCardBas := handle.FindProc("GetQRBase")
  2213. //
  2214. // str := make([]byte, 256)
  2215. // str1 := make([]byte, 256)
  2216. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2217. //
  2218. // fmt.Println(string(str))
  2219. // fmt.Println(r)
  2220. // return string(str), nil
  2221. //}
  2222. //func CardInit() int {
  2223. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2224. // add := DllTestDef.MustFindProc("Init")
  2225. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2226. // if err != nil {
  2227. // fmt.Println("SSCard的运算结果为:", ret)
  2228. // }
  2229. // result := int(ret)
  2230. // return result
  2231. //}
  2232. //func CardInit() int {
  2233. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2234. // if err != nil {
  2235. // fmt.Println("SSCard的运算结果为:", ret)
  2236. // }
  2237. // fmt.Println(err)
  2238. // result := int(ret)
  2239. // return result
  2240. //}
  2241. func IntPtr(n int) uintptr {
  2242. return uintptr(n)
  2243. }
  2244. func StrPtr(s string) uintptr {
  2245. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2246. }
  2247. type Result2001 struct {
  2248. Cainfo interface{} `json:"cainfo"`
  2249. ErrMsg string `json:"err_msg"`
  2250. InfRefmsgid string `json:"inf_refmsgid"`
  2251. Infcode int64 `json:"infcode"`
  2252. Output struct {
  2253. Trtinfo struct {
  2254. PsnNo string `json:"psn_no"`
  2255. TrtChkType string `json:"trt_chk_type"`
  2256. FundPayType string `json:"fund_pay_type"`
  2257. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2258. Begndate string `json:"begndate"`
  2259. Enddate string `json:"enddate"`
  2260. TrtChkRslt string `json:"trt_chk_rslt"`
  2261. } `json:"trtinfo"`
  2262. } `json:"output"`
  2263. RefmsgTime string `json:"refmsg_time"`
  2264. RespondTime string `json:"respond_time"`
  2265. Signtype interface{} `json:"signtype"`
  2266. WarnMsg interface{} `json:"warn_msg"`
  2267. }
  2268. type Result2001Org10265 struct {
  2269. Cainfo interface{} `json:"cainfo"`
  2270. ErrMsg string `json:"err_msg"`
  2271. InfRefmsgid string `json:"inf_refmsgid"`
  2272. Infcode string `json:"infcode"`
  2273. Output struct {
  2274. Trtinfo struct {
  2275. PsnNo string `json:"psn_no"`
  2276. TrtChkType string `json:"trt_chk_type"`
  2277. FundPayType string `json:"fund_pay_type"`
  2278. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2279. Begndate string `json:"begndate"`
  2280. Enddate string `json:"enddate"`
  2281. TrtChkRslt string `json:"trt_chk_rslt"`
  2282. } `json:"trtinfo"`
  2283. } `json:"output"`
  2284. RefmsgTime string `json:"refmsg_time"`
  2285. RespondTime string `json:"respond_time"`
  2286. Signtype interface{} `json:"signtype"`
  2287. WarnMsg interface{} `json:"warn_msg"`
  2288. }
  2289. type ResultTwo struct {
  2290. ErrMsg string `json:"err_msg"`
  2291. InfRefmsgid string `json:"inf_refmsgid"`
  2292. Infcode int64 `json:"infcode"`
  2293. Output struct {
  2294. Baseinfo struct {
  2295. Age float64 `json:"age"`
  2296. Brdy string `json:"brdy"`
  2297. Certno string `json:"certno"`
  2298. Gend string `json:"gend"`
  2299. Naty string `json:"naty"`
  2300. PsnCertType string `json:"psn_cert_type"`
  2301. PsnName string `json:"psn_name"`
  2302. PsnNo string `json:"psn_no"`
  2303. } `json:"baseinfo"`
  2304. Idetinfo []interface{} `json:"idetinfo"`
  2305. Iinfo []struct {
  2306. Balc float64 `json:"balc"`
  2307. CvlservFlag string `json:"cvlserv_flag"`
  2308. EmpName string `json:"emp_name"`
  2309. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2310. Insutype string `json:"insutype"`
  2311. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2312. PausInsuDate string `json:"paus_insu_date"`
  2313. PsnInsuDate string `json:"psn_insu_date"`
  2314. PsnInsuStas string `json:"psn_insu_stas"`
  2315. PsnType string `json:"psn_type"`
  2316. } `json:"insuinfo"`
  2317. } `json:"output"`
  2318. RefmsgTime string `json:"refmsg_time"`
  2319. RespondTime string `json:"respond_time"`
  2320. Signtype interface{} `json:"signtype"`
  2321. WarnInfo interface{} `json:"warn_info"`
  2322. }
  2323. type ResultTwo10265 struct {
  2324. ErrMsg string `json:"err_msg"`
  2325. InfRefmsgid string `json:"inf_refmsgid"`
  2326. Infcode string `json:"infcode"`
  2327. Output struct {
  2328. Baseinfo struct {
  2329. Age float64 `json:"age"`
  2330. Brdy string `json:"brdy"`
  2331. Certno string `json:"certno"`
  2332. Gend string `json:"gend"`
  2333. Naty string `json:"naty"`
  2334. PsnCertType string `json:"psn_cert_type"`
  2335. PsnName string `json:"psn_name"`
  2336. PsnNo string `json:"psn_no"`
  2337. } `json:"baseinfo"`
  2338. Idetinfo []interface{} `json:"idetinfo"`
  2339. Iinfo []struct {
  2340. Balc float64 `json:"balc"`
  2341. CvlservFlag string `json:"cvlserv_flag"`
  2342. EmpName string `json:"emp_name"`
  2343. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2344. Insutype string `json:"insutype"`
  2345. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2346. PausInsuDate string `json:"paus_insu_date"`
  2347. PsnInsuDate string `json:"psn_insu_date"`
  2348. PsnInsuStas string `json:"psn_insu_stas"`
  2349. PsnType string `json:"psn_type"`
  2350. } `json:"insuinfo"`
  2351. } `json:"output"`
  2352. RefmsgTime string `json:"refmsg_time"`
  2353. RespondTime string `json:"respond_time"`
  2354. Signtype interface{} `json:"signtype"`
  2355. WarnInfo interface{} `json:"warn_info"`
  2356. }
  2357. type ResultThree struct {
  2358. Cainfo interface{} `json:"cainfo"`
  2359. ErrMsg string `json:"err_msg"`
  2360. InfRefmsgid string `json:"inf_refmsgid"`
  2361. Infcode int64 `json:"infcode"`
  2362. Output struct {
  2363. Data struct {
  2364. IptOtpNo string `json:"ipt_otp_no"`
  2365. MdtrtID string `json:"mdtrt_id"`
  2366. PsnNo string `json:"psn_no"`
  2367. } `json:"data"`
  2368. } `json:"output"`
  2369. RefmsgTime string `json:"refmsg_time"`
  2370. RespondTime string `json:"respond_time"`
  2371. Signtype interface{} `json:"signtype"`
  2372. WarnMsg interface{} `json:"warn_msg"`
  2373. }
  2374. type ResultThree10265 struct {
  2375. Cainfo interface{} `json:"cainfo"`
  2376. ErrMsg string `json:"err_msg"`
  2377. InfRefmsgid string `json:"inf_refmsgid"`
  2378. Infcode string `json:"infcode"`
  2379. Output struct {
  2380. Data struct {
  2381. IptOtpNo string `json:"ipt_otp_no"`
  2382. MdtrtID string `json:"mdtrt_id"`
  2383. PsnNo string `json:"psn_no"`
  2384. } `json:"data"`
  2385. } `json:"output"`
  2386. RefmsgTime string `json:"refmsg_time"`
  2387. RespondTime string `json:"respond_time"`
  2388. Signtype interface{} `json:"signtype"`
  2389. WarnMsg interface{} `json:"warn_msg"`
  2390. }
  2391. type ResultFour struct {
  2392. Cainfo string `json:"cainfo"`
  2393. ErrMsg string `json:"err_msg"`
  2394. InfRefmsgid string `json:"inf_refmsgid"`
  2395. Infcode int64 `json:"infcode"`
  2396. Output struct {
  2397. Result []struct {
  2398. BasMednFlag string `json:"bas_medn_flag"`
  2399. ChldMedcFlag string `json:"chld_medc_flag"`
  2400. ChrgitmLv string `json:"chrgitm_lv"`
  2401. Cnt float64 `json:"cnt"`
  2402. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2403. DrtReimFlag string `json:"drt_reim_flag"`
  2404. FeedetlSn string `json:"feedetl_sn"`
  2405. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2406. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2407. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2408. ListSpItemFlag string `json:"list_sp_item_flag"`
  2409. LmtUsedFlag string `json:"lmt_used_flag"`
  2410. MedChrgitmType string `json:"med_chrgitm_type"`
  2411. Memo string `json:"memo"`
  2412. OverlmtAmt float64 `json:"overlmt_amt"`
  2413. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2414. Pric float64 `json:"pric"`
  2415. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2416. SelfpayProp float64 `json:"selfpay_prop"`
  2417. } `json:"result"`
  2418. } `json:"output"`
  2419. RefmsgTime string `json:"refmsg_time"`
  2420. RespondTime string `json:"respond_time"`
  2421. Signtype string `json:"signtype"`
  2422. WarnMsg string `json:"warn_msg"`
  2423. }
  2424. type ResultFour10265 struct {
  2425. Cainfo string `json:"cainfo"`
  2426. ErrMsg string `json:"err_msg"`
  2427. InfRefmsgid string `json:"inf_refmsgid"`
  2428. Infcode string `json:"infcode"`
  2429. Output struct {
  2430. Result []struct {
  2431. BasMednFlag string `json:"bas_medn_flag"`
  2432. ChldMedcFlag string `json:"chld_medc_flag"`
  2433. ChrgitmLv string `json:"chrgitm_lv"`
  2434. Cnt float64 `json:"cnt"`
  2435. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2436. DrtReimFlag string `json:"drt_reim_flag"`
  2437. FeedetlSn string `json:"feedetl_sn"`
  2438. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2439. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2440. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2441. ListSpItemFlag string `json:"list_sp_item_flag"`
  2442. LmtUsedFlag string `json:"lmt_used_flag"`
  2443. MedChrgitmType string `json:"med_chrgitm_type"`
  2444. Memo string `json:"memo"`
  2445. OverlmtAmt float64 `json:"overlmt_amt"`
  2446. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2447. Pric float64 `json:"pric"`
  2448. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2449. SelfpayProp float64 `json:"selfpay_prop"`
  2450. } `json:"result"`
  2451. } `json:"output"`
  2452. RefmsgTime string `json:"refmsg_time"`
  2453. RespondTime string `json:"respond_time"`
  2454. Signtype string `json:"signtype"`
  2455. WarnMsg string `json:"warn_msg"`
  2456. }
  2457. type ResultFive struct {
  2458. Balc float64 `json:"balc"`
  2459. CvlservFlag string `json:"cvlserv_flag"`
  2460. EmpName string `json:"emp_name"`
  2461. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2462. Insutype string `json:"insutype"`
  2463. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2464. PausInsuDate string `json:"paus_insu_date"`
  2465. PsnInsuDate string `json:"psn_insu_date"`
  2466. PsnInsuStas string `json:"psn_insu_stas"`
  2467. PsnType string `json:"psn_type"`
  2468. }
  2469. type ResultSix struct {
  2470. Cainfo interface{} `json:"cainfo"`
  2471. ErrMsg string `json:"err_msg"`
  2472. InfRefmsgid string `json:"inf_refmsgid"`
  2473. Infcode int64 `json:"infcode"`
  2474. Output struct {
  2475. } `json:"output"`
  2476. RefmsgTime string `json:"refmsg_time"`
  2477. RespondTime string `json:"respond_time"`
  2478. Signtype interface{} `json:"signtype"`
  2479. WarnMsg interface{} `json:"warn_msg"`
  2480. }
  2481. type ResultSix10265 struct {
  2482. Cainfo interface{} `json:"cainfo"`
  2483. ErrMsg string `json:"err_msg"`
  2484. InfRefmsgid string `json:"inf_refmsgid"`
  2485. Infcode string `json:"infcode"`
  2486. Output struct {
  2487. } `json:"output"`
  2488. RefmsgTime string `json:"refmsg_time"`
  2489. RespondTime string `json:"respond_time"`
  2490. Signtype interface{} `json:"signtype"`
  2491. WarnMsg interface{} `json:"warn_msg"`
  2492. }
  2493. type ResultSeven struct {
  2494. Cainfo string `json:"cainfo"`
  2495. ErrMsg string `json:"err_msg"`
  2496. InfRefmsgid string `json:"inf_refmsgid"`
  2497. Infcode int64 `json:"infcode"`
  2498. Output struct {
  2499. Setldetail []interface{} `json:"setldetail"`
  2500. Setlinfo struct {
  2501. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2502. AcctPay float64 `json:"acct_pay"`
  2503. ActPayDedc float64 `json:"act_pay_dedc"`
  2504. Age float64 `json:"age"`
  2505. Balc float64 `json:"balc"`
  2506. Brdy string `json:"brdy"`
  2507. Certno string `json:"certno"`
  2508. ClrOptins string `json:"clr_optins"`
  2509. ClrType string `json:"clr_type"`
  2510. ClrWay string `json:"clr_way"`
  2511. CvlservFlag string `json:"cvlserv_flag"`
  2512. CvlservPay float64 `json:"cvlserv_pay"`
  2513. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2514. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2515. Gend string `json:"gend"`
  2516. HifesPay float64 `json:"hifes_pay"`
  2517. HifmiPay float64 `json:"hifmi_pay"`
  2518. HifpPay float64 `json:"hifp_pay"`
  2519. HospPartAmt float64 `json:"hosp_part_amt"`
  2520. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2521. Insutype string `json:"insutype"`
  2522. MafPay float64 `json:"maf_pay"`
  2523. MdtrtCertType string `json:"mdtrt_cert_type"`
  2524. HifobPay float64 `json:"hifob_pay"`
  2525. MdtrtID string `json:"mdtrt_id"`
  2526. MedType string `json:"med_type"`
  2527. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2528. MedinsSetlID string `json:"medins_setl_id"`
  2529. Naty string `json:"naty"`
  2530. OthPay float64 `json:"oth_pay"`
  2531. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2532. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2533. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2534. PsnCashPay float64 `json:"psn_cash_pay"`
  2535. PsnCertType string `json:"psn_cert_type"`
  2536. PsnName string `json:"psn_name"`
  2537. PsnNo string `json:"psn_no"`
  2538. PsnPartAmt float64 `json:"psn_part_amt"`
  2539. PsnType string `json:"psn_type"`
  2540. SetlID string `json:"setl_id"`
  2541. SetlTime string `json:"setl_time"`
  2542. } `json:"setlinfo"`
  2543. } `json:"output"`
  2544. RefmsgTime string `json:"refmsg_time"`
  2545. RespondTime string `json:"respond_time"`
  2546. Signtype interface{} `json:"signtype"`
  2547. WarnMsg interface{} `json:"warn_msg"`
  2548. }
  2549. type ResultSeven10265 struct {
  2550. Cainfo string `json:"cainfo"`
  2551. ErrMsg string `json:"err_msg"`
  2552. InfRefmsgid string `json:"inf_refmsgid"`
  2553. Infcode string `json:"infcode"`
  2554. Output struct {
  2555. Setldetail []interface{} `json:"setldetail"`
  2556. Setlinfo struct {
  2557. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2558. AcctPay float64 `json:"acct_pay"`
  2559. ActPayDedc float64 `json:"act_pay_dedc"`
  2560. Age float64 `json:"age"`
  2561. Balc float64 `json:"balc"`
  2562. Brdy string `json:"brdy"`
  2563. Certno string `json:"certno"`
  2564. ClrOptins string `json:"clr_optins"`
  2565. ClrType string `json:"clr_type"`
  2566. ClrWay string `json:"clr_way"`
  2567. CvlservFlag string `json:"cvlserv_flag"`
  2568. CvlservPay float64 `json:"cvlserv_pay"`
  2569. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2570. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2571. Gend string `json:"gend"`
  2572. HifesPay float64 `json:"hifes_pay"`
  2573. HifmiPay float64 `json:"hifmi_pay"`
  2574. HifpPay float64 `json:"hifp_pay"`
  2575. HospPartAmt float64 `json:"hosp_part_amt"`
  2576. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2577. Insutype string `json:"insutype"`
  2578. MafPay float64 `json:"maf_pay"`
  2579. MdtrtCertType string `json:"mdtrt_cert_type"`
  2580. HifobPay float64 `json:"hifob_pay"`
  2581. MdtrtID string `json:"mdtrt_id"`
  2582. MedType string `json:"med_type"`
  2583. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2584. MedinsSetlID string `json:"medins_setl_id"`
  2585. Naty string `json:"naty"`
  2586. OthPay float64 `json:"oth_pay"`
  2587. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2588. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2589. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2590. PsnCashPay float64 `json:"psn_cash_pay"`
  2591. PsnCertType string `json:"psn_cert_type"`
  2592. PsnName string `json:"psn_name"`
  2593. PsnNo string `json:"psn_no"`
  2594. PsnPartAmt float64 `json:"psn_part_amt"`
  2595. PsnType string `json:"psn_type"`
  2596. SetlID string `json:"setl_id"`
  2597. SetlTime string `json:"setl_time"`
  2598. } `json:"setlinfo"`
  2599. } `json:"output"`
  2600. RefmsgTime string `json:"refmsg_time"`
  2601. RespondTime string `json:"respond_time"`
  2602. Signtype interface{} `json:"signtype"`
  2603. WarnMsg interface{} `json:"warn_msg"`
  2604. }
  2605. type ResultEight struct {
  2606. Cainfo string `json:"cainfo"`
  2607. ErrMsg string `json:"err_msg"`
  2608. InfRefmsgid string `json:"inf_refmsgid"`
  2609. Infcode int64 `json:"infcode"`
  2610. Output struct {
  2611. Stmtinfo struct {
  2612. SetlOptins string `json:"setl_optins"`
  2613. StmtRslt string `json:"stmt_rslt"`
  2614. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2615. } `json:"stmtinfo"`
  2616. } `json:"output"`
  2617. RefmsgTime string `json:"refmsg_time"`
  2618. RespondTime string `json:"respond_time"`
  2619. Signtype interface{} `json:"signtype"`
  2620. WarnMsg interface{} `json:"warn_msg"`
  2621. }
  2622. type ResultEightFor10188 struct {
  2623. Cainfo string `json:"cainfo"`
  2624. ErrMsg string `json:"err_msg"`
  2625. InfRefmsgid string `json:"inf_refmsgid"`
  2626. Infcode string `json:"infcode"`
  2627. Output struct {
  2628. Stmtinfo struct {
  2629. SetlOptins string `json:"setl_optins"`
  2630. StmtRslt string `json:"stmt_rslt"`
  2631. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2632. } `json:"stmtinfo"`
  2633. } `json:"output"`
  2634. RefmsgTime string `json:"refmsg_time"`
  2635. RespondTime string `json:"respond_time"`
  2636. Signtype interface{} `json:"signtype"`
  2637. WarnMsg interface{} `json:"warn_msg"`
  2638. }
  2639. type ResultNine struct {
  2640. Cainfo string `json:"cainfo"`
  2641. ErrMsg string `json:"err_msg"`
  2642. InfRefmsgid string `json:"inf_refmsgid"`
  2643. Infcode int64 `json:"infcode"`
  2644. Output struct {
  2645. FileQuryNo string `json:"file_qury_no"`
  2646. } `json:"output"`
  2647. RefmsgTime string `json:"refmsg_time"`
  2648. RespondTime string `json:"respond_time"`
  2649. Signtype interface{} `json:"signtype"`
  2650. WarnMsg interface{} `json:"warn_msg"`
  2651. }
  2652. type ResultTen struct {
  2653. Cainfo string `json:"cainfo"`
  2654. ErrMsg string `json:"err_msg"`
  2655. InfRefmsgid string `json:"inf_refmsgid"`
  2656. Infcode int64 `json:"infcode"`
  2657. Output struct {
  2658. DldEndtime string `json:"dld_endtime"`
  2659. FileQuryNo string `json:"file_qury_no"`
  2660. Filename string `json:"filename"`
  2661. } `json:"output"`
  2662. RefmsgTime string `json:"refmsg_time"`
  2663. RespondTime string `json:"respond_time"`
  2664. Signtype interface{} `json:"signtype"`
  2665. WarnMsg interface{} `json:"warn_msg"`
  2666. }
  2667. //type Autogenerated struct {
  2668. // Output struct {
  2669. // Setlinfo struct {
  2670. // SetlTime string `json:"setl_time"`
  2671. // CvlservPay float64 `json:"cvlserv_pay"`
  2672. // Year string `json:"year"`
  2673. // MedType string `json:"med_type"`
  2674. // PsnPay float64 `json:"psn_pay"`
  2675. // OpterID string `json:"opter_id"`
  2676. // Begndate string `json:"begndate"`
  2677. // FlxempeFlag string `json:"flxempe_flag"`
  2678. // HifmiPay float64 `json:"hifmi_pay"`
  2679. // PsnNo string `json:"psn_no"`
  2680. // ActPayDedc float64 `json:"act_pay_dedc"`
  2681. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2682. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2683. // ClrWay string `json:"clr_way"`
  2684. // OthPay float64 `json:"oth_pay"`
  2685. // Gend string `json:"gend"`
  2686. // MdtrtID string `json:"mdtrt_id"`
  2687. // AcctPay float64 `json:"acct_pay"`
  2688. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2689. // Insutype string `json:"insutype"`
  2690. // Invono interface{} `json:"invono"`
  2691. // Enddate string `json:"enddate"`
  2692. // CashPayamt float64 `json:"cash_payamt"`
  2693. // PsnType string `json:"psn_type"`
  2694. // FixmedinsName string `json:"fixmedins_name"`
  2695. // HifpPay float64 `json:"hifp_pay"`
  2696. // NewFlag interface{} `json:"new_flag"`
  2697. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2698. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2699. // PayLoc string `json:"pay_loc"`
  2700. // ClrType string `json:"clr_type"`
  2701. // RefdSetlFlag string `json:"refd_setl_flag"`
  2702. // CvlservFlag string `json:"cvlserv_flag"`
  2703. // EmpName string `json:"emp_name"`
  2704. // Brdy string `json:"brdy"`
  2705. // Naty string `json:"naty"`
  2706. // Certno string `json:"certno"`
  2707. // DiseCode string `json:"dise_code"`
  2708. // FixmedinsCode string `json:"fixmedins_code"`
  2709. // DedcHospLv string `json:"dedc_hosp_lv"`
  2710. // OpterName string `json:"opter_name"`
  2711. // Balc float64 `json:"balc"`
  2712. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2713. // PsnCertType string `json:"psn_cert_type"`
  2714. // HifobPay float64 `json:"hifob_pay"`
  2715. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2716. // HifesPay float64 `json:"hifes_pay"`
  2717. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2718. // OptTime string `json:"opt_time"`
  2719. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2720. // SetlID string `json:"setl_id"`
  2721. // MafPay float64 `json:"maf_pay"`
  2722. // PsnName string `json:"psn_name"`
  2723. // InsuOptins interface{} `json:"insu_optins"`
  2724. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2725. // ClrOptins string `json:"clr_optins"`
  2726. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2727. // DiseName string `json:"dise_name"`
  2728. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2729. // Age float64 `json:"age"`
  2730. // DtrtCertType string `json:"dtrt_cert_type"`
  2731. // HospLv string `json:"hosp_lv"`
  2732. // } `json:"setlinfo"`
  2733. // Setldetail []struct {
  2734. // FundPayType string `json:"fund_pay_type"`
  2735. // FundPayamt float64 `json:"fund_payamt"`
  2736. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2737. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2738. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2739. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2740. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2741. // } `json:"setldetail"`
  2742. // } `json:"output"`
  2743. // Infcode int `json:"infcode"`
  2744. // WarnMsg interface{} `json:"warn_msg"`
  2745. // Cainfo interface{} `json:"cainfo"`
  2746. // ErrMsg interface{} `json:"err_msg"`
  2747. // RefmsgTime string `json:"refmsg_time"`
  2748. // Signtype interface{} `json:"signtype"`
  2749. // RespondTime string `json:"respond_time"`
  2750. // InfRefmsgid string `json:"inf_refmsgid"`
  2751. //}
  2752. type ResultEleven struct {
  2753. Cainfo string `json:"cainfo"`
  2754. ErrMsg string `json:"err_msg"`
  2755. InfRefmsgid string `json:"inf_refmsgid"`
  2756. Infcode int64 `json:"infcode"`
  2757. Output struct {
  2758. Setlinfo struct {
  2759. SetlTime string `json:"setl_time"`
  2760. CvlservPay float64 `json:"cvlserv_pay"`
  2761. Year string `json:"year"`
  2762. MedType string `json:"med_type"`
  2763. PsnPay float64 `json:"psn_pay"`
  2764. OpterID string `json:"opter_id"`
  2765. Begndate string `json:"begndate"`
  2766. FlxempeFlag string `json:"flxempe_flag"`
  2767. HifmiPay float64 `json:"hifmi_pay"`
  2768. PsnNo string `json:"psn_no"`
  2769. ActPayDedc float64 `json:"act_pay_dedc"`
  2770. MedinsSetlID interface{} `json:"medins_setl_id"`
  2771. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2772. ClrWay string `json:"clr_way"`
  2773. OthPay float64 `json:"oth_pay"`
  2774. Gend string `json:"gend"`
  2775. MdtrtID string `json:"mdtrt_id"`
  2776. AcctPay float64 `json:"acct_pay"`
  2777. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2778. Insutype string `json:"insutype"`
  2779. Invono interface{} `json:"invono"`
  2780. Enddate string `json:"enddate"`
  2781. CashPayamt float64 `json:"cash_payamt"`
  2782. PsnType string `json:"psn_type"`
  2783. FixmedinsName string `json:"fixmedins_name"`
  2784. HifpPay float64 `json:"hifp_pay"`
  2785. NewFlag interface{} `json:"new_flag"`
  2786. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2787. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2788. PayLoc string `json:"pay_loc"`
  2789. ClrType string `json:"clr_type"`
  2790. RefdSetlFlag string `json:"refd_setl_flag"`
  2791. CvlservFlag string `json:"cvlserv_flag"`
  2792. EmpName string `json:"emp_name"`
  2793. Brdy string `json:"brdy"`
  2794. Naty string `json:"naty"`
  2795. Certno string `json:"certno"`
  2796. DiseCode string `json:"dise_code"`
  2797. FixmedinsCode string `json:"fixmedins_code"`
  2798. DedcHospLv string `json:"dedc_hosp_lv"`
  2799. OpterName string `json:"opter_name"`
  2800. Balc float64 `json:"balc"`
  2801. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2802. PsnCertType string `json:"psn_cert_type"`
  2803. HifobPay float64 `json:"hifob_pay"`
  2804. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2805. HifesPay float64 `json:"hifes_pay"`
  2806. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2807. OptTime string `json:"opt_time"`
  2808. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2809. SetlID string `json:"setl_id"`
  2810. MafPay float64 `json:"maf_pay"`
  2811. PsnName string `json:"psn_name"`
  2812. InsuOptins interface{} `json:"insu_optins"`
  2813. PrefFundPay interface{} `json:"pref_fund_pay"`
  2814. ClrOptins string `json:"clr_optins"`
  2815. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2816. DiseName string `json:"dise_name"`
  2817. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2818. Age float64 `json:"age"`
  2819. DtrtCertType string `json:"dtrt_cert_type"`
  2820. HospLv string `json:"hosp_lv"`
  2821. } `json:"setlinfo"`
  2822. } `json:"output"`
  2823. RefmsgTime string `json:"refmsg_time"`
  2824. RespondTime string `json:"respond_time"`
  2825. Signtype interface{} `json:"signtype"`
  2826. WarnMsg interface{} `json:"warn_msg"`
  2827. }
  2828. type ResultEleven10265 struct {
  2829. Cainfo string `json:"cainfo"`
  2830. ErrMsg string `json:"err_msg"`
  2831. InfRefmsgid string `json:"inf_refmsgid"`
  2832. Infcode string `json:"infcode"`
  2833. Output struct {
  2834. Setlinfo struct {
  2835. SetlTime string `json:"setl_time"`
  2836. CvlservPay float64 `json:"cvlserv_pay"`
  2837. Year string `json:"year"`
  2838. MedType string `json:"med_type"`
  2839. PsnPay float64 `json:"psn_pay"`
  2840. OpterID string `json:"opter_id"`
  2841. Begndate string `json:"begndate"`
  2842. FlxempeFlag string `json:"flxempe_flag"`
  2843. HifmiPay float64 `json:"hifmi_pay"`
  2844. PsnNo string `json:"psn_no"`
  2845. ActPayDedc float64 `json:"act_pay_dedc"`
  2846. MedinsSetlID interface{} `json:"medins_setl_id"`
  2847. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2848. ClrWay string `json:"clr_way"`
  2849. OthPay float64 `json:"oth_pay"`
  2850. Gend string `json:"gend"`
  2851. MdtrtID string `json:"mdtrt_id"`
  2852. AcctPay float64 `json:"acct_pay"`
  2853. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2854. Insutype string `json:"insutype"`
  2855. Invono interface{} `json:"invono"`
  2856. Enddate string `json:"enddate"`
  2857. CashPayamt float64 `json:"cash_payamt"`
  2858. PsnType string `json:"psn_type"`
  2859. FixmedinsName string `json:"fixmedins_name"`
  2860. HifpPay float64 `json:"hifp_pay"`
  2861. NewFlag interface{} `json:"new_flag"`
  2862. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2863. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2864. PayLoc string `json:"pay_loc"`
  2865. ClrType string `json:"clr_type"`
  2866. RefdSetlFlag string `json:"refd_setl_flag"`
  2867. CvlservFlag string `json:"cvlserv_flag"`
  2868. EmpName string `json:"emp_name"`
  2869. Brdy string `json:"brdy"`
  2870. Naty string `json:"naty"`
  2871. Certno string `json:"certno"`
  2872. DiseCode string `json:"dise_code"`
  2873. FixmedinsCode string `json:"fixmedins_code"`
  2874. DedcHospLv string `json:"dedc_hosp_lv"`
  2875. OpterName string `json:"opter_name"`
  2876. Balc float64 `json:"balc"`
  2877. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2878. PsnCertType string `json:"psn_cert_type"`
  2879. HifobPay float64 `json:"hifob_pay"`
  2880. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2881. HifesPay float64 `json:"hifes_pay"`
  2882. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2883. OptTime string `json:"opt_time"`
  2884. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2885. SetlID string `json:"setl_id"`
  2886. MafPay float64 `json:"maf_pay"`
  2887. PsnName string `json:"psn_name"`
  2888. InsuOptins interface{} `json:"insu_optins"`
  2889. PrefFundPay interface{} `json:"pref_fund_pay"`
  2890. ClrOptins string `json:"clr_optins"`
  2891. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2892. DiseName string `json:"dise_name"`
  2893. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2894. Age float64 `json:"age"`
  2895. DtrtCertType string `json:"dtrt_cert_type"`
  2896. HospLv string `json:"hosp_lv"`
  2897. } `json:"setlinfo"`
  2898. } `json:"output"`
  2899. RefmsgTime string `json:"refmsg_time"`
  2900. RespondTime string `json:"respond_time"`
  2901. Signtype interface{} `json:"signtype"`
  2902. WarnMsg interface{} `json:"warn_msg"`
  2903. }
  2904. type ResultTwelve struct {
  2905. Cainfo string `json:"cainfo"`
  2906. ErrMsg string `json:"err_msg"`
  2907. InfRefmsgid string `json:"inf_refmsgid"`
  2908. Infcode int64 `json:"infcode"`
  2909. Output struct {
  2910. MdtrtId string `json:"mdtrt_id"`
  2911. ChrgBchno string `json:"chrg_bchno"`
  2912. PsnNo string `json:"psn_no"`
  2913. } `json:"output"`
  2914. RefmsgTime string `json:"refmsg_time"`
  2915. RespondTime string `json:"respond_time"`
  2916. Signtype interface{} `json:"signtype"`
  2917. WarnMsg interface{} `json:"warn_msg"`
  2918. }
  2919. type ResultThirteen struct {
  2920. ErrMsg string `json:"err_msg"`
  2921. InfRefmsgid string `json:"inf_refmsgid"`
  2922. Infcode int64 `json:"infcode"`
  2923. Output struct {
  2924. Result struct {
  2925. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2926. } `json:"result"`
  2927. } `json:"output"`
  2928. RefmsgTime string `json:"refmsg_time"`
  2929. RespondTime string `json:"respond_time"`
  2930. Signtype interface{} `json:"signtype"`
  2931. WarnInfo interface{} `json:"warn_info"`
  2932. }
  2933. type ResultThirteen10265 struct {
  2934. ErrMsg string `json:"err_msg"`
  2935. InfRefmsgid string `json:"inf_refmsgid"`
  2936. Infcode string `json:"infcode"`
  2937. Output struct {
  2938. Result struct {
  2939. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2940. } `json:"result"`
  2941. } `json:"output"`
  2942. RefmsgTime string `json:"refmsg_time"`
  2943. RespondTime string `json:"respond_time"`
  2944. Signtype interface{} `json:"signtype"`
  2945. WarnInfo interface{} `json:"warn_info"`
  2946. }
  2947. type ResultFourteen struct {
  2948. ErrMsg string `json:"err_msg"`
  2949. InfRefmsgid string `json:"inf_refmsgid"`
  2950. Infcode int64 `json:"infcode"`
  2951. Output struct {
  2952. } `json:"output"`
  2953. RefmsgTime string `json:"refmsg_time"`
  2954. RespondTime string `json:"respond_time"`
  2955. Signtype interface{} `json:"signtype"`
  2956. WarnInfo interface{} `json:"warn_info"`
  2957. }
  2958. type ResultFourteen10265 struct {
  2959. ErrMsg string `json:"err_msg"`
  2960. InfRefmsgid string `json:"inf_refmsgid"`
  2961. Infcode string `json:"infcode"`
  2962. Output struct {
  2963. } `json:"output"`
  2964. RefmsgTime string `json:"refmsg_time"`
  2965. RespondTime string `json:"respond_time"`
  2966. Signtype interface{} `json:"signtype"`
  2967. WarnInfo interface{} `json:"warn_info"`
  2968. }
  2969. type ResultSixteen struct {
  2970. Cainfo string `json:"cainfo"`
  2971. ErrMsg string `json:"err_msg"`
  2972. InfRefmsgid string `json:"inf_refmsgid"`
  2973. Infcode int64 `json:"infcode"`
  2974. Output struct {
  2975. Setldetail []interface{} `json:"setldetail"`
  2976. Setlinfo struct {
  2977. MdtrtID string `json:"mdtrt_id"`
  2978. SetlID string `json:"setl_id"`
  2979. ClrOptins string `json:"clr_optins"`
  2980. SetlTime string `json:"setl_time"`
  2981. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2982. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2983. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2984. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2985. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2986. ActPayDedc float64 `json:"act_pay_dedc"`
  2987. HifpPay float64 `json:"hifp_pay"`
  2988. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2989. Lfpay float64 `json:"selfpay"`
  2990. CvlservPay float64 `json:"cvlserv_pay"`
  2991. HifesPay float64 `json:"hifes_pay"`
  2992. HifmiPay float64 `json:"hifmi_pay"`
  2993. HifobPay float64 `json:"hifob_pay"`
  2994. MafPay float64 `json:"maf_pay"`
  2995. OthPay float64 `json:"oth_pay"`
  2996. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2997. PsnPartAmt float64 `json:"psn_part_amt"`
  2998. AcctPay float64 `json:"acct_pay"`
  2999. Balc float64 `json:"balc"`
  3000. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3001. HospPartAmt float64 `json:"hosp_part_amt"`
  3002. MedinsSetlID string `json:"medins_setl_id"`
  3003. PdnCashPay string `json:"pdn_cash_pay"`
  3004. } `json:"setlinfo"`
  3005. } `json:"output"`
  3006. RefmsgTime string `json:"refmsg_time"`
  3007. RespondTime string `json:"respond_time"`
  3008. Signtype interface{} `json:"signtype"`
  3009. WarnMsg interface{} `json:"warn_msg"`
  3010. }
  3011. type ResultSixteen10265 struct {
  3012. Cainfo string `json:"cainfo"`
  3013. ErrMsg string `json:"err_msg"`
  3014. InfRefmsgid string `json:"inf_refmsgid"`
  3015. Infcode string `json:"infcode"`
  3016. Output struct {
  3017. Setldetail []interface{} `json:"setldetail"`
  3018. Setlinfo struct {
  3019. MdtrtID string `json:"mdtrt_id"`
  3020. SetlID string `json:"setl_id"`
  3021. ClrOptins string `json:"clr_optins"`
  3022. SetlTime string `json:"setl_time"`
  3023. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3024. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3025. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3026. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3027. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3028. ActPayDedc float64 `json:"act_pay_dedc"`
  3029. HifpPay float64 `json:"hifp_pay"`
  3030. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3031. Lfpay float64 `json:"selfpay"`
  3032. CvlservPay float64 `json:"cvlserv_pay"`
  3033. HifesPay float64 `json:"hifes_pay"`
  3034. HifmiPay float64 `json:"hifmi_pay"`
  3035. HifobPay float64 `json:"hifob_pay"`
  3036. MafPay float64 `json:"maf_pay"`
  3037. OthPay float64 `json:"oth_pay"`
  3038. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3039. PsnPartAmt float64 `json:"psn_part_amt"`
  3040. AcctPay float64 `json:"acct_pay"`
  3041. Balc float64 `json:"balc"`
  3042. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3043. HospPartAmt float64 `json:"hosp_part_amt"`
  3044. MedinsSetlID string `json:"medins_setl_id"`
  3045. PdnCashPay string `json:"pdn_cash_pay"`
  3046. } `json:"setlinfo"`
  3047. } `json:"output"`
  3048. RefmsgTime string `json:"refmsg_time"`
  3049. RespondTime string `json:"respond_time"`
  3050. Signtype interface{} `json:"signtype"`
  3051. WarnMsg interface{} `json:"warn_msg"`
  3052. }
  3053. type ResultSeventeen struct {
  3054. ErrMsg string `json:"err_msg"`
  3055. InfRefmsgid string `json:"inf_refmsgid"`
  3056. Infcode int64 `json:"infcode"`
  3057. Output struct {
  3058. SetlListId string `json:"setl_list_id"`
  3059. } `json:"output"`
  3060. RefmsgTime string `json:"refmsg_time"`
  3061. RespondTime string `json:"respond_time"`
  3062. Signtype string `json:"signtype"`
  3063. WarnInfo string `json:"warn_info"`
  3064. }
  3065. type Result90991 struct {
  3066. ErrMsg string `json:"err_msg"`
  3067. InfRefmsgid string `json:"inf_refmsgid"`
  3068. Infcode int64 `json:"infcode"`
  3069. Output struct {
  3070. Result struct {
  3071. PsnNo string `json:"psn_no"`
  3072. CardStat string `json:"card_stat"`
  3073. Certno string `json:"certno"`
  3074. PsnName string `json:"psn_name"`
  3075. CheckStat string `json:"check_stat"`
  3076. } `json:"result"`
  3077. } `json:"output"`
  3078. RefmsgTime string `json:"refmsg_time"`
  3079. RespondTime string `json:"respond_time"`
  3080. Signtype interface{} `json:"signtype"`
  3081. WarnInfo interface{} `json:"warn_info"`
  3082. }
  3083. type Result90100 struct {
  3084. ErrMsg string `json:"err_msg"`
  3085. InfRefmsgid string `json:"inf_refmsgid"`
  3086. Infcode int64 `json:"infcode"`
  3087. Output struct {
  3088. PoolareaNo string `json:"poolarea_no"`
  3089. PoolareaNoName string `json:"poolarea_no_name"`
  3090. Insutype string `json:"insutype"`
  3091. InsutypeName string `json:"insutype_name"`
  3092. ClctType string `json:"clct_type"`
  3093. ClctTypeName string `json:"clct_type_name"`
  3094. ClctFlag string `json:"clct_flag"`
  3095. ClctFlagName string `json:"clct_flag_name"`
  3096. AccrymBegn string `json:"accrym_begn"`
  3097. AccrymEnd string `json:"accrym_end"`
  3098. ClctTime string `json:"clct_time"`
  3099. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3100. } `json:"output"`
  3101. RefmsgTime string `json:"refmsg_time"`
  3102. RespondTime string `json:"respond_time"`
  3103. Signtype interface{} `json:"signtype"`
  3104. WarnInfo interface{} `json:"warn_info"`
  3105. }
  3106. type Custom struct {
  3107. DetItemFeeSumamt string
  3108. Cut string
  3109. FeedetlSn string
  3110. Price string
  3111. MedListCodg string
  3112. Type int64
  3113. AdviceId int64
  3114. ProjectId int64
  3115. ItemId int64
  3116. }
  3117. type Result5301 struct {
  3118. ErrMsg string `json:"err_msg"`
  3119. InfRefmsgid string `json:"inf_refmsgid"`
  3120. Infcode int64 `json:"infcode"`
  3121. Output struct {
  3122. Result []struct {
  3123. OpspDiseCode string `json:"opsp_dise_code"`
  3124. OpspDiseName string `json:"opsp_dise_name"`
  3125. Begndate string `json:"begndate"`
  3126. Enddate string `json:"enddate"`
  3127. } `json:"feedetail"`
  3128. } `json:"output"`
  3129. RefmsgTime string `json:"refmsg_time"`
  3130. RespondTime string `json:"respond_time"`
  3131. Signtype interface{} `json:"signtype"`
  3132. WarnInfo interface{} `json:"warn_info"`
  3133. }
  3134. type Result5301For10265 struct {
  3135. ErrMsg string `json:"err_msg"`
  3136. InfRefmsgid string `json:"inf_refmsgid"`
  3137. Infcode string `json:"infcode"`
  3138. Output struct {
  3139. Result []struct {
  3140. OpspDiseCode string `json:"opsp_dise_code"`
  3141. OpspDiseName string `json:"opsp_dise_name"`
  3142. Begndate string `json:"begndate"`
  3143. Enddate string `json:"enddate"`
  3144. } `json:"feedetail"`
  3145. } `json:"output"`
  3146. RefmsgTime string `json:"refmsg_time"`
  3147. RespondTime string `json:"respond_time"`
  3148. Signtype interface{} `json:"signtype"`
  3149. WarnInfo interface{} `json:"warn_info"`
  3150. }
  3151. //获取个人信息----挂号-----上传就诊信息
  3152. func (c *HisApiController) GetRegisterInfo() {
  3153. id, _ := c.GetInt64("id")
  3154. record_time := c.GetString("record_time")
  3155. settlementValue, _ := c.GetInt64("settlement_value")
  3156. medical_insurance_card := c.GetString("medical_insurance_card")
  3157. name := c.GetString("name")
  3158. id_card_type, _ := c.GetInt64("id_card_type")
  3159. certificates, _ := c.GetInt64("certificates")
  3160. medical_care, _ := c.GetInt64("medical_care")
  3161. birthday := c.GetString("birthday")
  3162. id_card := c.GetString("id_card")
  3163. register_type, _ := c.GetInt64("register")
  3164. doctor, _ := c.GetInt64("doctor")
  3165. department, _ := c.GetInt64("department")
  3166. gender, _ := c.GetInt64("sex")
  3167. registration_fee, _ := c.GetFloat("registration_fee")
  3168. medical_expenses, _ := c.GetFloat("medical_expenses")
  3169. social_type, _ := c.GetInt64("social_type")
  3170. med_type := c.GetString("social_type")
  3171. admin_user_id, _ := c.GetInt64("admin_user_id")
  3172. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3173. timeLayout := "2006-01-02"
  3174. loc, _ := time.LoadLocation("Local")
  3175. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3176. birthUnix := birthdays.Unix()
  3177. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3178. if err != nil {
  3179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3180. return
  3181. }
  3182. recordDateTime := theTime.Unix()
  3183. adminInfo := c.GetAdminUserInfo()
  3184. var patient service.Patients
  3185. if id == 0 {
  3186. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3187. } else {
  3188. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3189. }
  3190. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3191. if patientPrescription.ID == 0 {
  3192. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3193. }
  3194. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3195. if patient.ID == 0 {
  3196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3197. return
  3198. }
  3199. if len(patient.IdCardNo) == 0 {
  3200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3201. return
  3202. }
  3203. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3204. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3205. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3206. //就诊结算未完成,不能进行二次挂号
  3207. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3208. if len(his) >= 1 {
  3209. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3210. if len(his) >= 1 && order.ID == 0 {
  3211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3212. return
  3213. }
  3214. }
  3215. //var register_log string
  3216. if config.IsOpen == 1 {
  3217. var res ResultTwo
  3218. var res10265 ResultTwo10265
  3219. var PsnNo string
  3220. var PsnCertType string
  3221. var Certno string
  3222. var PsnName string
  3223. var Gend string
  3224. var Naty string
  3225. var Brdy string
  3226. var Age float64
  3227. var infoStr string
  3228. var idetinfoStr string
  3229. var infocode int64
  3230. var verify_number string
  3231. fmt.Println(verify_number)
  3232. if miConfig.MdtrtareaAdmvs == "421300" {
  3233. psn_info, _ := service.GetPsnByPatientId(id)
  3234. PsnNo = psn_info.PsnNo
  3235. PsnCertType = psn_info.PsnCertType
  3236. Certno = psn_info.Certno
  3237. PsnName = psn_info.PsnName
  3238. Gend = psn_info.Gend
  3239. Naty = psn_info.Naty
  3240. Brdy = psn_info.Brdy
  3241. Age = psn_info.Age
  3242. infoStr = psn_info.Insuinfo
  3243. idetinfoStr = psn_info.Idetinfo
  3244. infocode = 0
  3245. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3246. psn_info, _ := service.GetPsnByPatientId(id)
  3247. PsnNo = psn_info.PsnNo
  3248. PsnCertType = psn_info.PsnCertType
  3249. Certno = psn_info.Certno
  3250. PsnName = psn_info.PsnName
  3251. Gend = psn_info.Gend
  3252. Naty = psn_info.Naty
  3253. Brdy = psn_info.Brdy
  3254. Age = psn_info.Age
  3255. infoStr = psn_info.Insuinfo
  3256. idetinfoStr = psn_info.Idetinfo
  3257. infocode = 0
  3258. verify_number = psn_info.VerifyNumber
  3259. } else {
  3260. var result string
  3261. var requestLog string
  3262. if miConfig.UserOrgId == 10138 {
  3263. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3264. } else {
  3265. 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)
  3266. }
  3267. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3268. if miConfig.Code == "H15049901371" {
  3269. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3270. utils.ErrorLog("解析失败:%v", err)
  3271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3272. return
  3273. }
  3274. res.ErrMsg = res10265.ErrMsg
  3275. res.Output = res10265.Output
  3276. res.InfRefmsgid = res10265.InfRefmsgid
  3277. } else {
  3278. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3279. utils.ErrorLog("解析失败:%v", err)
  3280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3281. return
  3282. }
  3283. }
  3284. PsnNo = res.Output.Baseinfo.PsnNo
  3285. PsnCertType = res.Output.Baseinfo.PsnCertType
  3286. Certno = res.Output.Baseinfo.Certno
  3287. PsnName = res.Output.Baseinfo.PsnName
  3288. Gend = res.Output.Baseinfo.Gend
  3289. Naty = res.Output.Baseinfo.Naty
  3290. Brdy = res.Output.Baseinfo.Brdy
  3291. Age = res.Output.Baseinfo.Age
  3292. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3293. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3294. infoStr = string(Iinfos)
  3295. idetinfoStr = string(Idetinfos)
  3296. if miConfig.Code == "H15049901371" {
  3297. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3298. } else {
  3299. infocode = res.Infcode
  3300. }
  3301. }
  3302. if infocode == 0 {
  3303. his := models.VMHisPatient{
  3304. Name: name,
  3305. Gender: gender,
  3306. Birthday: birthUnix,
  3307. MedicalTreatmentType: medical_care,
  3308. IdType: certificates,
  3309. IdCardNo: id_card,
  3310. BalanceAccountsType: settlementValue,
  3311. SocialType: social_type,
  3312. MedicalInsuranceNumber: medical_insurance_card,
  3313. RegisterType: register_type,
  3314. RegisterCost: registration_fee,
  3315. TreatmentCost: medical_expenses,
  3316. Status: 1,
  3317. Ctime: time.Now().Unix(),
  3318. Mtime: time.Now().Unix(),
  3319. PsnNo: PsnNo,
  3320. PsnCertType: PsnCertType,
  3321. Certno: Certno,
  3322. PsnName: PsnName,
  3323. Gend: Gend,
  3324. Naty: Naty,
  3325. Brdy: Brdy,
  3326. Age: Age,
  3327. Iinfo: infoStr,
  3328. Idetinfo: idetinfoStr,
  3329. PatientId: patient.ID,
  3330. RecordDate: theTime.Unix(),
  3331. UserOrgId: adminInfo.CurrentOrgId,
  3332. AdminUserId: admin_user_id,
  3333. IsReturn: 1,
  3334. IdCardType: id_card_type,
  3335. Doctor: doctor,
  3336. Departments: department,
  3337. }
  3338. timestamp := time.Now().Unix()
  3339. tempTime := time.Unix(timestamp, 0)
  3340. timeFormat := tempTime.Format("20060102150405")
  3341. chrgBchno := rand.Intn(100000) + 10000
  3342. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3343. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3344. department, _ := service.GetDepartMentDetail(department)
  3345. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3346. IdCardNo := ""
  3347. if id_card_type == 1 {
  3348. // IdCardNo = medical_insurance_card
  3349. IdCardNo = patient.IdCardNo
  3350. } else {
  3351. IdCardNo = patient.IdCardNo
  3352. }
  3353. var rf []*ResultFive
  3354. json.Unmarshal([]byte(his.Iinfo), &rf)
  3355. var insutypes []*ResultFive
  3356. var insutype string
  3357. var insuplc_admdvs_temp string
  3358. var is390 int = 0
  3359. var is310 int = 0
  3360. for _, item := range rf {
  3361. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3362. insutypes = append(insutypes, item)
  3363. }
  3364. }
  3365. if len(insutypes) == 1 {
  3366. insutype = insutypes[0].Insutype
  3367. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3368. } else {
  3369. for _, i := range insutypes {
  3370. if i.Insutype == "390" {
  3371. is390 = 1
  3372. }
  3373. if i.Insutype == "310" {
  3374. is310 = 1
  3375. }
  3376. }
  3377. }
  3378. if is390 == 1 {
  3379. insutype = "390"
  3380. }
  3381. if is310 == 1 {
  3382. insutype = "310"
  3383. }
  3384. if len(insutypes) == 0 {
  3385. insutype = "310"
  3386. }
  3387. if len(insutypes) == 2 {
  3388. insutype = med_type
  3389. }
  3390. if len(med_type) > 0 {
  3391. insutype = med_type
  3392. }
  3393. //for _, item := range rf {
  3394. // if item.Insutype == insutype {
  3395. // insuplc_admdvs = item.InsuplcAdmdvs
  3396. // }
  3397. //}
  3398. var infocode int64
  3399. var resThree ResultThree
  3400. var resThree10265 ResultThree10265
  3401. if len(insuplc_admdvs) == 0 {
  3402. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3403. } else {
  3404. insuplc_admdvs_temp = insuplc_admdvs
  3405. }
  3406. if miConfig.MdtrtareaAdmvs == "421300" {
  3407. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3408. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3409. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  3410. resp, requestErr := http.Get(api)
  3411. if requestErr != nil {
  3412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3413. return
  3414. }
  3415. body, ioErr := ioutil.ReadAll(resp.Body)
  3416. if ioErr != nil {
  3417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3419. return
  3420. }
  3421. var respJSON map[string]interface{}
  3422. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3425. return
  3426. }
  3427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3428. result, _ := json.Marshal(respJSON)
  3429. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3430. utils.ErrorLog("解析失败:%v", err)
  3431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3432. return
  3433. }
  3434. infocode = resThree.Infcode
  3435. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3436. psn_info, _ := service.GetPsnByPatientId(id)
  3437. bas := strings.Split(psn_info.CardInfo, "|")
  3438. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3439. var api string
  3440. if miConfig.MdtrtareaAdmvs == "320921" {
  3441. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3442. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3443. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3444. } else {
  3445. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3446. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3447. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3448. }
  3449. resp, requestErr := http.Get(api)
  3450. if requestErr != nil {
  3451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3452. return
  3453. }
  3454. body, ioErr := ioutil.ReadAll(resp.Body)
  3455. if ioErr != nil {
  3456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3458. return
  3459. }
  3460. var respJSON map[string]interface{}
  3461. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3464. return
  3465. }
  3466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3467. result, _ := json.Marshal(respJSON)
  3468. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3469. utils.ErrorLog("解析失败:%v", err)
  3470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. return
  3472. }
  3473. resThree.ErrMsg = resThree10265.ErrMsg
  3474. resThree.Output = resThree10265.Output
  3475. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3476. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3477. } else {
  3478. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3479. saveLog(result, requestLog, "2201", "挂号")
  3480. if miConfig.Code == "H15049901371" {
  3481. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3482. utils.ErrorLog("解析失败:%v", err)
  3483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3484. return
  3485. }
  3486. resThree.ErrMsg = resThree10265.ErrMsg
  3487. resThree.Output = resThree10265.Output
  3488. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3489. } else {
  3490. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3491. utils.ErrorLog("解析失败:%v", err)
  3492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3493. return
  3494. }
  3495. }
  3496. if miConfig.Code == "H15049901371" {
  3497. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3498. } else {
  3499. infocode = resThree.Infcode
  3500. }
  3501. }
  3502. if infocode != 0 {
  3503. adminUser := c.GetAdminUserInfo()
  3504. errlog := &models.HisOrderError{
  3505. UserOrgId: adminUser.CurrentOrgId,
  3506. Ctime: time.Now().Unix(),
  3507. Mtime: time.Now().Unix(),
  3508. ErrMsg: resThree.ErrMsg,
  3509. Status: 1,
  3510. PatientId: id,
  3511. RecordTime: recordDateTime,
  3512. Stage: 2,
  3513. }
  3514. service.CreateErrMsgLog(errlog)
  3515. c.ServeSuccessJSON(map[string]interface{}{
  3516. "failed_code": -10,
  3517. "msg": resThree.ErrMsg,
  3518. })
  3519. return
  3520. }
  3521. his.Number = resThree.Output.Data.MdtrtID
  3522. his.PsnNo = resThree.Output.Data.PsnNo
  3523. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3524. his.IdCardNo = patient.IdCardNo
  3525. his.PhoneNumber = patient.Phone
  3526. his.UserOrgId = adminInfo.CurrentOrgId
  3527. his.Insutype = insutype
  3528. his.Ctime = time.Now().Unix()
  3529. his.Mtime = time.Now().Unix()
  3530. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3531. his.Status = 1
  3532. service.UpdateHisPatientStatus(&his)
  3533. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3534. c.ServeSuccessJSON(map[string]interface{}{
  3535. "his_info": his,
  3536. })
  3537. } else {
  3538. adminUser := c.GetAdminUserInfo()
  3539. errlog := &models.HisOrderError{
  3540. UserOrgId: adminUser.CurrentOrgId,
  3541. Ctime: time.Now().Unix(),
  3542. Mtime: time.Now().Unix(),
  3543. ErrMsg: res.ErrMsg,
  3544. Status: 1,
  3545. PatientId: id,
  3546. RecordTime: recordDateTime,
  3547. Stage: 1,
  3548. }
  3549. service.CreateErrMsgLog(errlog)
  3550. c.ServeSuccessJSON(map[string]interface{}{
  3551. "failed_code": -10,
  3552. "msg": res.ErrMsg,
  3553. })
  3554. return
  3555. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3556. }
  3557. }
  3558. }
  3559. //上传明细----预结算----确认订单
  3560. func (c *HisApiController) GetUploadInfo() {
  3561. id, _ := c.GetInt64("id")
  3562. record_time := c.GetString("record_time")
  3563. his_patient_id, _ := c.GetInt64("his_patient_id")
  3564. order_id, _ := c.GetInt64("order_id")
  3565. pay_way, _ := c.GetInt64("pay_way")
  3566. pay_price, _ := c.GetFloat("pay_price")
  3567. pay_card_no := c.GetString("pay_card_no")
  3568. discount_price, _ := c.GetFloat("discount_price")
  3569. preferential_price, _ := c.GetFloat("preferential_price")
  3570. reality_price, _ := c.GetFloat("reality_price")
  3571. found_price, _ := c.GetFloat("found_price")
  3572. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3573. private_price, _ := c.GetFloat("private_price")
  3574. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3575. admin_user_id, _ := c.GetInt64("admin_user_id")
  3576. fapiao_code := c.GetString("fapiao_code")
  3577. fapiao_number := c.GetString("fapiao_number")
  3578. diagnosis_id := c.GetString("diagnosis")
  3579. sick_type, _ := c.GetInt64("sick_type")
  3580. reg_type, _ := c.GetInt64("p_type")
  3581. begin_time := c.GetString("begin_time")
  3582. id_str := c.GetString("ids")
  3583. ids_arr := strings.Split(id_str, ",")
  3584. timeLayout := "2006-01-02"
  3585. loc, _ := time.LoadLocation("Local")
  3586. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3587. if err != nil {
  3588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3589. return
  3590. }
  3591. recordDateTime := theTime.Unix()
  3592. adminUser := c.GetAdminUserInfo()
  3593. var tempOrder models.HisOrder
  3594. tempOrder, _ = service.GetHisOrderByID(order_id)
  3595. var prescriptions []*models.HisPrescription
  3596. var start_time int64
  3597. var end_time int64
  3598. //if adminUser.CurrentOrgId == 10106{
  3599. // if len(fapiao_code) == 0{
  3600. // fapiao_code = "144072080589"
  3601. // }
  3602. // if len(fapiao_number) == 0{
  3603. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3604. // if order.ID == 0{
  3605. // fapiao_number = "00001520"
  3606. // }else{
  3607. // //fapiao_code = "00001520"
  3608. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3609. // var zero string
  3610. // if fpNumber >= 1000{
  3611. // zero = "0000" + strconv.Itoa(fpNumber)
  3612. // }else if fpNumber >= 10000{
  3613. // zero = "000" + strconv.Itoa(fpNumber)
  3614. // } else if fpNumber >= 100000{
  3615. // zero = "00" + strconv.Itoa(fpNumber)
  3616. // } else if fpNumber >= 1000000{
  3617. // zero = "0" + strconv.Itoa(fpNumber)
  3618. // }else {
  3619. // zero = strconv.Itoa(fpNumber)
  3620. // }
  3621. // fapiao_number = zero
  3622. // }
  3623. // }
  3624. //}
  3625. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3626. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3627. var patientPrescription models.HisPrescriptionInfo
  3628. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3629. if patientPrescription.ID == 0 {
  3630. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3631. }
  3632. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3633. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3634. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3635. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3636. var config []*models.HisXtDiagnoseConfig
  3637. for _, item := range diagnosis_ids {
  3638. id, _ := strconv.ParseInt(item, 10, 64)
  3639. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3640. config = append(config, &diagnosisConfig)
  3641. }
  3642. sickConfig, _ := service.FindSickById(sick_type)
  3643. //if tempOrder.ID == 0 {
  3644. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3645. //}
  3646. if tempOrder.ID == 0 {
  3647. var result string
  3648. var requestLog string
  3649. var res2 ResultSix
  3650. var ressix10265 ResultSix10265
  3651. if miConfig.MdtrtareaAdmvs == "421300" {
  3652. data := make(map[string]interface{})
  3653. client := &http.Client{}
  3654. data["psn_no"] = his.PsnNo
  3655. data["mdtrt_id"] = his.Number
  3656. data["doctor"] = roles.UserName
  3657. data["department"] = department.Name
  3658. data["org_name"] = miConfig.OrgName
  3659. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3660. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3661. data["fixmedins_code"] = miConfig.Code
  3662. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3663. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3664. data["secret_key"] = miConfig.SecretKey
  3665. data["sick_code"] = sickConfig.CountryCode
  3666. data["sick_name"] = sickConfig.ClassName
  3667. data["dept"] = strconv.FormatInt(department.ID, 10)
  3668. data["config"] = config
  3669. data["begin_time"] = begin_time
  3670. bytesData, _ := json.Marshal(data)
  3671. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3672. resp, _ := client.Do(req)
  3673. defer resp.Body.Close()
  3674. body, ioErr := ioutil.ReadAll(resp.Body)
  3675. if ioErr != nil {
  3676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. return
  3679. }
  3680. var respJSON map[string]interface{}
  3681. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3684. return
  3685. }
  3686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3687. userJSONBytes, _ := json.Marshal(respJSON)
  3688. fmt.Println("log")
  3689. fmt.Println(string(userJSONBytes))
  3690. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3691. utils.ErrorLog("解析失败:%v", err)
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3693. return
  3694. }
  3695. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3696. //江苏地区国家医保医疗类别
  3697. //职工透析:医疗类别选特殊情况门诊9933
  3698. //居民血透门慢: 医疗类别选门诊慢病1402
  3699. //var med_type string
  3700. //if his.Insutype == "310" {
  3701. // if reg_type == 14 {
  3702. // med_type = "9933"
  3703. // } else if reg_type == 11 {
  3704. // med_type = "11"
  3705. //
  3706. // }
  3707. //} else if his.Insutype == "390" {
  3708. // if reg_type == 14 {
  3709. // med_type = "1402"
  3710. // } else if reg_type == 11 {
  3711. // med_type = "11"
  3712. // }
  3713. //}
  3714. data := make(map[string]interface{})
  3715. client := &http.Client{}
  3716. data["psn_no"] = his.PsnNo
  3717. data["mdtrt_id"] = his.Number
  3718. data["doctor"] = roles.UserName
  3719. data["department"] = department.Name
  3720. data["org_name"] = miConfig.OrgName
  3721. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3722. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3723. data["fixmedins_code"] = miConfig.Code
  3724. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3725. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3726. data["secret_key"] = miConfig.SecretKey
  3727. data["sick_code"] = sickConfig.CountryCode
  3728. data["sick_name"] = sickConfig.ClassName
  3729. data["url"] = miConfig.Url
  3730. data["ak"] = miConfig.AccessKey
  3731. data["begin_time"] = begin_time
  3732. data["cainfo"] = miConfig.Cainfo
  3733. data["dept"] = strconv.FormatInt(department.ID, 10)
  3734. data["config"] = config
  3735. bytesData, _ := json.Marshal(data)
  3736. var req *http.Request
  3737. if miConfig.MdtrtareaAdmvs == "320921" {
  3738. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3739. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3740. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3741. } else {
  3742. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3743. }
  3744. resp, _ := client.Do(req)
  3745. defer resp.Body.Close()
  3746. body, ioErr := ioutil.ReadAll(resp.Body)
  3747. if ioErr != nil {
  3748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3750. return
  3751. }
  3752. var respJSON map[string]interface{}
  3753. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3756. return
  3757. }
  3758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3759. userJSONBytes, _ := json.Marshal(respJSON)
  3760. fmt.Println("log")
  3761. fmt.Println(string(userJSONBytes))
  3762. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3763. utils.ErrorLog("解析失败:%v", err)
  3764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3765. return
  3766. }
  3767. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3768. res2.Output = ressix10265.Output
  3769. res2.ErrMsg = ressix10265.ErrMsg
  3770. res2.Cainfo = ressix10265.Cainfo
  3771. res2.WarnMsg = ressix10265.WarnMsg
  3772. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3773. res2.Infcode = infocode
  3774. } else {
  3775. if miConfig.MdtrtareaAdmvs == "440781" { //
  3776. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3777. } else {
  3778. if miConfig.Code == "H15049901371" {
  3779. //赤峰地区国家医保医疗类别
  3780. //职工透析:医疗类别选特殊情况门诊990502
  3781. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3782. var med_type string
  3783. if his.Insutype == "390" {
  3784. if reg_type == 14 {
  3785. med_type = "9933"
  3786. } else if reg_type == 11 {
  3787. med_type = "11"
  3788. }
  3789. } else if his.Insutype == "310" {
  3790. if reg_type == 14 {
  3791. med_type = "990502"
  3792. } else if reg_type == 11 {
  3793. med_type = "11"
  3794. }
  3795. }
  3796. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3797. } else {
  3798. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3799. }
  3800. }
  3801. saveLog(result, requestLog, "2203", "上传就诊信息")
  3802. var respJSON2 map[string]interface{}
  3803. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3806. return
  3807. }
  3808. userJSONBytes2, _ := json.Marshal(respJSON2)
  3809. if miConfig.Code == "H15049901371" {
  3810. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3811. utils.ErrorLog("解析失败:%v", err)
  3812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3813. return
  3814. }
  3815. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3816. res2.Output = ressix10265.Output
  3817. res2.ErrMsg = ressix10265.ErrMsg
  3818. res2.Cainfo = ressix10265.Cainfo
  3819. res2.WarnMsg = ressix10265.WarnMsg
  3820. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3821. res2.Infcode = infocode
  3822. } else {
  3823. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3824. utils.ErrorLog("解析失败:%v", err)
  3825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3826. return
  3827. }
  3828. }
  3829. }
  3830. if res2.Infcode != 0 {
  3831. adminUser := c.GetAdminUserInfo()
  3832. errlog := &models.HisOrderError{
  3833. UserOrgId: adminUser.CurrentOrgId,
  3834. Ctime: time.Now().Unix(),
  3835. Mtime: time.Now().Unix(),
  3836. ErrMsg: res2.ErrMsg,
  3837. Status: 1,
  3838. PatientId: id,
  3839. RecordTime: recordDateTime,
  3840. Stage: 3,
  3841. }
  3842. service.CreateErrMsgLog(errlog)
  3843. c.ServeSuccessJSON(map[string]interface{}{
  3844. "failed_code": -10,
  3845. "msg": res2.ErrMsg,
  3846. })
  3847. return
  3848. } else {
  3849. his.Diagnosis = diagnosis_id
  3850. his.SickType = sickConfig.ID
  3851. var p_type int64
  3852. if reg_type == 1111 || reg_type == 1112 {
  3853. p_type = 11
  3854. }
  3855. his.PType = fmt.Sprintf("%d", p_type)
  3856. service.UpdateHisPatientThree(&his)
  3857. data := make(map[string]interface{})
  3858. if settle_accounts_type == 1 { //日结
  3859. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3860. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3861. } else {
  3862. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3863. }
  3864. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3865. data["pre"] = prescriptions
  3866. } else { //月结
  3867. start_time_str := c.GetString("start_time")
  3868. end_time_str := c.GetString("end_time")
  3869. timeLayout := "2006-01-02"
  3870. loc, _ := time.LoadLocation("Local")
  3871. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3872. if err != nil {
  3873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3874. return
  3875. }
  3876. recordStartTime := theStartTime.Unix()
  3877. start_time = recordStartTime
  3878. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3879. if err != nil {
  3880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3881. return
  3882. }
  3883. recordEndTime := theEndTime.Unix()
  3884. end_time = recordEndTime
  3885. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3886. data["pre"] = prescriptions
  3887. }
  3888. timestamp := time.Now().Unix()
  3889. tempTime := time.Unix(timestamp, 0)
  3890. timeFormat := tempTime.Format("20060102150405")
  3891. chrgBchno := rand.Intn(100000) + 10000
  3892. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3893. strconv.FormatInt(his.PatientId, 10)
  3894. client := &http.Client{}
  3895. data["psn_no"] = his.PsnNo
  3896. data["mdtrt_id"] = his.Number
  3897. data["chrg_bchno"] = chrg_bchno
  3898. data["org_name"] = miConfig.OrgName
  3899. data["doctor"] = roles.UserName
  3900. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3901. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3902. data["fixmedins_code"] = miConfig.Code
  3903. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3904. // data["dept_code"] = "15"
  3905. //} else {
  3906. data["dept_code"] = department.Number
  3907. //}
  3908. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3909. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3910. data["secret_key"] = miConfig.SecretKey
  3911. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3912. data["url"] = miConfig.Url
  3913. data["ak"] = miConfig.AccessKey
  3914. data["new_doctor_name"] = patientPrescription.Doctor
  3915. data["diag_code"] = sickConfig.CountryCode
  3916. data["cainfo"] = miConfig.Cainfo
  3917. var ids []int64
  3918. for _, item := range prescriptions {
  3919. ids = append(ids, item.ID)
  3920. }
  3921. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3922. if config.IsOpen == 1 { //对接了医保,走医保流程
  3923. var res ResultFour
  3924. var resFour10265 ResultFour10265
  3925. if miConfig.MdtrtareaAdmvs == "421300" {
  3926. bytesData, _ := json.Marshal(data)
  3927. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3928. resp, _ := client.Do(req)
  3929. defer resp.Body.Close()
  3930. body, ioErr := ioutil.ReadAll(resp.Body)
  3931. if ioErr != nil {
  3932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. return
  3935. }
  3936. var respJSON map[string]interface{}
  3937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3940. return
  3941. }
  3942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3943. userJSONBytes, _ := json.Marshal(respJSON)
  3944. fmt.Println("log")
  3945. fmt.Println(string(userJSONBytes))
  3946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3947. utils.ErrorLog("解析失败:%v", err)
  3948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3949. return
  3950. }
  3951. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3952. bytesData, _ := json.Marshal(data)
  3953. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3954. resp, _ := client.Do(req)
  3955. defer resp.Body.Close()
  3956. body, ioErr := ioutil.ReadAll(resp.Body)
  3957. if ioErr != nil {
  3958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3960. return
  3961. }
  3962. var respJSON map[string]interface{}
  3963. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3966. return
  3967. }
  3968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3969. userJSONBytes, _ := json.Marshal(respJSON)
  3970. fmt.Println("log")
  3971. fmt.Println(string(userJSONBytes))
  3972. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3973. utils.ErrorLog("解析失败:%v", err)
  3974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3975. return
  3976. }
  3977. res.InfRefmsgid = resFour10265.InfRefmsgid
  3978. res.Output = resFour10265.Output
  3979. res.ErrMsg = resFour10265.ErrMsg
  3980. res.Cainfo = resFour10265.Cainfo
  3981. res.WarnMsg = resFour10265.WarnMsg
  3982. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3983. res.Infcode = infocode
  3984. } else {
  3985. if miConfig.Code == "H15049901371" {
  3986. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3987. var dat map[string]interface{}
  3988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3989. fmt.Println(dat)
  3990. } else {
  3991. fmt.Println(err)
  3992. }
  3993. saveLog(result, request_log, "2204", "上传费用明细")
  3994. userJSONBytes, _ := json.Marshal(dat)
  3995. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3996. utils.ErrorLog("解析失败:%v", err)
  3997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3998. return
  3999. }
  4000. res.InfRefmsgid = resFour10265.InfRefmsgid
  4001. res.Output = resFour10265.Output
  4002. res.ErrMsg = resFour10265.ErrMsg
  4003. res.Cainfo = resFour10265.Cainfo
  4004. res.WarnMsg = resFour10265.WarnMsg
  4005. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4006. res.Infcode = infocode
  4007. } else {
  4008. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  4009. var dat map[string]interface{}
  4010. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4011. fmt.Println(dat)
  4012. } else {
  4013. fmt.Println(err)
  4014. }
  4015. saveLog(result, request_log, "2204", "上传费用明细")
  4016. userJSONBytes, _ := json.Marshal(dat)
  4017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4018. utils.ErrorLog("解析失败:%v", err)
  4019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4020. return
  4021. }
  4022. }
  4023. }
  4024. if res.Infcode == 0 {
  4025. order := &models.HisOrder{
  4026. UserOrgId: adminUser.CurrentOrgId,
  4027. HisPatientId: his.ID,
  4028. PatientId: his.PatientId,
  4029. SettleAccountsDate: recordDateTime,
  4030. MdtrtId: his.Number,
  4031. PsnNo: his.PsnNo,
  4032. MedType: strconv.FormatInt(reg_type, 10),
  4033. Ctime: time.Now().Unix(),
  4034. Mtime: time.Now().Unix(),
  4035. Status: 1,
  4036. Number: chrg_bchno,
  4037. Infcode: res.Infcode,
  4038. WarnMsg: res.WarnMsg,
  4039. Cainfo: res.Cainfo,
  4040. ErrMsg: res.ErrMsg,
  4041. RespondTime: res.RefmsgTime,
  4042. InfRefmsgid: res.InfRefmsgid,
  4043. OrderStatus: 1,
  4044. PayWay: pay_way,
  4045. PayPrice: pay_price,
  4046. PayCardNo: pay_card_no,
  4047. DiscountPrice: discount_price,
  4048. PreferentialPrice: preferential_price,
  4049. RealityPrice: reality_price,
  4050. FoundPrice: found_price,
  4051. MedicalInsurancePrice: medical_insurance_price,
  4052. PrivatePrice: private_price,
  4053. IsMedicineInsurance: 1,
  4054. SettleType: settle_accounts_type,
  4055. SettleStartTime: start_time,
  4056. SettleEndTime: end_time,
  4057. Creator: roles.AdminUserId,
  4058. Modify: roles.AdminUserId,
  4059. FaPiaoNumber: fapiao_number,
  4060. FaPiaoCode: fapiao_code,
  4061. PType: 2,
  4062. Diagnosis: diagnosis_id,
  4063. }
  4064. err = service.CreateOrder(order)
  4065. if err != nil {
  4066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4067. return
  4068. }
  4069. for _, item := range res.Output.Result {
  4070. temp := strings.Split(item.FeedetlSn, "-")
  4071. var advice_id int64 = 0
  4072. var project_id int64 = 0
  4073. var types int64 = 0
  4074. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4075. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4076. if temp[1] == "1" {
  4077. advice_id = id
  4078. project_id = 0
  4079. } else if temp[1] == "2" {
  4080. advice_id = 0
  4081. project_id = id
  4082. }
  4083. info := &models.HisOrderInfo{
  4084. OrderNumber: order.Number,
  4085. FeedetlSn: item.FeedetlSn,
  4086. UploadDate: time.Now().Unix(),
  4087. AdviceId: advice_id,
  4088. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4089. Cnt: item.Cnt,
  4090. Pric: float64(item.Pric),
  4091. PatientId: his.PatientId,
  4092. PricUplmtAmt: item.PricUplmtAmt,
  4093. SelfpayProp: item.SelfpayProp,
  4094. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4095. OverlmtAmt: item.OverlmtAmt,
  4096. PreselfpayAmt: item.PreselfpayAmt,
  4097. BasMednFlag: item.BasMednFlag,
  4098. MedChrgitmType: item.MedChrgitmType,
  4099. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4100. Status: 1,
  4101. Memo: item.Memo,
  4102. Mtime: time.Now().Unix(),
  4103. InscpScpAmt: item.InscpScpAmt,
  4104. DrtReimFlag: item.DrtReimFlag,
  4105. Ctime: time.Now().Unix(),
  4106. ListSpItemFlag: item.ListSpItemFlag,
  4107. ChldMedcFlag: item.ChldMedcFlag,
  4108. LmtUsedFlag: item.LmtUsedFlag,
  4109. ChrgitmLv: item.ChrgitmLv,
  4110. UserOrgId: adminUser.CurrentOrgId,
  4111. HisPatientId: his.ID,
  4112. OrderId: order.ID,
  4113. ProjectId: project_id,
  4114. Type: types,
  4115. }
  4116. service.CreateOrderInfo(info)
  4117. }
  4118. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4119. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4120. var total float64
  4121. for _, item := range prescriptions {
  4122. if item.Type == 1 { //药品
  4123. for _, subItem := range item.HisDoctorAdviceInfo {
  4124. total = total + (subItem.Price * subItem.PrescribingNumber)
  4125. }
  4126. }
  4127. if item.Type == 2 { //项目
  4128. for _, subItem := range item.HisPrescriptionProject {
  4129. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4130. total = total + (subItem.Price * cnt)
  4131. }
  4132. }
  4133. }
  4134. for _, item := range prescriptions {
  4135. for _, subItem := range item.HisAdditionalCharge {
  4136. total = total + (subItem.Price * float64(subItem.Count))
  4137. }
  4138. }
  4139. var allTotal string
  4140. if adminUser.CurrentOrgId == 9919 {
  4141. allTotal = fmt.Sprintf("%.4f", total)
  4142. } else {
  4143. allTotal = fmt.Sprintf("%.4f", total)
  4144. }
  4145. if res.Infcode == 0 {
  4146. var rf []*ResultFive
  4147. json.Unmarshal([]byte(his.Iinfo), &rf)
  4148. chrg_bchno := chrg_bchno
  4149. cert_no := his.Certno
  4150. var insutypes []string
  4151. var insutype string
  4152. var is390 int = 0
  4153. var is310 int = 0
  4154. for _, item := range rf {
  4155. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4156. insutypes = append(insutypes, item.Insutype)
  4157. }
  4158. }
  4159. if len(insutypes) == 1 {
  4160. insutype = insutypes[0]
  4161. } else {
  4162. for _, i := range insutypes {
  4163. if i == "390" {
  4164. is390 = 1
  4165. }
  4166. if i == "310" {
  4167. is310 = 1
  4168. }
  4169. }
  4170. }
  4171. if is390 == 1 {
  4172. insutype = "390"
  4173. }
  4174. if is310 == 1 {
  4175. insutype = "310"
  4176. }
  4177. if len(insutypes) == 0 {
  4178. insutype = "310"
  4179. }
  4180. if len(insutypes) == 2 {
  4181. insutype = strconv.FormatInt(his.SocialType, 10)
  4182. }
  4183. insutype = strconv.FormatInt(his.SocialType, 10)
  4184. //insutype = "390"
  4185. if his.IdCardType == 1 {
  4186. // cert_no = his.MedicalInsuranceNumber
  4187. cert_no = his.Certno
  4188. } else {
  4189. cert_no = his.Certno
  4190. }
  4191. var res ResultSeven
  4192. var resSeven10265 ResultSeven10265
  4193. var src_resquest string
  4194. var result2 string
  4195. var acct_used_flag string
  4196. fmt.Println("pay_way")
  4197. fmt.Println(pay_way)
  4198. fmt.Println("pay_way")
  4199. if pay_way == 4 {
  4200. acct_used_flag = "1"
  4201. } else {
  4202. acct_used_flag = "0"
  4203. }
  4204. if miConfig.MdtrtareaAdmvs == "421300" {
  4205. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4206. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4207. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4208. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4209. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4210. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4211. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4212. resp, requestErr := http.Get(api)
  4213. if requestErr != nil {
  4214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4215. return
  4216. }
  4217. body, ioErr := ioutil.ReadAll(resp.Body)
  4218. if ioErr != nil {
  4219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4221. return
  4222. }
  4223. var respJSON map[string]interface{}
  4224. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4227. return
  4228. }
  4229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4230. result, _ := json.Marshal(respJSON)
  4231. if miConfig.Code == "H15049901371" {
  4232. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4233. utils.ErrorLog("解析失败:%v", err)
  4234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4235. return
  4236. }
  4237. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4238. res.Output = resSeven10265.Output
  4239. res.ErrMsg = resSeven10265.ErrMsg
  4240. res.Cainfo = resSeven10265.Cainfo
  4241. res.WarnMsg = resSeven10265.WarnMsg
  4242. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4243. res.Infcode = infocode
  4244. } else {
  4245. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4246. utils.ErrorLog("解析失败:%v", err)
  4247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4248. return
  4249. }
  4250. }
  4251. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4252. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4253. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4254. //psn_info, _ := service.GetPsnByPatientId(id)
  4255. bas := strings.Split(psn_info.CardInfo, "|")
  4256. if his.IdCardType == 1 {
  4257. cert_no = bas[2]
  4258. } else {
  4259. cert_no = bas[1]
  4260. }
  4261. //江苏地区国家医保医疗类别
  4262. //职工透析:医疗类别选特殊情况门诊9933
  4263. //居民血透门慢: 医疗类别选门诊慢病1402
  4264. //var med_type string
  4265. //if his.Insutype == "310" {
  4266. // if reg_type == 14 {
  4267. // med_type = "9933"
  4268. // } else if reg_type == 11 {
  4269. // med_type = "11"
  4270. //
  4271. // }
  4272. //} else if his.Insutype == "390" {
  4273. // if reg_type == 14 {
  4274. // med_type = "1402"
  4275. // } else if reg_type == 11 {
  4276. // med_type = "11"
  4277. // }
  4278. //}
  4279. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4280. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4281. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4282. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4283. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4284. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4285. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4286. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4287. resp, requestErr := http.Get(api)
  4288. if requestErr != nil {
  4289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4290. return
  4291. }
  4292. body, ioErr := ioutil.ReadAll(resp.Body)
  4293. if ioErr != nil {
  4294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4296. return
  4297. }
  4298. var respJSON map[string]interface{}
  4299. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4302. return
  4303. }
  4304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4305. result, _ := json.Marshal(respJSON)
  4306. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4307. utils.ErrorLog("解析失败:%v", err)
  4308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. return
  4310. }
  4311. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4312. res.Output = resSeven10265.Output
  4313. res.ErrMsg = resSeven10265.ErrMsg
  4314. res.Cainfo = resSeven10265.Cainfo
  4315. res.WarnMsg = resSeven10265.WarnMsg
  4316. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4317. res.Infcode = infocode
  4318. } else {
  4319. if miConfig.Code == "H15049901371" {
  4320. //赤峰地区国家医保医疗类别
  4321. //职工透析:医疗类别选特殊情况门诊990502
  4322. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4323. var med_type string
  4324. if his.Insutype == "390" {
  4325. if reg_type == 14 {
  4326. med_type = "9933"
  4327. } else if reg_type == 11 {
  4328. med_type = "11"
  4329. }
  4330. } else if his.Insutype == "310" {
  4331. if reg_type == 14 {
  4332. med_type = "990502"
  4333. } else if reg_type == 11 {
  4334. med_type = "11"
  4335. }
  4336. }
  4337. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4338. } else {
  4339. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4340. }
  4341. //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)
  4342. var dat map[string]interface{}
  4343. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4344. fmt.Println(dat)
  4345. } else {
  4346. fmt.Println(err)
  4347. }
  4348. saveLog(result2, src_resquest, "2207", "结算")
  4349. userJSONBytes, _ := json.Marshal(dat)
  4350. if miConfig.Code == "H15049901371" {
  4351. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4352. utils.ErrorLog("解析失败:%v", err)
  4353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4354. return
  4355. }
  4356. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4357. res.Output = resSeven10265.Output
  4358. res.ErrMsg = resSeven10265.ErrMsg
  4359. res.Cainfo = resSeven10265.Cainfo
  4360. res.WarnMsg = resSeven10265.WarnMsg
  4361. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4362. res.Infcode = infocode
  4363. } else {
  4364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4365. utils.ErrorLog("解析失败:%v", err)
  4366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4367. return
  4368. }
  4369. }
  4370. }
  4371. if res.Infcode != 0 {
  4372. errlog := &models.HisOrderError{
  4373. UserOrgId: adminUser.CurrentOrgId,
  4374. Ctime: time.Now().Unix(),
  4375. Mtime: time.Now().Unix(),
  4376. Number: chrg_bchno,
  4377. ErrMsg: res.ErrMsg,
  4378. Status: 1,
  4379. PatientId: id,
  4380. RecordTime: recordDateTime,
  4381. Stage: 6,
  4382. }
  4383. service.CreateErrMsgLog(errlog)
  4384. c.ServeSuccessJSON(map[string]interface{}{
  4385. "failed_code": -10,
  4386. "msg": res.ErrMsg,
  4387. })
  4388. return
  4389. } else {
  4390. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4391. order.OrderStatus = 2
  4392. order.Status = 1
  4393. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4394. order.SetlId = res.Output.Setlinfo.SetlID
  4395. order.PsnNo = res.Output.Setlinfo.PsnNo
  4396. order.PsnName = res.Output.Setlinfo.PsnName
  4397. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4398. order.Certno = res.Output.Setlinfo.Certno
  4399. order.Gend = res.Output.Setlinfo.Gend
  4400. order.Naty = res.Output.Setlinfo.Naty
  4401. order.Age = res.Output.Setlinfo.Age
  4402. order.Insutype = res.Output.Setlinfo.Insutype
  4403. order.PsnType = res.Output.Setlinfo.PsnType
  4404. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4405. order.SetlTime = res.Output.Setlinfo.SetlTime
  4406. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4407. if res.Output.Setlinfo.MedType == "140101" {
  4408. order.MedType = "14"
  4409. } else {
  4410. order.MedType = res.Output.Setlinfo.MedType
  4411. }
  4412. if reg_type == 1112 {
  4413. order.MedType = "1112"
  4414. }
  4415. if reg_type == 1111 {
  4416. order.MedType = "1111"
  4417. }
  4418. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4419. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4420. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4421. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4422. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4423. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4424. order.HifpPay = res.Output.Setlinfo.HifpPay
  4425. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4426. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4427. order.HifesPay = res.Output.Setlinfo.HifesPay
  4428. order.HifobPay = res.Output.Setlinfo.HifobPay
  4429. order.MafPay = res.Output.Setlinfo.MafPay
  4430. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4431. order.OthPay = res.Output.Setlinfo.OthPay
  4432. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4433. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4434. order.AcctPay = res.Output.Setlinfo.AcctPay
  4435. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4436. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4437. order.Balc = res.Output.Setlinfo.Balc
  4438. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4439. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4440. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4441. order.ClrType = res.Output.Setlinfo.ClrType
  4442. order.ClrWay = res.Output.Setlinfo.ClrWay
  4443. order.Creator = order.Creator
  4444. order.Modify = roles.AdminUserId
  4445. order.RequestLog = src_resquest
  4446. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4447. detailStr := string(setlDetail)
  4448. order.SetlDetail = detailStr
  4449. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4450. err = service.UpDateOrder(order)
  4451. if err == nil {
  4452. c.ServeSuccessJSON(map[string]interface{}{
  4453. "msg": "结算成功",
  4454. })
  4455. } else {
  4456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4457. return
  4458. }
  4459. }
  4460. } else {
  4461. adminUser := c.GetAdminUserInfo()
  4462. errlog := &models.HisOrderError{
  4463. UserOrgId: adminUser.CurrentOrgId,
  4464. Ctime: time.Now().Unix(),
  4465. Mtime: time.Now().Unix(),
  4466. ErrMsg: res.ErrMsg,
  4467. Status: 1,
  4468. PatientId: id,
  4469. RecordTime: recordDateTime,
  4470. Stage: 4,
  4471. }
  4472. service.CreateErrMsgLog(errlog)
  4473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4474. return
  4475. }
  4476. } else {
  4477. adminUser := c.GetAdminUserInfo()
  4478. errlog := &models.HisOrderError{
  4479. UserOrgId: adminUser.CurrentOrgId,
  4480. Ctime: time.Now().Unix(),
  4481. Mtime: time.Now().Unix(),
  4482. ErrMsg: res.ErrMsg,
  4483. Status: 1,
  4484. PatientId: id,
  4485. RecordTime: recordDateTime,
  4486. Stage: 4,
  4487. }
  4488. service.CreateErrMsgLog(errlog)
  4489. c.ServeSuccessJSON(map[string]interface{}{
  4490. "failed_code": -10,
  4491. "msg": res.ErrMsg,
  4492. })
  4493. return
  4494. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4495. //return
  4496. }
  4497. }
  4498. }
  4499. } else if tempOrder.ID > 0 {
  4500. if tempOrder.IsPre == 1 {
  4501. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4502. var rf []*ResultFive
  4503. json.Unmarshal([]byte(his.Iinfo), &rf)
  4504. chrg_bchno := tempOrder.Number
  4505. cert_no := his.Certno
  4506. var insutypes []string
  4507. var insutype string
  4508. var is390 int = 0
  4509. var is310 int = 0
  4510. for _, item := range rf {
  4511. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4512. insutypes = append(insutypes, item.Insutype)
  4513. }
  4514. }
  4515. if len(insutypes) == 1 {
  4516. insutype = insutypes[0]
  4517. } else {
  4518. for _, i := range insutypes {
  4519. if i == "390" {
  4520. is390 = 1
  4521. }
  4522. if i == "310" {
  4523. is310 = 1
  4524. }
  4525. }
  4526. }
  4527. if is390 == 1 {
  4528. insutype = "390"
  4529. }
  4530. if is310 == 1 {
  4531. insutype = "310"
  4532. }
  4533. if len(insutypes) == 0 {
  4534. insutype = "310"
  4535. }
  4536. if len(insutypes) == 2 {
  4537. insutype = strconv.FormatInt(his.SocialType, 64)
  4538. }
  4539. //insutype = "390"
  4540. if his.IdCardType == 1 {
  4541. // cert_no = his.MedicalInsuranceNumber
  4542. cert_no = his.Certno
  4543. } else {
  4544. cert_no = his.Certno
  4545. }
  4546. var res ResultSeven
  4547. var resSeven10265 ResultSeven10265
  4548. var src_resquest string
  4549. var result2 string
  4550. var acct_used_flag string
  4551. fmt.Println("pay_way")
  4552. fmt.Println(pay_way)
  4553. fmt.Println("pay_way")
  4554. if pay_way == 4 {
  4555. acct_used_flag = "1"
  4556. } else {
  4557. acct_used_flag = "0"
  4558. }
  4559. if miConfig.MdtrtareaAdmvs == "421300" {
  4560. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4561. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4562. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4563. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4564. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4565. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4566. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4567. resp, requestErr := http.Get(api)
  4568. if requestErr != nil {
  4569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4570. return
  4571. }
  4572. body, ioErr := ioutil.ReadAll(resp.Body)
  4573. if ioErr != nil {
  4574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4576. return
  4577. }
  4578. var respJSON map[string]interface{}
  4579. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4582. return
  4583. }
  4584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4585. result, _ := json.Marshal(respJSON)
  4586. fmt.Println("log")
  4587. fmt.Println(string(result))
  4588. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4589. utils.ErrorLog("解析失败:%v", err)
  4590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4591. return
  4592. }
  4593. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4594. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4595. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4596. //psn_info, _ := service.GetPsnByPatientId(id)
  4597. bas := strings.Split(psn_info.CardInfo, "|")
  4598. if his.IdCardType == 1 {
  4599. cert_no = bas[2]
  4600. } else {
  4601. cert_no = bas[1]
  4602. }
  4603. //江苏地区国家医保医疗类别
  4604. //职工透析:医疗类别选特殊情况门诊9933
  4605. //居民血透门慢: 医疗类别选门诊慢病1402
  4606. //var med_type string
  4607. //if his.Insutype == "310" {
  4608. // if reg_type == 14 {
  4609. // med_type = "9933"
  4610. // } else if reg_type == 11 {
  4611. // med_type = "11"
  4612. //
  4613. // }
  4614. //} else if his.Insutype == "390" {
  4615. // if reg_type == 14 {
  4616. // med_type = "1402"
  4617. // } else if reg_type == 11 {
  4618. // med_type = "11"
  4619. // }
  4620. //}
  4621. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4622. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4623. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4624. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4625. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4626. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4627. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4628. resp, requestErr := http.Get(api)
  4629. if requestErr != nil {
  4630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4631. return
  4632. }
  4633. body, ioErr := ioutil.ReadAll(resp.Body)
  4634. if ioErr != nil {
  4635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4637. return
  4638. }
  4639. var respJSON map[string]interface{}
  4640. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4643. return
  4644. }
  4645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4646. result, _ := json.Marshal(respJSON)
  4647. fmt.Println("log")
  4648. fmt.Println(string(result))
  4649. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4650. utils.ErrorLog("解析失败:%v", err)
  4651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4652. return
  4653. }
  4654. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4655. res.Output = resSeven10265.Output
  4656. res.ErrMsg = resSeven10265.ErrMsg
  4657. res.Cainfo = resSeven10265.Cainfo
  4658. res.WarnMsg = resSeven10265.WarnMsg
  4659. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4660. res.Infcode = infocode
  4661. } else {
  4662. var src_resquest string
  4663. if miConfig.Code == "H15049901371" {
  4664. //赤峰地区国家医保医疗类别
  4665. //职工透析:医疗类别选特殊情况门诊990502
  4666. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4667. var med_type string
  4668. if his.Insutype == "390" {
  4669. if reg_type == 14 {
  4670. med_type = "9933"
  4671. } else if reg_type == 11 {
  4672. med_type = "11"
  4673. }
  4674. } else if his.Insutype == "310" {
  4675. if reg_type == 14 {
  4676. med_type = "990502"
  4677. } else if reg_type == 11 {
  4678. med_type = "11"
  4679. }
  4680. }
  4681. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4682. } else {
  4683. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4684. }
  4685. var dat map[string]interface{}
  4686. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4687. fmt.Println(dat)
  4688. } else {
  4689. fmt.Println(err)
  4690. }
  4691. saveLog(result2, src_resquest, "2207", "结算")
  4692. userJSONBytes, _ := json.Marshal(dat)
  4693. if miConfig.Code == "H15049901371" {
  4694. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4695. utils.ErrorLog("解析失败:%v", err)
  4696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4697. return
  4698. }
  4699. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4700. res.Output = resSeven10265.Output
  4701. res.ErrMsg = resSeven10265.ErrMsg
  4702. res.Cainfo = resSeven10265.Cainfo
  4703. res.WarnMsg = resSeven10265.WarnMsg
  4704. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4705. res.Infcode = infocode
  4706. } else {
  4707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4708. utils.ErrorLog("解析失败:%v", err)
  4709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. return
  4711. }
  4712. }
  4713. }
  4714. if res.Infcode != 0 {
  4715. errlog := &models.HisOrderError{
  4716. UserOrgId: adminUser.CurrentOrgId,
  4717. Ctime: time.Now().Unix(),
  4718. Mtime: time.Now().Unix(),
  4719. Number: chrg_bchno,
  4720. ErrMsg: res.ErrMsg,
  4721. Status: 1,
  4722. PatientId: id,
  4723. RecordTime: recordDateTime,
  4724. Stage: 6,
  4725. }
  4726. service.CreateErrMsgLog(errlog)
  4727. c.ServeSuccessJSON(map[string]interface{}{
  4728. "failed_code": -10,
  4729. "msg": res.ErrMsg,
  4730. })
  4731. return
  4732. } else {
  4733. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4734. order.OrderStatus = 2
  4735. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4736. order.SetlId = res.Output.Setlinfo.SetlID
  4737. order.PsnNo = res.Output.Setlinfo.PsnNo
  4738. order.PsnName = res.Output.Setlinfo.PsnName
  4739. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4740. order.Certno = res.Output.Setlinfo.Certno
  4741. order.Gend = res.Output.Setlinfo.Gend
  4742. order.Naty = res.Output.Setlinfo.Naty
  4743. order.Age = res.Output.Setlinfo.Age
  4744. order.Insutype = res.Output.Setlinfo.Insutype
  4745. order.PsnType = res.Output.Setlinfo.PsnType
  4746. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4747. order.SetlTime = res.Output.Setlinfo.SetlTime
  4748. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4749. //order.MedType = res.Output.Setlinfo.MedType
  4750. if reg_type == 1112 {
  4751. order.MedType = "1112"
  4752. }
  4753. if reg_type == 1111 {
  4754. order.MedType = "1111"
  4755. }
  4756. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4757. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4758. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4759. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4760. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4761. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4762. order.HifpPay = res.Output.Setlinfo.HifpPay
  4763. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4764. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4765. order.HifesPay = res.Output.Setlinfo.HifesPay
  4766. order.HifobPay = res.Output.Setlinfo.HifobPay
  4767. order.MafPay = res.Output.Setlinfo.MafPay
  4768. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4769. order.OthPay = res.Output.Setlinfo.OthPay
  4770. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4771. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4772. order.AcctPay = res.Output.Setlinfo.AcctPay
  4773. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4774. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4775. order.Balc = res.Output.Setlinfo.Balc
  4776. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4777. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4778. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4779. order.ClrWay = res.Output.Setlinfo.ClrWay
  4780. order.Creator = order.Creator
  4781. order.Modify = roles.AdminUserId
  4782. order.RequestLog = src_resquest
  4783. order.Diagnosis = diagnosis_id
  4784. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4785. detailStr := string(setlDetail)
  4786. order.SetlDetail = detailStr
  4787. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4788. err = service.UpDateOrder(order)
  4789. if err == nil {
  4790. c.ServeSuccessJSON(map[string]interface{}{
  4791. "msg": "结算成功",
  4792. })
  4793. } else {
  4794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4795. return
  4796. }
  4797. }
  4798. }
  4799. }
  4800. }
  4801. //func (c *HisApiController) GetPreUploadInfo() {
  4802. // id, _ := c.GetInt64("id")
  4803. // record_time := c.GetString("record_time")
  4804. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4805. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4806. //
  4807. // timeLayout := "2006-01-02"
  4808. // loc, _ := time.LoadLocation("Local")
  4809. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4810. // if err != nil {
  4811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4812. // return
  4813. // }
  4814. // recordDateTime := theTime.Unix()
  4815. // adminUser := c.GetAdminUserInfo()
  4816. //
  4817. // var prescriptions []*models.HisPrescription
  4818. //
  4819. // var start_time int64
  4820. // var end_time int64
  4821. //
  4822. // data := make(map[string]interface{})
  4823. // if settle_accounts_type == 1 { //日结
  4824. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4825. // data["pre"] = prescriptions
  4826. //
  4827. // } else { //月结
  4828. // start_time_str := c.GetString("start_time")
  4829. // end_time_str := c.GetString("end_time")
  4830. // timeLayout := "2006-01-02"
  4831. // loc, _ := time.LoadLocation("Local")
  4832. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4833. // if err != nil {
  4834. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4835. // return
  4836. // }
  4837. // recordStartTime := theStartTime.Unix()
  4838. // start_time = recordStartTime
  4839. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4840. // if err != nil {
  4841. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4842. // return
  4843. // }
  4844. // recordEndTime := theEndTime.Unix()
  4845. // end_time = recordEndTime
  4846. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4847. // data["pre"] = prescriptions
  4848. //
  4849. // }
  4850. //
  4851. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4852. //
  4853. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4854. // timestamp := time.Now().Unix()
  4855. // tempTime := time.Unix(timestamp, 0)
  4856. // timeFormat := tempTime.Format("20060102150405")
  4857. // chrgBchno := rand.Intn(100000) + 10000
  4858. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4859. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4860. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4861. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4862. // strconv.FormatInt(his.PatientId, 10)
  4863. // client := &http.Client{}
  4864. // data["psn_no"] = his.PsnNo
  4865. // data["mdtrt_id"] = his.Number
  4866. // data["chrg_bchno"] = chrg_bchno
  4867. // data["org_name"] = miConfig.OrgName
  4868. // data["doctor"] = roles.UserName
  4869. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4870. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4871. // data["fixmedins_code"] = miConfig.Code
  4872. // data["dept_code"] = department.Number
  4873. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4874. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4875. // data["secret_key"] = miConfig.SecretKey
  4876. // var ids []int64
  4877. //
  4878. // for _, item := range prescriptions {
  4879. // ids = append(ids, item.ID)
  4880. // }
  4881. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4882. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4883. // bytesData, _ := json.Marshal(data)
  4884. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4885. // resp, _ := client.Do(req)
  4886. // defer resp.Body.Close()
  4887. // body, ioErr := ioutil.ReadAll(resp.Body)
  4888. // if ioErr != nil {
  4889. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4891. // return
  4892. // }
  4893. // var respJSON map[string]interface{}
  4894. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4895. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4897. // return
  4898. // }
  4899. //
  4900. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4901. // userJSONBytes, _ := json.Marshal(respJSON)
  4902. // var res ResultFour
  4903. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4904. // utils.ErrorLog("解析失败:%v", err)
  4905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4906. // return
  4907. // }
  4908. //
  4909. // if res.Infcode == 0 {
  4910. // order := &models.HisOrder{
  4911. // UserOrgId: adminUser.CurrentOrgId,
  4912. // HisPatientId: his.ID,
  4913. // PatientId: his.PatientId,
  4914. // SettleAccountsDate: recordDateTime,
  4915. // Ctime: time.Now().Unix(),
  4916. // Mtime: time.Now().Unix(),
  4917. // Status: 1,
  4918. // Number: chrg_bchno,
  4919. // Infcode: res.Infcode,
  4920. // WarnMsg: res.WarnMsg,
  4921. // Cainfo: res.Cainfo,
  4922. // ErrMsg: res.ErrMsg,
  4923. // RespondTime: res.RefmsgTime,
  4924. // InfRefmsgid: res.InfRefmsgid,
  4925. // OrderStatus: 1,
  4926. // IsMedicineInsurance: 1,
  4927. // SettleType: settle_accounts_type,
  4928. // SettleStartTime: start_time,
  4929. // SettleEndTime: end_time,
  4930. // Creator: roles.ID,
  4931. // Modify: roles.ID,
  4932. // PType: 2,
  4933. // }
  4934. // err = service.CreateOrder(order)
  4935. // if err != nil {
  4936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4937. // return
  4938. // }
  4939. //
  4940. // for _, item := range res.Output.Result {
  4941. // temp := strings.Split(item.FeedetlSn, "-")
  4942. // var advice_id int64 = 0
  4943. // var project_id int64 = 0
  4944. // var types int64 = 0
  4945. //
  4946. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4947. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4948. //
  4949. // if temp[1] == "1" {
  4950. // advice_id = id
  4951. // project_id = 0
  4952. // } else if temp[1] == "2" {
  4953. // advice_id = 0
  4954. // project_id = id
  4955. // }
  4956. //
  4957. // info := &models.HisOrderInfo{
  4958. // OrderNumber: order.Number,
  4959. // FeedetlSn: item.FeedetlSn,
  4960. // UploadDate: time.Now().Unix(),
  4961. // AdviceId: advice_id,
  4962. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4963. // Cnt: item.Cnt,
  4964. // Pric: float64(item.Pric),
  4965. // PatientId: his.PatientId,
  4966. // PricUplmtAmt: item.PricUplmtAmt,
  4967. // SelfpayProp: item.SelfpayProp,
  4968. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4969. // OverlmtAmt: item.OverlmtAmt,
  4970. // PreselfpayAmt: item.PreselfpayAmt,
  4971. // BasMednFlag: item.BasMednFlag,
  4972. // MedChrgitmType: item.MedChrgitmType,
  4973. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4974. // Status: 1,
  4975. // Memo: item.Memo,
  4976. // Mtime: time.Now().Unix(),
  4977. // InscpScpAmt: item.InscpScpAmt,
  4978. // DrtReimFlag: item.DrtReimFlag,
  4979. // Ctime: time.Now().Unix(),
  4980. // ListSpItemFlag: item.ListSpItemFlag,
  4981. // ChldMedcFlag: item.ChldMedcFlag,
  4982. // LmtUsedFlag: item.LmtUsedFlag,
  4983. // ChrgitmLv: item.ChrgitmLv,
  4984. // UserOrgId: adminUser.CurrentOrgId,
  4985. // HisPatientId: his.ID,
  4986. // OrderId: order.ID,
  4987. // ProjectId: project_id,
  4988. // Type: types,
  4989. // }
  4990. // service.CreateOrderInfo(info)
  4991. //
  4992. // }
  4993. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4994. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4995. //
  4996. // var total float64
  4997. // for _, item := range prescriptions {
  4998. // if item.Type == 1 { //药品
  4999. // for _, subItem := range item.HisDoctorAdviceInfo {
  5000. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5001. // }
  5002. // }
  5003. // if item.Type == 2 { //项目
  5004. // for _, subItem := range item.HisPrescriptionProject {
  5005. // total = total + (subItem.Price * float64(subItem.Count))
  5006. // }
  5007. // }
  5008. // }
  5009. //
  5010. // for _, item := range prescriptions {
  5011. // for _, subItem := range item.HisAdditionalCharge {
  5012. // total = total + (subItem.Price * float64(subItem.Count))
  5013. // }
  5014. // }
  5015. //
  5016. // allTotal := fmt.Sprintf("%.2f", total)
  5017. // if res.Infcode == 0 {
  5018. // var rf []*ResultFive
  5019. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5020. // psn_no := his.PsnNo
  5021. // mdtrt_id := his.Number
  5022. // chrg_bchno := chrg_bchno
  5023. // cert_no := his.Certno
  5024. // insutype := rf[0].Insutype
  5025. //
  5026. // if his.IdCardType == 1 {
  5027. // cert_no = his.MedicalInsuranceNumber
  5028. //
  5029. // } else {
  5030. //
  5031. // cert_no = his.Certno
  5032. //
  5033. // }
  5034. //
  5035. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5036. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5037. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5038. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5039. // resp, requestErr := http.Get(api)
  5040. // if requestErr != nil {
  5041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5042. // return
  5043. // }
  5044. // defer resp.Body.Close()
  5045. // body, ioErr := ioutil.ReadAll(resp.Body)
  5046. // if ioErr != nil {
  5047. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5049. // return
  5050. // }
  5051. // var respJSON map[string]interface{}
  5052. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5053. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5055. // return
  5056. // }
  5057. // fmt.Println(respJSON)
  5058. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5059. // userJSONBytes, _ := json.Marshal(respJSON)
  5060. // var res ResultSeven
  5061. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5062. // utils.ErrorLog("解析失败:%v", err)
  5063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5064. // return
  5065. // }
  5066. // if res.Infcode != 0 {
  5067. // errlog := &models.HisOrderError{
  5068. // UserOrgId: adminUser.CurrentOrgId,
  5069. // Ctime: time.Now().Unix(),
  5070. // Mtime: time.Now().Unix(),
  5071. // Number: chrg_bchno,
  5072. // ErrMsg: res.ErrMsg,
  5073. // Status: 1,
  5074. // PatientId: id,
  5075. // RecordTime: recordDateTime,
  5076. // Stage: 7,
  5077. // }
  5078. // service.CreateErrMsgLog(errlog)
  5079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5080. // return
  5081. // } else {
  5082. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5083. // order.OrderStatus = 1
  5084. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5085. // order.SetlId = res.Output.Setlinfo.SetlID
  5086. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5087. // order.PsnName = res.Output.Setlinfo.PsnName
  5088. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5089. // order.Certno = res.Output.Setlinfo.Certno
  5090. // order.Gend = res.Output.Setlinfo.Gend
  5091. // order.Naty = res.Output.Setlinfo.Naty
  5092. // order.Age = res.Output.Setlinfo.Age
  5093. // order.Insutype = res.Output.Setlinfo.Insutype
  5094. // order.PsnType = res.Output.Setlinfo.PsnType
  5095. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5096. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5097. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5098. // order.MedType = res.Output.Setlinfo.MedType
  5099. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5100. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5101. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5102. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5103. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5104. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5105. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5106. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5107. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5108. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5109. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5110. // order.MafPay = res.Output.Setlinfo.MafPay
  5111. // order.OthPay = res.Output.Setlinfo.OthPay
  5112. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5113. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5114. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5115. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5116. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5117. // order.Balc = res.Output.Setlinfo.Balc
  5118. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5119. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5120. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5121. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5122. // order.Creator = order.Creator
  5123. // order.Modify = roles.ID
  5124. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5125. // detailStr := string(setlDetail)
  5126. // order.SetlDetail = detailStr
  5127. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5128. // err = service.UpDateOrder(order)
  5129. // if err == nil {
  5130. // c.ServeSuccessJSON(map[string]interface{}{
  5131. // "msg": "预结算成功",
  5132. // })
  5133. // } else {
  5134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5135. // return
  5136. // }
  5137. // }
  5138. // } else {
  5139. // adminUser := c.GetAdminUserInfo()
  5140. // errlog := &models.HisOrderError{
  5141. // UserOrgId: adminUser.CurrentOrgId,
  5142. // Ctime: time.Now().Unix(),
  5143. // Mtime: time.Now().Unix(),
  5144. // ErrMsg: res.ErrMsg,
  5145. // Status: 1,
  5146. // PatientId: id,
  5147. // RecordTime: recordDateTime,
  5148. // Stage: 4,
  5149. // }
  5150. // service.CreateErrMsgLog(errlog)
  5151. //
  5152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5153. // return
  5154. // }
  5155. // } else {
  5156. // adminUser := c.GetAdminUserInfo()
  5157. // errlog := &models.HisOrderError{
  5158. // UserOrgId: adminUser.CurrentOrgId,
  5159. // Ctime: time.Now().Unix(),
  5160. // Mtime: time.Now().Unix(),
  5161. // ErrMsg: res.ErrMsg,
  5162. // Status: 1,
  5163. // PatientId: id,
  5164. // RecordTime: recordDateTime,
  5165. // Stage: 4,
  5166. // }
  5167. // service.CreateErrMsgLog(errlog)
  5168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5169. // return
  5170. // }
  5171. //
  5172. // } else {
  5173. // var total float64
  5174. // for _, item := range prescriptions {
  5175. // if item.Type == 1 { //药品
  5176. // for _, subItem := range item.HisDoctorAdviceInfo {
  5177. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5178. // }
  5179. // }
  5180. // if item.Type == 2 { //项目
  5181. // for _, subItem := range item.HisPrescriptionProject {
  5182. // total = total + (subItem.Price * float64(subItem.Count))
  5183. // }
  5184. // }
  5185. //
  5186. // for _, subItem := range item.HisAdditionalCharge {
  5187. // total = total + (subItem.Price * float64(subItem.Count))
  5188. // }
  5189. // }
  5190. //
  5191. // allTotal := fmt.Sprintf("%.2f", total)
  5192. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5193. // order := &models.HisOrder{
  5194. // UserOrgId: adminUser.CurrentOrgId,
  5195. // HisPatientId: his.ID,
  5196. // PatientId: id,
  5197. // SettleAccountsDate: recordDateTime,
  5198. // Ctime: time.Now().Unix(),
  5199. // Mtime: time.Now().Unix(),
  5200. // Status: 1,
  5201. // OrderStatus: 2,
  5202. // Number: chrg_bchno,
  5203. // MedfeeSumamt: totals,
  5204. // }
  5205. // err = service.CreateOrder(order)
  5206. // if err != nil {
  5207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5208. // return
  5209. // }
  5210. //
  5211. // var customs []*Custom
  5212. // for _, item := range prescriptions {
  5213. //
  5214. // if item.Type == 1 { //药品
  5215. // for _, subItem := range item.HisDoctorAdviceInfo {
  5216. // cus := &Custom{
  5217. // AdviceId: subItem.ID,
  5218. // ProjectId: 0,
  5219. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5220. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5221. // FeedetlSn: subItem.FeedetlSn,
  5222. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5223. // MedListCodg: subItem.MedListCodg,
  5224. // Type: 1,
  5225. // }
  5226. // customs = append(customs, cus)
  5227. // }
  5228. // }
  5229. //
  5230. // if item.Type == 2 { //项目
  5231. // for _, subItem := range item.HisPrescriptionProject {
  5232. //
  5233. // cus := &Custom{
  5234. // AdviceId: 0,
  5235. // ProjectId: subItem.ID,
  5236. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5237. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5238. // FeedetlSn: subItem.FeedetlSn,
  5239. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5240. // MedListCodg: subItem.MedListCodg,
  5241. // Type: 2,
  5242. // }
  5243. //
  5244. // customs = append(customs, cus)
  5245. // }
  5246. // }
  5247. //
  5248. // for _, item := range item.HisAdditionalCharge {
  5249. // cus := &Custom{
  5250. // ItemId: item.ID,
  5251. // AdviceId: 0,
  5252. // ProjectId: 0,
  5253. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5254. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5255. // FeedetlSn: item.FeedetlSn,
  5256. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5257. // MedListCodg: item.XtHisAddtionConfig.Code,
  5258. // Type: 3,
  5259. // }
  5260. //
  5261. // customs = append(customs, cus)
  5262. // }
  5263. //
  5264. // }
  5265. //
  5266. // for _, item := range customs {
  5267. // var advice_id int64 = 0
  5268. // var project_id int64 = 0
  5269. // var item_id int64 = 0
  5270. //
  5271. // var types int64 = 0
  5272. //
  5273. // if item.Type == 1 {
  5274. // advice_id = item.AdviceId
  5275. // project_id = 0
  5276. // item_id = 0
  5277. // } else if item.Type == 2 {
  5278. // advice_id = 0
  5279. // item_id = 0
  5280. //
  5281. // project_id = item.ProjectId
  5282. // } else if item.Type == 3 {
  5283. // advice_id = 0
  5284. // item_id = item.ItemId
  5285. // project_id = 0
  5286. // }
  5287. //
  5288. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5289. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5290. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5291. //
  5292. // info := &models.HisOrderInfo{
  5293. // OrderNumber: order.Number,
  5294. // UploadDate: time.Now().Unix(),
  5295. // AdviceId: advice_id,
  5296. // DetItemFeeSumamt: detItemFeeSumamt,
  5297. // Cnt: cut,
  5298. // Pric: pric,
  5299. // PatientId: id,
  5300. // Status: 1,
  5301. // Mtime: time.Now().Unix(),
  5302. // Ctime: time.Now().Unix(),
  5303. // UserOrgId: adminUser.CurrentOrgId,
  5304. // HisPatientId: his.ID,
  5305. // OrderId: order.ID,
  5306. // ProjectId: project_id,
  5307. // Type: types,
  5308. // ItemId: item_id,
  5309. // }
  5310. // service.CreateOrderInfo(info)
  5311. // }
  5312. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5313. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5314. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5315. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5316. // if err == nil {
  5317. // c.ServeSuccessJSON(map[string]interface{}{
  5318. // "msg": "结算成功",
  5319. // })
  5320. // } else {
  5321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5322. // return
  5323. // }
  5324. // }
  5325. //}
  5326. //上传明细-预结算-
  5327. func (c *HisApiController) GetPreUploadInfo() {
  5328. id, _ := c.GetInt64("id")
  5329. record_time := c.GetString("record_time")
  5330. his_patient_id, _ := c.GetInt64("his_patient_id")
  5331. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5332. admin_user_id, _ := c.GetInt64("admin_user_id")
  5333. diagnosis_id := c.GetString("diagnosis")
  5334. sick_type, _ := c.GetInt64("sick_type")
  5335. reg_type, _ := c.GetInt64("p_type")
  5336. begin_time := c.GetString("begin_time")
  5337. id_str := c.GetString("ids")
  5338. ids_arr := strings.Split(id_str, ",")
  5339. timeLayout := "2006-01-02"
  5340. loc, _ := time.LoadLocation("Local")
  5341. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5342. if err != nil {
  5343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5344. return
  5345. }
  5346. recordDateTime := theTime.Unix()
  5347. adminUser := c.GetAdminUserInfo()
  5348. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5349. var config []*models.HisXtDiagnoseConfig
  5350. for _, item := range diagnosis_ids {
  5351. id, _ := strconv.ParseInt(item, 10, 64)
  5352. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5353. config = append(config, &diagnosisConfig)
  5354. }
  5355. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5356. sickConfig, _ := service.FindSickById(sick_type)
  5357. var prescriptions []*models.HisPrescription
  5358. var start_time int64
  5359. var end_time int64
  5360. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5361. fmt.Println(his_patient_id)
  5362. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5363. timestamp := time.Now().Unix()
  5364. tempTime := time.Unix(timestamp, 0)
  5365. timeFormat := tempTime.Format("20060102150405")
  5366. chrgBchno := rand.Intn(100000) + 10000
  5367. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5368. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5369. var patientPrescription models.HisPrescriptionInfo
  5370. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5371. if patientPrescription.ID == 0 {
  5372. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5373. }
  5374. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5375. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5376. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5377. strconv.FormatInt(his.PatientId, 10)
  5378. var res2 ResultSix
  5379. var resSix10265 ResultSix10265
  5380. var time_stamp string
  5381. if miConfig.MdtrtareaAdmvs == "421300" {
  5382. data := make(map[string]interface{})
  5383. client := &http.Client{}
  5384. data["psn_no"] = his.PsnNo
  5385. data["mdtrt_id"] = his.Number
  5386. data["doctor"] = roles.UserName
  5387. data["department"] = department.Name
  5388. data["org_name"] = miConfig.OrgName
  5389. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5390. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5391. data["fixmedins_code"] = miConfig.Code
  5392. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5393. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5394. data["secret_key"] = miConfig.SecretKey
  5395. data["sick_code"] = sickConfig.CountryCode
  5396. data["sick_name"] = sickConfig.ClassName
  5397. data["begin_time"] = begin_time
  5398. data["dept"] = strconv.FormatInt(department.ID, 10)
  5399. data["config"] = config
  5400. fmt.Println(data)
  5401. bytesData, _ := json.Marshal(data)
  5402. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5403. resp, _ := client.Do(req)
  5404. defer resp.Body.Close()
  5405. body, ioErr := ioutil.ReadAll(resp.Body)
  5406. if ioErr != nil {
  5407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5409. return
  5410. }
  5411. var respJSON map[string]interface{}
  5412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5415. return
  5416. }
  5417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5418. userJSONBytes, _ := json.Marshal(respJSON)
  5419. fmt.Println("log")
  5420. fmt.Println(string(userJSONBytes))
  5421. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5422. utils.ErrorLog("解析失败:%v", err)
  5423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5424. return
  5425. }
  5426. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5427. //江苏地区国家医保医疗类别
  5428. //职工透析:医疗类别选特殊情况门诊9933
  5429. //居民血透门慢: 医疗类别选门诊慢病1402
  5430. //var med_type string
  5431. //if his.Insutype == "310" {
  5432. // if reg_type == 14 {
  5433. // med_type = "9933"
  5434. // } else if reg_type == 11 {
  5435. // med_type = "11"
  5436. //
  5437. // }
  5438. //} else if his.Insutype == "390" {
  5439. // if reg_type == 14 {
  5440. // med_type = "1402"
  5441. // } else if reg_type == 11 {
  5442. // med_type = "11"
  5443. // }
  5444. //}
  5445. data := make(map[string]interface{})
  5446. client := &http.Client{}
  5447. data["psn_no"] = his.PsnNo
  5448. data["mdtrt_id"] = his.Number
  5449. data["doctor"] = roles.UserName
  5450. data["department"] = department.Name
  5451. data["org_name"] = miConfig.OrgName
  5452. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5453. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5454. data["fixmedins_code"] = miConfig.Code
  5455. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5456. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5457. data["secret_key"] = miConfig.SecretKey
  5458. data["sick_code"] = sickConfig.CountryCode
  5459. data["sick_name"] = sickConfig.ClassName
  5460. data["begin_time"] = begin_time
  5461. data["dept"] = strconv.FormatInt(department.ID, 10)
  5462. data["config"] = config
  5463. data["url"] = miConfig.Url
  5464. data["ak"] = miConfig.AccessKey
  5465. data["cainfo"] = miConfig.Cainfo
  5466. bytesData, _ := json.Marshal(data)
  5467. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5468. resp, _ := client.Do(req)
  5469. defer resp.Body.Close()
  5470. body, ioErr := ioutil.ReadAll(resp.Body)
  5471. if ioErr != nil {
  5472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5474. return
  5475. }
  5476. var respJSON map[string]interface{}
  5477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5480. return
  5481. }
  5482. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5483. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5484. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5486. userJSONBytes, _ := json.Marshal(respJSON)
  5487. fmt.Println("log")
  5488. fmt.Println(string(userJSONBytes))
  5489. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5490. utils.ErrorLog("解析失败:%v", err)
  5491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5492. return
  5493. }
  5494. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5495. res2.Output = resSix10265.Output
  5496. res2.ErrMsg = resSix10265.ErrMsg
  5497. res2.Cainfo = resSix10265.Cainfo
  5498. res2.WarnMsg = resSix10265.WarnMsg
  5499. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5500. res2.Infcode = infocode
  5501. } else {
  5502. var result string
  5503. var requestLog string
  5504. if miConfig.MdtrtareaAdmvs == "440781" { //
  5505. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5506. } else {
  5507. if miConfig.Code == "H15049901371" {
  5508. //赤峰地区国家医保医疗类别
  5509. //职工透析:医疗类别选特殊情况门诊990502
  5510. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5511. var med_type string
  5512. if his.Insutype == "390" {
  5513. if reg_type == 14 {
  5514. med_type = "9933"
  5515. } else if reg_type == 11 {
  5516. med_type = "11"
  5517. }
  5518. } else if his.Insutype == "310" {
  5519. if reg_type == 14 {
  5520. med_type = "990502"
  5521. } else if reg_type == 11 {
  5522. med_type = "11"
  5523. }
  5524. }
  5525. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5526. } else {
  5527. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5528. }
  5529. saveLog(result, requestLog, "2203", "上传就诊信息")
  5530. var respJSON2 map[string]interface{}
  5531. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5534. return
  5535. }
  5536. userJSONBytes2, _ := json.Marshal(respJSON2)
  5537. if miConfig.Code == "H15049901371" {
  5538. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5539. utils.ErrorLog("解析失败:%v", err)
  5540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5541. return
  5542. }
  5543. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5544. res2.Output = resSix10265.Output
  5545. res2.ErrMsg = resSix10265.ErrMsg
  5546. res2.Cainfo = resSix10265.Cainfo
  5547. res2.WarnMsg = resSix10265.WarnMsg
  5548. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5549. res2.Infcode = infocode
  5550. } else {
  5551. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5552. utils.ErrorLog("解析失败:%v", err)
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return
  5555. }
  5556. }
  5557. }
  5558. }
  5559. if res2.Infcode != 0 {
  5560. adminUser := c.GetAdminUserInfo()
  5561. errlog := &models.HisOrderError{
  5562. UserOrgId: adminUser.CurrentOrgId,
  5563. Ctime: time.Now().Unix(),
  5564. Mtime: time.Now().Unix(),
  5565. ErrMsg: res2.ErrMsg,
  5566. Status: 1,
  5567. PatientId: id,
  5568. RecordTime: recordDateTime,
  5569. Stage: 3,
  5570. }
  5571. service.CreateErrMsgLog(errlog)
  5572. c.ServeSuccessJSON(map[string]interface{}{
  5573. "failed_code": -10,
  5574. "msg": res2.ErrMsg,
  5575. })
  5576. return
  5577. } else {
  5578. his.Diagnosis = diagnosis_id
  5579. his.SickType = sickConfig.ID
  5580. his.PType = fmt.Sprintf("%d", reg_type)
  5581. service.UpdateHisPatientThree(&his)
  5582. data := make(map[string]interface{})
  5583. if settle_accounts_type == 1 { //日结
  5584. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5585. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5586. } else {
  5587. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5588. }
  5589. data["pre"] = prescriptions
  5590. } else { //月结
  5591. start_time_str := c.GetString("start_time")
  5592. end_time_str := c.GetString("end_time")
  5593. timeLayout := "2006-01-02"
  5594. loc, _ := time.LoadLocation("Local")
  5595. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5596. if err != nil {
  5597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5598. return
  5599. }
  5600. recordStartTime := theStartTime.Unix()
  5601. start_time = recordStartTime
  5602. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5603. if err != nil {
  5604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5605. return
  5606. }
  5607. recordEndTime := theEndTime.Unix()
  5608. end_time = recordEndTime
  5609. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5610. data["pre"] = prescriptions
  5611. }
  5612. client := &http.Client{}
  5613. data["psn_no"] = his.PsnNo
  5614. data["mdtrt_id"] = his.Number
  5615. data["chrg_bchno"] = chrg_bchno
  5616. data["org_name"] = miConfig.OrgName
  5617. data["doctor"] = roles.UserName
  5618. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5619. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5620. data["fixmedins_code"] = miConfig.Code
  5621. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5622. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5623. data["dept_code"] = "15"
  5624. } else {
  5625. data["dept_code"] = department.Number
  5626. }
  5627. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5628. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5629. data["secret_key"] = miConfig.SecretKey
  5630. data["url"] = miConfig.Url
  5631. data["ak"] = miConfig.AccessKey
  5632. data["new_doctor_name"] = patientPrescription.Doctor
  5633. data["diag_code"] = sickConfig.CountryCode
  5634. data["time_stamp"] = time_stamp
  5635. data["cainfo"] = miConfig.Cainfo
  5636. var ids []int64
  5637. for _, item := range prescriptions {
  5638. ids = append(ids, item.ID)
  5639. }
  5640. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5641. if config.IsOpen == 1 { //对接了医保,走医保流程
  5642. var res ResultFour
  5643. var resFour10265 ResultFour10265
  5644. if miConfig.MdtrtareaAdmvs == "421300" {
  5645. bytesData, _ := json.Marshal(data)
  5646. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5647. resp, _ := client.Do(req)
  5648. defer resp.Body.Close()
  5649. body, ioErr := ioutil.ReadAll(resp.Body)
  5650. if ioErr != nil {
  5651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5653. return
  5654. }
  5655. var respJSON map[string]interface{}
  5656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5659. return
  5660. }
  5661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5662. userJSONBytes, _ := json.Marshal(respJSON)
  5663. fmt.Println("log")
  5664. fmt.Println(string(userJSONBytes))
  5665. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5666. utils.ErrorLog("解析失败:%v", err)
  5667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5668. return
  5669. }
  5670. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5671. bytesData, _ := json.Marshal(data)
  5672. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5673. resp, _ := client.Do(req)
  5674. defer resp.Body.Close()
  5675. body, ioErr := ioutil.ReadAll(resp.Body)
  5676. if ioErr != nil {
  5677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5679. return
  5680. }
  5681. var respJSON map[string]interface{}
  5682. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5685. return
  5686. }
  5687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5688. userJSONBytes, _ := json.Marshal(respJSON)
  5689. fmt.Println("log")
  5690. fmt.Println(string(userJSONBytes))
  5691. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5692. utils.ErrorLog("解析失败:%v", err)
  5693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5694. return
  5695. }
  5696. res.InfRefmsgid = resFour10265.InfRefmsgid
  5697. res.Output = resFour10265.Output
  5698. res.ErrMsg = resFour10265.ErrMsg
  5699. res.Cainfo = resFour10265.Cainfo
  5700. res.WarnMsg = resFour10265.WarnMsg
  5701. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5702. res.Infcode = infocode
  5703. } else {
  5704. if miConfig.Code == "H15049901371" {
  5705. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  5706. var dat map[string]interface{}
  5707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5708. fmt.Println(dat)
  5709. } else {
  5710. fmt.Println(err)
  5711. }
  5712. saveLog(result, request_log, "2204", "上传费用明细")
  5713. userJSONBytes, _ := json.Marshal(dat)
  5714. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5715. utils.ErrorLog("解析失败:%v", err)
  5716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5717. return
  5718. }
  5719. res.InfRefmsgid = resFour10265.InfRefmsgid
  5720. res.Output = resFour10265.Output
  5721. res.ErrMsg = resFour10265.ErrMsg
  5722. res.Cainfo = resFour10265.Cainfo
  5723. res.WarnMsg = resFour10265.WarnMsg
  5724. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5725. res.Infcode = infocode
  5726. } else {
  5727. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  5728. var dat map[string]interface{}
  5729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5730. fmt.Println(dat)
  5731. } else {
  5732. fmt.Println(err)
  5733. }
  5734. saveLog(result, request_log, "2204", "上传费用明细")
  5735. userJSONBytes, _ := json.Marshal(dat)
  5736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5737. utils.ErrorLog("解析失败:%v", err)
  5738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5739. return
  5740. }
  5741. }
  5742. }
  5743. if res.Infcode == 0 {
  5744. order := &models.HisOrder{
  5745. UserOrgId: adminUser.CurrentOrgId,
  5746. HisPatientId: his.ID,
  5747. PatientId: his.PatientId,
  5748. SettleAccountsDate: recordDateTime,
  5749. Ctime: time.Now().Unix(),
  5750. Mtime: time.Now().Unix(),
  5751. MdtrtId: his.Number,
  5752. PsnNo: his.PsnNo,
  5753. MedType: strconv.FormatInt(reg_type, 10),
  5754. Status: 1,
  5755. Number: chrg_bchno,
  5756. Infcode: res.Infcode,
  5757. WarnMsg: res.WarnMsg,
  5758. Cainfo: res.Cainfo,
  5759. ErrMsg: res.ErrMsg,
  5760. RespondTime: res.RefmsgTime,
  5761. InfRefmsgid: res.InfRefmsgid,
  5762. OrderStatus: 1,
  5763. IsMedicineInsurance: 1,
  5764. SettleType: settle_accounts_type,
  5765. SettleStartTime: start_time,
  5766. SettleEndTime: end_time,
  5767. Creator: roles.AdminUserId,
  5768. Modify: roles.AdminUserId,
  5769. PType: 2,
  5770. Diagnosis: diagnosis_id,
  5771. }
  5772. err = service.CreateOrder(order)
  5773. if err != nil {
  5774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5775. return
  5776. }
  5777. for _, item := range res.Output.Result {
  5778. temp := strings.Split(item.FeedetlSn, "-")
  5779. var advice_id int64 = 0
  5780. var project_id int64 = 0
  5781. var types int64 = 0
  5782. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5783. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5784. if temp[1] == "1" {
  5785. advice_id = id
  5786. project_id = 0
  5787. } else if temp[1] == "2" {
  5788. advice_id = 0
  5789. project_id = id
  5790. }
  5791. info := &models.HisOrderInfo{
  5792. OrderNumber: order.Number,
  5793. FeedetlSn: item.FeedetlSn,
  5794. UploadDate: time.Now().Unix(),
  5795. AdviceId: advice_id,
  5796. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5797. Cnt: item.Cnt,
  5798. Pric: float64(item.Pric),
  5799. PatientId: his.PatientId,
  5800. PricUplmtAmt: item.PricUplmtAmt,
  5801. SelfpayProp: item.SelfpayProp,
  5802. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5803. OverlmtAmt: item.OverlmtAmt,
  5804. PreselfpayAmt: item.PreselfpayAmt,
  5805. BasMednFlag: item.BasMednFlag,
  5806. MedChrgitmType: item.MedChrgitmType,
  5807. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5808. Status: 1,
  5809. Memo: item.Memo,
  5810. Mtime: time.Now().Unix(),
  5811. InscpScpAmt: item.InscpScpAmt,
  5812. DrtReimFlag: item.DrtReimFlag,
  5813. Ctime: time.Now().Unix(),
  5814. ListSpItemFlag: item.ListSpItemFlag,
  5815. ChldMedcFlag: item.ChldMedcFlag,
  5816. LmtUsedFlag: item.LmtUsedFlag,
  5817. ChrgitmLv: item.ChrgitmLv,
  5818. UserOrgId: adminUser.CurrentOrgId,
  5819. HisPatientId: his.ID,
  5820. OrderId: order.ID,
  5821. ProjectId: project_id,
  5822. Type: types,
  5823. }
  5824. service.CreateOrderInfo(info)
  5825. }
  5826. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5827. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5828. var total float64
  5829. for _, item := range prescriptions {
  5830. if item.Type == 1 { //药品
  5831. for _, subItem := range item.HisDoctorAdviceInfo {
  5832. total = total + (subItem.Price * subItem.PrescribingNumber)
  5833. }
  5834. }
  5835. if item.Type == 2 { //项目
  5836. for _, subItem := range item.HisPrescriptionProject {
  5837. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5838. total = total + (subItem.Price * cnt)
  5839. }
  5840. }
  5841. }
  5842. for _, item := range prescriptions {
  5843. for _, subItem := range item.HisAdditionalCharge {
  5844. total = total + (subItem.Price * float64(subItem.Count))
  5845. }
  5846. }
  5847. allTotal := fmt.Sprintf("%.4f", total)
  5848. if res.Infcode == 0 {
  5849. var rf []*ResultFive
  5850. json.Unmarshal([]byte(his.Iinfo), &rf)
  5851. chrg_bchno := chrg_bchno
  5852. cert_no := his.Certno
  5853. var insutypes []string
  5854. var insutype string
  5855. var is390 int = 0
  5856. var is310 int = 0
  5857. for _, item := range rf {
  5858. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5859. insutypes = append(insutypes, item.Insutype)
  5860. }
  5861. }
  5862. if len(insutypes) == 1 {
  5863. insutype = insutypes[0]
  5864. } else {
  5865. for _, i := range insutypes {
  5866. if i == "390" {
  5867. is390 = 1
  5868. }
  5869. if i == "310" {
  5870. is310 = 1
  5871. }
  5872. }
  5873. }
  5874. if is390 == 1 {
  5875. insutype = "390"
  5876. }
  5877. if is310 == 1 {
  5878. insutype = "310"
  5879. }
  5880. if len(insutypes) == 0 {
  5881. insutype = "310"
  5882. }
  5883. if len(insutypes) == 2 {
  5884. insutype = strconv.FormatInt(his.SocialType, 64)
  5885. }
  5886. //insutype = "390"
  5887. if his.IdCardType == 1 {
  5888. cert_no = his.MedicalInsuranceNumber
  5889. } else {
  5890. cert_no = his.Certno
  5891. }
  5892. var res ResultSeven
  5893. var resSeven10265 ResultSeven10265
  5894. if miConfig.MdtrtareaAdmvs == "421300" {
  5895. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5896. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5897. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5898. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5899. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5900. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5901. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5902. resp, requestErr := http.Get(api)
  5903. if requestErr != nil {
  5904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5905. return
  5906. }
  5907. body, ioErr := ioutil.ReadAll(resp.Body)
  5908. if ioErr != nil {
  5909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5911. return
  5912. }
  5913. var respJSON map[string]interface{}
  5914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5917. return
  5918. }
  5919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5920. result, _ := json.Marshal(respJSON)
  5921. fmt.Println("log")
  5922. fmt.Println(string(result))
  5923. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5924. utils.ErrorLog("解析失败:%v", err)
  5925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5926. return
  5927. }
  5928. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5929. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5930. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5931. bas := strings.Split(psn_info.CardInfo, "|")
  5932. if his.IdCardType == 1 {
  5933. cert_no = bas[2]
  5934. } else {
  5935. cert_no = bas[1]
  5936. }
  5937. //江苏地区国家医保医疗类别
  5938. //职工透析:医疗类别选特殊情况门诊9933
  5939. //居民血透门慢: 医疗类别选门诊慢病1402
  5940. //var med_type string
  5941. //if his.Insutype == "310" {
  5942. // if reg_type == 14 {
  5943. // med_type = "9933"
  5944. // } else if reg_type == 11 {
  5945. // med_type = "11"
  5946. //
  5947. // }
  5948. //} else if his.Insutype == "390" {
  5949. // if reg_type == 14 {
  5950. // med_type = "1402"
  5951. // } else if reg_type == 11 {
  5952. // med_type = "11"
  5953. // }
  5954. //}
  5955. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5956. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5957. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5958. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5959. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5960. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5961. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5962. resp, requestErr := http.Get(api)
  5963. if requestErr != nil {
  5964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5965. return
  5966. }
  5967. body, ioErr := ioutil.ReadAll(resp.Body)
  5968. if ioErr != nil {
  5969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5971. return
  5972. }
  5973. var respJSON map[string]interface{}
  5974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5977. return
  5978. }
  5979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5980. result, _ := json.Marshal(respJSON)
  5981. fmt.Println("log")
  5982. fmt.Println(string(result))
  5983. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5984. utils.ErrorLog("解析失败:%v", err)
  5985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5986. return
  5987. }
  5988. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5989. res.Output = resSeven10265.Output
  5990. res.ErrMsg = resSeven10265.ErrMsg
  5991. res.Cainfo = resSeven10265.Cainfo
  5992. res.WarnMsg = resSeven10265.WarnMsg
  5993. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5994. res.Infcode = infocode
  5995. } else {
  5996. var result string
  5997. var request_log string
  5998. if miConfig.Code == "H15049901371" {
  5999. //赤峰地区国家医保医疗类别
  6000. //职工透析:医疗类别选特殊情况门诊990502
  6001. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6002. var med_type string
  6003. if his.Insutype == "390" {
  6004. if reg_type == 14 {
  6005. med_type = "9933"
  6006. } else if reg_type == 11 {
  6007. med_type = "11"
  6008. }
  6009. } else if his.Insutype == "310" {
  6010. if reg_type == 14 {
  6011. med_type = "990502"
  6012. } else if reg_type == 11 {
  6013. med_type = "11"
  6014. }
  6015. }
  6016. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  6017. } else {
  6018. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  6019. }
  6020. var dat map[string]interface{}
  6021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6022. fmt.Println(dat)
  6023. } else {
  6024. fmt.Println(err)
  6025. }
  6026. saveLog(result, request_log, "2206", "预结算")
  6027. //userJSONBytes, _ := json.Marshal(dat)
  6028. //
  6029. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6030. // utils.ErrorLog("解析失败:%v", err)
  6031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6032. // return
  6033. //}
  6034. userJSONBytes, _ := json.Marshal(dat)
  6035. if miConfig.Code == "H15049901371" {
  6036. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6037. utils.ErrorLog("解析失败:%v", err)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. return
  6040. }
  6041. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6042. res.Output = resSeven10265.Output
  6043. res.ErrMsg = resSeven10265.ErrMsg
  6044. res.Cainfo = resSeven10265.Cainfo
  6045. res.WarnMsg = resSeven10265.WarnMsg
  6046. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6047. res.Infcode = infocode
  6048. } else {
  6049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6050. utils.ErrorLog("解析失败:%v", err)
  6051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6052. return
  6053. }
  6054. }
  6055. }
  6056. if res.Infcode != 0 {
  6057. errlog := &models.HisOrderError{
  6058. UserOrgId: adminUser.CurrentOrgId,
  6059. Ctime: time.Now().Unix(),
  6060. Mtime: time.Now().Unix(),
  6061. Number: chrg_bchno,
  6062. ErrMsg: res.ErrMsg,
  6063. Status: 1,
  6064. PatientId: id,
  6065. RecordTime: recordDateTime,
  6066. Stage: 20,
  6067. }
  6068. service.CreateErrMsgLog(errlog)
  6069. c.ServeSuccessJSON(map[string]interface{}{
  6070. "failed_code": -10,
  6071. "msg": res.ErrMsg,
  6072. })
  6073. return
  6074. } else {
  6075. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6076. order.OrderStatus = 1
  6077. order.IsPre = 1
  6078. order.Status = 1
  6079. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6080. order.SetlId = res.Output.Setlinfo.SetlID
  6081. order.PsnNo = res.Output.Setlinfo.PsnNo
  6082. order.PsnName = res.Output.Setlinfo.PsnName
  6083. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6084. order.Certno = res.Output.Setlinfo.Certno
  6085. order.Gend = res.Output.Setlinfo.Gend
  6086. order.Naty = res.Output.Setlinfo.Naty
  6087. order.Age = res.Output.Setlinfo.Age
  6088. order.Insutype = res.Output.Setlinfo.Insutype
  6089. order.PsnType = res.Output.Setlinfo.PsnType
  6090. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6091. order.SetlTime = res.Output.Setlinfo.SetlTime
  6092. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6093. if res.Output.Setlinfo.MedType == "140101" {
  6094. order.MedType = "14"
  6095. } else {
  6096. order.MedType = res.Output.Setlinfo.MedType
  6097. }
  6098. if reg_type == 1112 {
  6099. order.MedType = "1112"
  6100. }
  6101. if reg_type == 1111 {
  6102. order.MedType = "1111"
  6103. }
  6104. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6105. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6106. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6107. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6108. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6109. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6110. order.HifpPay = res.Output.Setlinfo.HifpPay
  6111. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6112. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6113. order.HifesPay = res.Output.Setlinfo.HifesPay
  6114. order.HifobPay = res.Output.Setlinfo.HifobPay
  6115. order.MafPay = res.Output.Setlinfo.MafPay
  6116. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6117. order.OthPay = res.Output.Setlinfo.OthPay
  6118. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6119. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6120. order.AcctPay = res.Output.Setlinfo.AcctPay
  6121. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6122. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6123. order.Balc = res.Output.Setlinfo.Balc
  6124. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6125. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6126. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6127. order.ClrWay = res.Output.Setlinfo.ClrWay
  6128. order.Creator = order.Creator
  6129. order.Modify = roles.AdminUserId
  6130. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6131. detailStr := string(setlDetail)
  6132. order.SetlDetail = detailStr
  6133. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6134. err = service.UpDateOrder(order)
  6135. if err == nil {
  6136. c.ServeSuccessJSON(map[string]interface{}{
  6137. "msg": "预结算成功",
  6138. })
  6139. } else {
  6140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6141. return
  6142. }
  6143. }
  6144. } else {
  6145. adminUser := c.GetAdminUserInfo()
  6146. errlog := &models.HisOrderError{
  6147. UserOrgId: adminUser.CurrentOrgId,
  6148. Ctime: time.Now().Unix(),
  6149. Mtime: time.Now().Unix(),
  6150. ErrMsg: res.ErrMsg,
  6151. Status: 1,
  6152. PatientId: id,
  6153. RecordTime: recordDateTime,
  6154. Stage: 4,
  6155. }
  6156. service.CreateErrMsgLog(errlog)
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6158. return
  6159. }
  6160. } else {
  6161. adminUser := c.GetAdminUserInfo()
  6162. errlog := &models.HisOrderError{
  6163. UserOrgId: adminUser.CurrentOrgId,
  6164. Ctime: time.Now().Unix(),
  6165. Mtime: time.Now().Unix(),
  6166. ErrMsg: res.ErrMsg,
  6167. Status: 1,
  6168. PatientId: id,
  6169. RecordTime: recordDateTime,
  6170. Stage: 4,
  6171. }
  6172. service.CreateErrMsgLog(errlog)
  6173. c.ServeSuccessJSON(map[string]interface{}{
  6174. "failed_code": -10,
  6175. "msg": res.ErrMsg,
  6176. })
  6177. return
  6178. }
  6179. }
  6180. }
  6181. }
  6182. //func (c *HisApiController) GetSettleInfo() {
  6183. // id, _ := c.GetInt64("id")
  6184. // order_id, _ := c.GetInt64("order_id")
  6185. //
  6186. // record_time := c.GetString("record_time")
  6187. // pay_way, _ := c.GetInt64("pay_way")
  6188. // pay_price, _ := c.GetFloat("pay_price")
  6189. // pay_card_no := c.GetString("pay_card_no")
  6190. // discount_price, _ := c.GetFloat("discount_price")
  6191. // preferential_price, _ := c.GetFloat("preferential_price")
  6192. // reality_price, _ := c.GetFloat("reality_price")
  6193. // found_price, _ := c.GetFloat("found_price")
  6194. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6195. // private_price, _ := c.GetFloat("private_price")
  6196. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6197. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6198. //
  6199. // timeLayout := "2006-01-02"
  6200. // loc, _ := time.LoadLocation("Local")
  6201. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6202. // if err != nil {
  6203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6204. // return
  6205. // }
  6206. // recordDateTime := theTime.Unix()
  6207. // adminUser := c.GetAdminUserInfo()
  6208. //
  6209. // var prescriptions []*models.HisPrescription
  6210. //
  6211. // data := make(map[string]interface{})
  6212. // if settle_accounts_type == 1 { //日结
  6213. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6214. // data["pre"] = prescriptions
  6215. //
  6216. // } else { //月结
  6217. // start_time_str := c.GetString("start_time")
  6218. // end_time_str := c.GetString("end_time")
  6219. // timeLayout := "2006-01-02"
  6220. // loc, _ := time.LoadLocation("Local")
  6221. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6222. // if err != nil {
  6223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6224. // return
  6225. // }
  6226. // recordStartTime := theStartTime.Unix()
  6227. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6228. // if err != nil {
  6229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6230. // return
  6231. // }
  6232. // recordEndTime := theEndTime.Unix()
  6233. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6234. // data["pre"] = prescriptions
  6235. //
  6236. // }
  6237. //
  6238. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6239. //
  6240. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6241. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6242. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6243. // strconv.FormatInt(his.PatientId, 10)
  6244. //
  6245. // order_src, _ := service.GetHisOrderByID(order_id)
  6246. //
  6247. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6248. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6249. //
  6250. // var total float64
  6251. // for _, item := range prescriptions {
  6252. // if item.Type == 1 { //药品
  6253. // for _, subItem := range item.HisDoctorAdviceInfo {
  6254. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6255. // }
  6256. // }
  6257. // if item.Type == 2 { //项目
  6258. // for _, subItem := range item.HisPrescriptionProject {
  6259. // total = total + (subItem.Price * float64(subItem.Count))
  6260. // }
  6261. // }
  6262. // }
  6263. //
  6264. // for _, item := range prescriptions {
  6265. // for _, subItem := range item.HisAdditionalCharge {
  6266. // total = total + (subItem.Price * float64(subItem.Count))
  6267. // }
  6268. // }
  6269. //
  6270. // allTotal := fmt.Sprintf("%.2f", total)
  6271. // var rf []*ResultFive
  6272. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6273. // psn_no := order_src.PsnNo
  6274. // mdtrt_id := order_src.MdtrtId
  6275. // chrg_bchno := order_src.Number
  6276. // cert_no := order_src.Certno
  6277. // insutype := rf[0].Insutype
  6278. //
  6279. // if his.IdCardType == 1 {
  6280. // cert_no = his.MedicalInsuranceNumber
  6281. // } else {
  6282. // cert_no = his.Certno
  6283. // }
  6284. //
  6285. // 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)
  6286. // var dat map[string]interface{}
  6287. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6288. // fmt.Println(dat)
  6289. // } else {
  6290. // fmt.Println(err)
  6291. // }
  6292. //
  6293. // userJSONBytes, _ := json.Marshal(dat)
  6294. //
  6295. //
  6296. //
  6297. // var res ResultSeven
  6298. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6299. // utils.ErrorLog("解析失败:%v", err)
  6300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6301. // return
  6302. // }
  6303. // if res.Infcode == -1 {
  6304. // errlog := &models.HisOrderError{
  6305. // UserOrgId: adminUser.CurrentOrgId,
  6306. // Ctime: time.Now().Unix(),
  6307. // Mtime: time.Now().Unix(),
  6308. // Number: chrg_bchno,
  6309. // ErrMsg: res.ErrMsg,
  6310. // Status: 1,
  6311. // PatientId: id,
  6312. // RecordTime: recordDateTime,
  6313. // Stage: 6,
  6314. // }
  6315. // service.CreateErrMsgLog(errlog)
  6316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6317. // return
  6318. // } else {
  6319. // order_src.OrderStatus = 2
  6320. // order_src.PayWay = pay_way
  6321. // order_src.PayPrice = pay_price
  6322. // order_src.PayCardNo = pay_card_no
  6323. // order_src.DiscountPrice = discount_price
  6324. // order_src.PreferentialPrice = preferential_price
  6325. // order_src.RealityPrice = reality_price
  6326. // order_src.FoundPrice = found_price
  6327. // order_src.MedicalInsurancePrice = medical_insurance_price
  6328. // order_src.PrivatePrice = private_price
  6329. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6330. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6331. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6332. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6333. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6334. // order_src.Certno = res.Output.Setlinfo.Certno
  6335. // order_src.Gend = res.Output.Setlinfo.Gend
  6336. // order_src.Naty = res.Output.Setlinfo.Naty
  6337. // order_src.Age = res.Output.Setlinfo.Age
  6338. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6339. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6340. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6341. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6342. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6343. // order_src.MedType = res.Output.Setlinfo.MedType
  6344. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6345. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6346. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6347. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6348. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6349. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6350. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6351. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6352. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6353. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6354. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6355. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6356. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6357. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6358. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6359. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6360. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6361. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6362. // order_src.Balc = res.Output.Setlinfo.Balc
  6363. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6364. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6365. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6366. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6367. // order_src.Creator = order_src.Creator
  6368. // order_src.Modify = roles.ID
  6369. // order_src.RequestLog = src_resquest
  6370. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6371. // detailStr := string(setlDetail)
  6372. // order_src.SetlDetail = detailStr
  6373. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6374. // err = service.UpDateOrder(order_src)
  6375. //
  6376. // if err == nil {
  6377. // c.ServeSuccessJSON(map[string]interface{}{
  6378. // "msg": "结算成功",
  6379. // })
  6380. // } else {
  6381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6382. // return
  6383. // }
  6384. // }
  6385. // }
  6386. //}
  6387. //退款
  6388. func (c *HisApiController) Refund() {
  6389. order_id, _ := c.GetInt64("order_id")
  6390. admin_user_id, _ := c.GetInt64("admin_user_id")
  6391. adminUser := c.GetAdminUserInfo()
  6392. var order models.HisOrder
  6393. order, _ = service.GetHisOrderByID(order_id)
  6394. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6395. if order.ID == 0 {
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6397. return
  6398. }
  6399. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6400. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6401. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6402. if config.IsOpen == 1 { //对接了医保,走医保流程
  6403. var res ResultSixteen
  6404. var resSixteen10265 ResultSixteen10265
  6405. var src_resquest string
  6406. var result string
  6407. if miConfig.MdtrtareaAdmvs == "421300" {
  6408. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6409. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6410. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6411. resp3, requestErr3 := http.Get(api3)
  6412. if requestErr3 != nil {
  6413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6414. return
  6415. }
  6416. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6417. if ioErr3 != nil {
  6418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. return
  6421. }
  6422. var respJSON3 map[string]interface{}
  6423. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6426. return
  6427. }
  6428. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6429. userJSONBytes3, _ := json.Marshal(respJSON3)
  6430. fmt.Println("log")
  6431. fmt.Println(string(userJSONBytes3))
  6432. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6433. utils.ErrorLog("解析失败:%v", err)
  6434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. return
  6436. }
  6437. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6438. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6439. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6440. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6441. resp3, requestErr3 := http.Get(api3)
  6442. if requestErr3 != nil {
  6443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6444. return
  6445. }
  6446. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6447. if ioErr3 != nil {
  6448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6450. return
  6451. }
  6452. var respJSON3 map[string]interface{}
  6453. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6456. return
  6457. }
  6458. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6459. userJSONBytes3, _ := json.Marshal(respJSON3)
  6460. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6461. utils.ErrorLog("解析失败:%v", err)
  6462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6463. return
  6464. }
  6465. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6466. res.Output = resSixteen10265.Output
  6467. res.ErrMsg = resSixteen10265.ErrMsg
  6468. res.Cainfo = resSixteen10265.Cainfo
  6469. res.WarnMsg = resSixteen10265.WarnMsg
  6470. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6471. res.Infcode = infocode
  6472. } else {
  6473. if miConfig.Code == "H15049901371" {
  6474. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6475. var dat map[string]interface{}
  6476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6477. fmt.Println(dat)
  6478. } else {
  6479. fmt.Println(err)
  6480. }
  6481. saveLog(result, src_resquest, "2208", "退费")
  6482. userJSONBytes, _ := json.Marshal(dat)
  6483. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6484. utils.ErrorLog("解析失败:%v", err)
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. return
  6487. }
  6488. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6489. res.Output = resSixteen10265.Output
  6490. res.ErrMsg = resSixteen10265.ErrMsg
  6491. res.Cainfo = resSixteen10265.Cainfo
  6492. res.WarnMsg = resSixteen10265.WarnMsg
  6493. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6494. res.Infcode = infocode
  6495. } else {
  6496. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6497. var dat map[string]interface{}
  6498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6499. fmt.Println(dat)
  6500. } else {
  6501. fmt.Println(err)
  6502. }
  6503. saveLog(result, src_resquest, "2208", "退费")
  6504. userJSONBytes, _ := json.Marshal(dat)
  6505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6506. utils.ErrorLog("解析失败:%v", err)
  6507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6508. return
  6509. }
  6510. }
  6511. }
  6512. if res.Infcode == 0 {
  6513. var res2 ResultSix
  6514. var resSix10265 ResultSix10265
  6515. if miConfig.MdtrtareaAdmvs == "421300" {
  6516. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6517. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6518. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6519. resp3, requestErr3 := http.Get(api3)
  6520. if requestErr3 != nil {
  6521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6522. return
  6523. }
  6524. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6525. if ioErr3 != nil {
  6526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6528. return
  6529. }
  6530. var respJSON3 map[string]interface{}
  6531. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6534. return
  6535. }
  6536. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6537. userJSONBytes3, _ := json.Marshal(respJSON3)
  6538. fmt.Println("log")
  6539. fmt.Println(string(userJSONBytes3))
  6540. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6541. utils.ErrorLog("解析失败:%v", err)
  6542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6543. return
  6544. }
  6545. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6546. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6547. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6548. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6549. resp3, requestErr3 := http.Get(api3)
  6550. if requestErr3 != nil {
  6551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6552. return
  6553. }
  6554. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6555. if ioErr3 != nil {
  6556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6558. return
  6559. }
  6560. var respJSON3 map[string]interface{}
  6561. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6564. return
  6565. }
  6566. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6567. userJSONBytes3, _ := json.Marshal(respJSON3)
  6568. fmt.Println("log")
  6569. fmt.Println(string(userJSONBytes3))
  6570. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6571. utils.ErrorLog("解析失败:%v", err)
  6572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6573. return
  6574. }
  6575. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6576. res2.Output = resSix10265.Output
  6577. res2.ErrMsg = resSix10265.ErrMsg
  6578. res2.Cainfo = resSix10265.Cainfo
  6579. res2.WarnMsg = resSix10265.WarnMsg
  6580. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6581. res2.Infcode = infocode
  6582. } else {
  6583. if miConfig.Code == "H15049901371" {
  6584. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6585. var dat map[string]interface{}
  6586. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6587. fmt.Println(dat)
  6588. } else {
  6589. fmt.Println(err)
  6590. }
  6591. saveLog(result2, src_request, "2205", "撤销明细")
  6592. userJSONBytes, _ := json.Marshal(dat)
  6593. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6594. utils.ErrorLog("解析失败:%v", err)
  6595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6596. return
  6597. }
  6598. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6599. res2.Output = resSix10265.Output
  6600. res2.ErrMsg = resSix10265.ErrMsg
  6601. res2.Cainfo = resSix10265.Cainfo
  6602. res2.WarnMsg = resSix10265.WarnMsg
  6603. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6604. res2.Infcode = infocode
  6605. } else {
  6606. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6607. var dat map[string]interface{}
  6608. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6609. fmt.Println(dat)
  6610. } else {
  6611. fmt.Println(err)
  6612. }
  6613. saveLog(result2, src_request, "2205", "撤销明细")
  6614. userJSONBytes, _ := json.Marshal(dat)
  6615. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6616. utils.ErrorLog("解析失败:%v", err)
  6617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6618. return
  6619. }
  6620. }
  6621. }
  6622. if res2.Infcode == 0 {
  6623. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6624. if err == nil {
  6625. c.ServeSuccessJSON(map[string]interface{}{
  6626. "msg": "退费成功",
  6627. })
  6628. } else {
  6629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6630. return
  6631. }
  6632. } else {
  6633. c.ServeSuccessJSON(map[string]interface{}{
  6634. "code": -10,
  6635. "msg": res2.ErrMsg,
  6636. })
  6637. }
  6638. } else {
  6639. c.ServeSuccessJSON(map[string]interface{}{
  6640. "code": -10,
  6641. "msg": res.ErrMsg,
  6642. })
  6643. }
  6644. }
  6645. }
  6646. func (c *HisApiController) RefundNumber() {
  6647. record_time := c.GetString("record_time")
  6648. //patient_id, _ := c.GetInt64("patient_id")
  6649. admin_user_id, _ := c.GetInt64("admin_user_id")
  6650. his_patient_id, _ := c.GetInt64("id")
  6651. timeLayout := "2006-01-02"
  6652. loc, _ := time.LoadLocation("Local")
  6653. adminUser := c.GetAdminUserInfo()
  6654. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6655. fmt.Println(err)
  6656. if err != nil {
  6657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6658. return
  6659. }
  6660. recordDateTime := theTime.Unix()
  6661. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6662. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6663. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6664. //order, _ := service.GetHisOrderByID(order_id)
  6665. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6666. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6667. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6668. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6669. if count > 0 {
  6670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6671. return
  6672. }
  6673. if config.IsOpen == 1 { //对接了医保,走医保流程
  6674. var res2 ResultSix
  6675. var resSix10265 ResultSix10265
  6676. if miConfig.MdtrtareaAdmvs == "421300" {
  6677. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6678. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6679. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6680. resp3, requestErr3 := http.Get(api3)
  6681. if requestErr3 != nil {
  6682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6683. return
  6684. }
  6685. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6686. if ioErr3 != nil {
  6687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6689. return
  6690. }
  6691. var respJSON3 map[string]interface{}
  6692. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6695. return
  6696. }
  6697. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6698. userJSONBytes3, _ := json.Marshal(respJSON3)
  6699. fmt.Println("log")
  6700. fmt.Println(string(userJSONBytes3))
  6701. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6702. utils.ErrorLog("解析失败:%v", err)
  6703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6704. return
  6705. }
  6706. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6707. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6708. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6710. resp3, requestErr3 := http.Get(api3)
  6711. if requestErr3 != nil {
  6712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6713. return
  6714. }
  6715. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6716. if ioErr3 != nil {
  6717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6719. return
  6720. }
  6721. var respJSON3 map[string]interface{}
  6722. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6725. return
  6726. }
  6727. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6728. userJSONBytes3, _ := json.Marshal(respJSON3)
  6729. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6730. utils.ErrorLog("解析失败:%v", err)
  6731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6732. return
  6733. }
  6734. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6735. res2.Output = resSix10265.Output
  6736. res2.ErrMsg = resSix10265.ErrMsg
  6737. res2.Cainfo = resSix10265.Cainfo
  6738. res2.WarnMsg = resSix10265.WarnMsg
  6739. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6740. res2.Infcode = infocode
  6741. } else {
  6742. var api3 string
  6743. if miConfig.Code == "H15049901371" {
  6744. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6745. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6746. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6747. } else {
  6748. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6749. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6750. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6751. }
  6752. resp3, requestErr3 := http.Get(api3)
  6753. if requestErr3 != nil {
  6754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6755. return
  6756. }
  6757. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6758. if ioErr3 != nil {
  6759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6761. return
  6762. }
  6763. var respJSON3 map[string]interface{}
  6764. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6767. return
  6768. }
  6769. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6770. userJSONBytes3, _ := json.Marshal(respJSON3)
  6771. if miConfig.Code == "H15049901371" {
  6772. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6773. utils.ErrorLog("解析失败:%v", err)
  6774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6775. return
  6776. }
  6777. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6778. res2.Output = resSix10265.Output
  6779. res2.ErrMsg = resSix10265.ErrMsg
  6780. res2.Cainfo = resSix10265.Cainfo
  6781. res2.WarnMsg = resSix10265.WarnMsg
  6782. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6783. res2.Infcode = infocode
  6784. } else {
  6785. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6786. utils.ErrorLog("解析失败:%v", err)
  6787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6788. return
  6789. }
  6790. }
  6791. }
  6792. if res2.Infcode == 0 {
  6793. if err == nil {
  6794. c.ServeSuccessJSON(map[string]interface{}{
  6795. "msg": "退号成功",
  6796. })
  6797. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6798. } else {
  6799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6800. return
  6801. }
  6802. } else {
  6803. c.ServeSuccessJSON(map[string]interface{}{
  6804. "code": -10,
  6805. "msg": res2.ErrMsg,
  6806. })
  6807. }
  6808. } else {
  6809. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6810. //if err == nil {
  6811. // c.ServeSuccessJSON(map[string]interface{}{
  6812. // "msg": "退费成功",
  6813. // })
  6814. //} else {
  6815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6816. // return
  6817. //}
  6818. }
  6819. }
  6820. func (c *HisApiController) RefundDetail() {
  6821. order_id, _ := c.GetInt64("order_id")
  6822. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6823. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6824. number := c.GetString("number")
  6825. record_time := c.GetString("record_time")
  6826. patient_id, _ := c.GetInt64("patient_id")
  6827. timeLayout := "2006-01-02"
  6828. loc, _ := time.LoadLocation("Local")
  6829. adminUser := c.GetAdminUserInfo()
  6830. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6831. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6832. fmt.Println(err)
  6833. if err != nil {
  6834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6835. return
  6836. }
  6837. recordDateTime := theTime.Unix()
  6838. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6839. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6840. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6841. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6842. var order models.HisOrder
  6843. order, _ = service.GetHisOrderByID(order_id)
  6844. if order.ID == 0 {
  6845. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6846. }
  6847. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6848. if config.IsOpen == 1 { //对接了医保,走医保流程
  6849. var res2 ResultSix
  6850. if miConfig.MdtrtareaAdmvs == "421300" {
  6851. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6852. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6854. resp3, requestErr3 := http.Get(api3)
  6855. if requestErr3 != nil {
  6856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6857. return
  6858. }
  6859. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6860. if ioErr3 != nil {
  6861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6863. return
  6864. }
  6865. var respJSON3 map[string]interface{}
  6866. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6869. return
  6870. }
  6871. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6872. userJSONBytes3, _ := json.Marshal(respJSON3)
  6873. fmt.Println("log")
  6874. fmt.Println(string(userJSONBytes3))
  6875. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6876. utils.ErrorLog("解析失败:%v", err)
  6877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6878. return
  6879. }
  6880. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6881. if err == nil {
  6882. c.ServeSuccessJSON(map[string]interface{}{
  6883. "msg": "撤销明细成功",
  6884. })
  6885. return
  6886. } else {
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6888. return
  6889. }
  6890. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6891. var resSix10265 ResultSix10265
  6892. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6893. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6894. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6895. resp3, requestErr3 := http.Get(api3)
  6896. if requestErr3 != nil {
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6898. return
  6899. }
  6900. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6901. if ioErr3 != nil {
  6902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6904. return
  6905. }
  6906. var respJSON3 map[string]interface{}
  6907. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. return
  6911. }
  6912. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6913. userJSONBytes3, _ := json.Marshal(respJSON3)
  6914. fmt.Println("log")
  6915. fmt.Println(string(userJSONBytes3))
  6916. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6917. utils.ErrorLog("解析失败:%v", err)
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6919. return
  6920. }
  6921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6922. res2.Output = resSix10265.Output
  6923. res2.ErrMsg = resSix10265.ErrMsg
  6924. res2.Cainfo = resSix10265.Cainfo
  6925. res2.WarnMsg = resSix10265.WarnMsg
  6926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6927. res2.Infcode = infocode
  6928. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6929. if err == nil {
  6930. c.ServeSuccessJSON(map[string]interface{}{
  6931. "msg": "撤销明细成功",
  6932. })
  6933. return
  6934. } else {
  6935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6936. return
  6937. }
  6938. } else {
  6939. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6940. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6941. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6942. resp2, requestErr2 := http.Get(api2)
  6943. if requestErr2 != nil {
  6944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6945. return
  6946. }
  6947. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6948. if ioErr2 != nil {
  6949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6951. return
  6952. }
  6953. var respJSON2 map[string]interface{}
  6954. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6957. return
  6958. }
  6959. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6960. if err == nil {
  6961. c.ServeSuccessJSON(map[string]interface{}{
  6962. "msg": "撤销明细成功",
  6963. })
  6964. return
  6965. } else {
  6966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6967. return
  6968. }
  6969. }
  6970. } else {
  6971. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6972. if err == nil {
  6973. c.ServeSuccessJSON(map[string]interface{}{
  6974. "msg": "退费成功",
  6975. })
  6976. } else {
  6977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6978. return
  6979. }
  6980. }
  6981. }
  6982. //对账
  6983. func (c *HisApiController) GetCheckAccount() {
  6984. start_time := c.GetString("start_time")
  6985. end_time := c.GetString("end_time")
  6986. insutype := c.GetString("insutype")
  6987. clr_type := c.GetString("clr_type")
  6988. clr_org := c.GetString("clr_optins")
  6989. admin_user_id, _ := c.GetInt64("admin_user_id")
  6990. adminUser := c.GetAdminUserInfo()
  6991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6992. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6993. if len(clr_org) == 0 {
  6994. clr_org = miConfig.MdtrtareaAdmvs
  6995. }
  6996. timeLayout := "2006-01-02"
  6997. loc, _ := time.LoadLocation("Local")
  6998. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6999. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7000. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7001. fixmedins_setl_cnt := int64(len(orders))
  7002. var medfee_sumamt float64
  7003. var acct_pay float64
  7004. var fund_pay_sumamt float64
  7005. for _, item := range orders {
  7006. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7007. acct_pay = acct_pay + item.AcctPay
  7008. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7009. }
  7010. var user_name string
  7011. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7012. if role.ID == 0 {
  7013. user_name = "xxx"
  7014. } else {
  7015. user_name = role.UserName
  7016. }
  7017. var res ResultEight
  7018. var res10188 ResultEightFor10188
  7019. if config.IsOpen == 1 {
  7020. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7021. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7022. "insutype=" + insutype +
  7023. "&clr_type=" + "11" +
  7024. "&setl_optins=" + clr_org +
  7025. "&stmt_begndate=" + start_time +
  7026. "&stm_enddate=" + end_time +
  7027. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7028. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7029. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7030. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7031. "&fixmedins_code=" + miConfig.Code +
  7032. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7033. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7034. "&secret_key=" + miConfig.SecretKey +
  7035. "&org_name=" + miConfig.OrgName +
  7036. "&doctor=" + user_name +
  7037. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7038. fmt.Println(api)
  7039. resp, requestErr := http.Get(api)
  7040. if requestErr != nil {
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. return
  7043. }
  7044. body, ioErr := ioutil.ReadAll(resp.Body)
  7045. fmt.Println(body)
  7046. if ioErr != nil {
  7047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7049. return
  7050. }
  7051. var respJSON map[string]interface{}
  7052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. return
  7056. }
  7057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7058. userJSONBytes, _ := json.Marshal(respJSON)
  7059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7060. utils.ErrorLog("解析失败:%v", err)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. return
  7063. }
  7064. res.InfRefmsgid = res10188.InfRefmsgid
  7065. res.Output = res10188.Output
  7066. res.ErrMsg = res10188.ErrMsg
  7067. res.Cainfo = res10188.Cainfo
  7068. res.WarnMsg = res10188.WarnMsg
  7069. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7070. res.Infcode = infocode
  7071. } else {
  7072. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7073. "insutype=" + insutype +
  7074. "&clr_type=" + clr_type +
  7075. "&setl_optins=" + clr_org +
  7076. "&stmt_begndate=" + start_time +
  7077. "&stm_enddate=" + end_time +
  7078. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7079. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7080. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7081. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7082. "&fixmedins_code=" + miConfig.Code +
  7083. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7084. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7085. "&secret_key=" + miConfig.SecretKey +
  7086. "&org_name=" + miConfig.OrgName +
  7087. "&doctor=" + user_name
  7088. fmt.Println(api)
  7089. resp, requestErr := http.Get(api)
  7090. if requestErr != nil {
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. return
  7093. }
  7094. body, ioErr := ioutil.ReadAll(resp.Body)
  7095. fmt.Println(body)
  7096. if ioErr != nil {
  7097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7099. return
  7100. }
  7101. var respJSON map[string]interface{}
  7102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7105. return
  7106. }
  7107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7108. userJSONBytes, _ := json.Marshal(respJSON)
  7109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7110. utils.ErrorLog("解析失败:%v", err)
  7111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7112. return
  7113. }
  7114. }
  7115. if res.Infcode == 0 {
  7116. if res.Output.Stmtinfo.StmtRslt == "0" {
  7117. micc := &models.MedicalInsuranceCostCompare{
  7118. StartTime: startime.Unix(),
  7119. EndTime: endtime.Unix(),
  7120. Insutype: insutype,
  7121. CheckType: 1,
  7122. Num: fixmedins_setl_cnt,
  7123. Mtime: time.Now().Unix(),
  7124. Status: 1,
  7125. UserOrgId: adminUser.CurrentOrgId,
  7126. CostTotal: medfee_sumamt,
  7127. FuncTotal: fund_pay_sumamt,
  7128. PsnPay: acct_pay,
  7129. Creator: admin_user_id,
  7130. Ctime: time.Now().Unix(),
  7131. }
  7132. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7133. if err == nil {
  7134. c.ServeSuccessJSON(map[string]interface{}{
  7135. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7136. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7137. })
  7138. } else {
  7139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. }
  7141. } else {
  7142. c.ServeSuccessJSON(map[string]interface{}{
  7143. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7144. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7145. })
  7146. }
  7147. } else {
  7148. c.ServeSuccessJSON(map[string]interface{}{
  7149. "code": -10,
  7150. "msg": res.ErrMsg,
  7151. })
  7152. }
  7153. }
  7154. }
  7155. func (c *HisApiController) Check310() {
  7156. adminUser := c.GetAdminUserInfo()
  7157. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7158. var user_name string
  7159. user_name = "高慧裕"
  7160. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7161. "insutype=" + "310" +
  7162. "&clr_type=" + "" +
  7163. "&setl_optins=" + "441202" +
  7164. "&stmt_begndate=" + "2022-03-01" +
  7165. "&stm_enddate=" + "2022-03-31" +
  7166. "&medfee_sumamt=" + "194930.12" +
  7167. "&fund_pay_sumamt=" + "188741.46" +
  7168. "&acct_pay=" + "0" +
  7169. "&fixmedins_setl_cnt=" + "452" +
  7170. "&fixmedins_code=" + miConfig.Code +
  7171. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7172. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7173. "&secret_key=" + miConfig.SecretKey +
  7174. "&org_name=" + miConfig.OrgName +
  7175. "&doctor=" + user_name
  7176. fmt.Println(api)
  7177. resp, requestErr := http.Get(api)
  7178. if requestErr != nil {
  7179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7180. return
  7181. }
  7182. body, ioErr := ioutil.ReadAll(resp.Body)
  7183. fmt.Println(body)
  7184. if ioErr != nil {
  7185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7187. return
  7188. }
  7189. var respJSON map[string]interface{}
  7190. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7193. return
  7194. }
  7195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7196. userJSONBytes, _ := json.Marshal(respJSON)
  7197. var res ResultEight
  7198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7199. utils.ErrorLog("解析失败:%v", err)
  7200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7201. return
  7202. }
  7203. }
  7204. func (c *HisApiController) Check390() {
  7205. adminUser := c.GetAdminUserInfo()
  7206. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7207. var user_name string
  7208. user_name = "高慧裕"
  7209. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7210. "insutype=" + "390" +
  7211. "&clr_type=" + "" +
  7212. "&setl_optins=" + "441202" +
  7213. "&stmt_begndate=" + "2022-03-01" +
  7214. "&stm_enddate=" + "2022-03-31" +
  7215. "&medfee_sumamt=" + "1068448.89" +
  7216. "&fund_pay_sumamt=" + "1014677.62" +
  7217. "&acct_pay=" + "0" +
  7218. "&fixmedins_setl_cnt=" + "1950" +
  7219. "&fixmedins_code=" + miConfig.Code +
  7220. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7221. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7222. "&secret_key=" + miConfig.SecretKey +
  7223. "&org_name=" + miConfig.OrgName +
  7224. "&doctor=" + user_name
  7225. fmt.Println(api)
  7226. resp, requestErr := http.Get(api)
  7227. if requestErr != nil {
  7228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7229. return
  7230. }
  7231. body, ioErr := ioutil.ReadAll(resp.Body)
  7232. fmt.Println(body)
  7233. if ioErr != nil {
  7234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. return
  7237. }
  7238. var respJSON map[string]interface{}
  7239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7242. return
  7243. }
  7244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7245. userJSONBytes, _ := json.Marshal(respJSON)
  7246. var res ResultEight
  7247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7248. utils.ErrorLog("解析失败:%v", err)
  7249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7250. return
  7251. }
  7252. }
  7253. //对账明细
  7254. func (c *HisApiController) GetCheckDetailAccount() {
  7255. start_time := c.GetString("start_time")
  7256. end_time := c.GetString("end_time")
  7257. admin_user_id, _ := c.GetInt64("admin_user_id")
  7258. adminUser := c.GetAdminUserInfo()
  7259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7260. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7261. timeLayout := "2006-01-02"
  7262. loc, _ := time.LoadLocation("Local")
  7263. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7264. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7265. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7266. Mkdir(miConfig.OrgName)
  7267. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7268. file_name := file + ".txt"
  7269. zip_name := file + ".zip"
  7270. zip_path := miConfig.OrgName + "/" + zip_name
  7271. file_path := miConfig.OrgName + "/" + file_name
  7272. decimal.DivisionPrecision = 2
  7273. var medfee_sumamt float64
  7274. var psn_cash_pay float64
  7275. var fund_pay_sumamt float64
  7276. fixmedins_setl_cnt := int64(len(orders))
  7277. for _, item := range orders {
  7278. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7279. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7280. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7281. }
  7282. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7283. defer f.Close()
  7284. if err != nil {
  7285. fmt.Println(err.Error())
  7286. } else {
  7287. for _, item := range orders {
  7288. var refd_setl_flag string
  7289. if item.OrderStatus == 2 {
  7290. refd_setl_flag = "0"
  7291. var str string
  7292. str = item.SetlId + " " +
  7293. item.MdtrtId + " " +
  7294. item.PsnNo + " " +
  7295. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7296. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7297. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7298. _, err = f.Write([]byte(str))
  7299. }
  7300. if item.OrderStatus == 3 {
  7301. var str string
  7302. str = item.SetlId + " " +
  7303. item.MdtrtId + " " +
  7304. item.PsnNo + " " +
  7305. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7306. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7307. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7308. _, err = f.Write([]byte(str))
  7309. var str2 string
  7310. str2 = item.SetlId + " " +
  7311. item.MdtrtId + " " +
  7312. item.PsnNo + " " +
  7313. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7314. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7315. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7316. _, err = f.Write([]byte(str2))
  7317. }
  7318. }
  7319. }
  7320. Zip(file_path, zip_path)
  7321. fmt.Println(ReadFile(zip_path))
  7322. fmt.Println(string(ReadFile(zip_path)))
  7323. if config.IsOpen == 1 {
  7324. var user_name string
  7325. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7326. if role.ID == 0 {
  7327. user_name = "管理员"
  7328. } else {
  7329. user_name = role.UserName
  7330. }
  7331. baseParams := models.BaseParams{
  7332. SecretKey: miConfig.SecretKey,
  7333. FixmedinsCode: miConfig.Code,
  7334. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7335. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7336. OrgName: miConfig.OrgName,
  7337. Doctor: user_name,
  7338. }
  7339. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7340. var dat map[string]interface{}
  7341. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7342. fmt.Println(dat)
  7343. } else {
  7344. fmt.Println(err)
  7345. }
  7346. userJSONBytes, _ := json.Marshal(dat)
  7347. var res ResultNine
  7348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7349. utils.ErrorLog("解析失败:%v", err)
  7350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7351. return
  7352. }
  7353. if res.Infcode == 0 {
  7354. fileNo := res.Output.FileQuryNo
  7355. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7356. "file_qury_no=" + fileNo +
  7357. "&setl_optins=" + "定点医保中心" +
  7358. "&stmt_begndate=" + start_time +
  7359. "&stm_enddate=" + end_time +
  7360. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7361. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7362. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7363. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7364. "&fixmedins_code=" + miConfig.Code +
  7365. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7366. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7367. "&secret_key=" + miConfig.SecretKey +
  7368. "&org_name=" + miConfig.OrgName +
  7369. "&doctor=" + user_name
  7370. resp, requestErr := http.Get(api)
  7371. if requestErr != nil {
  7372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7373. return
  7374. }
  7375. body, ioErr := ioutil.ReadAll(resp.Body)
  7376. if ioErr != nil {
  7377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7379. return
  7380. }
  7381. var respJSON map[string]interface{}
  7382. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7385. return
  7386. }
  7387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7388. userJSONBytes, _ := json.Marshal(respJSON)
  7389. var res ResultTen
  7390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7391. utils.ErrorLog("解析失败:%v", err)
  7392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. return
  7394. }
  7395. if res.Infcode == 0 {
  7396. service.Gdyb9102(baseParams, zip_name, fileNo)
  7397. micc := &models.MedicalInsuranceCostCompare{
  7398. StartTime: startime.Unix(),
  7399. EndTime: endtime.Unix(),
  7400. Insutype: "0",
  7401. CheckType: 2,
  7402. Num: fixmedins_setl_cnt,
  7403. Mtime: time.Now().Unix(),
  7404. Status: 1,
  7405. UserOrgId: adminUser.CurrentOrgId,
  7406. CostTotal: medfee_sumamt,
  7407. FuncTotal: fund_pay_sumamt,
  7408. PsnPay: psn_cash_pay,
  7409. Creator: admin_user_id,
  7410. Ctime: time.Now().Unix(),
  7411. }
  7412. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7413. c.ServeSuccessJSON(map[string]interface{}{
  7414. "msg": "明细对账成功",
  7415. })
  7416. }
  7417. } else {
  7418. }
  7419. }
  7420. }
  7421. type CustomOrderInfo struct {
  7422. Name string
  7423. Spec string
  7424. Unit string
  7425. Count float64
  7426. Price float64
  7427. Total float64
  7428. }
  7429. func (c *HisApiController) GetSettleAccounts() {
  7430. //id, _ := c.GetInt64("id")
  7431. //record_time := c.GetString("record_time")
  7432. order_id, _ := c.GetInt64("order_id")
  7433. admin_user_id, _ := c.GetInt64("admin_user_id")
  7434. //timeLayout := "2006-01-02"
  7435. //loc, _ := time.LoadLocation("Local")
  7436. //
  7437. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7438. //if err != nil {
  7439. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7440. // return
  7441. //}
  7442. //recordDateTime := theTime.Unix()
  7443. adminUser := c.GetAdminUserInfo()
  7444. order, _ := service.GetHisOrderByID(order_id)
  7445. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7446. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7447. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7448. orderInfos = append(orderInfos, orderInfos_two...)
  7449. //his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7450. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7451. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7452. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7453. //var config []*models.HisXtDiagnoseConfig
  7454. var name string
  7455. for _, item := range diagnosis_ids {
  7456. id, _ := strconv.ParseInt(item, 10, 64)
  7457. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7458. if len(name) == 0 {
  7459. name = diagnosisConfig.ClassName
  7460. } else {
  7461. name = name + "," + diagnosisConfig.ClassName
  7462. }
  7463. }
  7464. var bedCostTotal float64 = 0 //床位总费
  7465. var bedCostSelfTotal float64 = 0 //床位自费
  7466. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7467. var operationCostTotal float64 = 0 //手术费
  7468. var operationCostSelfTotal float64 = 0 //手术费
  7469. var operationCostPartSelfTotal float64 = 0 //手术费
  7470. var otherCostTotal float64 = 0 //其他费用
  7471. var otherCostSelfTotal float64 = 0 //其他费用
  7472. var otherCostPartSelfTotal float64 = 0 //其他费用
  7473. var materialCostTotal float64 = 0 //材料费
  7474. var materialCostSelfTotal float64 = 0 //材料费
  7475. var materialCostPartSelfTotal float64 = 0 //材料费
  7476. var westernMedicineCostTotal float64 = 0 //西药费
  7477. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7478. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7479. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7480. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7481. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7482. var checkCostTotal float64 = 0 //检查费
  7483. var checkCostSelfTotal float64 = 0 //检查费
  7484. var checkCostPartSelfTotal float64 = 0 //检查费
  7485. var laboratoryCostTotal float64 = 0 //化验费
  7486. var laboratoryCostSelfTotal float64 = 0 //化验费
  7487. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7488. var treatCostTotal float64 = 0 //治疗费用
  7489. var treatCostSelfTotal float64 = 0 //治疗费用
  7490. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7491. decimal.DivisionPrecision = 2
  7492. for _, item := range orderInfos {
  7493. if item.MedChrgitmType == "01" { //床位费
  7494. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7495. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7496. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7497. }
  7498. if item.MedChrgitmType == "03" { //检查费
  7499. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7500. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7501. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7502. }
  7503. if item.MedChrgitmType == "04" { //化验费
  7504. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7505. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7506. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7507. }
  7508. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7509. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7510. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7511. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7512. }
  7513. if item.MedChrgitmType == "06" { //手术费
  7514. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7515. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7516. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7517. }
  7518. if item.MedChrgitmType == "08" { //材料费
  7519. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7520. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7521. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7522. }
  7523. if item.MedChrgitmType == "09" { //西药费
  7524. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7525. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7526. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7527. }
  7528. if item.MedChrgitmType == "11" { //中成费
  7529. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7530. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7531. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7532. }
  7533. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7534. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7535. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7536. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7537. }
  7538. }
  7539. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7540. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7541. var user_name string
  7542. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7543. if role.ID == 0 {
  7544. user_name = "管理员"
  7545. } else {
  7546. user_name = role.UserName
  7547. }
  7548. baseParams := models.BaseParams{
  7549. SecretKey: miConfig.SecretKey,
  7550. FixmedinsCode: miConfig.Code,
  7551. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7552. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7553. OrgName: miConfig.OrgName,
  7554. Doctor: user_name,
  7555. }
  7556. businessParams := models.BusinessParams{
  7557. PsnNo: order.PsnNo,
  7558. MdtrtId: order.MdtrtId,
  7559. SetlId: order.SetlId,
  7560. }
  7561. var res ResultEleven
  7562. var resEleven10265 ResultEleven10265
  7563. if config.IsOpen == 1 {
  7564. if miConfig.MdtrtareaAdmvs == "421300" {
  7565. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7566. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7567. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7568. resp, requestErr := http.Get(api)
  7569. if requestErr != nil {
  7570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7571. return
  7572. }
  7573. body, ioErr := ioutil.ReadAll(resp.Body)
  7574. if ioErr != nil {
  7575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7577. return
  7578. }
  7579. var respJSON map[string]interface{}
  7580. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7583. return
  7584. }
  7585. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7586. result, _ := json.Marshal(respJSON)
  7587. fmt.Println("log")
  7588. fmt.Println(string(result))
  7589. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7590. utils.ErrorLog("解析失败:%v", err)
  7591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7592. return
  7593. }
  7594. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7595. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7596. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7597. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7598. resp, requestErr := http.Get(api)
  7599. if requestErr != nil {
  7600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7601. return
  7602. }
  7603. body, ioErr := ioutil.ReadAll(resp.Body)
  7604. if ioErr != nil {
  7605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7607. return
  7608. }
  7609. var respJSON map[string]interface{}
  7610. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7613. return
  7614. }
  7615. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7616. result, _ := json.Marshal(respJSON)
  7617. fmt.Println("log")
  7618. fmt.Println(string(result))
  7619. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7620. utils.ErrorLog("解析失败:%v", err)
  7621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7622. return
  7623. }
  7624. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7625. res.Output = resEleven10265.Output
  7626. res.ErrMsg = resEleven10265.ErrMsg
  7627. res.Cainfo = resEleven10265.Cainfo
  7628. res.WarnMsg = resEleven10265.WarnMsg
  7629. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7630. res.Infcode = infocode
  7631. } else {
  7632. result2 := service.Gdyb5204(baseParams, businessParams)
  7633. saveLog(result2, "", "5204", "查询")
  7634. result := service.Gdyb5203(baseParams, businessParams)
  7635. var dat map[string]interface{}
  7636. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7637. fmt.Println(dat)
  7638. } else {
  7639. fmt.Println(err)
  7640. }
  7641. userJSONBytes, _ := json.Marshal(dat)
  7642. if miConfig.Code == "H15049901371" {
  7643. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7644. utils.ErrorLog("解析失败:%v", err)
  7645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7646. return
  7647. }
  7648. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7649. res.Output = resEleven10265.Output
  7650. res.ErrMsg = resEleven10265.ErrMsg
  7651. res.Cainfo = resEleven10265.Cainfo
  7652. res.WarnMsg = resEleven10265.WarnMsg
  7653. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7654. res.Infcode = infocode
  7655. } else {
  7656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7657. utils.ErrorLog("解析失败:%v", err)
  7658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7659. return
  7660. }
  7661. }
  7662. }
  7663. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7664. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7665. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7666. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7667. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7668. var doctor_name string
  7669. if roles.ID == 0 {
  7670. doctor_name = "管理员"
  7671. } else {
  7672. doctor_name = roles.UserName
  7673. }
  7674. yiliao_leibie := ""
  7675. switch order.MedType {
  7676. case "11":
  7677. yiliao_leibie = "普通门诊"
  7678. break
  7679. case "12":
  7680. yiliao_leibie = "门诊挂号"
  7681. break
  7682. case "13":
  7683. yiliao_leibie = "急诊"
  7684. break
  7685. case "14":
  7686. yiliao_leibie = "门诊特殊病"
  7687. break
  7688. case "15":
  7689. yiliao_leibie = "门诊统筹"
  7690. break
  7691. case "16":
  7692. yiliao_leibie = "门诊慢性病"
  7693. break
  7694. case "21":
  7695. yiliao_leibie = "普通住院"
  7696. break
  7697. }
  7698. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7699. if res.Infcode == 0 {
  7700. c.ServeSuccessJSON(map[string]interface{}{
  7701. "diagnosis": name,
  7702. "order_infos": orderInfos,
  7703. "number": order.MdtrtId,
  7704. "date": order.SettleAccountsDate,
  7705. "charge_admin": charge_admin,
  7706. "printor_admin": printor_admin,
  7707. "info": res.Output.Setlinfo,
  7708. "bedCostTotal": bedCostTotal,
  7709. "bedCostSelfTotal": bedCostSelfTotal,
  7710. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7711. "operationCostTotal": operationCostTotal,
  7712. "operationCostSelfTotal": operationCostSelfTotal,
  7713. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7714. "otherCostTotal": otherCostTotal,
  7715. "otherCostSelfTotal": otherCostSelfTotal,
  7716. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7717. "materialCostTotal": materialCostTotal,
  7718. "materialCostSelfTotal": materialCostSelfTotal,
  7719. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7720. "westernMedicineCostTotal": westernMedicineCostTotal,
  7721. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7722. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7723. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7724. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7725. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7726. "checkCostTotal": checkCostTotal,
  7727. "checkCostSelfTotal": checkCostSelfTotal,
  7728. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7729. "laboratoryCostTotal": laboratoryCostTotal,
  7730. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7731. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7732. "treatCostTotal": treatCostTotal,
  7733. "treatCostSelfTotal": treatCostSelfTotal,
  7734. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7735. "doctor_code": adminRole_two.DoctorCode,
  7736. "doctor_name": doctor_name,
  7737. "health_card_no": order.PsnNo,
  7738. "department": departments.Name,
  7739. "yiliao_leibie": yiliao_leibie,
  7740. "after_money": order.AccountPrice,
  7741. "patient": patient,
  7742. "org_name": miConfig.OrgName,
  7743. "org_code": miConfig.Code,
  7744. "order_number": order.Number,
  7745. //"his": his_hospital,
  7746. //"check_order_info": cus_slice,
  7747. })
  7748. }
  7749. }
  7750. }
  7751. func (c *HisApiController) CheckTreatment() {
  7752. patient_id, _ := c.GetInt64("patient_id")
  7753. id_card_no := c.GetString("id_card_no")
  7754. insutype := c.GetString("insutype")
  7755. med_type := c.GetString("med_type")
  7756. admin_user_id, _ := c.GetInt64("admin_user_id")
  7757. adminUser := c.GetAdminUserInfo()
  7758. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7759. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7760. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7761. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7762. if miConfig.MdtrtareaAdmvs == "421300" {
  7763. var res ResultTwo
  7764. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7765. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7766. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(2, 10)
  7767. resp, requestErr := http.Get(api)
  7768. if requestErr != nil {
  7769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7770. return
  7771. }
  7772. body, ioErr := ioutil.ReadAll(resp.Body)
  7773. if ioErr != nil {
  7774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7776. return
  7777. }
  7778. var respJSON map[string]interface{}
  7779. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7782. return
  7783. }
  7784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7785. result, _ := json.Marshal(respJSON)
  7786. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7787. utils.ErrorLog("解析失败:%v", err)
  7788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7789. return
  7790. }
  7791. if res.Infcode == 0 {
  7792. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7793. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7794. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7795. resp, requestErr := http.Get(api)
  7796. if requestErr != nil {
  7797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7798. return
  7799. }
  7800. body, ioErr := ioutil.ReadAll(resp.Body)
  7801. if ioErr != nil {
  7802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7804. return
  7805. }
  7806. var respJSON map[string]interface{}
  7807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7810. return
  7811. }
  7812. var res Result2001
  7813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7814. result2, _ := json.Marshal(respJSON)
  7815. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7816. utils.ErrorLog("解析失败:%v", err)
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7818. return
  7819. }
  7820. if res.Infcode == 0 {
  7821. c.ServeSuccessJSON(map[string]interface{}{
  7822. "msg": res.Output.Trtinfo,
  7823. })
  7824. }
  7825. } else {
  7826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7827. return
  7828. }
  7829. } else {
  7830. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7831. var dat map[string]interface{}
  7832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7833. fmt.Println(dat)
  7834. } else {
  7835. fmt.Println(err)
  7836. }
  7837. userJSONBytes, _ := json.Marshal(dat)
  7838. var res ResultTwo
  7839. var res10265 ResultTwo10265
  7840. if miConfig.Code == "H15049901371" {
  7841. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7842. utils.ErrorLog("解析失败:%v", err)
  7843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7844. return
  7845. }
  7846. res.ErrMsg = res10265.ErrMsg
  7847. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7848. res.Infcode = infocode
  7849. res.Output = res10265.Output
  7850. res.InfRefmsgid = res10265.InfRefmsgid
  7851. } else {
  7852. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7853. utils.ErrorLog("解析失败:%v", err)
  7854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7855. return
  7856. }
  7857. }
  7858. var user_name string
  7859. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7860. if role.ID == 0 {
  7861. user_name = "xxx"
  7862. } else {
  7863. user_name = role.UserName
  7864. }
  7865. baseParams := models.BaseParams{
  7866. SecretKey: miConfig.SecretKey,
  7867. FixmedinsCode: miConfig.Code,
  7868. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7869. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7870. OrgName: miConfig.OrgName,
  7871. Doctor: user_name,
  7872. }
  7873. if config.IsOpen == 1 {
  7874. if miConfig.Code == "H15049901371" {
  7875. if med_type == "14" {
  7876. if insutype == "390" {
  7877. med_type = "9933"
  7878. } else if insutype == "310" {
  7879. med_type = "990502"
  7880. }
  7881. } else if med_type == "11" {
  7882. med_type = "11"
  7883. }
  7884. }
  7885. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7886. var dat map[string]interface{}
  7887. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7888. fmt.Println(dat)
  7889. } else {
  7890. fmt.Println(err)
  7891. }
  7892. var res Result2001
  7893. var res10265 Result2001Org10265
  7894. if miConfig.Code == "H15049901371" {
  7895. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7896. utils.ErrorLog("解析失败:%v", err)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. res.ErrMsg = res10265.ErrMsg
  7901. res.Output = res10265.Output
  7902. res.InfRefmsgid = res10265.InfRefmsgid
  7903. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7904. res.Infcode = infocode
  7905. } else {
  7906. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7907. utils.ErrorLog("解析失败:%v", err)
  7908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7909. return
  7910. }
  7911. }
  7912. if res.Infcode == 0 {
  7913. c.ServeSuccessJSON(map[string]interface{}{
  7914. "msg": res.Output.Trtinfo,
  7915. })
  7916. }
  7917. }
  7918. }
  7919. }
  7920. //func (c *HisApiController) PutRecord() {
  7921. // id, _ := c.GetInt64("id")
  7922. // record_time := c.GetString("record_time")
  7923. // timeLayout := "2006-01-02"
  7924. // loc, _ := time.LoadLocation("Local")
  7925. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7926. // if err != nil {
  7927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7928. // return
  7929. // }
  7930. // recordDateTime := theTime.Unix()
  7931. //
  7932. // adminInfo := c.GetAdminUserInfo()
  7933. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7934. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7935. //
  7936. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7937. //
  7938. // fmt.Println(miConfig.SecretKey)
  7939. //
  7940. // if patient == nil {
  7941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7942. // return
  7943. // }
  7944. // if len(patient.IdCardNo) == 0 {
  7945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7946. // return
  7947. // }
  7948. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7949. // if config.IsOpen == 1 {
  7950. // 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
  7951. // resp, requestErr := http.Get(api)
  7952. // if requestErr != nil {
  7953. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7954. // return
  7955. // }
  7956. // defer resp.Body.Close()
  7957. // body, ioErr := ioutil.ReadAll(resp.Body)
  7958. // if ioErr != nil {
  7959. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7961. // return
  7962. // }
  7963. // var respJSON map[string]interface{}
  7964. //
  7965. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7966. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7968. // return
  7969. // }
  7970. //
  7971. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7972. // userJSONBytes, _ := json.Marshal(userJSON)
  7973. // var res ResultTwo
  7974. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7975. // utils.ErrorLog("解析失败:%v", err)
  7976. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7977. // return
  7978. // }
  7979. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7980. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7981. // infoStr := string(Iinfos)
  7982. // idetinfoStr := string(Idetinfos)
  7983. //
  7984. // if res.Infcode == 0 {
  7985. // his := models.VMHisPatient{
  7986. // Status: 1,
  7987. // Ctime: time.Now().Unix(),
  7988. // Mtime: time.Now().Unix(),
  7989. // PsnNo: res.Output.Baseinfo.PsnNo,
  7990. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7991. // Certno: res.Output.Baseinfo.Certno,
  7992. // PsnName: res.Output.Baseinfo.PsnName,
  7993. // Gend: res.Output.Baseinfo.Gend,
  7994. // Naty: res.Output.Baseinfo.Naty,
  7995. // Brdy: res.Output.Baseinfo.Brdy,
  7996. // Age: res.Output.Baseinfo.Age,
  7997. // Iinfo: infoStr,
  7998. // Idetinfo: idetinfoStr,
  7999. // PatientId: patient.ID,
  8000. // RecordDate: theTime.Unix(),
  8001. // UserOrgId: adminInfo.CurrentOrgId,
  8002. // AdminUserId: adminInfo.AdminUser.Id,
  8003. // IsReturn: 1,
  8004. // }
  8005. //
  8006. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8007. // //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")
  8008. // //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")
  8009. //
  8010. // //var dat map[string]interface{}
  8011. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8012. // // fmt.Println(dat)
  8013. // //} else {
  8014. // // fmt.Println(err)
  8015. // //}
  8016. //
  8017. // var dat2 map[string]interface{}
  8018. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8019. // fmt.Println(dat2)
  8020. // } else {
  8021. // fmt.Println(err)
  8022. // }
  8023. //
  8024. // } else {
  8025. // adminUser := c.GetAdminUserInfo()
  8026. // errlog := &models.HisOrderError{
  8027. // UserOrgId: adminUser.CurrentOrgId,
  8028. // Ctime: time.Now().Unix(),
  8029. // Mtime: time.Now().Unix(),
  8030. // ErrMsg: res.ErrMsg,
  8031. // Status: 1,
  8032. // PatientId: id,
  8033. // RecordTime: recordDateTime,
  8034. // Stage: 1,
  8035. // }
  8036. // service.CreateErrMsgLog(errlog)
  8037. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8038. // return
  8039. // }
  8040. // }
  8041. //
  8042. //}
  8043. //func (c *HisApiController) GetUploadDiag() {
  8044. // id, _ := c.GetInt64("id")
  8045. // record_time := c.GetString("record_time")
  8046. //
  8047. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8048. // sick_type, _ := c.GetInt64("sick_type")
  8049. // reg_type, _ := c.GetInt64("reg_type")
  8050. //
  8051. // timeLayout := "2006-01-02"
  8052. // loc, _ := time.LoadLocation("Local")
  8053. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8054. // if err != nil {
  8055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8056. // return
  8057. // }
  8058. //
  8059. // var patientPrescription models.HisPrescriptionInfo
  8060. // recordDateTime := theTime.Unix()
  8061. // adminInfo := c.GetAdminUserInfo()
  8062. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8063. //
  8064. // if patientPrescription.ID == 0 {
  8065. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8066. // }
  8067. //
  8068. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8069. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8070. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8071. // sickConfig, _ := service.FindSickById(sick_type)
  8072. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8073. //
  8074. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8075. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8076. // "&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 +
  8077. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8078. // resp2, requestErr2 := http.Get(api2)
  8079. // if requestErr2 != nil {
  8080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. // return
  8082. // }
  8083. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8084. // if ioErr2 != nil {
  8085. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. // return
  8088. // }
  8089. // var respJSON2 map[string]interface{}
  8090. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8091. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8093. // return
  8094. // }
  8095. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8096. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8097. //
  8098. // var res2 ResultSix
  8099. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8100. // utils.ErrorLog("解析失败:%v", err)
  8101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8102. // return
  8103. // }
  8104. // if res2.Infcode != 0 {
  8105. // adminUser := c.GetAdminUserInfo()
  8106. // errlog := &models.HisOrderError{
  8107. // UserOrgId: adminUser.CurrentOrgId,
  8108. // Ctime: time.Now().Unix(),
  8109. // Mtime: time.Now().Unix(),
  8110. // ErrMsg: res2.ErrMsg,
  8111. // Status: 1,
  8112. // PatientId: id,
  8113. // RecordTime: recordDateTime,
  8114. // Stage: 3,
  8115. // }
  8116. // service.CreateErrMsgLog(errlog)
  8117. //
  8118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8119. // return
  8120. // }
  8121. //
  8122. // c.ServeSuccessJSON(map[string]interface{}{
  8123. // "msg": "上传成功",
  8124. // })
  8125. //
  8126. //}
  8127. type QueryResult struct {
  8128. ID int64
  8129. Name string
  8130. Code string
  8131. List_type_code string
  8132. }
  8133. func (c *HisApiController) GetCheckCode() {
  8134. ids_str := c.GetString("ids")
  8135. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8136. ids_arr := strings.Split(ids_str, ",")
  8137. var queryResult []QueryResult
  8138. ids := make([]int64, 0)
  8139. for _, item := range ids_arr {
  8140. id, _ := strconv.ParseInt(item, 10, 64)
  8141. ids = append(ids, id)
  8142. }
  8143. if record_type == 1 {
  8144. drugs, _ := service.GetBatchDrugList(ids)
  8145. for _, item := range drugs {
  8146. result := QueryResult{
  8147. ID: item.ID,
  8148. Name: item.DrugName,
  8149. Code: item.MedicalInsuranceNumber,
  8150. List_type_code: "101",
  8151. }
  8152. queryResult = append(queryResult, result)
  8153. }
  8154. } else if record_type == 2 {
  8155. goods, _ := service.GetBatchGoodInformationList(ids)
  8156. for _, item := range goods {
  8157. result := QueryResult{
  8158. ID: item.ID,
  8159. Name: item.GoodName,
  8160. Code: item.MedicalInsuranceNumber,
  8161. List_type_code: "301",
  8162. }
  8163. queryResult = append(queryResult, result)
  8164. }
  8165. } else if record_type == 3 {
  8166. projects, _ := service.GetBathchMyPorjecgList(ids)
  8167. for _, item := range projects {
  8168. result := QueryResult{
  8169. ID: item.ID,
  8170. Name: item.ProjectName,
  8171. Code: item.MedicalCode,
  8172. List_type_code: "201",
  8173. }
  8174. queryResult = append(queryResult, result)
  8175. }
  8176. }
  8177. admin_user_id, _ := c.GetInt64("admin_user_id")
  8178. adminUser := c.GetAdminUserInfo()
  8179. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8180. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8181. var user_name string
  8182. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8183. if role.ID == 0 {
  8184. user_name = "xxx"
  8185. } else {
  8186. user_name = role.UserName
  8187. }
  8188. baseParams := &models.BaseParams{
  8189. SecretKey: miConfig.SecretKey,
  8190. FixmedinsCode: miConfig.Code,
  8191. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8192. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8193. OrgName: miConfig.OrgName,
  8194. Doctor: user_name,
  8195. }
  8196. if config.IsOpen == 1 {
  8197. for _, item := range queryResult {
  8198. var result string
  8199. if record_type == 1 {
  8200. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8201. } else if record_type == 2 {
  8202. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8203. } else if record_type == 3 {
  8204. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8205. }
  8206. var dat map[string]interface{}
  8207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8208. fmt.Println(dat)
  8209. } else {
  8210. fmt.Println(err)
  8211. }
  8212. userJSONBytes, _ := json.Marshal(dat)
  8213. var res ResultSix
  8214. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8215. utils.ErrorLog("解析失败:%v", err)
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. return
  8218. }
  8219. if res.Infcode == 0 {
  8220. if record_type == 1 {
  8221. service.UpdateBaseDrugById(item.ID)
  8222. } else if record_type == 2 {
  8223. service.UpdateGoodInformaitonByDetail(item.ID)
  8224. } else if record_type == 3 {
  8225. service.UpdateProjectById(item.ID)
  8226. }
  8227. c.ServeSuccessJSON(map[string]interface{}{
  8228. "failed_code": 0,
  8229. "msg": "目录对照成功",
  8230. })
  8231. } else {
  8232. c.ServeSuccessJSON(map[string]interface{}{
  8233. "failed_code": -10,
  8234. "msg": res.ErrMsg,
  8235. })
  8236. }
  8237. }
  8238. }
  8239. }
  8240. func (c *HisApiController) UnCheckCode() {
  8241. ids_str := c.GetString("ids")
  8242. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8243. admin_user_id, _ := c.GetInt64("admin_user_id")
  8244. ids_arr := strings.Split(ids_str, ",")
  8245. var queryResult []QueryResult
  8246. ids := make([]int64, 0)
  8247. for _, item := range ids_arr {
  8248. id, _ := strconv.ParseInt(item, 10, 64)
  8249. ids = append(ids, id)
  8250. }
  8251. if record_type == 1 {
  8252. drugs, _ := service.GetBatchDrugList(ids)
  8253. for _, item := range drugs {
  8254. result := QueryResult{
  8255. ID: item.ID,
  8256. Name: item.DrugName,
  8257. Code: item.MedicalInsuranceNumber,
  8258. List_type_code: "101",
  8259. }
  8260. queryResult = append(queryResult, result)
  8261. }
  8262. } else if record_type == 2 {
  8263. goods, _ := service.GetBatchGoodInformationList(ids)
  8264. for _, item := range goods {
  8265. result := QueryResult{
  8266. ID: item.ID,
  8267. Name: item.GoodName,
  8268. Code: item.MedicalInsuranceNumber,
  8269. List_type_code: "301",
  8270. }
  8271. queryResult = append(queryResult, result)
  8272. }
  8273. } else if record_type == 3 {
  8274. projects, _ := service.GetBathchMyPorjecgList(ids)
  8275. for _, item := range projects {
  8276. result := QueryResult{
  8277. ID: item.ID,
  8278. Name: item.ProjectName,
  8279. Code: item.MedicalCode,
  8280. List_type_code: "201",
  8281. }
  8282. queryResult = append(queryResult, result)
  8283. }
  8284. }
  8285. adminUser := c.GetAdminUserInfo()
  8286. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8287. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8288. var user_name string
  8289. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8290. if role.ID == 0 {
  8291. user_name = "xxx"
  8292. } else {
  8293. user_name = role.UserName
  8294. }
  8295. baseParams := &models.BaseParams{
  8296. SecretKey: miConfig.SecretKey,
  8297. FixmedinsCode: miConfig.Code,
  8298. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8299. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8300. OrgName: miConfig.OrgName,
  8301. Doctor: user_name,
  8302. }
  8303. if config.IsOpen == 1 {
  8304. for _, item := range queryResult {
  8305. var result string
  8306. if record_type == 1 {
  8307. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8308. } else if record_type == 2 {
  8309. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8310. } else if record_type == 3 {
  8311. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8312. }
  8313. var dat2 map[string]interface{}
  8314. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8315. fmt.Println(dat2)
  8316. } else {
  8317. fmt.Println(err)
  8318. }
  8319. userJSONBytes, _ := json.Marshal(dat2)
  8320. var res ResultSix
  8321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8322. utils.ErrorLog("解析失败:%v", err)
  8323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8324. return
  8325. }
  8326. if res.Infcode == 0 {
  8327. if record_type == 1 {
  8328. service.UpdateDrugByIdDetail(item.ID)
  8329. } else if record_type == 2 {
  8330. service.UpdateGoodInfoById(item.ID)
  8331. } else if record_type == 3 {
  8332. service.UpdateMyProjectById(item.ID)
  8333. }
  8334. c.ServeSuccessJSON(map[string]interface{}{
  8335. "failed_code": 0,
  8336. "msg": "撤销目录对照成功",
  8337. })
  8338. } else {
  8339. c.ServeSuccessJSON(map[string]interface{}{
  8340. "failed_code": -10,
  8341. "msg": res.ErrMsg,
  8342. })
  8343. }
  8344. }
  8345. }
  8346. }
  8347. func (c *HisApiController) GetPatientInfo() {
  8348. id_card_no := c.GetString("id_card_no")
  8349. admin_user_id, _ := c.GetInt64("admin_user_id")
  8350. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8351. if patient.ID == 0 {
  8352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8353. return
  8354. }
  8355. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8356. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8357. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8358. if config.IsOpen == 1 {
  8359. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8360. var dat map[string]interface{}
  8361. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8362. fmt.Println(dat)
  8363. } else {
  8364. fmt.Println(err)
  8365. }
  8366. userJSONBytes, _ := json.Marshal(dat)
  8367. var res ResultTwo
  8368. var res10265 ResultTwo10265
  8369. if miConfig.Code == "H15049901371" {
  8370. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8371. utils.ErrorLog("解析失败:%v", err)
  8372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8373. return
  8374. }
  8375. res.ErrMsg = res10265.ErrMsg
  8376. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8377. res.Infcode = infocode
  8378. res.Output = res10265.Output
  8379. res.InfRefmsgid = res10265.InfRefmsgid
  8380. } else {
  8381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8382. utils.ErrorLog("解析失败:%v", err)
  8383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8384. return
  8385. }
  8386. }
  8387. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8388. // utils.ErrorLog("解析失败:%v", err)
  8389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8390. // return
  8391. //}
  8392. if res.Infcode != 0 {
  8393. c.ServeSuccessJSON(map[string]interface{}{
  8394. "failed_code": -10,
  8395. "msg": res.ErrMsg,
  8396. })
  8397. } else {
  8398. c.ServeSuccessJSON(map[string]interface{}{
  8399. "failed_code": 0,
  8400. "info": res,
  8401. })
  8402. }
  8403. }
  8404. }
  8405. func (c *HisApiController) PsnPutOnRecord() {
  8406. record_type, _ := c.GetInt64("type")
  8407. patient_id, _ := c.GetInt64("patient_id")
  8408. admin_user_id, _ := c.GetInt64("admin_user_id")
  8409. start_time := c.GetString("start_time")
  8410. end_time := c.GetString("end_time")
  8411. adminUser := c.GetAdminUserInfo()
  8412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8413. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8414. var patients []*models.Patients
  8415. if record_type == 1 { //全部备案
  8416. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8417. patients = append(patients, patient...)
  8418. } else { //单个备案
  8419. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8420. patients = append(patients, patient)
  8421. }
  8422. var user_name string
  8423. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8424. if role.ID == 0 {
  8425. user_name = "xxx"
  8426. } else {
  8427. user_name = role.UserName
  8428. }
  8429. if config.IsOpen == 1 {
  8430. for _, item := range patients {
  8431. 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
  8432. resp, requestErr := http.Get(api)
  8433. if requestErr != nil {
  8434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8435. return
  8436. }
  8437. defer resp.Body.Close()
  8438. body, ioErr := ioutil.ReadAll(resp.Body)
  8439. if ioErr != nil {
  8440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8442. return
  8443. }
  8444. var respJSON map[string]interface{}
  8445. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8448. return
  8449. }
  8450. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8451. userJSONBytes, _ := json.Marshal(userJSON)
  8452. var res ResultTwo
  8453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8454. utils.ErrorLog("解析失败:%v", err)
  8455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8456. return
  8457. }
  8458. if res.Infcode == 0 {
  8459. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8460. var dat map[string]interface{}
  8461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8462. fmt.Println(dat)
  8463. } else {
  8464. fmt.Println(err)
  8465. }
  8466. userJSONBytes, _ := json.Marshal(dat)
  8467. var res2 ResultThirteen
  8468. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8469. utils.ErrorLog("解析失败:%v", err)
  8470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8471. return
  8472. }
  8473. if res2.Infcode == 0 {
  8474. psnResult := &models.GdybPsnRecord{
  8475. UserOrgId: adminUser.CurrentOrgId,
  8476. PatientId: item.ID,
  8477. PsnNo: res.Output.Baseinfo.PsnNo,
  8478. Ctime: time.Now().Unix(),
  8479. Mtime: time.Now().Unix(),
  8480. Status: 1,
  8481. IsCancel: 1,
  8482. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8483. }
  8484. service.CreatePsnRecord(psnResult)
  8485. } else {
  8486. c.ServeSuccessJSON(map[string]interface{}{
  8487. "failed_code": -10,
  8488. "msg": res2.ErrMsg,
  8489. })
  8490. return
  8491. }
  8492. }
  8493. }
  8494. }
  8495. }
  8496. func (c *HisApiController) PsnUnPutOnRecord() {
  8497. id, _ := c.GetInt64("id")
  8498. //record_type, _ := c.GetInt64("type")
  8499. admin_user_id, _ := c.GetInt64("admin_user_id")
  8500. adminUser := c.GetAdminUserInfo()
  8501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8502. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8503. var user_name string
  8504. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8505. if role.ID == 0 {
  8506. user_name = "xxx"
  8507. } else {
  8508. user_name = role.UserName
  8509. }
  8510. psn_record, _ := service.GetPsnRecordById(id)
  8511. if psn_record.ID == 0 {
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8513. return
  8514. }
  8515. if config.IsOpen == 1 {
  8516. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8517. var dat map[string]interface{}
  8518. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8519. fmt.Println(dat)
  8520. } else {
  8521. fmt.Println(err)
  8522. }
  8523. userJSONBytes, _ := json.Marshal(dat)
  8524. var res ResultFourteen
  8525. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8526. utils.ErrorLog("解析失败:%v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. if res.Infcode == 0 {
  8531. psn_record.IsCancel = 2
  8532. service.CreatePsnRecord(&psn_record)
  8533. } else {
  8534. c.ServeSuccessJSON(map[string]interface{}{
  8535. "failed_code": -10,
  8536. "msg": res.ErrMsg,
  8537. })
  8538. return
  8539. }
  8540. }
  8541. }
  8542. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8543. patient_id, _ := c.GetInt64("patient_id")
  8544. insutype_two := c.GetString("insutype")
  8545. psn_no := c.GetString("psn_no")
  8546. doctor_id, _ := c.GetInt64("doctor_id")
  8547. sick_id, _ := c.GetInt64("sick_id")
  8548. department_id, _ := c.GetInt64("department_id")
  8549. start_time := c.GetString("start_time")
  8550. end_time := c.GetString("end_time")
  8551. check_time := c.GetString("check_time")
  8552. adminUser := c.GetAdminUserInfo()
  8553. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8554. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8555. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8556. sick, _ := service.FindSickById(sick_id)
  8557. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8558. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8559. var res ResultTwo
  8560. var res10265 ResultTwo10265
  8561. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8562. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8563. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8564. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8565. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8566. resp, requestErr := http.Get(api)
  8567. if requestErr != nil {
  8568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8569. return
  8570. }
  8571. body, ioErr := ioutil.ReadAll(resp.Body)
  8572. if ioErr != nil {
  8573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8575. return
  8576. }
  8577. var respJSON map[string]interface{}
  8578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8581. return
  8582. }
  8583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8584. result, _ := json.Marshal(respJSON)
  8585. fmt.Println("log")
  8586. fmt.Println(string(result))
  8587. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8588. utils.ErrorLog("解析失败:%v", err)
  8589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8590. return
  8591. }
  8592. res.ErrMsg = res10265.ErrMsg
  8593. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8594. res.Infcode = infocode
  8595. res.Output = res10265.Output
  8596. res.InfRefmsgid = res10265.InfRefmsgid
  8597. } else {
  8598. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8599. if miConfig.Code == "H15049901371" {
  8600. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8601. utils.ErrorLog("解析失败:%v", err)
  8602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8603. return
  8604. }
  8605. res.ErrMsg = res10265.ErrMsg
  8606. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8607. res.Infcode = infocode
  8608. res.Output = res10265.Output
  8609. res.InfRefmsgid = res10265.InfRefmsgid
  8610. } else {
  8611. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8612. utils.ErrorLog("解析失败:%v", err)
  8613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8614. return
  8615. }
  8616. }
  8617. }
  8618. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8619. infoStr := string(Iinfos)
  8620. var rf []*ResultFive
  8621. json.Unmarshal([]byte(infoStr), &rf)
  8622. var insuplc_admdvs string
  8623. var insutype string
  8624. var is390 int = 0
  8625. var is310 int = 0
  8626. var insutypes []*ResultFive
  8627. for _, item := range rf {
  8628. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8629. insutypes = append(insutypes, item)
  8630. }
  8631. }
  8632. if len(insutypes) == 1 {
  8633. insutype = insutypes[0].Insutype
  8634. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8635. } else {
  8636. for _, i := range insutypes {
  8637. if i.Insutype == "390" {
  8638. is390 = 1
  8639. }
  8640. if i.Insutype == "310" {
  8641. is310 = 1
  8642. }
  8643. }
  8644. }
  8645. if is390 == 1 {
  8646. insutype = "390"
  8647. }
  8648. if is310 == 1 {
  8649. insutype = "310"
  8650. }
  8651. if len(insutypes) == 2 {
  8652. insutype = insutype_two
  8653. }
  8654. if len(insutypes) == 0 {
  8655. insutype = "310"
  8656. }
  8657. insutype = insutype_two
  8658. fmt.Println(insutype)
  8659. for _, item := range rf {
  8660. fmt.Println(item.Insutype)
  8661. fmt.Println(insutype)
  8662. if item.Insutype == insutype {
  8663. fmt.Println(item.Insutype)
  8664. fmt.Println(insutype)
  8665. insuplc_admdvs = item.InsuplcAdmdvs
  8666. }
  8667. }
  8668. fmt.Println(insuplc_admdvs)
  8669. var res2 ResultThirteen
  8670. var res10265_2 ResultThirteen10265
  8671. if config.IsOpen == 1 {
  8672. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8673. } else {
  8674. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  8675. var dat map[string]interface{}
  8676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8677. fmt.Println(dat)
  8678. } else {
  8679. fmt.Println(err)
  8680. }
  8681. userJSONBytes, _ := json.Marshal(dat)
  8682. if miConfig.Code == "H15049901371" {
  8683. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8684. utils.ErrorLog("解析失败:%v", err)
  8685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8686. return
  8687. }
  8688. res2.ErrMsg = res10265_2.ErrMsg
  8689. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8690. res2.Infcode = infocode
  8691. res2.Output = res10265_2.Output
  8692. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8693. } else {
  8694. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8695. utils.ErrorLog("解析失败:%v", err)
  8696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8697. return
  8698. }
  8699. }
  8700. }
  8701. if res2.Infcode == 0 {
  8702. psnResult := &models.GdybPsnNcdsRecord{
  8703. UserOrgId: adminUser.CurrentOrgId,
  8704. PatientId: patient.ID,
  8705. PsnNo: psn_no,
  8706. DoctorId: doctor.AdminUserId,
  8707. DepartmentId: department_id,
  8708. SickType: sick_id,
  8709. Insutype: insutype,
  8710. Ctime: time.Now().Unix(),
  8711. Mtime: time.Now().Unix(),
  8712. Status: 1,
  8713. IsCancel: 1,
  8714. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8715. }
  8716. service.CreatePsnNCDSRecord(psnResult)
  8717. c.ServeSuccessJSON(map[string]interface{}{
  8718. "failed_code": 0,
  8719. "msg": "备案成功",
  8720. "result": psnResult,
  8721. })
  8722. } else {
  8723. c.ServeSuccessJSON(map[string]interface{}{
  8724. "failed_code": -10,
  8725. "msg": res2.ErrMsg,
  8726. })
  8727. return
  8728. }
  8729. }
  8730. }
  8731. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8732. id, _ := c.GetInt64("id")
  8733. admin_user_id, _ := c.GetInt64("admin_user_id")
  8734. adminUser := c.GetAdminUserInfo()
  8735. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8736. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8737. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8738. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8739. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8740. //var user_name string
  8741. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8742. //if role.ID == 0 {
  8743. // user_name = "xxx"
  8744. //} else {
  8745. // user_name = role.UserName
  8746. //}
  8747. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8748. if psn_record.ID == 0 {
  8749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8750. return
  8751. }
  8752. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8753. var res ResultTwo
  8754. var res10265 ResultTwo10265
  8755. if miConfig.Code == "H15049901371" {
  8756. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8757. utils.ErrorLog("解析失败:%v", err)
  8758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8759. return
  8760. }
  8761. res.ErrMsg = res10265.ErrMsg
  8762. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8763. res.Infcode = infocode
  8764. res.Output = res10265.Output
  8765. res.InfRefmsgid = res10265.InfRefmsgid
  8766. } else {
  8767. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8768. utils.ErrorLog("解析失败:%v", err)
  8769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. return
  8771. }
  8772. }
  8773. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8774. infoStr := string(Iinfos)
  8775. var rf []*ResultFive
  8776. json.Unmarshal([]byte(infoStr), &rf)
  8777. var insuplc_admdvs string
  8778. var insutype string
  8779. var is390 int = 0
  8780. var is310 int = 0
  8781. var insutypes []*ResultFive
  8782. for _, item := range rf {
  8783. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8784. insutypes = append(insutypes, item)
  8785. }
  8786. }
  8787. if len(insutypes) == 1 {
  8788. insutype = insutypes[0].Insutype
  8789. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8790. } else {
  8791. for _, i := range insutypes {
  8792. if i.Insutype == "390" {
  8793. is390 = 1
  8794. }
  8795. if i.Insutype == "310" {
  8796. is310 = 1
  8797. }
  8798. }
  8799. }
  8800. if is390 == 1 {
  8801. insutype = "390"
  8802. }
  8803. if is310 == 1 {
  8804. insutype = "310"
  8805. }
  8806. if len(insutypes) == 0 {
  8807. insutype = "310"
  8808. }
  8809. insutype = psn_record.Insutype
  8810. for _, item := range rf {
  8811. if item.Insutype == insutype {
  8812. insuplc_admdvs = item.InsuplcAdmdvs
  8813. }
  8814. }
  8815. if config.IsOpen == 1 {
  8816. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8817. var dat map[string]interface{}
  8818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8819. fmt.Println(dat)
  8820. } else {
  8821. fmt.Println(err)
  8822. }
  8823. userJSONBytes, _ := json.Marshal(dat)
  8824. var res ResultFourteen
  8825. var res10265 ResultFourteen10265
  8826. if miConfig.Code == "H15049901371" {
  8827. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8828. utils.ErrorLog("解析失败:%v", err)
  8829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8830. return
  8831. }
  8832. res.ErrMsg = res10265.ErrMsg
  8833. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8834. res.Infcode = infocode
  8835. res.Output = res10265.Output
  8836. res.InfRefmsgid = res10265.InfRefmsgid
  8837. } else {
  8838. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8839. utils.ErrorLog("解析失败:%v", err)
  8840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8841. return
  8842. }
  8843. }
  8844. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8845. // utils.ErrorLog("解析失败:%v", err)
  8846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8847. // return
  8848. //}
  8849. if res.Infcode == 0 {
  8850. psn_record.IsCancel = 2
  8851. service.CreatePsnNCDSRecord(&psn_record)
  8852. c.ServeSuccessJSON(map[string]interface{}{
  8853. "failed_code": 0,
  8854. "msg": "撤销备案成功",
  8855. })
  8856. } else {
  8857. c.ServeSuccessJSON(map[string]interface{}{
  8858. "failed_code": -10,
  8859. "msg": res.ErrMsg,
  8860. })
  8861. return
  8862. }
  8863. }
  8864. }
  8865. func (c *HisApiController) TestTest() {
  8866. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8867. fmt.Println(patient.Iinfo)
  8868. }
  8869. type CustomData struct {
  8870. MsgId string
  8871. PsnNo string
  8872. Info string
  8873. }
  8874. func (c *HisApiController) ReversalData() {
  8875. var customData []*CustomData
  8876. custom := &CustomData{
  8877. MsgId: "H44022900158202103301714472004",
  8878. PsnNo: "44020000001101329945",
  8879. Info: "2207",
  8880. }
  8881. customData = append(customData, custom)
  8882. custom1 := &CustomData{
  8883. MsgId: "H4402290015820210330172057803",
  8884. PsnNo: "44020000001101161813",
  8885. Info: "2207",
  8886. }
  8887. customData = append(customData, custom1)
  8888. custom2 := &CustomData{
  8889. MsgId: "H44022900158202103301705198813",
  8890. PsnNo: "44190000133097375417",
  8891. Info: "2207",
  8892. }
  8893. customData = append(customData, custom2)
  8894. custom3 := &CustomData{
  8895. MsgId: "H44022900158202103301715524756",
  8896. PsnNo: "44020000001100187221",
  8897. Info: "2207",
  8898. }
  8899. customData = append(customData, custom3)
  8900. custom4 := &CustomData{
  8901. MsgId: "H44022900158202103301730376224",
  8902. PsnNo: "44020000001101959155",
  8903. Info: "2207",
  8904. }
  8905. customData = append(customData, custom4)
  8906. custom5 := &CustomData{
  8907. MsgId: "H44022900158202103301748008725",
  8908. PsnNo: "44020000001104246641",
  8909. Info: "2207",
  8910. }
  8911. customData = append(customData, custom5)
  8912. custom6 := &CustomData{
  8913. MsgId: "H44022900158202103301718096755",
  8914. PsnNo: "44020000001102211860",
  8915. Info: "2207",
  8916. }
  8917. customData = append(customData, custom6)
  8918. custom7 := &CustomData{
  8919. MsgId: "H44022900158202103301736551640",
  8920. PsnNo: "44020000001102687718",
  8921. Info: "2207",
  8922. }
  8923. customData = append(customData, custom7)
  8924. custom8 := &CustomData{
  8925. MsgId: "H44022900158202103301743097676",
  8926. PsnNo: "44020000001102127785",
  8927. Info: "2207",
  8928. }
  8929. customData = append(customData, custom8)
  8930. custom9 := &CustomData{
  8931. MsgId: "H44022900158202103301712304203",
  8932. PsnNo: "44020000001101518097",
  8933. Info: "2207",
  8934. }
  8935. customData = append(customData, custom9)
  8936. custom10 := &CustomData{
  8937. MsgId: "H44022900158202103301738448785",
  8938. PsnNo: "44020000001100500813",
  8939. Info: "2207",
  8940. }
  8941. customData = append(customData, custom10)
  8942. custom11 := &CustomData{
  8943. MsgId: "H44022900158202103301732455843",
  8944. PsnNo: "44020000001102690557",
  8945. Info: "2207",
  8946. }
  8947. customData = append(customData, custom11)
  8948. custom12 := &CustomData{
  8949. MsgId: "H44022900158202103301745421708",
  8950. PsnNo: "44020000001102211928",
  8951. Info: "2207",
  8952. }
  8953. customData = append(customData, custom12)
  8954. custom1212 := &CustomData{
  8955. MsgId: "H440229001582021033017351627",
  8956. PsnNo: "44020000001102481733",
  8957. Info: "2207",
  8958. }
  8959. customData = append(customData, custom1212)
  8960. custom13 := &CustomData{
  8961. MsgId: "H44022900158202103301740327951",
  8962. PsnNo: "44020000001103174866",
  8963. Info: "2207",
  8964. }
  8965. customData = append(customData, custom13)
  8966. custom14 := &CustomData{
  8967. MsgId: "H4402290015820210330174922668",
  8968. PsnNo: "44020000001102927272",
  8969. Info: "2207",
  8970. }
  8971. customData = append(customData, custom14)
  8972. custom15 := &CustomData{
  8973. MsgId: "H44022900158202103301752362273",
  8974. PsnNo: "44020000001102942890",
  8975. Info: "2207",
  8976. }
  8977. customData = append(customData, custom15)
  8978. custom16 := &CustomData{
  8979. MsgId: "H44022900158202103301751082917",
  8980. PsnNo: "44020000001101662162",
  8981. Info: "2207",
  8982. }
  8983. customData = append(customData, custom16)
  8984. custom17 := &CustomData{
  8985. MsgId: "H44022900158202103301754147728",
  8986. PsnNo: "44020000000229014511",
  8987. Info: "2207",
  8988. }
  8989. customData = append(customData, custom17)
  8990. adminUser := c.GetAdminUserInfo()
  8991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8992. for _, item := range customData {
  8993. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8994. fmt.Println(result)
  8995. }
  8996. }
  8997. func (c *HisApiController) GetAllopatry() {
  8998. year := c.GetString("year")
  8999. month := c.GetString("month")
  9000. admin_user_id, _ := c.GetInt64("admin_user_id")
  9001. adminUser := c.GetAdminUserInfo()
  9002. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9003. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9004. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9005. var dat map[string]interface{}
  9006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9007. fmt.Println(dat)
  9008. } else {
  9009. fmt.Println(err)
  9010. }
  9011. userJSONBytes, _ := json.Marshal(dat)
  9012. var res models.Result9001
  9013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9014. utils.ErrorLog("解析失败:%v", err)
  9015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9016. return
  9017. }
  9018. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9019. var dat2 map[string]interface{}
  9020. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9021. fmt.Println(dat)
  9022. } else {
  9023. fmt.Println(err)
  9024. }
  9025. userJSONBytes2, _ := json.Marshal(dat2)
  9026. var res2 models.Result3260
  9027. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9028. utils.ErrorLog("解析失败:%v", err)
  9029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9030. return
  9031. }
  9032. if res2.Infcode == 0 {
  9033. c.ServeSuccessJSON(map[string]interface{}{
  9034. "list": res2.Output.Data,
  9035. })
  9036. return
  9037. } else {
  9038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9039. return
  9040. }
  9041. }
  9042. func (c *HisApiController) ComfirmAllopatry() {
  9043. year := c.GetString("year")
  9044. month := c.GetString("month")
  9045. admin_user_id, _ := c.GetInt64("admin_user_id")
  9046. adminUser := c.GetAdminUserInfo()
  9047. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9048. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9049. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9050. var dat map[string]interface{}
  9051. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9052. fmt.Println(dat)
  9053. } else {
  9054. fmt.Println(err)
  9055. }
  9056. userJSONBytes, _ := json.Marshal(dat)
  9057. var res models.Result9001
  9058. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9059. utils.ErrorLog("解析失败:%v", err)
  9060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9061. return
  9062. }
  9063. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9064. var dat2 map[string]interface{}
  9065. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9066. fmt.Println(dat)
  9067. } else {
  9068. fmt.Println(err)
  9069. }
  9070. userJSONBytes2, _ := json.Marshal(dat2)
  9071. var res2 models.Result3260
  9072. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9073. utils.ErrorLog("解析失败:%v", err)
  9074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9075. return
  9076. }
  9077. if res2.Infcode == 0 {
  9078. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9079. var dat map[string]interface{}
  9080. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9081. fmt.Println(dat)
  9082. } else {
  9083. fmt.Println(err)
  9084. }
  9085. userJSONBytes, _ := json.Marshal(dat)
  9086. var res3 models.Result3261
  9087. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9088. utils.ErrorLog("解析失败:%v", err)
  9089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9090. return
  9091. }
  9092. if res3.Infcode == 0 {
  9093. record := &models.HisYidiClearRecord{
  9094. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9095. Ctime: time.Now().Unix(),
  9096. Mtime: time.Now().Unix(),
  9097. Status: 1,
  9098. MsgId: msgId,
  9099. }
  9100. service.SaveClearRecord(record)
  9101. c.ServeSuccessJSON(map[string]interface{}{
  9102. "msg": "提取成功",
  9103. })
  9104. }
  9105. }
  9106. }
  9107. func (c *HisApiController) RefundAllopatry() {
  9108. year := c.GetString("year")
  9109. month := c.GetString("month")
  9110. id, _ := c.GetInt64("id")
  9111. admin_user_id, _ := c.GetInt64("admin_user_id")
  9112. adminUser := c.GetAdminUserInfo()
  9113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9114. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9115. record, _ := service.GetClearRecordById(id)
  9116. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9117. var dat map[string]interface{}
  9118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9119. fmt.Println(dat)
  9120. } else {
  9121. fmt.Println(err)
  9122. }
  9123. userJSONBytes, _ := json.Marshal(dat)
  9124. var empty ResultFourteen
  9125. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9126. utils.ErrorLog("解析失败:%v", err)
  9127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9128. return
  9129. }
  9130. if empty.Infcode == 0 {
  9131. c.ServeSuccessJSON(map[string]interface{}{
  9132. "msg": "撤销成功",
  9133. })
  9134. return
  9135. }
  9136. }
  9137. func (c *HisApiController) ReversalOtherData() {
  9138. var customData []*CustomData
  9139. custom := &CustomData{
  9140. MsgId: "H44022900158202103301714472004",
  9141. PsnNo: "44020000001101329945",
  9142. Info: "2208",
  9143. }
  9144. customData = append(customData, custom)
  9145. custom1 := &CustomData{
  9146. MsgId: "H4402290015820210330172057803",
  9147. PsnNo: "44020000001101161813",
  9148. Info: "2208",
  9149. }
  9150. customData = append(customData, custom1)
  9151. custom2 := &CustomData{
  9152. MsgId: "H44022900158202103301705198813",
  9153. PsnNo: "44190000133097375417",
  9154. Info: "2208",
  9155. }
  9156. customData = append(customData, custom2)
  9157. custom3 := &CustomData{
  9158. MsgId: "H44022900158202103301715524756",
  9159. PsnNo: "44020000001100187221",
  9160. Info: "2208",
  9161. }
  9162. customData = append(customData, custom3)
  9163. custom4 := &CustomData{
  9164. MsgId: "H44022900158202103301730376224",
  9165. PsnNo: "44020000001101959155",
  9166. Info: "2208",
  9167. }
  9168. customData = append(customData, custom4)
  9169. custom5 := &CustomData{
  9170. MsgId: "H44022900158202103301748008725",
  9171. PsnNo: "44020000001104246641",
  9172. Info: "2208",
  9173. }
  9174. customData = append(customData, custom5)
  9175. custom6 := &CustomData{
  9176. MsgId: "H44022900158202103301718096755",
  9177. PsnNo: "44020000001102211860",
  9178. Info: "2208",
  9179. }
  9180. customData = append(customData, custom6)
  9181. custom7 := &CustomData{
  9182. MsgId: "H44022900158202103301736551640",
  9183. PsnNo: "44020000001102687718",
  9184. Info: "2208",
  9185. }
  9186. customData = append(customData, custom7)
  9187. custom8 := &CustomData{
  9188. MsgId: "H44022900158202103301743097676",
  9189. PsnNo: "44020000001102127785",
  9190. Info: "2208",
  9191. }
  9192. customData = append(customData, custom8)
  9193. custom9 := &CustomData{
  9194. MsgId: "H44022900158202103301712304203",
  9195. PsnNo: "44020000001101518097",
  9196. Info: "2208",
  9197. }
  9198. customData = append(customData, custom9)
  9199. custom10 := &CustomData{
  9200. MsgId: "H44022900158202103301738448785",
  9201. PsnNo: "44020000001100500813",
  9202. Info: "2208",
  9203. }
  9204. customData = append(customData, custom10)
  9205. custom11 := &CustomData{
  9206. MsgId: "H44022900158202103301732455843",
  9207. PsnNo: "44020000001102690557",
  9208. Info: "2208",
  9209. }
  9210. customData = append(customData, custom11)
  9211. custom12 := &CustomData{
  9212. MsgId: "H44022900158202103301745421708",
  9213. PsnNo: "44020000001102211928",
  9214. Info: "2208",
  9215. }
  9216. customData = append(customData, custom12)
  9217. custom1212 := &CustomData{
  9218. MsgId: "H440229001582021033017351627",
  9219. PsnNo: "44020000001102481733",
  9220. Info: "2208",
  9221. }
  9222. customData = append(customData, custom1212)
  9223. custom13 := &CustomData{
  9224. MsgId: "H44022900158202103301740327951",
  9225. PsnNo: "44020000001103174866",
  9226. Info: "2208",
  9227. }
  9228. customData = append(customData, custom13)
  9229. custom14 := &CustomData{
  9230. MsgId: "H4402290015820210330174922668",
  9231. PsnNo: "44020000001102927272",
  9232. Info: "2208",
  9233. }
  9234. customData = append(customData, custom14)
  9235. custom15 := &CustomData{
  9236. MsgId: "H44022900158202103301752362273",
  9237. PsnNo: "44020000001102942890",
  9238. Info: "2208",
  9239. }
  9240. customData = append(customData, custom15)
  9241. custom16 := &CustomData{
  9242. MsgId: "H44022900158202103301751082917",
  9243. PsnNo: "44020000001101662162",
  9244. Info: "2208",
  9245. }
  9246. customData = append(customData, custom16)
  9247. custom17 := &CustomData{
  9248. MsgId: "H44022900158202103301754147728",
  9249. PsnNo: "44020000000229014511",
  9250. Info: "2208",
  9251. }
  9252. customData = append(customData, custom17)
  9253. adminUser := c.GetAdminUserInfo()
  9254. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9255. for _, item := range customData {
  9256. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9257. fmt.Println(result)
  9258. }
  9259. }
  9260. func PathExists(path string) (bool, error) {
  9261. _, err := os.Stat(path)
  9262. if err == nil {
  9263. return true, nil
  9264. }
  9265. if os.IsNotExist(err) {
  9266. return false, nil
  9267. }
  9268. return false, err
  9269. }
  9270. //创建文件夹
  9271. func Mkdir(dir string) {
  9272. // 创建文件夹
  9273. exist, err := PathExists(dir)
  9274. if err != nil {
  9275. fmt.Println(err.Error())
  9276. } else {
  9277. if exist {
  9278. fmt.Println(dir + "文件夹已存在!")
  9279. } else {
  9280. // 文件夹名称,权限
  9281. err := os.Mkdir(dir, os.ModePerm)
  9282. if err != nil {
  9283. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9284. } else {
  9285. fmt.Println(dir + "文件夹创建成功!")
  9286. }
  9287. }
  9288. }
  9289. }
  9290. //压缩文件
  9291. func Zip(srcFile string, destZip string) error {
  9292. zipfile, err := os.Create(destZip)
  9293. if err != nil {
  9294. return err
  9295. }
  9296. defer zipfile.Close()
  9297. archive := zip.NewWriter(zipfile)
  9298. defer archive.Close()
  9299. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9300. if err != nil {
  9301. return err
  9302. }
  9303. header, err := zip.FileInfoHeader(info)
  9304. if err != nil {
  9305. return err
  9306. }
  9307. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9308. // header.Name = path
  9309. if info.IsDir() {
  9310. header.Name += "/"
  9311. } else {
  9312. header.Method = zip.Deflate
  9313. }
  9314. writer, err := archive.CreateHeader(header)
  9315. if err != nil {
  9316. return err
  9317. }
  9318. if !info.IsDir() {
  9319. file, err := os.Open(path)
  9320. if err != nil {
  9321. return err
  9322. }
  9323. defer file.Close()
  9324. _, err = io.Copy(writer, file)
  9325. }
  9326. return err
  9327. })
  9328. return err
  9329. }
  9330. func ReadFile(filePath string) []byte {
  9331. f, err := os.Open(filePath)
  9332. if err != nil {
  9333. fmt.Println("read file fail", err)
  9334. return nil
  9335. }
  9336. defer f.Close()
  9337. fd, err := ioutil.ReadAll(f)
  9338. if err != nil {
  9339. fmt.Println("read to fd fail", err)
  9340. return nil
  9341. }
  9342. return fd
  9343. }
  9344. func saveLog(result string, request string, infno string, desc string) {
  9345. org_id, _ := beego.AppConfig.Int64("org_id")
  9346. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9347. dir := miConfig.OrgName + "日志"
  9348. utils.Mkdir(dir)
  9349. month := time.Unix(1557042972, 0).Format("1")
  9350. year := time.Now().Format("2006")
  9351. month = time.Now().Format("01")
  9352. day := time.Now().Format("02")
  9353. hour := time.Now().Format("15")
  9354. min := time.Now().Format("04")
  9355. sec := time.Now().Format("05")
  9356. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9357. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9358. file_name := file + ".txt"
  9359. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9360. exist, _ := utils.PathExists(file_path)
  9361. if exist { //存在
  9362. fmt.Println("存在")
  9363. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9364. if err != nil {
  9365. fmt.Println("read fail")
  9366. }
  9367. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9368. n, _ := f.Seek(0, 2)
  9369. _, err = f.WriteAt([]byte(content), n)
  9370. } else { //不存在
  9371. fmt.Println("文件不存在,创建文件")
  9372. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9373. defer f.Close()
  9374. if err != nil {
  9375. } else {
  9376. _, err = f.Write([]byte("记录日志"))
  9377. }
  9378. }
  9379. }
  9380. type Charset string
  9381. const (
  9382. UTF8 = Charset("UTF-8")
  9383. GB18030 = Charset("GB18030")
  9384. )
  9385. func ConvertToString(src string, srcCode string, tagCode string) string {
  9386. srcCoder := mahonia.NewDecoder(srcCode)
  9387. srcResult := srcCoder.ConvertString(src)
  9388. tagCoder := mahonia.NewDecoder(tagCode)
  9389. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9390. result := string(cdata)
  9391. return result
  9392. }