his_api_controller.go 334KB

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