his_api_controller.go 354KB

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