his_api_controller.go 354KB

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