his_api_controller.go 404KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. }
  74. func (c *HisApiController) Check() {
  75. psn_no := c.GetString("psn_no")
  76. in := c.GetString("in")
  77. mt := c.GetString("mt")
  78. baseParams := models.BaseParams{
  79. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  80. FixmedinsCode: "H15049901371",
  81. InsuplcAdmdvs: "150499",
  82. MdtrtareaAdmvs: "150499",
  83. OrgName: "赤峰费森血液透析中心",
  84. Doctor: "1111",
  85. }
  86. service.Gdyb2001(baseParams, psn_no, in, mt)
  87. }
  88. func (c *HisApiController) GetPsnNcdsInfo() {
  89. admin_user_id, _ := c.GetInt64("admin_user_id")
  90. patient_id, _ := c.GetInt64("patient_id")
  91. id, _ := c.GetInt64("id")
  92. adminUser := c.GetAdminUserInfo()
  93. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  94. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  95. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  96. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  97. psn_record, _ := service.GetPsnNCDSRecordById(id)
  98. //
  99. //if psn_record.ID == 0 {
  100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  101. // return
  102. //}
  103. var res Result5301
  104. var res10265 Result5301For10265
  105. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  106. psn_info, _ := service.GetPsnByPatientId(patient_id)
  107. var api string
  108. if miConfig.MdtrtareaAdmvs == "320921" {
  109. 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 +
  110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  111. } else {
  112. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  114. }
  115. resp, requestErr := http.Get(api)
  116. if requestErr != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  118. return
  119. }
  120. body, ioErr := ioutil.ReadAll(resp.Body)
  121. if ioErr != nil {
  122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  124. return
  125. }
  126. var respJSON map[string]interface{}
  127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  130. return
  131. }
  132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  133. result, _ := json.Marshal(respJSON)
  134. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  135. utils.ErrorLog("解析失败:%v", err)
  136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  137. return
  138. }
  139. res.ErrMsg = res10265.ErrMsg
  140. res.Output = res10265.Output
  141. res.InfRefmsgid = res10265.InfRefmsgid
  142. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  143. res.Infcode = infocode
  144. } else {
  145. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  146. var dat map[string]interface{}
  147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  148. fmt.Println(dat)
  149. } else {
  150. fmt.Println(err)
  151. }
  152. userJSONBytes, _ := json.Marshal(dat)
  153. if miConfig.Code == "H15049901371" {
  154. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  155. utils.ErrorLog("解析失败:%v", err)
  156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  157. return
  158. }
  159. res.InfRefmsgid = res10265.InfRefmsgid
  160. res.Output = res10265.Output
  161. res.ErrMsg = res10265.ErrMsg
  162. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  163. res.Infcode = infocode
  164. } else {
  165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  166. utils.ErrorLog("解析失败:%v", err)
  167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  168. return
  169. }
  170. }
  171. }
  172. if res.Infcode == 0 {
  173. c.ServeSuccessJSON(map[string]interface{}{
  174. "result": res.Output.Result,
  175. })
  176. }
  177. }
  178. func (c *HisApiController) CheckInsutype() {
  179. his_patient_id, _ := c.GetInt64("his_patient_id")
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  182. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  183. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  184. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  185. var dat map[string]interface{}
  186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  187. fmt.Println(dat)
  188. } else {
  189. fmt.Println(err)
  190. }
  191. userJSONBytes, _ := json.Marshal(dat)
  192. var res Result90100
  193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  194. utils.ErrorLog("解析失败:%v", err)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. if res.Infcode != 0 {
  199. c.ServeSuccessJSON(map[string]interface{}{
  200. "failed_code": -10,
  201. "msg": res.ErrMsg,
  202. })
  203. return
  204. } else {
  205. fmt.Println(res)
  206. }
  207. }
  208. func (c *HisApiController) CheckCardPWD() {
  209. card_pwd := c.GetString("card_pwd")
  210. his_patient_id, _ := c.GetInt64("his_patient_id")
  211. admin_user_id, _ := c.GetInt64("admin_user_id")
  212. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  214. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  215. psn, _ := service.GetPsnByPatientId(his.PatientId)
  216. bas := strings.Split(psn.CardInfo, "|")
  217. basNumber := bas[2]
  218. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  219. var dat map[string]interface{}
  220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  221. fmt.Println(dat)
  222. } else {
  223. fmt.Println(err)
  224. }
  225. userJSONBytes, _ := json.Marshal(dat)
  226. var res Result90991
  227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  228. utils.ErrorLog("解析失败:%v", err)
  229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  230. return
  231. }
  232. if res.Infcode != 0 {
  233. c.ServeSuccessJSON(map[string]interface{}{
  234. "failed_code": -10,
  235. "msg": res.ErrMsg,
  236. })
  237. return
  238. } else {
  239. if res.Output.Result.CheckStat == "0" {
  240. var msg string
  241. switch res.Output.Result.CardStat {
  242. case "00":
  243. msg = "未激活"
  244. break
  245. case "10":
  246. msg = "激活"
  247. break
  248. case "20":
  249. msg = "窗口挂失"
  250. break
  251. case "21":
  252. msg = "电话挂失"
  253. break
  254. case "22":
  255. msg = "单位网上申报挂失"
  256. break
  257. case "23":
  258. msg = "保健办挂失"
  259. break
  260. case "24":
  261. msg = "个人网上挂失"
  262. break
  263. case "25":
  264. msg = "网上服务大厅挂失"
  265. break
  266. case "30":
  267. msg = "注销"
  268. break
  269. case "40":
  270. msg = "回收"
  271. break
  272. case "99":
  273. msg = "制卡中(无效卡)"
  274. break
  275. }
  276. c.ServeSuccessJSON(map[string]interface{}{
  277. "failed_code": -10,
  278. "msg": msg,
  279. })
  280. return
  281. } else {
  282. c.ServeSuccessJSON(map[string]interface{}{
  283. "msg": "校验成功",
  284. })
  285. return
  286. }
  287. }
  288. }
  289. func (c *HisApiController) ReadCard() {
  290. id_card_type, _ := c.GetInt64("id_card_type")
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. certificates, _ := c.GetInt64("certificates")
  293. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  294. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  295. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  296. switch id_card_type {
  297. case 1:
  298. if miConfig.MdtrtareaAdmvs == "421300" {
  299. var res ResultTwo
  300. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  301. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  302. "&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)
  303. resp, requestErr := http.Get(api)
  304. if requestErr != nil {
  305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  306. return
  307. }
  308. body, ioErr := ioutil.ReadAll(resp.Body)
  309. if ioErr != nil {
  310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  312. return
  313. }
  314. var respJSON map[string]interface{}
  315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  318. return
  319. }
  320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  321. result, _ := json.Marshal(respJSON)
  322. fmt.Println("log")
  323. fmt.Println(string(result))
  324. if err := json.Unmarshal([]byte(result), &res); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  327. return
  328. }
  329. if res.Infcode == 0 {
  330. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  331. if err == gorm.ErrRecordNotFound {
  332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  333. return
  334. } else if err != nil {
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  336. return
  337. } else {
  338. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  339. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  340. infoStr := string(Iinfos)
  341. idetinfoStr := string(Idetinfos)
  342. psn := &models.HisPsn{
  343. PsnNo: res.Output.Baseinfo.PsnNo,
  344. Age: res.Output.Baseinfo.Age,
  345. PatientId: patient.ID,
  346. Certno: res.Output.Baseinfo.Certno,
  347. Brdy: res.Output.Baseinfo.Brdy,
  348. Gend: res.Output.Baseinfo.Gend,
  349. Naty: res.Output.Baseinfo.Naty,
  350. PsnCertType: res.Output.Baseinfo.PsnCertType,
  351. PsnName: res.Output.Baseinfo.PsnName,
  352. Idetinfo: idetinfoStr,
  353. Insuinfo: infoStr,
  354. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  355. }
  356. service.CreateHisPsn(psn)
  357. c.ServeSuccessJSON(map[string]interface{}{
  358. "patient": patient,
  359. "number": res.Output.Baseinfo.Certno,
  360. })
  361. }
  362. } else {
  363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  364. return
  365. }
  366. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  367. var api string
  368. if miConfig.MdtrtareaAdmvs == "320921" {
  369. 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 +
  370. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  371. fmt.Println(api)
  372. } else {
  373. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  374. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  375. }
  376. resp, requestErr := http.Get(api)
  377. if requestErr != nil {
  378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  379. return
  380. }
  381. body, ioErr := ioutil.ReadAll(resp.Body)
  382. if ioErr != nil {
  383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  385. return
  386. }
  387. var respJSON map[string]interface{}
  388. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  391. return
  392. }
  393. var status string
  394. status = respJSON["data"].(map[string]interface{})["status"].(string)
  395. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  396. //console.log()
  397. fmt.Println("type===")
  398. fmt.Println(card_type)
  399. var token string
  400. var res ResultTwo //1101结果
  401. var res10265 ResultTwo10265 //1101结果
  402. var card_info string //卡信息
  403. var busi_card_info string
  404. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  405. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  406. if status == "0" { //读卡成功
  407. if card_type == "1" {
  408. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  409. result, _ := json.Marshal(respJSON)
  410. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  411. utils.ErrorLog("解析失败:%v", err)
  412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  413. return
  414. }
  415. res.ErrMsg = res10265.ErrMsg
  416. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  417. res.Infcode = infocode
  418. res.Output = res10265.Output
  419. res.InfRefmsgid = res10265.InfRefmsgid
  420. } else {
  421. //var card_info string //卡信息
  422. //var busi_card_info string
  423. token = respJSON["data"].(map[string]interface{})["token"].(string)
  424. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  425. //fmt.Println(card_info)
  426. //fmt.Println(busi_card_info)
  427. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  428. result, _ := json.Marshal(respJSON)
  429. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  430. utils.ErrorLog("解析失败:%v", err)
  431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  432. return
  433. }
  434. res.ErrMsg = res10265.ErrMsg
  435. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  436. res.Infcode = infocode
  437. res.Output = res10265.Output
  438. res.InfRefmsgid = res10265.InfRefmsgid
  439. }
  440. if res.Infcode == 0 {
  441. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  442. if err == gorm.ErrRecordNotFound {
  443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  444. return
  445. } else if err != nil {
  446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  447. return
  448. } else {
  449. if card_type == "1" {
  450. bas := strings.Split(card_info, "|")
  451. basNumber := bas[2]
  452. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  453. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  454. infoStr := string(Iinfos)
  455. idetinfoStr := string(Idetinfos)
  456. psn := &models.HisPsn{
  457. PsnNo: res.Output.Baseinfo.PsnNo,
  458. Age: res.Output.Baseinfo.Age,
  459. PatientId: patient.ID,
  460. Certno: res.Output.Baseinfo.Certno,
  461. Brdy: res.Output.Baseinfo.Brdy,
  462. Gend: res.Output.Baseinfo.Gend,
  463. Naty: res.Output.Baseinfo.Naty,
  464. PsnCertType: res.Output.Baseinfo.PsnCertType,
  465. PsnName: res.Output.Baseinfo.PsnName,
  466. Idetinfo: idetinfoStr,
  467. Insuinfo: infoStr,
  468. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  469. CardInfo: card_info,
  470. VerifyNumber: busi_card_info,
  471. }
  472. service.CreateHisPsn(psn)
  473. c.ServeSuccessJSON(map[string]interface{}{
  474. "patient": patient,
  475. "number": basNumber,
  476. })
  477. } else {
  478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  480. infoStr := string(Iinfos)
  481. idetinfoStr := string(Idetinfos)
  482. psn := &models.HisPsn{
  483. PsnNo: res.Output.Baseinfo.PsnNo,
  484. Age: res.Output.Baseinfo.Age,
  485. PatientId: patient.ID,
  486. Certno: res.Output.Baseinfo.Certno,
  487. Brdy: res.Output.Baseinfo.Brdy,
  488. Gend: res.Output.Baseinfo.Gend,
  489. Naty: res.Output.Baseinfo.Naty,
  490. PsnCertType: res.Output.Baseinfo.PsnCertType,
  491. PsnName: res.Output.Baseinfo.PsnName,
  492. Idetinfo: idetinfoStr,
  493. Insuinfo: infoStr,
  494. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  495. CardInfo: card_info,
  496. VerifyNumber: token,
  497. }
  498. service.CreateHisPsn(psn)
  499. c.ServeSuccessJSON(map[string]interface{}{
  500. "patient": patient,
  501. "number": token,
  502. })
  503. }
  504. }
  505. } else {
  506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  507. return
  508. }
  509. } else { //读卡失败
  510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  511. return
  512. }
  513. } else {
  514. if initFlag == 0 {
  515. c.TestGetBasBaseInit()
  516. }
  517. basStr := c.GetBasBaseInfo()
  518. if len(basStr) == 0 {
  519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  520. return
  521. }
  522. fmt.Println(basStr)
  523. bas := strings.Split(basStr, "|")
  524. basNumber := bas[1]
  525. fmt.Println(basNumber)
  526. card_sn := bas[3]
  527. fmt.Println(card_sn)
  528. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  529. var dat map[string]interface{}
  530. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  531. fmt.Println(dat)
  532. } else {
  533. fmt.Println(err)
  534. }
  535. userJSONBytes, _ := json.Marshal(dat)
  536. var res ResultTwo
  537. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  538. utils.ErrorLog("解析失败:%v", err)
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  540. return
  541. }
  542. if res.Infcode == 0 {
  543. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  544. if err == gorm.ErrRecordNotFound {
  545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  546. return
  547. } else if err != nil {
  548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  549. return
  550. } else {
  551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  553. infoStr := string(Iinfos)
  554. idetinfoStr := string(Idetinfos)
  555. psn := &models.HisPsn{
  556. PsnNo: res.Output.Baseinfo.PsnNo,
  557. Age: res.Output.Baseinfo.Age,
  558. PatientId: patient.ID,
  559. Certno: res.Output.Baseinfo.Certno,
  560. Brdy: res.Output.Baseinfo.Brdy,
  561. Gend: res.Output.Baseinfo.Gend,
  562. Naty: res.Output.Baseinfo.Naty,
  563. PsnCertType: res.Output.Baseinfo.PsnCertType,
  564. PsnName: res.Output.Baseinfo.PsnName,
  565. Idetinfo: idetinfoStr,
  566. Insuinfo: infoStr,
  567. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  568. CardInfo: basStr,
  569. VerifyNumber: "",
  570. }
  571. service.CreateHisPsn(psn)
  572. c.ServeSuccessJSON(map[string]interface{}{
  573. "patient": patient,
  574. "number": basNumber,
  575. })
  576. }
  577. } else {
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  579. return
  580. }
  581. break
  582. }
  583. case 2:
  584. SFZStr := c.GetSFZBaseInfo()
  585. id_card_str := strings.Split(SFZStr, "^")
  586. id_card_number := id_card_str[0]
  587. card_sn := ""
  588. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  589. var dat map[string]interface{}
  590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  591. fmt.Println(dat)
  592. } else {
  593. fmt.Println(err)
  594. }
  595. userJSONBytes, _ := json.Marshal(dat)
  596. var res ResultTwo
  597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  598. utils.ErrorLog("解析失败:%v", err)
  599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  600. return
  601. }
  602. if res.Infcode == 0 {
  603. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  604. if err == gorm.ErrRecordNotFound {
  605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  606. return
  607. } else if err != nil {
  608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  609. return
  610. } else {
  611. c.ServeSuccessJSON(map[string]interface{}{
  612. "patient": patient,
  613. "number": id_card_number,
  614. })
  615. }
  616. } else {
  617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  618. return
  619. }
  620. break
  621. case 3:
  622. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  623. var api string
  624. if miConfig.MdtrtareaAdmvs == "320921" {
  625. 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 +
  626. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  627. fmt.Println(api)
  628. } else {
  629. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  630. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  631. }
  632. resp, requestErr := http.Get(api)
  633. if requestErr != nil {
  634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  635. return
  636. }
  637. body, ioErr := ioutil.ReadAll(resp.Body)
  638. if ioErr != nil {
  639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  641. return
  642. }
  643. var respJSON map[string]interface{}
  644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. var status string
  650. status = respJSON["data"].(map[string]interface{})["status"].(string)
  651. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  652. var token string
  653. var res ResultTwo //1101结果
  654. var res10265 ResultTwo10265 //1101结果
  655. var card_info string //卡信息
  656. var busi_card_info string
  657. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  658. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  659. if status == "0" { //读卡成功
  660. if card_type == "1" {
  661. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  662. result, _ := json.Marshal(respJSON)
  663. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  664. utils.ErrorLog("解析失败:%v", err)
  665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  666. return
  667. }
  668. res.ErrMsg = res10265.ErrMsg
  669. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  670. res.Infcode = infocode
  671. res.Output = res10265.Output
  672. res.InfRefmsgid = res10265.InfRefmsgid
  673. } else {
  674. //var card_info string //卡信息
  675. //var busi_card_info string
  676. token = respJSON["data"].(map[string]interface{})["token"].(string)
  677. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  678. //fmt.Println(card_info)
  679. //fmt.Println(busi_card_info)
  680. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  681. result, _ := json.Marshal(respJSON)
  682. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  683. utils.ErrorLog("解析失败:%v", err)
  684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  685. return
  686. }
  687. res.ErrMsg = res10265.ErrMsg
  688. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  689. res.Infcode = infocode
  690. res.Output = res10265.Output
  691. res.InfRefmsgid = res10265.InfRefmsgid
  692. }
  693. if res.Infcode == 0 {
  694. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  695. if err == gorm.ErrRecordNotFound {
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  697. return
  698. } else if err != nil {
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  700. return
  701. } else {
  702. if card_type == "1" {
  703. bas := strings.Split(card_info, "|")
  704. basNumber := bas[2]
  705. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  706. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  707. infoStr := string(Iinfos)
  708. idetinfoStr := string(Idetinfos)
  709. psn := &models.HisPsn{
  710. PsnNo: res.Output.Baseinfo.PsnNo,
  711. Age: res.Output.Baseinfo.Age,
  712. PatientId: patient.ID,
  713. Certno: res.Output.Baseinfo.Certno,
  714. Brdy: res.Output.Baseinfo.Brdy,
  715. Gend: res.Output.Baseinfo.Gend,
  716. Naty: res.Output.Baseinfo.Naty,
  717. PsnCertType: res.Output.Baseinfo.PsnCertType,
  718. PsnName: res.Output.Baseinfo.PsnName,
  719. Idetinfo: idetinfoStr,
  720. Insuinfo: infoStr,
  721. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  722. CardInfo: card_info,
  723. VerifyNumber: busi_card_info,
  724. }
  725. service.CreateHisPsn(psn)
  726. c.ServeSuccessJSON(map[string]interface{}{
  727. "patient": patient,
  728. "number": basNumber,
  729. })
  730. } else {
  731. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  732. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  733. infoStr := string(Iinfos)
  734. idetinfoStr := string(Idetinfos)
  735. psn := &models.HisPsn{
  736. PsnNo: res.Output.Baseinfo.PsnNo,
  737. Age: res.Output.Baseinfo.Age,
  738. PatientId: patient.ID,
  739. Certno: res.Output.Baseinfo.Certno,
  740. Brdy: res.Output.Baseinfo.Brdy,
  741. Gend: res.Output.Baseinfo.Gend,
  742. Naty: res.Output.Baseinfo.Naty,
  743. PsnCertType: res.Output.Baseinfo.PsnCertType,
  744. PsnName: res.Output.Baseinfo.PsnName,
  745. Idetinfo: idetinfoStr,
  746. Insuinfo: infoStr,
  747. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  748. CardInfo: card_info,
  749. VerifyNumber: token,
  750. }
  751. service.CreateHisPsn(psn)
  752. c.ServeSuccessJSON(map[string]interface{}{
  753. "patient": patient,
  754. "number": token,
  755. })
  756. }
  757. }
  758. } else {
  759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  760. return
  761. }
  762. } else { //读卡失败
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  764. return
  765. }
  766. }
  767. break
  768. case 4:
  769. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  770. var api string
  771. if miConfig.MdtrtareaAdmvs == "320921" {
  772. 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 +
  773. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  774. fmt.Println(api)
  775. } else {
  776. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  777. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  778. }
  779. resp, requestErr := http.Get(api)
  780. if requestErr != nil {
  781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  782. return
  783. }
  784. body, ioErr := ioutil.ReadAll(resp.Body)
  785. if ioErr != nil {
  786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  788. return
  789. }
  790. var respJSON map[string]interface{}
  791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  794. return
  795. }
  796. var status string
  797. status = respJSON["data"].(map[string]interface{})["status"].(string)
  798. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  799. var token string
  800. var res ResultTwo //1101结果
  801. var res10265 ResultTwo10265 //1101结果
  802. if status == "0" { //读卡成功
  803. var card_info string //卡信息
  804. var busi_card_info string
  805. token = respJSON["data"].(map[string]interface{})["token"].(string)
  806. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  807. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  808. fmt.Println(card_info)
  809. fmt.Println(busi_card_info)
  810. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  811. result, _ := json.Marshal(respJSON)
  812. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  813. utils.ErrorLog("解析失败:%v", err)
  814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  815. return
  816. }
  817. res.ErrMsg = res10265.ErrMsg
  818. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  819. res.Infcode = infocode
  820. res.Output = res10265.Output
  821. res.InfRefmsgid = res10265.InfRefmsgid
  822. if res.Infcode == 0 {
  823. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  824. if err == gorm.ErrRecordNotFound {
  825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  826. return
  827. } else if err != nil {
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  829. return
  830. } else {
  831. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  832. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  833. infoStr := string(Iinfos)
  834. idetinfoStr := string(Idetinfos)
  835. psn := &models.HisPsn{
  836. PsnNo: res.Output.Baseinfo.PsnNo,
  837. Age: res.Output.Baseinfo.Age,
  838. PatientId: patient.ID,
  839. Certno: res.Output.Baseinfo.Certno,
  840. Brdy: res.Output.Baseinfo.Brdy,
  841. Gend: res.Output.Baseinfo.Gend,
  842. Naty: res.Output.Baseinfo.Naty,
  843. PsnCertType: res.Output.Baseinfo.PsnCertType,
  844. PsnName: res.Output.Baseinfo.PsnName,
  845. Idetinfo: idetinfoStr,
  846. Insuinfo: infoStr,
  847. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  848. CardInfo: card_info,
  849. VerifyNumber: token,
  850. }
  851. service.CreateHisPsn(psn)
  852. c.ServeSuccessJSON(map[string]interface{}{
  853. "patient": patient,
  854. "number": token,
  855. })
  856. }
  857. } else {
  858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  859. return
  860. }
  861. } else { //读卡失败
  862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  863. return
  864. }
  865. }
  866. break
  867. }
  868. }
  869. var initFlag int64 = 0
  870. func (c *HisApiController) TestGetBasBaseInit() {
  871. DllDef := syscall.MustLoadDLL("SSCard.dll")
  872. Iinit := DllDef.MustFindProc("Init")
  873. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  874. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  875. if ret != 0 {
  876. fmt.Println("SSCard的报错原因:", err)
  877. fmt.Println("SSCard的运算结果为:", ret)
  878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  879. return
  880. }
  881. result := int(ret)
  882. fmt.Println("SSCard的运算结果为1:", result)
  883. initFlag = 1
  884. return
  885. }
  886. func (c *HisApiController) GetSFZBaseInfo() string {
  887. DllDef := syscall.MustLoadDLL("SSCard.dll")
  888. readCard := DllDef.MustFindProc("ReadSFZ")
  889. if readCard == nil {
  890. fmt.Println("readcard is nil")
  891. readCard = DllDef.MustFindProc("ReadSFZ")
  892. }
  893. str := make([]byte, 256)
  894. str1 := make([]byte, 256)
  895. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  896. fmt.Println(r)
  897. return string(str)
  898. }
  899. func (c *HisApiController) GetBasBaseInfo() string {
  900. DllDef := syscall.MustLoadDLL("SSCard.dll")
  901. readCard := DllDef.MustFindProc("ReadCardBas")
  902. if readCard == nil {
  903. fmt.Println("readcard is nil")
  904. readCard = DllDef.MustFindProc("ReadCardBas")
  905. }
  906. str := make([]byte, 1024)
  907. str1 := make([]byte, 1024)
  908. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  909. fmt.Println(string(str1))
  910. fmt.Println(string(str))
  911. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  912. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  913. if ret2 != 0 {
  914. return ""
  915. }
  916. return string(str)
  917. }
  918. type CustomFundPay struct {
  919. FundPayType string `json:"fund_pay_type"`
  920. FundPayamt float64 `json:"fund_payamt"`
  921. }
  922. func (c *HisApiController) GetSettleList() {
  923. order_id, _ := c.GetInt64("order_id")
  924. admin_user_id, _ := c.GetInt64("admin_user_id")
  925. order, _ := service.GetHisOrderByIDTwo(order_id)
  926. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  927. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  928. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  929. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  930. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  931. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  932. if order.ID == 0 {
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  934. return
  935. }
  936. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  937. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  938. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  939. fmt.Println(count)
  940. var zero string
  941. number := count + 1
  942. if number >= 1000 {
  943. zero = "0000" + strconv.FormatInt(number, 10)
  944. } else if number >= 10000 {
  945. zero = "000" + strconv.FormatInt(number, 10)
  946. } else if number >= 100000 {
  947. zero = "00" + strconv.FormatInt(number, 10)
  948. } else if number >= 1000000 {
  949. zero = "0" + strconv.FormatInt(number, 10)
  950. } else {
  951. zero = strconv.FormatInt(number, 10)
  952. }
  953. fmt.Println(zero)
  954. struct4101 := service.Struct4101{
  955. PsnNo: order.PsnNo,
  956. MdtrtId: order.MdtrtId,
  957. SetlId: order.SetlId,
  958. PsnName: order.PsnName,
  959. Gend: order.Gend,
  960. Brdy: his.Brdy,
  961. Age: his.Age,
  962. Naty: order.Naty,
  963. PatnCertType: "01",
  964. Certno: order.Certno,
  965. Prfs: "90",
  966. ConerName: roles[0].UserName,
  967. PatnRlts: "99",
  968. ConerAddr: miConfig.OrgName,
  969. ConerTel: admin.Mobile,
  970. HiType: order.Insutype,
  971. Insuplc: miConfig.InsuplcAdmdvs,
  972. MaindiagFlag: "1",
  973. BillCode: last_order.FaPiaoCode,
  974. BillNo: zero,
  975. BizSn: order.Number,
  976. PsnSelfPay: order.PsnPartAmt,
  977. PsnOwnPay: order.PsnPartAmt,
  978. AcctPay: order.AcctPay,
  979. PsnCashpay: order.PsnCashPay,
  980. HiPaymtd: "1",
  981. Hsorg: miConfig.InsuplcAdmdvs,
  982. HsorgOpter: miConfig.InsuplcAdmdvs,
  983. MedinsFillPsn: curRoles.UserName,
  984. MedinsFillDept: depart.Name,
  985. IptMedType: "2",
  986. }
  987. struct4101.SetlBegnDate = order.SetlTime
  988. struct4101.SetlEndDate = order.SetlTime
  989. time_arr := strings.Split(order.SetlTime, " ")
  990. struct4101.AdmTime = time_arr[0]
  991. struct4101.AdmEndTime = time_arr[0]
  992. var rf []CustomFundPay
  993. json.Unmarshal([]byte(order.SetlDetail), &rf)
  994. var tempFunPays []service.CustomStruct
  995. for _, item := range rf {
  996. var tempFunPay service.CustomStruct
  997. tempFunPay.FundPayamt = item.FundPayamt
  998. tempFunPay.FundPayType = item.FundPayType
  999. tempFunPays = append(tempFunPays, tempFunPay)
  1000. }
  1001. struct4101.CustomStruct = tempFunPays
  1002. var tempDiaginfos []service.DiaginfoStructTwo
  1003. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1004. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1005. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1006. var config []*models.HisXtDiagnoseConfig
  1007. for _, item := range diagnosis_ids {
  1008. id, _ := strconv.ParseInt(item, 10, 64)
  1009. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1010. config = append(config, &diagnosisConfig)
  1011. }
  1012. for index, item := range config {
  1013. if index == 0 {
  1014. var tempDiaginfo service.DiaginfoStructTwo
  1015. tempDiaginfo.DiagCode = item.CountryCode
  1016. tempDiaginfo.DiagName = item.CountryContentName
  1017. tempDiaginfo.DiagType = "1"
  1018. tempDiaginfo.MaindiagFlag = "1"
  1019. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1020. } else {
  1021. var tempDiaginfo service.DiaginfoStructTwo
  1022. tempDiaginfo.DiagCode = item.CountryCode
  1023. tempDiaginfo.DiagName = item.CountryContentName
  1024. tempDiaginfo.DiagType = "2"
  1025. tempDiaginfo.MaindiagFlag = "0"
  1026. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1027. }
  1028. }
  1029. struct4101.Diseinfo = tempDiaginfos
  1030. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1031. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1032. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1033. tempOpspdiseinfo2.OprnOprtCode = ""
  1034. tempOpspdiseinfo2.OprnOprtName = ""
  1035. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1036. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1037. var iteminfo service.IteminfoStruct
  1038. var bedCostTotal float64 = 0 //床位总费
  1039. var bedCostSelfTotal float64 = 0 //床位自费
  1040. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1041. var operationCostTotal float64 = 0 //手术费
  1042. var operationCostSelfTotal float64 = 0 //手术费
  1043. var operationCostPartSelfTotal float64 = 0 //手术费
  1044. var otherCostTotal float64 = 0 //其他费用
  1045. var otherCostSelfTotal float64 = 0 //其他费用
  1046. var otherCostPartSelfTotal float64 = 0 //其他费用
  1047. var materialCostTotal float64 = 0 //材料费
  1048. var materialCostSelfTotal float64 = 0 //材料费
  1049. var materialCostPartSelfTotal float64 = 0 //材料费
  1050. var westernMedicineCostTotal float64 = 0 //西药费
  1051. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1052. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1053. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1054. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1055. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1056. var checkCostTotal float64 = 0 //检查费
  1057. var checkCostSelfTotal float64 = 0 //检查费
  1058. var checkCostPartSelfTotal float64 = 0 //检查费
  1059. var laboratoryCostTotal float64 = 0 //化验费
  1060. var laboratoryCostSelfTotal float64 = 0 //化验费
  1061. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1062. var treatCostTotal float64 = 0 //治疗费用
  1063. var treatCostSelfTotal float64 = 0 //治疗费用
  1064. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1065. decimal.DivisionPrecision = 2
  1066. var bed_fulamt_ownpay_amt float64 = 0
  1067. var operation_fulamt_ownpay_amt float64 = 0
  1068. var other_fulamt_ownpay_amt float64 = 0
  1069. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1070. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1071. var check_fulamt_ownpay_amt float64 = 0
  1072. var material_fulamt_ownpay_amt float64 = 0
  1073. var laboratory_fulamt_ownpay_amt float64 = 0
  1074. var treat_fulamt_ownpay_amt float64 = 0
  1075. var bed_claa_sunmfee float64 = 0
  1076. var bed_clab_amt float64 = 0
  1077. var bed_other_amt float64 = 0
  1078. var operation_claa_sunmfee float64 = 0
  1079. var operation_clab_amt float64 = 0
  1080. var operation_other_amt float64 = 0
  1081. var other_claa_sunmfee float64 = 0
  1082. var other_clab_amt float64 = 0
  1083. var other_other_amt float64 = 0
  1084. var westernMedicine_claa_sunmfee float64 = 0
  1085. var westernMedicine_clab_amt float64 = 0
  1086. var westernMedicine_other_amt float64 = 0
  1087. var chineseTraditional_claa_sunmfee float64 = 0
  1088. var chineseTraditional_clab_amt float64 = 0
  1089. var chineseTraditional_other_amt float64 = 0
  1090. var check_claa_sunmfee float64 = 0
  1091. var check_clab_amt float64 = 0
  1092. var check_other_amt float64 = 0
  1093. var material_claa_sunmfee float64 = 0
  1094. var material_clab_amt float64 = 0
  1095. var material_other_amt float64 = 0
  1096. var laboratory_claa_sunmfee float64 = 0
  1097. var laboratory_clab_amt float64 = 0
  1098. var laboratory_other_amt float64 = 0
  1099. var treat_claa_sunmfee float64 = 0
  1100. var treat_clab_amt float64 = 0
  1101. var treat_other_amt float64 = 0
  1102. for _, item := range order.HisOrderInfo {
  1103. if item.MedChrgitmType == "01" { //床位费
  1104. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1105. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1106. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1107. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1108. if item.ChrgitmLv == "1" {
  1109. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1110. }
  1111. if item.ChrgitmLv == "2" {
  1112. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1113. }
  1114. if item.ChrgitmLv == "3" {
  1115. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1116. }
  1117. }
  1118. if item.MedChrgitmType == "03" { //检查费
  1119. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1120. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1121. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1122. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1123. if item.ChrgitmLv == "1" {
  1124. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1125. }
  1126. if item.ChrgitmLv == "2" {
  1127. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1128. }
  1129. if item.ChrgitmLv == "3" {
  1130. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1131. }
  1132. }
  1133. if item.MedChrgitmType == "04" { //化验费
  1134. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1135. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1136. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1137. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1138. if item.ChrgitmLv == "1" {
  1139. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1140. }
  1141. if item.ChrgitmLv == "2" {
  1142. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1143. }
  1144. if item.ChrgitmLv == "3" {
  1145. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1146. }
  1147. }
  1148. if item.MedChrgitmType == "05" { //治疗费
  1149. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1150. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1151. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1152. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1153. if item.ChrgitmLv == "1" {
  1154. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1155. }
  1156. if item.ChrgitmLv == "2" {
  1157. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1158. }
  1159. if item.ChrgitmLv == "3" {
  1160. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1161. }
  1162. }
  1163. if item.MedChrgitmType == "06" { //手术费
  1164. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1165. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1166. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1167. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1168. if item.ChrgitmLv == "1" {
  1169. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1170. }
  1171. if item.ChrgitmLv == "2" {
  1172. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1173. }
  1174. if item.ChrgitmLv == "3" {
  1175. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1176. }
  1177. }
  1178. if item.MedChrgitmType == "08" { //材料费
  1179. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1180. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1181. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1182. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1183. if item.ChrgitmLv == "1" {
  1184. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1185. }
  1186. if item.ChrgitmLv == "2" {
  1187. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1188. }
  1189. if item.ChrgitmLv == "3" {
  1190. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1191. }
  1192. }
  1193. if item.MedChrgitmType == "09" { //西药费
  1194. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1195. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1196. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1197. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1198. if item.ChrgitmLv == "1" {
  1199. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1200. }
  1201. if item.ChrgitmLv == "2" {
  1202. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1203. }
  1204. if item.ChrgitmLv == "3" {
  1205. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1206. }
  1207. }
  1208. if item.MedChrgitmType == "11" { //中成费
  1209. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1210. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1211. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1212. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1213. if item.ChrgitmLv == "1" {
  1214. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1215. }
  1216. if item.ChrgitmLv == "2" {
  1217. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1218. }
  1219. if item.ChrgitmLv == "3" {
  1220. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1221. }
  1222. }
  1223. if item.MedChrgitmType == "14" { //其他费
  1224. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1225. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1226. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1227. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1228. if item.ChrgitmLv == "1" {
  1229. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1230. }
  1231. if item.ChrgitmLv == "2" {
  1232. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1233. }
  1234. if item.ChrgitmLv == "3" {
  1235. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1236. }
  1237. }
  1238. }
  1239. var iteminfoStructs []service.IteminfoStruct
  1240. if bedCostTotal != 0 {
  1241. iteminfo.MedChrgitm = "01"
  1242. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1243. iteminfo.Amt = bedCostTotal
  1244. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1245. iteminfo.ClabAmt = bed_clab_amt
  1246. iteminfo.OthAmt = bed_other_amt
  1247. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1248. }
  1249. if checkCostTotal != 0 {
  1250. iteminfo.MedChrgitm = "03"
  1251. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1252. iteminfo.Amt = checkCostTotal
  1253. iteminfo.ClaaSumfee = check_claa_sunmfee
  1254. iteminfo.ClabAmt = check_clab_amt
  1255. iteminfo.OthAmt = check_other_amt
  1256. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1257. }
  1258. if laboratoryCostTotal != 0 {
  1259. iteminfo.MedChrgitm = "04"
  1260. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1261. iteminfo.Amt = laboratoryCostTotal
  1262. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1263. iteminfo.ClabAmt = laboratory_clab_amt
  1264. iteminfo.OthAmt = laboratory_other_amt
  1265. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1266. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1267. }
  1268. if treatCostTotal != 0 {
  1269. iteminfo.MedChrgitm = "05"
  1270. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1271. iteminfo.Amt = treatCostTotal
  1272. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1273. iteminfo.ClabAmt = treat_clab_amt
  1274. iteminfo.OthAmt = treat_other_amt
  1275. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1276. //(struct4101.IteminfoStruct, iteminfo)
  1277. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1278. }
  1279. if operationCostTotal != 0 {
  1280. iteminfo.MedChrgitm = "06"
  1281. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1282. iteminfo.Amt = operationCostTotal
  1283. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1284. iteminfo.ClabAmt = operation_clab_amt
  1285. iteminfo.OthAmt = operation_other_amt
  1286. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1287. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1288. }
  1289. if materialCostTotal != 0 {
  1290. iteminfo.MedChrgitm = "08"
  1291. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1292. iteminfo.Amt = materialCostTotal
  1293. iteminfo.ClaaSumfee = material_claa_sunmfee
  1294. iteminfo.ClabAmt = material_clab_amt
  1295. iteminfo.OthAmt = material_other_amt
  1296. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1297. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1298. }
  1299. if westernMedicineCostTotal != 0 {
  1300. iteminfo.MedChrgitm = "09"
  1301. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1302. iteminfo.Amt = westernMedicineCostTotal
  1303. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1304. iteminfo.ClabAmt = westernMedicine_clab_amt
  1305. iteminfo.OthAmt = westernMedicine_other_amt
  1306. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1307. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1308. }
  1309. if chineseTraditionalMedicineCostTotal != 0 {
  1310. iteminfo.MedChrgitm = "11"
  1311. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1312. iteminfo.Amt = westernMedicineCostTotal
  1313. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1314. iteminfo.ClabAmt = westernMedicine_clab_amt
  1315. iteminfo.OthAmt = westernMedicine_other_amt
  1316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1317. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1318. }
  1319. if otherCostTotal != 0 {
  1320. iteminfo.MedChrgitm = "14"
  1321. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1322. iteminfo.Amt = otherCostTotal
  1323. iteminfo.ClaaSumfee = other_claa_sunmfee
  1324. iteminfo.ClabAmt = other_clab_amt
  1325. iteminfo.OthAmt = other_other_amt
  1326. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1327. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1328. }
  1329. struct4101.IteminfoStruct = iteminfoStructs
  1330. struct4101.Ntly = "中国"
  1331. struct4101.AdmCaty = "A03.06"
  1332. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1333. fmt.Println(result)
  1334. var dat map[string]interface{}
  1335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1336. fmt.Println(dat)
  1337. } else {
  1338. fmt.Println(err)
  1339. }
  1340. userJSONBytes, _ := json.Marshal(dat)
  1341. var res ResultSeventeen
  1342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1343. utils.ErrorLog("解析失败:%v", err)
  1344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1345. return
  1346. }
  1347. if res.Infcode != 0 {
  1348. c.ServeSuccessJSON(map[string]interface{}{
  1349. "failed_code": -10,
  1350. "msg": res.ErrMsg,
  1351. })
  1352. return
  1353. } else {
  1354. order.FaPiaoNumber = zero
  1355. order.FaPiaoCode = last_order.FaPiaoCode
  1356. service.UpdateOrder(order)
  1357. hisFundSettleListResult := &models.HisFundSettleListResult{
  1358. Number: res.Output.SetlListId,
  1359. Status: 1,
  1360. Ctime: time.Now().Unix(),
  1361. Mtime: time.Now().Unix(),
  1362. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1363. IsUpload: 1,
  1364. OrderId: order_id,
  1365. }
  1366. service.CreateUploadRecord(hisFundSettleListResult)
  1367. c.ServeSuccessJSON(map[string]interface{}{
  1368. "msg": "上传成功",
  1369. "result": hisFundSettleListResult,
  1370. })
  1371. return
  1372. }
  1373. }
  1374. func (c *HisApiController) GetSettleListHospital() {
  1375. order_id, _ := c.GetInt64("order_id")
  1376. admin_user_id, _ := c.GetInt64("admin_user_id")
  1377. order, _ := service.GetHisOrderByIDTwo(order_id)
  1378. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1379. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1380. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1381. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1382. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1383. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1384. if order.ID == 0 {
  1385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1386. return
  1387. }
  1388. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1389. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1390. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1391. fmt.Println(count)
  1392. var zero string
  1393. number := count + 1
  1394. if number >= 1000 {
  1395. zero = "0000" + strconv.FormatInt(number, 10)
  1396. } else if number >= 10000 {
  1397. zero = "000" + strconv.FormatInt(number, 10)
  1398. } else if number >= 100000 {
  1399. zero = "00" + strconv.FormatInt(number, 10)
  1400. } else if number >= 1000000 {
  1401. zero = "0" + strconv.FormatInt(number, 10)
  1402. } else {
  1403. zero = strconv.FormatInt(number, 10)
  1404. }
  1405. fmt.Println(zero)
  1406. struct4101 := service.Struct4101{
  1407. PsnNo: order.PsnNo,
  1408. MdtrtId: order.MdtrtId,
  1409. SetlId: order.SetlId,
  1410. PsnName: order.PsnName,
  1411. Gend: order.Gend,
  1412. Brdy: his.Brdy,
  1413. Age: int64(order.Age),
  1414. Naty: order.Naty,
  1415. PatnCertType: "01",
  1416. Certno: order.Certno,
  1417. Prfs: "90",
  1418. ConerName: roles[0].UserName,
  1419. PatnRlts: "99",
  1420. ConerAddr: miConfig.OrgName,
  1421. ConerTel: admin.Mobile,
  1422. HiType: order.Insutype,
  1423. Insuplc: miConfig.InsuplcAdmdvs,
  1424. MaindiagFlag: "1",
  1425. BillCode: last_order.FaPiaoCode,
  1426. BillNo: zero,
  1427. BizSn: order.Number,
  1428. PsnSelfPay: order.PsnPartAmt,
  1429. PsnOwnPay: order.PsnPartAmt,
  1430. AcctPay: order.AcctPay,
  1431. PsnCashpay: order.PsnCashPay,
  1432. HiPaymtd: "1",
  1433. Hsorg: miConfig.InsuplcAdmdvs,
  1434. HsorgOpter: miConfig.InsuplcAdmdvs,
  1435. MedinsFillPsn: curRoles.UserName,
  1436. MedinsFillDept: depart.Name,
  1437. IptMedType: "2",
  1438. AdmTime: his.InHosptialTime,
  1439. AdmEndTime: his.OutHosptialTime,
  1440. }
  1441. struct4101.SetlBegnDate = order.SetlTime
  1442. struct4101.SetlEndDate = order.SetlTime
  1443. var rf []CustomFundPay
  1444. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1445. var tempFunPays []service.CustomStruct
  1446. for _, item := range rf {
  1447. var tempFunPay service.CustomStruct
  1448. tempFunPay.FundPayamt = item.FundPayamt
  1449. tempFunPay.FundPayType = item.FundPayType
  1450. tempFunPays = append(tempFunPays, tempFunPay)
  1451. }
  1452. struct4101.CustomStruct = tempFunPays
  1453. var tempDiaginfos []service.DiaginfoStructTwo
  1454. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1455. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1456. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1457. var config []*models.HisXtDiagnoseConfig
  1458. for _, item := range diagnosis_ids {
  1459. id, _ := strconv.ParseInt(item, 10, 64)
  1460. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1461. config = append(config, &diagnosisConfig)
  1462. }
  1463. for index, item := range config {
  1464. if index == 0 {
  1465. var tempDiaginfo service.DiaginfoStructTwo
  1466. tempDiaginfo.DiagCode = item.CountryCode
  1467. tempDiaginfo.DiagName = item.CountryContentName
  1468. tempDiaginfo.DiagType = "1"
  1469. tempDiaginfo.MaindiagFlag = "1"
  1470. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1471. } else {
  1472. var tempDiaginfo service.DiaginfoStructTwo
  1473. tempDiaginfo.DiagCode = item.CountryCode
  1474. tempDiaginfo.DiagName = item.CountryContentName
  1475. tempDiaginfo.DiagType = "2"
  1476. tempDiaginfo.MaindiagFlag = "0"
  1477. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1478. }
  1479. }
  1480. struct4101.Diseinfo = tempDiaginfos
  1481. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1482. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1483. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1484. tempOpspdiseinfo2.OprnOprtCode = ""
  1485. tempOpspdiseinfo2.OprnOprtName = ""
  1486. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1487. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1488. var iteminfo service.IteminfoStruct
  1489. var bedCostTotal float64 = 0 //床位总费
  1490. var bedCostSelfTotal float64 = 0 //床位自费
  1491. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1492. var operationCostTotal float64 = 0 //手术费
  1493. var operationCostSelfTotal float64 = 0 //手术费
  1494. var operationCostPartSelfTotal float64 = 0 //手术费
  1495. var otherCostTotal float64 = 0 //其他费用
  1496. var otherCostSelfTotal float64 = 0 //其他费用
  1497. var otherCostPartSelfTotal float64 = 0 //其他费用
  1498. var materialCostTotal float64 = 0 //材料费
  1499. var materialCostSelfTotal float64 = 0 //材料费
  1500. var materialCostPartSelfTotal float64 = 0 //材料费
  1501. var westernMedicineCostTotal float64 = 0 //西药费
  1502. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1503. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1504. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1505. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1506. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1507. var checkCostTotal float64 = 0 //检查费
  1508. var checkCostSelfTotal float64 = 0 //检查费
  1509. var checkCostPartSelfTotal float64 = 0 //检查费
  1510. var laboratoryCostTotal float64 = 0 //化验费
  1511. var laboratoryCostSelfTotal float64 = 0 //化验费
  1512. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1513. var treatCostTotal float64 = 0 //治疗费用
  1514. var treatCostSelfTotal float64 = 0 //治疗费用
  1515. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1516. decimal.DivisionPrecision = 2
  1517. var bed_fulamt_ownpay_amt float64 = 0
  1518. var operation_fulamt_ownpay_amt float64 = 0
  1519. var other_fulamt_ownpay_amt float64 = 0
  1520. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1521. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1522. var check_fulamt_ownpay_amt float64 = 0
  1523. var material_fulamt_ownpay_amt float64 = 0
  1524. var laboratory_fulamt_ownpay_amt float64 = 0
  1525. var treat_fulamt_ownpay_amt float64 = 0
  1526. var bed_claa_sunmfee float64 = 0
  1527. var bed_clab_amt float64 = 0
  1528. var bed_other_amt float64 = 0
  1529. var operation_claa_sunmfee float64 = 0
  1530. var operation_clab_amt float64 = 0
  1531. var operation_other_amt float64 = 0
  1532. var other_claa_sunmfee float64 = 0
  1533. var other_clab_amt float64 = 0
  1534. var other_other_amt float64 = 0
  1535. var westernMedicine_claa_sunmfee float64 = 0
  1536. var westernMedicine_clab_amt float64 = 0
  1537. var westernMedicine_other_amt float64 = 0
  1538. var chineseTraditional_claa_sunmfee float64 = 0
  1539. var chineseTraditional_clab_amt float64 = 0
  1540. var chineseTraditional_other_amt float64 = 0
  1541. var check_claa_sunmfee float64 = 0
  1542. var check_clab_amt float64 = 0
  1543. var check_other_amt float64 = 0
  1544. var material_claa_sunmfee float64 = 0
  1545. var material_clab_amt float64 = 0
  1546. var material_other_amt float64 = 0
  1547. var laboratory_claa_sunmfee float64 = 0
  1548. var laboratory_clab_amt float64 = 0
  1549. var laboratory_other_amt float64 = 0
  1550. var treat_claa_sunmfee float64 = 0
  1551. var treat_clab_amt float64 = 0
  1552. var treat_other_amt float64 = 0
  1553. for _, item := range order.HisOrderInfo {
  1554. if item.MedChrgitmType == "01" { //床位费
  1555. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1556. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1557. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1558. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1559. if item.ChrgitmLv == "1" {
  1560. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1561. }
  1562. if item.ChrgitmLv == "2" {
  1563. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1564. }
  1565. if item.ChrgitmLv == "3" {
  1566. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1567. }
  1568. }
  1569. if item.MedChrgitmType == "03" { //检查费
  1570. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1571. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1572. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1573. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1574. if item.ChrgitmLv == "1" {
  1575. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1576. }
  1577. if item.ChrgitmLv == "2" {
  1578. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1579. }
  1580. if item.ChrgitmLv == "3" {
  1581. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1582. }
  1583. }
  1584. if item.MedChrgitmType == "04" { //化验费
  1585. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1586. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1587. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1588. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1589. if item.ChrgitmLv == "1" {
  1590. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1591. }
  1592. if item.ChrgitmLv == "2" {
  1593. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1594. }
  1595. if item.ChrgitmLv == "3" {
  1596. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1597. }
  1598. }
  1599. if item.MedChrgitmType == "05" { //治疗费
  1600. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1601. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1602. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1603. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1604. if item.ChrgitmLv == "1" {
  1605. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1606. }
  1607. if item.ChrgitmLv == "2" {
  1608. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1609. }
  1610. if item.ChrgitmLv == "3" {
  1611. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1612. }
  1613. }
  1614. if item.MedChrgitmType == "06" { //手术费
  1615. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1616. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1617. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1618. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1619. if item.ChrgitmLv == "1" {
  1620. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1621. }
  1622. if item.ChrgitmLv == "2" {
  1623. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1624. }
  1625. if item.ChrgitmLv == "3" {
  1626. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1627. }
  1628. }
  1629. if item.MedChrgitmType == "08" { //材料费
  1630. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1631. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1632. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1633. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1634. if item.ChrgitmLv == "1" {
  1635. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1636. }
  1637. if item.ChrgitmLv == "2" {
  1638. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1639. }
  1640. if item.ChrgitmLv == "3" {
  1641. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1642. }
  1643. }
  1644. if item.MedChrgitmType == "09" { //西药费
  1645. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1646. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1647. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1648. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1649. if item.ChrgitmLv == "1" {
  1650. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1651. }
  1652. if item.ChrgitmLv == "2" {
  1653. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1654. }
  1655. if item.ChrgitmLv == "3" {
  1656. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1657. }
  1658. }
  1659. if item.MedChrgitmType == "11" { //中成费
  1660. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1661. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1662. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1663. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1664. if item.ChrgitmLv == "1" {
  1665. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1666. }
  1667. if item.ChrgitmLv == "2" {
  1668. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1669. }
  1670. if item.ChrgitmLv == "3" {
  1671. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1672. }
  1673. }
  1674. if item.MedChrgitmType == "14" { //其他费
  1675. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1676. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1677. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1678. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1679. if item.ChrgitmLv == "1" {
  1680. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1681. }
  1682. if item.ChrgitmLv == "2" {
  1683. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1684. }
  1685. if item.ChrgitmLv == "3" {
  1686. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1687. }
  1688. }
  1689. }
  1690. var iteminfoStructs []service.IteminfoStruct
  1691. if bedCostTotal != 0 {
  1692. iteminfo.MedChrgitm = "01"
  1693. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1694. iteminfo.Amt = bedCostTotal
  1695. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1696. iteminfo.ClabAmt = bed_clab_amt
  1697. iteminfo.OthAmt = bed_other_amt
  1698. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1699. }
  1700. if checkCostTotal != 0 {
  1701. iteminfo.MedChrgitm = "03"
  1702. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1703. iteminfo.Amt = checkCostTotal
  1704. iteminfo.ClaaSumfee = check_claa_sunmfee
  1705. iteminfo.ClabAmt = check_clab_amt
  1706. iteminfo.OthAmt = check_other_amt
  1707. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1708. }
  1709. if laboratoryCostTotal != 0 {
  1710. iteminfo.MedChrgitm = "04"
  1711. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1712. iteminfo.Amt = laboratoryCostTotal
  1713. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1714. iteminfo.ClabAmt = laboratory_clab_amt
  1715. iteminfo.OthAmt = laboratory_other_amt
  1716. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1717. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1718. }
  1719. if treatCostTotal != 0 {
  1720. iteminfo.MedChrgitm = "05"
  1721. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1722. iteminfo.Amt = treatCostTotal
  1723. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1724. iteminfo.ClabAmt = treat_clab_amt
  1725. iteminfo.OthAmt = treat_other_amt
  1726. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1727. //(struct4101.IteminfoStruct, iteminfo)
  1728. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1729. }
  1730. if operationCostTotal != 0 {
  1731. iteminfo.MedChrgitm = "06"
  1732. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1733. iteminfo.Amt = operationCostTotal
  1734. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1735. iteminfo.ClabAmt = operation_clab_amt
  1736. iteminfo.OthAmt = operation_other_amt
  1737. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1738. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1739. }
  1740. if materialCostTotal != 0 {
  1741. iteminfo.MedChrgitm = "08"
  1742. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1743. iteminfo.Amt = materialCostTotal
  1744. iteminfo.ClaaSumfee = material_claa_sunmfee
  1745. iteminfo.ClabAmt = material_clab_amt
  1746. iteminfo.OthAmt = material_other_amt
  1747. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1748. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1749. }
  1750. if westernMedicineCostTotal != 0 {
  1751. iteminfo.MedChrgitm = "09"
  1752. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1753. iteminfo.Amt = westernMedicineCostTotal
  1754. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1755. iteminfo.ClabAmt = westernMedicine_clab_amt
  1756. iteminfo.OthAmt = westernMedicine_other_amt
  1757. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1758. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1759. }
  1760. if chineseTraditionalMedicineCostTotal != 0 {
  1761. iteminfo.MedChrgitm = "11"
  1762. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1763. iteminfo.Amt = westernMedicineCostTotal
  1764. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1765. iteminfo.ClabAmt = westernMedicine_clab_amt
  1766. iteminfo.OthAmt = westernMedicine_other_amt
  1767. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1768. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1769. }
  1770. if otherCostTotal != 0 {
  1771. iteminfo.MedChrgitm = "14"
  1772. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1773. iteminfo.Amt = otherCostTotal
  1774. iteminfo.ClaaSumfee = other_claa_sunmfee
  1775. iteminfo.ClabAmt = other_clab_amt
  1776. iteminfo.OthAmt = other_other_amt
  1777. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1778. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1779. }
  1780. struct4101.IteminfoStruct = iteminfoStructs
  1781. struct4101.Ntly = "中国"
  1782. struct4101.AdmCaty = "A03.06"
  1783. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1784. fmt.Println(result)
  1785. var dat map[string]interface{}
  1786. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1787. fmt.Println(dat)
  1788. } else {
  1789. fmt.Println(err)
  1790. }
  1791. userJSONBytes, _ := json.Marshal(dat)
  1792. var res ResultSeventeen
  1793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1794. utils.ErrorLog("解析失败:%v", err)
  1795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1796. return
  1797. }
  1798. if res.Infcode != 0 {
  1799. c.ServeSuccessJSON(map[string]interface{}{
  1800. "failed_code": -10,
  1801. "msg": res.ErrMsg,
  1802. })
  1803. return
  1804. } else {
  1805. order.FaPiaoNumber = zero
  1806. order.FaPiaoCode = last_order.FaPiaoCode
  1807. service.UpdateOrder(order)
  1808. hisFundSettleListResult := &models.HisFundSettleListResult{
  1809. Number: res.Output.SetlListId,
  1810. Status: 1,
  1811. Ctime: time.Now().Unix(),
  1812. Mtime: time.Now().Unix(),
  1813. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1814. IsUpload: 1,
  1815. OrderId: order_id,
  1816. }
  1817. service.CreateUploadRecord(hisFundSettleListResult)
  1818. c.ServeSuccessJSON(map[string]interface{}{
  1819. "msg": "上传成功",
  1820. "result": hisFundSettleListResult,
  1821. })
  1822. return
  1823. }
  1824. }
  1825. func (c *HisApiController) GetBatchSettleList() {
  1826. orders, _ := service.GetAllHisOrder(10106)
  1827. for _, item := range orders {
  1828. order_id := item.ID
  1829. order, _ := service.GetHisOrderByIDTwo(order_id)
  1830. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1831. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1832. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1833. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1834. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1835. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1836. if order.ID == 0 {
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1838. return
  1839. }
  1840. if his.BalanceAccountsType == 2 {
  1841. continue
  1842. }
  1843. struct4101 := service.Struct4101{
  1844. PsnNo: order.PsnNo,
  1845. MdtrtId: order.MdtrtId,
  1846. SetlId: order.SetlId,
  1847. PsnName: order.PsnName,
  1848. Gend: order.Gend,
  1849. Brdy: his.Brdy,
  1850. Age: his.Age,
  1851. Naty: order.Naty,
  1852. PatnCertType: "01",
  1853. Certno: order.Certno,
  1854. Prfs: "90",
  1855. ConerName: roles[0].UserName,
  1856. PatnRlts: "99",
  1857. ConerAddr: miConfig.OrgName,
  1858. ConerTel: admin.Mobile,
  1859. HiType: order.Insutype,
  1860. Insuplc: his.InsuplcAdmdvs,
  1861. MaindiagFlag: "1",
  1862. BillCode: order.FaPiaoCode,
  1863. BillNo: order.FaPiaoNumber,
  1864. BizSn: order.Number,
  1865. PsnSelfPay: order.PsnPartAmt,
  1866. PsnOwnPay: order.PsnPartAmt,
  1867. AcctPay: order.AcctPay,
  1868. PsnCashpay: order.PsnCashPay,
  1869. HiPaymtd: "1",
  1870. Hsorg: his.InsuplcAdmdvs,
  1871. HsorgOpter: his.InsuplcAdmdvs,
  1872. MedinsFillPsn: curRoles.UserName,
  1873. MedinsFillDept: depart.Name,
  1874. IptMedType: "2",
  1875. }
  1876. struct4101.SetlBegnDate = order.SetlTime
  1877. struct4101.SetlEndDate = order.SetlTime
  1878. //if order.SettleType == 1 {
  1879. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1880. // dateStr := t.Format("2006-01-02")
  1881. // struct4101.SetlBegnDate = dateStr
  1882. // struct4101.SetlEndDate = dateStr
  1883. //} else {
  1884. // t := time.Unix(int64(order.SettleStartTime), 0)
  1885. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1886. // dateStartStr := t.Format("2006-01-02")
  1887. // dateEndStr := t2.Format("2006-01-02")
  1888. // struct4101.SetlBegnDate = dateStartStr
  1889. // struct4101.SetlEndDate = dateEndStr
  1890. //}
  1891. var rf []CustomFundPay
  1892. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1893. var tempFunPays []service.CustomStruct
  1894. var tempFunPay610100 service.CustomStruct
  1895. for _, item := range rf {
  1896. if item.FundPayType == "610100" {
  1897. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1898. tempFunPay610100.FundPayType = item.FundPayType
  1899. } else {
  1900. var tempFunPay service.CustomStruct
  1901. tempFunPay.FundPayamt = item.FundPayamt
  1902. tempFunPay.FundPayType = item.FundPayType
  1903. tempFunPays = append(tempFunPays, tempFunPay)
  1904. }
  1905. }
  1906. tempFunPays = append(tempFunPays, tempFunPay610100)
  1907. struct4101.CustomStruct = tempFunPays
  1908. var tempDiaginfos []service.DiaginfoStructTwo
  1909. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1910. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1911. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1912. var config []*models.HisXtDiagnoseConfig
  1913. for _, item := range diagnosis_ids {
  1914. id, _ := strconv.ParseInt(item, 10, 64)
  1915. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1916. config = append(config, &diagnosisConfig)
  1917. }
  1918. for index, item := range config {
  1919. if index == 0 {
  1920. var tempDiaginfo service.DiaginfoStructTwo
  1921. tempDiaginfo.DiagCode = item.CountryCode
  1922. tempDiaginfo.DiagName = item.CountryContentName
  1923. tempDiaginfo.DiagType = "1"
  1924. tempDiaginfo.MaindiagFlag = "1"
  1925. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1926. } else {
  1927. var tempDiaginfo service.DiaginfoStructTwo
  1928. tempDiaginfo.DiagCode = item.CountryCode
  1929. tempDiaginfo.DiagName = item.CountryContentName
  1930. tempDiaginfo.DiagType = "2"
  1931. tempDiaginfo.MaindiagFlag = "0"
  1932. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1933. }
  1934. }
  1935. struct4101.Diseinfo = tempDiaginfos
  1936. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1937. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1938. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1939. tempOpspdiseinfo2.OprnOprtCode = ""
  1940. tempOpspdiseinfo2.OprnOprtName = ""
  1941. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1942. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1943. var iteminfo service.IteminfoStruct
  1944. var bedCostTotal float64 = 0 //床位总费
  1945. var bedCostSelfTotal float64 = 0 //床位自费
  1946. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1947. var examineCostTotal float64 = 0 //诊查总费
  1948. var examineCostSelfTotal float64 = 0 //诊查自费
  1949. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1950. var nursingCostTotal float64 = 0 //护理总费
  1951. var nursingCostSelfTotal float64 = 0 //护理自费
  1952. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1953. var chineseMedicineCostTotal float64 = 0 //中成药
  1954. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1955. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1956. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1957. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1958. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1959. var registerCostTotal float64 = 0 //一般诊疗费
  1960. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1961. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1962. var operationCostTotal float64 = 0 //手术费
  1963. var operationCostSelfTotal float64 = 0 //手术费
  1964. var operationCostPartSelfTotal float64 = 0 //手术费
  1965. var otherCostTotal float64 = 0 //其他费用
  1966. var otherCostSelfTotal float64 = 0 //其他费用
  1967. var otherCostPartSelfTotal float64 = 0 //其他费用
  1968. var materialCostTotal float64 = 0 //材料费
  1969. var materialCostSelfTotal float64 = 0 //材料费
  1970. var materialCostPartSelfTotal float64 = 0 //材料费
  1971. var westernMedicineCostTotal float64 = 0 //西药费
  1972. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1973. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1974. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1975. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1976. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1977. var checkCostTotal float64 = 0 //检查费
  1978. var checkCostSelfTotal float64 = 0 //检查费
  1979. var checkCostPartSelfTotal float64 = 0 //检查费
  1980. var laboratoryCostTotal float64 = 0 //化验费
  1981. var laboratoryCostSelfTotal float64 = 0 //化验费
  1982. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1983. var treatCostTotal float64 = 0 //治疗费用
  1984. var treatCostSelfTotal float64 = 0 //治疗费用
  1985. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1986. decimal.DivisionPrecision = 2
  1987. var bed_fulamt_ownpay_amt float64 = 0
  1988. var examine_fulamt_ownpay_amt float64 = 0
  1989. var nursing_fulamt_ownpay_amt float64 = 0
  1990. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1991. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1992. var register_fulamt_ownpay_amt float64 = 0
  1993. var operation_fulamt_ownpay_amt float64 = 0
  1994. var other_fulamt_ownpay_amt float64 = 0
  1995. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1996. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1997. var check_fulamt_ownpay_amt float64 = 0
  1998. var material_fulamt_ownpay_amt float64 = 0
  1999. var laboratory_fulamt_ownpay_amt float64 = 0
  2000. var treat_fulamt_ownpay_amt float64 = 0
  2001. var bed_claa_sunmfee float64 = 0
  2002. var bed_clab_amt float64 = 0
  2003. var bed_other_amt float64 = 0
  2004. var examine_claa_sunmfee float64 = 0
  2005. var examine_clab_amt float64 = 0
  2006. var examine_other_amt float64 = 0
  2007. var nursing_claa_sunmfee float64 = 0
  2008. var nursing_clab_amt float64 = 0
  2009. var nursing_other_amt float64 = 0
  2010. var chinese_medicine_claa_sunmfee float64 = 0
  2011. var chinese_medicine_clab_amt float64 = 0
  2012. var chinese_medicine_other_amt float64 = 0
  2013. var commonly_treatment_claa_sunmfee float64 = 0
  2014. var commonly_treatment_clab_amt float64 = 0
  2015. var commonly_treatment_other_amt float64 = 0
  2016. var operation_claa_sunmfee float64 = 0
  2017. var operation_clab_amt float64 = 0
  2018. var operation_other_amt float64 = 0
  2019. var other_claa_sunmfee float64 = 0
  2020. var other_clab_amt float64 = 0
  2021. var other_other_amt float64 = 0
  2022. var westernMedicine_claa_sunmfee float64 = 0
  2023. var westernMedicine_clab_amt float64 = 0
  2024. var westernMedicine_other_amt float64 = 0
  2025. var chineseTraditional_claa_sunmfee float64 = 0
  2026. var chineseTraditional_clab_amt float64 = 0
  2027. var chineseTraditional_other_amt float64 = 0
  2028. var check_claa_sunmfee float64 = 0
  2029. var check_clab_amt float64 = 0
  2030. var check_other_amt float64 = 0
  2031. var material_claa_sunmfee float64 = 0
  2032. var material_clab_amt float64 = 0
  2033. var material_other_amt float64 = 0
  2034. var laboratory_claa_sunmfee float64 = 0
  2035. var laboratory_clab_amt float64 = 0
  2036. var laboratory_other_amt float64 = 0
  2037. var treat_claa_sunmfee float64 = 0
  2038. var treat_clab_amt float64 = 0
  2039. var treat_other_amt float64 = 0
  2040. var register_claa_sunmfee float64 = 0
  2041. var register_clab_amt float64 = 0
  2042. var register_other_amt float64 = 0
  2043. for _, item := range order.HisOrderInfo {
  2044. if item.MedChrgitmType == "01" { //床位费
  2045. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2046. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2047. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2048. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2049. if item.ChrgitmLv == "1" {
  2050. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2051. }
  2052. if item.ChrgitmLv == "2" {
  2053. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2054. }
  2055. if item.ChrgitmLv == "3" {
  2056. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2057. }
  2058. }
  2059. if item.MedChrgitmType == "02" { //诊查
  2060. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2061. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2062. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2063. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2064. if item.ChrgitmLv == "1" {
  2065. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2066. }
  2067. if item.ChrgitmLv == "2" {
  2068. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2069. }
  2070. if item.ChrgitmLv == "3" {
  2071. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2072. }
  2073. }
  2074. if item.MedChrgitmType == "03" { //检查费
  2075. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2076. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2077. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2078. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2079. if item.ChrgitmLv == "1" {
  2080. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2081. }
  2082. if item.ChrgitmLv == "2" {
  2083. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2084. }
  2085. if item.ChrgitmLv == "3" {
  2086. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2087. }
  2088. }
  2089. if item.MedChrgitmType == "04" { //化验费
  2090. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2091. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2092. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2093. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2094. if item.ChrgitmLv == "1" {
  2095. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2096. }
  2097. if item.ChrgitmLv == "2" {
  2098. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2099. }
  2100. if item.ChrgitmLv == "3" {
  2101. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2102. }
  2103. }
  2104. if item.MedChrgitmType == "05" { //治疗费
  2105. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2106. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2107. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2108. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2109. if item.ChrgitmLv == "1" {
  2110. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2111. }
  2112. if item.ChrgitmLv == "2" {
  2113. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2114. }
  2115. if item.ChrgitmLv == "3" {
  2116. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2117. }
  2118. }
  2119. if item.MedChrgitmType == "06" { //手术费
  2120. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2121. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2122. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2123. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2124. if item.ChrgitmLv == "1" {
  2125. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2126. }
  2127. if item.ChrgitmLv == "2" {
  2128. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2129. }
  2130. if item.ChrgitmLv == "3" {
  2131. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2132. }
  2133. }
  2134. if item.MedChrgitmType == "07" { //手术费
  2135. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2136. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2137. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2138. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2139. if item.ChrgitmLv == "1" {
  2140. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2141. }
  2142. if item.ChrgitmLv == "2" {
  2143. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2144. }
  2145. if item.ChrgitmLv == "3" {
  2146. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2147. }
  2148. }
  2149. if item.MedChrgitmType == "08" { //材料费
  2150. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2151. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2152. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2153. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2154. if item.ChrgitmLv == "1" {
  2155. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2156. }
  2157. if item.ChrgitmLv == "2" {
  2158. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2159. }
  2160. if item.ChrgitmLv == "3" {
  2161. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2162. }
  2163. }
  2164. if item.MedChrgitmType == "09" { //西药费
  2165. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2166. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2167. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2168. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2169. if item.ChrgitmLv == "1" {
  2170. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2171. }
  2172. if item.ChrgitmLv == "2" {
  2173. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2174. }
  2175. if item.ChrgitmLv == "3" {
  2176. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2177. }
  2178. }
  2179. if item.MedChrgitmType == "10" { //中药饮片
  2180. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2181. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2182. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2183. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2184. if item.ChrgitmLv == "1" {
  2185. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2186. }
  2187. if item.ChrgitmLv == "2" {
  2188. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2189. }
  2190. if item.ChrgitmLv == "3" {
  2191. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2192. }
  2193. }
  2194. if item.MedChrgitmType == "11" { //中成费
  2195. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2196. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2197. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2198. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2199. if item.ChrgitmLv == "1" {
  2200. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2201. }
  2202. if item.ChrgitmLv == "2" {
  2203. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2204. }
  2205. if item.ChrgitmLv == "3" {
  2206. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2207. }
  2208. }
  2209. if item.MedChrgitmType == "12" { //中成费
  2210. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2211. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2212. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2213. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2214. if item.ChrgitmLv == "1" {
  2215. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2216. }
  2217. if item.ChrgitmLv == "2" {
  2218. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2219. }
  2220. if item.ChrgitmLv == "3" {
  2221. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2222. }
  2223. }
  2224. if item.MedChrgitmType == "13" { //中成费
  2225. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2226. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2227. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2228. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2229. if item.ChrgitmLv == "1" {
  2230. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2231. }
  2232. if item.ChrgitmLv == "2" {
  2233. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2234. }
  2235. if item.ChrgitmLv == "3" {
  2236. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2237. }
  2238. }
  2239. if item.MedChrgitmType == "14" { //其他费
  2240. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2241. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2242. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2243. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2244. if item.ChrgitmLv == "1" {
  2245. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2246. }
  2247. if item.ChrgitmLv == "2" {
  2248. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2249. }
  2250. if item.ChrgitmLv == "3" {
  2251. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2252. }
  2253. }
  2254. }
  2255. var iteminfoStructs []service.IteminfoStruct
  2256. if bedCostTotal != 0 {
  2257. iteminfo.MedChrgitm = "01"
  2258. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2259. iteminfo.Amt = bedCostTotal
  2260. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2261. iteminfo.ClabAmt = bed_clab_amt
  2262. iteminfo.OthAmt = bed_other_amt
  2263. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2264. }
  2265. if examineCostTotal != 0 {
  2266. iteminfo.MedChrgitm = "02"
  2267. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2268. iteminfo.Amt = examineCostTotal
  2269. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2270. iteminfo.ClabAmt = examine_clab_amt
  2271. iteminfo.OthAmt = examine_other_amt
  2272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2273. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2274. }
  2275. if checkCostTotal != 0 {
  2276. iteminfo.MedChrgitm = "03"
  2277. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2278. iteminfo.Amt = checkCostTotal
  2279. iteminfo.ClaaSumfee = check_claa_sunmfee
  2280. iteminfo.ClabAmt = check_clab_amt
  2281. iteminfo.OthAmt = check_other_amt
  2282. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2283. }
  2284. if laboratoryCostTotal != 0 {
  2285. iteminfo.MedChrgitm = "04"
  2286. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2287. iteminfo.Amt = laboratoryCostTotal
  2288. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2289. iteminfo.ClabAmt = laboratory_clab_amt
  2290. iteminfo.OthAmt = laboratory_other_amt
  2291. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2293. }
  2294. if treatCostTotal != 0 {
  2295. iteminfo.MedChrgitm = "05"
  2296. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2297. iteminfo.Amt = treatCostTotal
  2298. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2299. iteminfo.ClabAmt = treat_clab_amt
  2300. iteminfo.OthAmt = treat_other_amt
  2301. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2302. //(struct4101.IteminfoStruct, iteminfo)
  2303. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2304. }
  2305. if operationCostTotal != 0 {
  2306. iteminfo.MedChrgitm = "06"
  2307. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2308. iteminfo.Amt = operationCostTotal
  2309. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2310. iteminfo.ClabAmt = operation_clab_amt
  2311. iteminfo.OthAmt = operation_other_amt
  2312. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2313. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2314. }
  2315. if nursingCostTotal != 0 {
  2316. iteminfo.MedChrgitm = "07"
  2317. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2318. iteminfo.Amt = nursingCostTotal
  2319. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2320. iteminfo.ClabAmt = nursing_clab_amt
  2321. iteminfo.OthAmt = nursing_other_amt
  2322. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2323. }
  2324. if materialCostTotal != 0 {
  2325. iteminfo.MedChrgitm = "08"
  2326. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2327. iteminfo.Amt = materialCostTotal
  2328. iteminfo.ClaaSumfee = material_claa_sunmfee
  2329. iteminfo.ClabAmt = material_clab_amt
  2330. iteminfo.OthAmt = material_other_amt
  2331. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2332. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2333. }
  2334. if westernMedicineCostTotal != 0 {
  2335. iteminfo.MedChrgitm = "09"
  2336. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2337. iteminfo.Amt = westernMedicineCostTotal
  2338. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2339. iteminfo.ClabAmt = westernMedicine_clab_amt
  2340. iteminfo.OthAmt = westernMedicine_other_amt
  2341. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2342. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2343. }
  2344. if chineseMedicineCostTotal != 0 {
  2345. iteminfo.MedChrgitm = "10"
  2346. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2347. iteminfo.Amt = chineseMedicineCostTotal
  2348. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2349. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2350. iteminfo.OthAmt = chinese_medicine_other_amt
  2351. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2353. }
  2354. if chineseTraditionalMedicineCostTotal != 0 {
  2355. iteminfo.MedChrgitm = "11"
  2356. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2357. iteminfo.Amt = westernMedicineCostTotal
  2358. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2359. iteminfo.ClabAmt = westernMedicine_clab_amt
  2360. iteminfo.OthAmt = westernMedicine_other_amt
  2361. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2362. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2363. }
  2364. if commonlyTreatmentCostTotal != 0 {
  2365. iteminfo.MedChrgitm = "12"
  2366. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2367. iteminfo.Amt = commonlyTreatmentCostTotal
  2368. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2369. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2370. iteminfo.OthAmt = commonly_treatment_other_amt
  2371. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2372. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2373. }
  2374. if registerCostTotal != 0 {
  2375. iteminfo.MedChrgitm = "13"
  2376. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2377. iteminfo.Amt = registerCostTotal
  2378. iteminfo.ClaaSumfee = register_claa_sunmfee
  2379. iteminfo.ClabAmt = register_clab_amt
  2380. iteminfo.OthAmt = register_other_amt
  2381. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2382. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2383. }
  2384. if otherCostTotal != 0 {
  2385. iteminfo.MedChrgitm = "14"
  2386. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2387. iteminfo.Amt = otherCostTotal
  2388. iteminfo.ClaaSumfee = other_claa_sunmfee
  2389. iteminfo.ClabAmt = other_clab_amt
  2390. iteminfo.OthAmt = other_other_amt
  2391. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2392. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2393. }
  2394. struct4101.IteminfoStruct = iteminfoStructs
  2395. struct4101.Ntly = "中国"
  2396. struct4101.AdmCaty = "A03.06"
  2397. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2398. fmt.Println(result)
  2399. var dat map[string]interface{}
  2400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2401. fmt.Println(dat)
  2402. } else {
  2403. fmt.Println(err)
  2404. }
  2405. userJSONBytes, _ := json.Marshal(dat)
  2406. var res ResultSeventeen
  2407. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2408. utils.ErrorLog("解析失败:%v", err)
  2409. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2410. adminUser := c.GetAdminUserInfo()
  2411. errlog := &models.HisOrderError{
  2412. UserOrgId: adminUser.CurrentOrgId,
  2413. Ctime: time.Now().Unix(),
  2414. Mtime: time.Now().Unix(),
  2415. ErrMsg: res.ErrMsg + "解析失败",
  2416. Status: 1,
  2417. PatientId: order_id,
  2418. Stage: 10106,
  2419. }
  2420. service.CreateErrMsgLog(errlog)
  2421. continue
  2422. }
  2423. if res.Infcode != 0 {
  2424. adminUser := c.GetAdminUserInfo()
  2425. errlog := &models.HisOrderError{
  2426. UserOrgId: adminUser.CurrentOrgId,
  2427. Ctime: time.Now().Unix(),
  2428. Mtime: time.Now().Unix(),
  2429. ErrMsg: res.ErrMsg,
  2430. Status: 1,
  2431. PatientId: order_id,
  2432. Stage: 10106,
  2433. }
  2434. service.CreateErrMsgLog(errlog)
  2435. continue
  2436. } else {
  2437. hisFundSettleListResult := &models.HisFundSettleListResult{
  2438. Number: res.Output.SetlListId,
  2439. Status: 1,
  2440. Ctime: time.Now().Unix(),
  2441. Mtime: time.Now().Unix(),
  2442. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2443. IsUpload: 1,
  2444. OrderId: order_id,
  2445. }
  2446. service.CreateUploadRecord(hisFundSettleListResult)
  2447. continue
  2448. }
  2449. }
  2450. }
  2451. func (c *HisApiController) GetOrgInfo() {
  2452. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2453. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2454. }
  2455. func (c *HisApiController) GetHisPatientInfo() {
  2456. medical_insurance_card := c.GetString("medical_insurance_card")
  2457. id_card_type, _ := c.GetInt64("id_card_type")
  2458. id_card := c.GetString("id_card")
  2459. adminInfo := c.GetAdminUserInfo()
  2460. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2461. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2462. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2463. IdCardNo := ""
  2464. if id_card_type == 1 {
  2465. IdCardNo = medical_insurance_card
  2466. } else if id_card_type == 2 {
  2467. IdCardNo = id_card
  2468. }
  2469. if config.IsOpen == 1 {
  2470. 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
  2471. resp, requestErr := http.Get(api)
  2472. if requestErr != nil {
  2473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2474. return
  2475. }
  2476. defer resp.Body.Close()
  2477. body, ioErr := ioutil.ReadAll(resp.Body)
  2478. if ioErr != nil {
  2479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2481. return
  2482. }
  2483. var respJSON map[string]interface{}
  2484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2487. return
  2488. }
  2489. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2490. userJSONBytes, _ := json.Marshal(userJSON)
  2491. var res ResultTwo
  2492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2493. utils.ErrorLog("解析失败:%v", err)
  2494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2495. return
  2496. }
  2497. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2498. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2499. infoStr := string(Iinfos)
  2500. idetinfoStr := string(Idetinfos)
  2501. if res.Infcode == 0 {
  2502. his := models.VMHisPatient{
  2503. Status: 1,
  2504. Ctime: time.Now().Unix(),
  2505. Mtime: time.Now().Unix(),
  2506. PsnNo: res.Output.Baseinfo.PsnNo,
  2507. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2508. Certno: res.Output.Baseinfo.Certno,
  2509. PsnName: res.Output.Baseinfo.PsnName,
  2510. Gend: res.Output.Baseinfo.Gend,
  2511. Naty: res.Output.Baseinfo.Naty,
  2512. Brdy: res.Output.Baseinfo.Brdy,
  2513. Age: res.Output.Baseinfo.Age,
  2514. Iinfo: infoStr,
  2515. Idetinfo: idetinfoStr,
  2516. UserOrgId: adminInfo.CurrentOrgId,
  2517. IsReturn: 1,
  2518. IdCardType: id_card_type,
  2519. }
  2520. c.ServeSuccessJSON(map[string]interface{}{
  2521. "info": his,
  2522. })
  2523. } else {
  2524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2525. return
  2526. }
  2527. }
  2528. }
  2529. //func GetBasBaseInfo() (jsonStr string, err error) {
  2530. //
  2531. // handle := syscall.NewLazyDLL("SSCard.dll")
  2532. // add := handle.NewProc("ReadCardBas")
  2533. // str := make([]byte, 1024)
  2534. // str1 := make([]byte, 1024)
  2535. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2536. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2537. //
  2538. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2539. //
  2540. // fmt.Println("> Add(4,5)的结果为:", ret)
  2541. // handle.Release()
  2542. //
  2543. // return "", nil
  2544. //
  2545. //}
  2546. //func GetQRBaseInfo() (jsonStr string, err error) {
  2547. // handle := syscall.LoadDLL("SSCard.dll")
  2548. // ReadCardBas := handle.FindProc("GetQRBase")
  2549. //
  2550. // str := make([]byte, 256)
  2551. // str1 := make([]byte, 256)
  2552. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2553. //
  2554. // fmt.Println(string(str))
  2555. // fmt.Println(r)
  2556. // return string(str), nil
  2557. //}
  2558. //func CardInit() int {
  2559. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2560. // add := DllTestDef.MustFindProc("Init")
  2561. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2562. // if err != nil {
  2563. // fmt.Println("SSCard的运算结果为:", ret)
  2564. // }
  2565. // result := int(ret)
  2566. // return result
  2567. //}
  2568. //func CardInit() int {
  2569. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2570. // if err != nil {
  2571. // fmt.Println("SSCard的运算结果为:", ret)
  2572. // }
  2573. // fmt.Println(err)
  2574. // result := int(ret)
  2575. // return result
  2576. //}
  2577. func IntPtr(n int) uintptr {
  2578. return uintptr(n)
  2579. }
  2580. func StrPtr(s string) uintptr {
  2581. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2582. }
  2583. type Result2001 struct {
  2584. Cainfo interface{} `json:"cainfo"`
  2585. ErrMsg string `json:"err_msg"`
  2586. InfRefmsgid string `json:"inf_refmsgid"`
  2587. Infcode int64 `json:"infcode"`
  2588. Output struct {
  2589. Trtinfo struct {
  2590. PsnNo string `json:"psn_no"`
  2591. TrtChkType string `json:"trt_chk_type"`
  2592. FundPayType string `json:"fund_pay_type"`
  2593. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2594. Begndate string `json:"begndate"`
  2595. Enddate string `json:"enddate"`
  2596. TrtChkRslt string `json:"trt_chk_rslt"`
  2597. } `json:"trtinfo"`
  2598. } `json:"output"`
  2599. RefmsgTime string `json:"refmsg_time"`
  2600. RespondTime string `json:"respond_time"`
  2601. Signtype interface{} `json:"signtype"`
  2602. WarnMsg interface{} `json:"warn_msg"`
  2603. }
  2604. type Result2001Org10265 struct {
  2605. Cainfo interface{} `json:"cainfo"`
  2606. ErrMsg string `json:"err_msg"`
  2607. InfRefmsgid string `json:"inf_refmsgid"`
  2608. Infcode string `json:"infcode"`
  2609. Output struct {
  2610. Trtinfo struct {
  2611. PsnNo string `json:"psn_no"`
  2612. TrtChkType string `json:"trt_chk_type"`
  2613. FundPayType string `json:"fund_pay_type"`
  2614. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2615. Begndate string `json:"begndate"`
  2616. Enddate string `json:"enddate"`
  2617. TrtChkRslt string `json:"trt_chk_rslt"`
  2618. } `json:"trtinfo"`
  2619. } `json:"output"`
  2620. RefmsgTime string `json:"refmsg_time"`
  2621. RespondTime string `json:"respond_time"`
  2622. Signtype interface{} `json:"signtype"`
  2623. WarnMsg interface{} `json:"warn_msg"`
  2624. }
  2625. type ResultTwo struct {
  2626. ErrMsg string `json:"err_msg"`
  2627. InfRefmsgid string `json:"inf_refmsgid"`
  2628. Infcode int64 `json:"infcode"`
  2629. Output struct {
  2630. Baseinfo struct {
  2631. Age float64 `json:"age"`
  2632. Brdy string `json:"brdy"`
  2633. Certno string `json:"certno"`
  2634. Gend string `json:"gend"`
  2635. Naty string `json:"naty"`
  2636. PsnCertType string `json:"psn_cert_type"`
  2637. PsnName string `json:"psn_name"`
  2638. PsnNo string `json:"psn_no"`
  2639. } `json:"baseinfo"`
  2640. Idetinfo []interface{} `json:"idetinfo"`
  2641. Iinfo []struct {
  2642. Balc float64 `json:"balc"`
  2643. CvlservFlag string `json:"cvlserv_flag"`
  2644. EmpName string `json:"emp_name"`
  2645. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2646. Insutype string `json:"insutype"`
  2647. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2648. PausInsuDate string `json:"paus_insu_date"`
  2649. PsnInsuDate string `json:"psn_insu_date"`
  2650. PsnInsuStas string `json:"psn_insu_stas"`
  2651. PsnType string `json:"psn_type"`
  2652. } `json:"insuinfo"`
  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. type ResultTwo10265 struct {
  2660. ErrMsg string `json:"err_msg"`
  2661. InfRefmsgid string `json:"inf_refmsgid"`
  2662. Infcode string `json:"infcode"`
  2663. Output struct {
  2664. Baseinfo struct {
  2665. Age float64 `json:"age"`
  2666. Brdy string `json:"brdy"`
  2667. Certno string `json:"certno"`
  2668. Gend string `json:"gend"`
  2669. Naty string `json:"naty"`
  2670. PsnCertType string `json:"psn_cert_type"`
  2671. PsnName string `json:"psn_name"`
  2672. PsnNo string `json:"psn_no"`
  2673. } `json:"baseinfo"`
  2674. Idetinfo []interface{} `json:"idetinfo"`
  2675. Iinfo []struct {
  2676. Balc float64 `json:"balc"`
  2677. CvlservFlag string `json:"cvlserv_flag"`
  2678. EmpName string `json:"emp_name"`
  2679. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2680. Insutype string `json:"insutype"`
  2681. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2682. PausInsuDate string `json:"paus_insu_date"`
  2683. PsnInsuDate string `json:"psn_insu_date"`
  2684. PsnInsuStas string `json:"psn_insu_stas"`
  2685. PsnType string `json:"psn_type"`
  2686. } `json:"insuinfo"`
  2687. } `json:"output"`
  2688. RefmsgTime string `json:"refmsg_time"`
  2689. RespondTime string `json:"respond_time"`
  2690. Signtype interface{} `json:"signtype"`
  2691. WarnInfo interface{} `json:"warn_info"`
  2692. }
  2693. type ResultThree struct {
  2694. Cainfo interface{} `json:"cainfo"`
  2695. ErrMsg string `json:"err_msg"`
  2696. InfRefmsgid string `json:"inf_refmsgid"`
  2697. Infcode int64 `json:"infcode"`
  2698. Output struct {
  2699. Data struct {
  2700. IptOtpNo string `json:"ipt_otp_no"`
  2701. MdtrtID string `json:"mdtrt_id"`
  2702. PsnNo string `json:"psn_no"`
  2703. } `json:"data"`
  2704. } `json:"output"`
  2705. RefmsgTime string `json:"refmsg_time"`
  2706. RespondTime string `json:"respond_time"`
  2707. Signtype interface{} `json:"signtype"`
  2708. WarnMsg interface{} `json:"warn_msg"`
  2709. }
  2710. type ResultThree10265 struct {
  2711. Cainfo interface{} `json:"cainfo"`
  2712. ErrMsg string `json:"err_msg"`
  2713. InfRefmsgid string `json:"inf_refmsgid"`
  2714. Infcode string `json:"infcode"`
  2715. Output struct {
  2716. Data struct {
  2717. IptOtpNo string `json:"ipt_otp_no"`
  2718. MdtrtID string `json:"mdtrt_id"`
  2719. PsnNo string `json:"psn_no"`
  2720. } `json:"data"`
  2721. } `json:"output"`
  2722. RefmsgTime string `json:"refmsg_time"`
  2723. RespondTime string `json:"respond_time"`
  2724. Signtype interface{} `json:"signtype"`
  2725. WarnMsg interface{} `json:"warn_msg"`
  2726. }
  2727. type ResultFour struct {
  2728. Cainfo string `json:"cainfo"`
  2729. ErrMsg string `json:"err_msg"`
  2730. InfRefmsgid string `json:"inf_refmsgid"`
  2731. Infcode int64 `json:"infcode"`
  2732. Output struct {
  2733. Result []struct {
  2734. BasMednFlag string `json:"bas_medn_flag"`
  2735. ChldMedcFlag string `json:"chld_medc_flag"`
  2736. ChrgitmLv string `json:"chrgitm_lv"`
  2737. Cnt float64 `json:"cnt"`
  2738. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2739. DrtReimFlag string `json:"drt_reim_flag"`
  2740. FeedetlSn string `json:"feedetl_sn"`
  2741. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2742. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2743. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2744. ListSpItemFlag string `json:"list_sp_item_flag"`
  2745. LmtUsedFlag string `json:"lmt_used_flag"`
  2746. MedChrgitmType string `json:"med_chrgitm_type"`
  2747. Memo string `json:"memo"`
  2748. OverlmtAmt float64 `json:"overlmt_amt"`
  2749. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2750. Pric float64 `json:"pric"`
  2751. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2752. SelfpayProp float64 `json:"selfpay_prop"`
  2753. } `json:"result"`
  2754. } `json:"output"`
  2755. RefmsgTime string `json:"refmsg_time"`
  2756. RespondTime string `json:"respond_time"`
  2757. Signtype string `json:"signtype"`
  2758. WarnMsg string `json:"warn_msg"`
  2759. }
  2760. type ResultFour10265 struct {
  2761. Cainfo string `json:"cainfo"`
  2762. ErrMsg string `json:"err_msg"`
  2763. InfRefmsgid string `json:"inf_refmsgid"`
  2764. Infcode string `json:"infcode"`
  2765. Output struct {
  2766. Result []struct {
  2767. BasMednFlag string `json:"bas_medn_flag"`
  2768. ChldMedcFlag string `json:"chld_medc_flag"`
  2769. ChrgitmLv string `json:"chrgitm_lv"`
  2770. Cnt float64 `json:"cnt"`
  2771. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2772. DrtReimFlag string `json:"drt_reim_flag"`
  2773. FeedetlSn string `json:"feedetl_sn"`
  2774. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2775. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2776. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2777. ListSpItemFlag string `json:"list_sp_item_flag"`
  2778. LmtUsedFlag string `json:"lmt_used_flag"`
  2779. MedChrgitmType string `json:"med_chrgitm_type"`
  2780. Memo string `json:"memo"`
  2781. OverlmtAmt float64 `json:"overlmt_amt"`
  2782. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2783. Pric float64 `json:"pric"`
  2784. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2785. SelfpayProp float64 `json:"selfpay_prop"`
  2786. } `json:"result"`
  2787. } `json:"output"`
  2788. RefmsgTime string `json:"refmsg_time"`
  2789. RespondTime string `json:"respond_time"`
  2790. Signtype string `json:"signtype"`
  2791. WarnMsg string `json:"warn_msg"`
  2792. }
  2793. type ResultFive struct {
  2794. Balc float64 `json:"balc"`
  2795. CvlservFlag string `json:"cvlserv_flag"`
  2796. EmpName string `json:"emp_name"`
  2797. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2798. Insutype string `json:"insutype"`
  2799. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2800. PausInsuDate string `json:"paus_insu_date"`
  2801. PsnInsuDate string `json:"psn_insu_date"`
  2802. PsnInsuStas string `json:"psn_insu_stas"`
  2803. PsnType string `json:"psn_type"`
  2804. }
  2805. type ResultSix struct {
  2806. Cainfo interface{} `json:"cainfo"`
  2807. ErrMsg string `json:"err_msg"`
  2808. InfRefmsgid string `json:"inf_refmsgid"`
  2809. Infcode int64 `json:"infcode"`
  2810. Output struct {
  2811. } `json:"output"`
  2812. RefmsgTime string `json:"refmsg_time"`
  2813. RespondTime string `json:"respond_time"`
  2814. Signtype interface{} `json:"signtype"`
  2815. WarnMsg interface{} `json:"warn_msg"`
  2816. }
  2817. type ResultSix10265 struct {
  2818. Cainfo interface{} `json:"cainfo"`
  2819. ErrMsg string `json:"err_msg"`
  2820. InfRefmsgid string `json:"inf_refmsgid"`
  2821. Infcode string `json:"infcode"`
  2822. Output struct {
  2823. } `json:"output"`
  2824. RefmsgTime string `json:"refmsg_time"`
  2825. RespondTime string `json:"respond_time"`
  2826. Signtype interface{} `json:"signtype"`
  2827. WarnMsg interface{} `json:"warn_msg"`
  2828. }
  2829. type ResultSeven struct {
  2830. Cainfo string `json:"cainfo"`
  2831. ErrMsg string `json:"err_msg"`
  2832. InfRefmsgid string `json:"inf_refmsgid"`
  2833. Infcode int64 `json:"infcode"`
  2834. Output struct {
  2835. Setldetail []interface{} `json:"setldetail"`
  2836. Setlinfo struct {
  2837. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2838. AcctPay float64 `json:"acct_pay"`
  2839. ActPayDedc float64 `json:"act_pay_dedc"`
  2840. Age float64 `json:"age"`
  2841. Balc float64 `json:"balc"`
  2842. Brdy string `json:"brdy"`
  2843. Certno string `json:"certno"`
  2844. ClrOptins string `json:"clr_optins"`
  2845. ClrType string `json:"clr_type"`
  2846. ClrWay string `json:"clr_way"`
  2847. CvlservFlag string `json:"cvlserv_flag"`
  2848. CvlservPay float64 `json:"cvlserv_pay"`
  2849. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2850. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2851. Gend string `json:"gend"`
  2852. HifesPay float64 `json:"hifes_pay"`
  2853. HifmiPay float64 `json:"hifmi_pay"`
  2854. HifpPay float64 `json:"hifp_pay"`
  2855. HospPartAmt float64 `json:"hosp_part_amt"`
  2856. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2857. Insutype string `json:"insutype"`
  2858. MafPay float64 `json:"maf_pay"`
  2859. MdtrtCertType string `json:"mdtrt_cert_type"`
  2860. HifobPay float64 `json:"hifob_pay"`
  2861. MdtrtID string `json:"mdtrt_id"`
  2862. MedType string `json:"med_type"`
  2863. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2864. MedinsSetlID string `json:"medins_setl_id"`
  2865. Naty string `json:"naty"`
  2866. OthPay float64 `json:"oth_pay"`
  2867. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2868. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2869. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2870. PsnCashPay float64 `json:"psn_cash_pay"`
  2871. PsnCertType string `json:"psn_cert_type"`
  2872. PsnName string `json:"psn_name"`
  2873. PsnNo string `json:"psn_no"`
  2874. PsnPartAmt float64 `json:"psn_part_amt"`
  2875. PsnType string `json:"psn_type"`
  2876. SetlID string `json:"setl_id"`
  2877. SetlTime string `json:"setl_time"`
  2878. } `json:"setlinfo"`
  2879. } `json:"output"`
  2880. RefmsgTime string `json:"refmsg_time"`
  2881. RespondTime string `json:"respond_time"`
  2882. Signtype interface{} `json:"signtype"`
  2883. WarnMsg interface{} `json:"warn_msg"`
  2884. }
  2885. type ResultSeven10265 struct {
  2886. Cainfo string `json:"cainfo"`
  2887. ErrMsg string `json:"err_msg"`
  2888. InfRefmsgid string `json:"inf_refmsgid"`
  2889. Infcode string `json:"infcode"`
  2890. Output struct {
  2891. Setldetail []interface{} `json:"setldetail"`
  2892. Setlinfo struct {
  2893. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2894. AcctPay float64 `json:"acct_pay"`
  2895. ActPayDedc float64 `json:"act_pay_dedc"`
  2896. Age float64 `json:"age"`
  2897. Balc float64 `json:"balc"`
  2898. Brdy string `json:"brdy"`
  2899. Certno string `json:"certno"`
  2900. ClrOptins string `json:"clr_optins"`
  2901. ClrType string `json:"clr_type"`
  2902. ClrWay string `json:"clr_way"`
  2903. CvlservFlag string `json:"cvlserv_flag"`
  2904. CvlservPay float64 `json:"cvlserv_pay"`
  2905. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2906. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2907. Gend string `json:"gend"`
  2908. HifesPay float64 `json:"hifes_pay"`
  2909. HifmiPay float64 `json:"hifmi_pay"`
  2910. HifpPay float64 `json:"hifp_pay"`
  2911. HospPartAmt float64 `json:"hosp_part_amt"`
  2912. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2913. Insutype string `json:"insutype"`
  2914. MafPay float64 `json:"maf_pay"`
  2915. MdtrtCertType string `json:"mdtrt_cert_type"`
  2916. HifobPay float64 `json:"hifob_pay"`
  2917. MdtrtID string `json:"mdtrt_id"`
  2918. MedType string `json:"med_type"`
  2919. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2920. MedinsSetlID string `json:"medins_setl_id"`
  2921. Naty string `json:"naty"`
  2922. OthPay float64 `json:"oth_pay"`
  2923. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2924. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2925. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2926. PsnCashPay float64 `json:"psn_cash_pay"`
  2927. PsnCertType string `json:"psn_cert_type"`
  2928. PsnName string `json:"psn_name"`
  2929. PsnNo string `json:"psn_no"`
  2930. PsnPartAmt float64 `json:"psn_part_amt"`
  2931. PsnType string `json:"psn_type"`
  2932. SetlID string `json:"setl_id"`
  2933. SetlTime string `json:"setl_time"`
  2934. } `json:"setlinfo"`
  2935. } `json:"output"`
  2936. RefmsgTime string `json:"refmsg_time"`
  2937. RespondTime string `json:"respond_time"`
  2938. Signtype interface{} `json:"signtype"`
  2939. WarnMsg interface{} `json:"warn_msg"`
  2940. }
  2941. type ResultEight struct {
  2942. Cainfo string `json:"cainfo"`
  2943. ErrMsg string `json:"err_msg"`
  2944. InfRefmsgid string `json:"inf_refmsgid"`
  2945. Infcode int64 `json:"infcode"`
  2946. Output struct {
  2947. Stmtinfo struct {
  2948. SetlOptins string `json:"setl_optins"`
  2949. StmtRslt string `json:"stmt_rslt"`
  2950. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2951. } `json:"stmtinfo"`
  2952. } `json:"output"`
  2953. RefmsgTime string `json:"refmsg_time"`
  2954. RespondTime string `json:"respond_time"`
  2955. Signtype interface{} `json:"signtype"`
  2956. WarnMsg interface{} `json:"warn_msg"`
  2957. }
  2958. type ResultEightFor10188 struct {
  2959. Cainfo string `json:"cainfo"`
  2960. ErrMsg string `json:"err_msg"`
  2961. InfRefmsgid string `json:"inf_refmsgid"`
  2962. Infcode string `json:"infcode"`
  2963. Output struct {
  2964. Stmtinfo struct {
  2965. SetlOptins string `json:"setl_optins"`
  2966. StmtRslt string `json:"stmt_rslt"`
  2967. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2968. } `json:"stmtinfo"`
  2969. } `json:"output"`
  2970. RefmsgTime string `json:"refmsg_time"`
  2971. RespondTime string `json:"respond_time"`
  2972. Signtype interface{} `json:"signtype"`
  2973. WarnMsg interface{} `json:"warn_msg"`
  2974. }
  2975. type ResultNine struct {
  2976. Cainfo string `json:"cainfo"`
  2977. ErrMsg string `json:"err_msg"`
  2978. InfRefmsgid string `json:"inf_refmsgid"`
  2979. Infcode int64 `json:"infcode"`
  2980. Output struct {
  2981. FileQuryNo string `json:"file_qury_no"`
  2982. } `json:"output"`
  2983. RefmsgTime string `json:"refmsg_time"`
  2984. RespondTime string `json:"respond_time"`
  2985. Signtype interface{} `json:"signtype"`
  2986. WarnMsg interface{} `json:"warn_msg"`
  2987. }
  2988. type ResultTen struct {
  2989. Cainfo string `json:"cainfo"`
  2990. ErrMsg string `json:"err_msg"`
  2991. InfRefmsgid string `json:"inf_refmsgid"`
  2992. Infcode int64 `json:"infcode"`
  2993. Output struct {
  2994. DldEndtime string `json:"dld_endtime"`
  2995. FileQuryNo string `json:"file_qury_no"`
  2996. Filename string `json:"filename"`
  2997. } `json:"output"`
  2998. RefmsgTime string `json:"refmsg_time"`
  2999. RespondTime string `json:"respond_time"`
  3000. Signtype interface{} `json:"signtype"`
  3001. WarnMsg interface{} `json:"warn_msg"`
  3002. }
  3003. //type Autogenerated struct {
  3004. // Output struct {
  3005. // Setlinfo struct {
  3006. // SetlTime string `json:"setl_time"`
  3007. // CvlservPay float64 `json:"cvlserv_pay"`
  3008. // Year string `json:"year"`
  3009. // MedType string `json:"med_type"`
  3010. // PsnPay float64 `json:"psn_pay"`
  3011. // OpterID string `json:"opter_id"`
  3012. // Begndate string `json:"begndate"`
  3013. // FlxempeFlag string `json:"flxempe_flag"`
  3014. // HifmiPay float64 `json:"hifmi_pay"`
  3015. // PsnNo string `json:"psn_no"`
  3016. // ActPayDedc float64 `json:"act_pay_dedc"`
  3017. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3018. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3019. // ClrWay string `json:"clr_way"`
  3020. // OthPay float64 `json:"oth_pay"`
  3021. // Gend string `json:"gend"`
  3022. // MdtrtID string `json:"mdtrt_id"`
  3023. // AcctPay float64 `json:"acct_pay"`
  3024. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3025. // Insutype string `json:"insutype"`
  3026. // Invono interface{} `json:"invono"`
  3027. // Enddate string `json:"enddate"`
  3028. // CashPayamt float64 `json:"cash_payamt"`
  3029. // PsnType string `json:"psn_type"`
  3030. // FixmedinsName string `json:"fixmedins_name"`
  3031. // HifpPay float64 `json:"hifp_pay"`
  3032. // NewFlag interface{} `json:"new_flag"`
  3033. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3034. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3035. // PayLoc string `json:"pay_loc"`
  3036. // ClrType string `json:"clr_type"`
  3037. // RefdSetlFlag string `json:"refd_setl_flag"`
  3038. // CvlservFlag string `json:"cvlserv_flag"`
  3039. // EmpName string `json:"emp_name"`
  3040. // Brdy string `json:"brdy"`
  3041. // Naty string `json:"naty"`
  3042. // Certno string `json:"certno"`
  3043. // DiseCode string `json:"dise_code"`
  3044. // FixmedinsCode string `json:"fixmedins_code"`
  3045. // DedcHospLv string `json:"dedc_hosp_lv"`
  3046. // OpterName string `json:"opter_name"`
  3047. // Balc float64 `json:"balc"`
  3048. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3049. // PsnCertType string `json:"psn_cert_type"`
  3050. // HifobPay float64 `json:"hifob_pay"`
  3051. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3052. // HifesPay float64 `json:"hifes_pay"`
  3053. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3054. // OptTime string `json:"opt_time"`
  3055. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3056. // SetlID string `json:"setl_id"`
  3057. // MafPay float64 `json:"maf_pay"`
  3058. // PsnName string `json:"psn_name"`
  3059. // InsuOptins interface{} `json:"insu_optins"`
  3060. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3061. // ClrOptins string `json:"clr_optins"`
  3062. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3063. // DiseName string `json:"dise_name"`
  3064. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3065. // Age float64 `json:"age"`
  3066. // DtrtCertType string `json:"dtrt_cert_type"`
  3067. // HospLv string `json:"hosp_lv"`
  3068. // } `json:"setlinfo"`
  3069. // Setldetail []struct {
  3070. // FundPayType string `json:"fund_pay_type"`
  3071. // FundPayamt float64 `json:"fund_payamt"`
  3072. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3073. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3074. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3075. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3076. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3077. // } `json:"setldetail"`
  3078. // } `json:"output"`
  3079. // Infcode int `json:"infcode"`
  3080. // WarnMsg interface{} `json:"warn_msg"`
  3081. // Cainfo interface{} `json:"cainfo"`
  3082. // ErrMsg interface{} `json:"err_msg"`
  3083. // RefmsgTime string `json:"refmsg_time"`
  3084. // Signtype interface{} `json:"signtype"`
  3085. // RespondTime string `json:"respond_time"`
  3086. // InfRefmsgid string `json:"inf_refmsgid"`
  3087. //}
  3088. type ResultEleven struct {
  3089. Cainfo string `json:"cainfo"`
  3090. ErrMsg string `json:"err_msg"`
  3091. InfRefmsgid string `json:"inf_refmsgid"`
  3092. Infcode int64 `json:"infcode"`
  3093. Output struct {
  3094. Setlinfo struct {
  3095. SetlTime string `json:"setl_time"`
  3096. CvlservPay float64 `json:"cvlserv_pay"`
  3097. Year string `json:"year"`
  3098. MedType string `json:"med_type"`
  3099. PsnPay float64 `json:"psn_pay"`
  3100. OpterID string `json:"opter_id"`
  3101. Begndate string `json:"begndate"`
  3102. FlxempeFlag string `json:"flxempe_flag"`
  3103. HifmiPay float64 `json:"hifmi_pay"`
  3104. PsnNo string `json:"psn_no"`
  3105. ActPayDedc float64 `json:"act_pay_dedc"`
  3106. MedinsSetlID interface{} `json:"medins_setl_id"`
  3107. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3108. ClrWay string `json:"clr_way"`
  3109. OthPay float64 `json:"oth_pay"`
  3110. Gend string `json:"gend"`
  3111. MdtrtID string `json:"mdtrt_id"`
  3112. AcctPay float64 `json:"acct_pay"`
  3113. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3114. Insutype string `json:"insutype"`
  3115. Invono interface{} `json:"invono"`
  3116. Enddate string `json:"enddate"`
  3117. CashPayamt float64 `json:"cash_payamt"`
  3118. PsnType string `json:"psn_type"`
  3119. FixmedinsName string `json:"fixmedins_name"`
  3120. HifpPay float64 `json:"hifp_pay"`
  3121. NewFlag interface{} `json:"new_flag"`
  3122. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3123. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3124. PayLoc string `json:"pay_loc"`
  3125. ClrType string `json:"clr_type"`
  3126. RefdSetlFlag string `json:"refd_setl_flag"`
  3127. CvlservFlag string `json:"cvlserv_flag"`
  3128. EmpName string `json:"emp_name"`
  3129. Brdy string `json:"brdy"`
  3130. Naty string `json:"naty"`
  3131. Certno string `json:"certno"`
  3132. DiseCode string `json:"dise_code"`
  3133. FixmedinsCode string `json:"fixmedins_code"`
  3134. DedcHospLv string `json:"dedc_hosp_lv"`
  3135. OpterName string `json:"opter_name"`
  3136. Balc float64 `json:"balc"`
  3137. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3138. PsnCertType string `json:"psn_cert_type"`
  3139. HifobPay float64 `json:"hifob_pay"`
  3140. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3141. HifesPay float64 `json:"hifes_pay"`
  3142. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3143. OptTime string `json:"opt_time"`
  3144. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3145. SetlID string `json:"setl_id"`
  3146. MafPay float64 `json:"maf_pay"`
  3147. PsnName string `json:"psn_name"`
  3148. InsuOptins interface{} `json:"insu_optins"`
  3149. PrefFundPay interface{} `json:"pref_fund_pay"`
  3150. ClrOptins string `json:"clr_optins"`
  3151. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3152. DiseName string `json:"dise_name"`
  3153. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3154. Age float64 `json:"age"`
  3155. DtrtCertType string `json:"dtrt_cert_type"`
  3156. HospLv string `json:"hosp_lv"`
  3157. } `json:"setlinfo"`
  3158. } `json:"output"`
  3159. RefmsgTime string `json:"refmsg_time"`
  3160. RespondTime string `json:"respond_time"`
  3161. Signtype interface{} `json:"signtype"`
  3162. WarnMsg interface{} `json:"warn_msg"`
  3163. }
  3164. type ResultEleven10265 struct {
  3165. Cainfo string `json:"cainfo"`
  3166. ErrMsg string `json:"err_msg"`
  3167. InfRefmsgid string `json:"inf_refmsgid"`
  3168. Infcode string `json:"infcode"`
  3169. Output struct {
  3170. Setlinfo struct {
  3171. SetlTime string `json:"setl_time"`
  3172. CvlservPay float64 `json:"cvlserv_pay"`
  3173. Year string `json:"year"`
  3174. MedType string `json:"med_type"`
  3175. PsnPay float64 `json:"psn_pay"`
  3176. OpterID string `json:"opter_id"`
  3177. Begndate string `json:"begndate"`
  3178. FlxempeFlag string `json:"flxempe_flag"`
  3179. HifmiPay float64 `json:"hifmi_pay"`
  3180. PsnNo string `json:"psn_no"`
  3181. ActPayDedc float64 `json:"act_pay_dedc"`
  3182. MedinsSetlID interface{} `json:"medins_setl_id"`
  3183. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3184. ClrWay string `json:"clr_way"`
  3185. OthPay float64 `json:"oth_pay"`
  3186. Gend string `json:"gend"`
  3187. MdtrtID string `json:"mdtrt_id"`
  3188. AcctPay float64 `json:"acct_pay"`
  3189. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3190. Insutype string `json:"insutype"`
  3191. Invono interface{} `json:"invono"`
  3192. Enddate string `json:"enddate"`
  3193. CashPayamt float64 `json:"cash_payamt"`
  3194. PsnType string `json:"psn_type"`
  3195. FixmedinsName string `json:"fixmedins_name"`
  3196. HifpPay float64 `json:"hifp_pay"`
  3197. NewFlag interface{} `json:"new_flag"`
  3198. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3199. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3200. PayLoc string `json:"pay_loc"`
  3201. ClrType string `json:"clr_type"`
  3202. RefdSetlFlag string `json:"refd_setl_flag"`
  3203. CvlservFlag string `json:"cvlserv_flag"`
  3204. EmpName string `json:"emp_name"`
  3205. Brdy string `json:"brdy"`
  3206. Naty string `json:"naty"`
  3207. Certno string `json:"certno"`
  3208. DiseCode string `json:"dise_code"`
  3209. FixmedinsCode string `json:"fixmedins_code"`
  3210. DedcHospLv string `json:"dedc_hosp_lv"`
  3211. OpterName string `json:"opter_name"`
  3212. Balc float64 `json:"balc"`
  3213. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3214. PsnCertType string `json:"psn_cert_type"`
  3215. HifobPay float64 `json:"hifob_pay"`
  3216. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3217. HifesPay float64 `json:"hifes_pay"`
  3218. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3219. OptTime string `json:"opt_time"`
  3220. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3221. SetlID string `json:"setl_id"`
  3222. MafPay float64 `json:"maf_pay"`
  3223. PsnName string `json:"psn_name"`
  3224. InsuOptins interface{} `json:"insu_optins"`
  3225. PrefFundPay interface{} `json:"pref_fund_pay"`
  3226. ClrOptins string `json:"clr_optins"`
  3227. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3228. DiseName string `json:"dise_name"`
  3229. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3230. Age float64 `json:"age"`
  3231. DtrtCertType string `json:"dtrt_cert_type"`
  3232. HospLv string `json:"hosp_lv"`
  3233. } `json:"setlinfo"`
  3234. } `json:"output"`
  3235. RefmsgTime string `json:"refmsg_time"`
  3236. RespondTime string `json:"respond_time"`
  3237. Signtype interface{} `json:"signtype"`
  3238. WarnMsg interface{} `json:"warn_msg"`
  3239. }
  3240. type ResultTwelve struct {
  3241. Cainfo string `json:"cainfo"`
  3242. ErrMsg string `json:"err_msg"`
  3243. InfRefmsgid string `json:"inf_refmsgid"`
  3244. Infcode int64 `json:"infcode"`
  3245. Output struct {
  3246. MdtrtId string `json:"mdtrt_id"`
  3247. ChrgBchno string `json:"chrg_bchno"`
  3248. PsnNo string `json:"psn_no"`
  3249. } `json:"output"`
  3250. RefmsgTime string `json:"refmsg_time"`
  3251. RespondTime string `json:"respond_time"`
  3252. Signtype interface{} `json:"signtype"`
  3253. WarnMsg interface{} `json:"warn_msg"`
  3254. }
  3255. type ResultThirteen struct {
  3256. ErrMsg string `json:"err_msg"`
  3257. InfRefmsgid string `json:"inf_refmsgid"`
  3258. Infcode int64 `json:"infcode"`
  3259. Output struct {
  3260. Result struct {
  3261. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3262. } `json:"result"`
  3263. } `json:"output"`
  3264. RefmsgTime string `json:"refmsg_time"`
  3265. RespondTime string `json:"respond_time"`
  3266. Signtype interface{} `json:"signtype"`
  3267. WarnInfo interface{} `json:"warn_info"`
  3268. }
  3269. type ResultThirteen10265 struct {
  3270. ErrMsg string `json:"err_msg"`
  3271. InfRefmsgid string `json:"inf_refmsgid"`
  3272. Infcode string `json:"infcode"`
  3273. Output struct {
  3274. Result struct {
  3275. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3276. } `json:"result"`
  3277. } `json:"output"`
  3278. RefmsgTime string `json:"refmsg_time"`
  3279. RespondTime string `json:"respond_time"`
  3280. Signtype interface{} `json:"signtype"`
  3281. WarnInfo interface{} `json:"warn_info"`
  3282. }
  3283. type ResultFourteen struct {
  3284. ErrMsg string `json:"err_msg"`
  3285. InfRefmsgid string `json:"inf_refmsgid"`
  3286. Infcode int64 `json:"infcode"`
  3287. Output struct {
  3288. } `json:"output"`
  3289. RefmsgTime string `json:"refmsg_time"`
  3290. RespondTime string `json:"respond_time"`
  3291. Signtype interface{} `json:"signtype"`
  3292. WarnInfo interface{} `json:"warn_info"`
  3293. }
  3294. type ResultFourteen10265 struct {
  3295. ErrMsg string `json:"err_msg"`
  3296. InfRefmsgid string `json:"inf_refmsgid"`
  3297. Infcode string `json:"infcode"`
  3298. Output struct {
  3299. } `json:"output"`
  3300. RefmsgTime string `json:"refmsg_time"`
  3301. RespondTime string `json:"respond_time"`
  3302. Signtype interface{} `json:"signtype"`
  3303. WarnInfo interface{} `json:"warn_info"`
  3304. }
  3305. type ResultSixteen struct {
  3306. Cainfo string `json:"cainfo"`
  3307. ErrMsg string `json:"err_msg"`
  3308. InfRefmsgid string `json:"inf_refmsgid"`
  3309. Infcode int64 `json:"infcode"`
  3310. Output struct {
  3311. Setldetail []interface{} `json:"setldetail"`
  3312. Setlinfo struct {
  3313. MdtrtID string `json:"mdtrt_id"`
  3314. SetlID string `json:"setl_id"`
  3315. ClrOptins string `json:"clr_optins"`
  3316. SetlTime string `json:"setl_time"`
  3317. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3318. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3319. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3320. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3321. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3322. ActPayDedc float64 `json:"act_pay_dedc"`
  3323. HifpPay float64 `json:"hifp_pay"`
  3324. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3325. Lfpay float64 `json:"selfpay"`
  3326. CvlservPay float64 `json:"cvlserv_pay"`
  3327. HifesPay float64 `json:"hifes_pay"`
  3328. HifmiPay float64 `json:"hifmi_pay"`
  3329. HifobPay float64 `json:"hifob_pay"`
  3330. MafPay float64 `json:"maf_pay"`
  3331. OthPay float64 `json:"oth_pay"`
  3332. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3333. PsnPartAmt float64 `json:"psn_part_amt"`
  3334. AcctPay float64 `json:"acct_pay"`
  3335. Balc float64 `json:"balc"`
  3336. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3337. HospPartAmt float64 `json:"hosp_part_amt"`
  3338. MedinsSetlID string `json:"medins_setl_id"`
  3339. PdnCashPay string `json:"pdn_cash_pay"`
  3340. } `json:"setlinfo"`
  3341. } `json:"output"`
  3342. RefmsgTime string `json:"refmsg_time"`
  3343. RespondTime string `json:"respond_time"`
  3344. Signtype interface{} `json:"signtype"`
  3345. WarnMsg interface{} `json:"warn_msg"`
  3346. }
  3347. type ResultSixteen10265 struct {
  3348. Cainfo string `json:"cainfo"`
  3349. ErrMsg string `json:"err_msg"`
  3350. InfRefmsgid string `json:"inf_refmsgid"`
  3351. Infcode string `json:"infcode"`
  3352. Output struct {
  3353. Setldetail []interface{} `json:"setldetail"`
  3354. Setlinfo struct {
  3355. MdtrtID string `json:"mdtrt_id"`
  3356. SetlID string `json:"setl_id"`
  3357. ClrOptins string `json:"clr_optins"`
  3358. SetlTime string `json:"setl_time"`
  3359. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3360. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3361. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3362. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3363. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3364. ActPayDedc float64 `json:"act_pay_dedc"`
  3365. HifpPay float64 `json:"hifp_pay"`
  3366. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3367. Lfpay float64 `json:"selfpay"`
  3368. CvlservPay float64 `json:"cvlserv_pay"`
  3369. HifesPay float64 `json:"hifes_pay"`
  3370. HifmiPay float64 `json:"hifmi_pay"`
  3371. HifobPay float64 `json:"hifob_pay"`
  3372. MafPay float64 `json:"maf_pay"`
  3373. OthPay float64 `json:"oth_pay"`
  3374. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3375. PsnPartAmt float64 `json:"psn_part_amt"`
  3376. AcctPay float64 `json:"acct_pay"`
  3377. Balc float64 `json:"balc"`
  3378. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3379. HospPartAmt float64 `json:"hosp_part_amt"`
  3380. MedinsSetlID string `json:"medins_setl_id"`
  3381. PdnCashPay string `json:"pdn_cash_pay"`
  3382. } `json:"setlinfo"`
  3383. } `json:"output"`
  3384. RefmsgTime string `json:"refmsg_time"`
  3385. RespondTime string `json:"respond_time"`
  3386. Signtype interface{} `json:"signtype"`
  3387. WarnMsg interface{} `json:"warn_msg"`
  3388. }
  3389. type ResultSeventeen struct {
  3390. ErrMsg string `json:"err_msg"`
  3391. InfRefmsgid string `json:"inf_refmsgid"`
  3392. Infcode int64 `json:"infcode"`
  3393. Output struct {
  3394. SetlListId string `json:"setl_list_id"`
  3395. } `json:"output"`
  3396. RefmsgTime string `json:"refmsg_time"`
  3397. RespondTime string `json:"respond_time"`
  3398. Signtype string `json:"signtype"`
  3399. WarnInfo string `json:"warn_info"`
  3400. }
  3401. type Result90991 struct {
  3402. ErrMsg string `json:"err_msg"`
  3403. InfRefmsgid string `json:"inf_refmsgid"`
  3404. Infcode int64 `json:"infcode"`
  3405. Output struct {
  3406. Result struct {
  3407. PsnNo string `json:"psn_no"`
  3408. CardStat string `json:"card_stat"`
  3409. Certno string `json:"certno"`
  3410. PsnName string `json:"psn_name"`
  3411. CheckStat string `json:"check_stat"`
  3412. } `json:"result"`
  3413. } `json:"output"`
  3414. RefmsgTime string `json:"refmsg_time"`
  3415. RespondTime string `json:"respond_time"`
  3416. Signtype interface{} `json:"signtype"`
  3417. WarnInfo interface{} `json:"warn_info"`
  3418. }
  3419. type Result90100 struct {
  3420. ErrMsg string `json:"err_msg"`
  3421. InfRefmsgid string `json:"inf_refmsgid"`
  3422. Infcode int64 `json:"infcode"`
  3423. Output struct {
  3424. PoolareaNo string `json:"poolarea_no"`
  3425. PoolareaNoName string `json:"poolarea_no_name"`
  3426. Insutype string `json:"insutype"`
  3427. InsutypeName string `json:"insutype_name"`
  3428. ClctType string `json:"clct_type"`
  3429. ClctTypeName string `json:"clct_type_name"`
  3430. ClctFlag string `json:"clct_flag"`
  3431. ClctFlagName string `json:"clct_flag_name"`
  3432. AccrymBegn string `json:"accrym_begn"`
  3433. AccrymEnd string `json:"accrym_end"`
  3434. ClctTime string `json:"clct_time"`
  3435. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3436. } `json:"output"`
  3437. RefmsgTime string `json:"refmsg_time"`
  3438. RespondTime string `json:"respond_time"`
  3439. Signtype interface{} `json:"signtype"`
  3440. WarnInfo interface{} `json:"warn_info"`
  3441. }
  3442. type Custom struct {
  3443. DetItemFeeSumamt string
  3444. Cut string
  3445. FeedetlSn string
  3446. Price string
  3447. MedListCodg string
  3448. Type int64
  3449. AdviceId int64
  3450. ProjectId int64
  3451. ItemId int64
  3452. }
  3453. type Result5301 struct {
  3454. ErrMsg string `json:"err_msg"`
  3455. InfRefmsgid string `json:"inf_refmsgid"`
  3456. Infcode int64 `json:"infcode"`
  3457. Output struct {
  3458. Result []struct {
  3459. OpspDiseCode string `json:"opsp_dise_code"`
  3460. OpspDiseName string `json:"opsp_dise_name"`
  3461. Begndate string `json:"begndate"`
  3462. Enddate string `json:"enddate"`
  3463. } `json:"feedetail"`
  3464. } `json:"output"`
  3465. RefmsgTime string `json:"refmsg_time"`
  3466. RespondTime string `json:"respond_time"`
  3467. Signtype interface{} `json:"signtype"`
  3468. WarnInfo interface{} `json:"warn_info"`
  3469. }
  3470. type Result5301For10265 struct {
  3471. ErrMsg string `json:"err_msg"`
  3472. InfRefmsgid string `json:"inf_refmsgid"`
  3473. Infcode string `json:"infcode"`
  3474. Output struct {
  3475. Result []struct {
  3476. OpspDiseCode string `json:"opsp_dise_code"`
  3477. OpspDiseName string `json:"opsp_dise_name"`
  3478. Begndate string `json:"begndate"`
  3479. Enddate string `json:"enddate"`
  3480. } `json:"feedetail"`
  3481. } `json:"output"`
  3482. RefmsgTime string `json:"refmsg_time"`
  3483. RespondTime string `json:"respond_time"`
  3484. Signtype interface{} `json:"signtype"`
  3485. WarnInfo interface{} `json:"warn_info"`
  3486. }
  3487. //获取个人信息----挂号-----上传就诊信息
  3488. func (c *HisApiController) GetRegisterInfo() {
  3489. id, _ := c.GetInt64("id")
  3490. record_time := c.GetString("record_time")
  3491. settlementValue, _ := c.GetInt64("settlement_value")
  3492. medical_insurance_card := c.GetString("medical_insurance_card")
  3493. name := c.GetString("name")
  3494. id_card_type, _ := c.GetInt64("id_card_type")
  3495. certificates, _ := c.GetInt64("certificates")
  3496. medical_care, _ := c.GetInt64("medical_care")
  3497. birthday := c.GetString("birthday")
  3498. id_card := c.GetString("id_card")
  3499. register_type, _ := c.GetInt64("register")
  3500. doctor, _ := c.GetInt64("doctor")
  3501. department, _ := c.GetInt64("department")
  3502. gender, _ := c.GetInt64("sex")
  3503. registration_fee, _ := c.GetFloat("registration_fee")
  3504. medical_expenses, _ := c.GetFloat("medical_expenses")
  3505. social_type, _ := c.GetInt64("social_type")
  3506. med_type := c.GetString("social_type")
  3507. admin_user_id, _ := c.GetInt64("admin_user_id")
  3508. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3509. timeLayout := "2006-01-02"
  3510. loc, _ := time.LoadLocation("Local")
  3511. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3512. birthUnix := birthdays.Unix()
  3513. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3514. if err != nil {
  3515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3516. return
  3517. }
  3518. recordDateTime := theTime.Unix()
  3519. adminInfo := c.GetAdminUserInfo()
  3520. var patient service.Patients
  3521. if id == 0 {
  3522. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3523. } else {
  3524. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3525. }
  3526. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3527. if patientPrescription.ID == 0 {
  3528. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3529. }
  3530. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3531. if patient.ID == 0 {
  3532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3533. return
  3534. }
  3535. if len(patient.IdCardNo) == 0 {
  3536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3537. return
  3538. }
  3539. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3540. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3541. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3542. //就诊结算未完成,不能进行二次挂号
  3543. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3544. if len(his) >= 1 {
  3545. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3546. if len(his) >= 1 && order.ID == 0 {
  3547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3548. return
  3549. }
  3550. }
  3551. //var register_log string
  3552. if config.IsOpen == 1 {
  3553. var res ResultTwo
  3554. var res10265 ResultTwo10265
  3555. var PsnNo string
  3556. var PsnCertType string
  3557. var Certno string
  3558. var PsnName string
  3559. var Gend string
  3560. var Naty string
  3561. var Brdy string
  3562. var Age float64
  3563. var infoStr string
  3564. var idetinfoStr string
  3565. var infocode int64
  3566. var verify_number string
  3567. fmt.Println(verify_number)
  3568. if miConfig.MdtrtareaAdmvs == "421300" {
  3569. psn_info, _ := service.GetPsnByPatientId(id)
  3570. PsnNo = psn_info.PsnNo
  3571. PsnCertType = psn_info.PsnCertType
  3572. Certno = psn_info.Certno
  3573. PsnName = psn_info.PsnName
  3574. Gend = psn_info.Gend
  3575. Naty = psn_info.Naty
  3576. Brdy = psn_info.Brdy
  3577. Age = psn_info.Age
  3578. infoStr = psn_info.Insuinfo
  3579. idetinfoStr = psn_info.Idetinfo
  3580. infocode = 0
  3581. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3582. psn_info, _ := service.GetPsnByPatientId(id)
  3583. PsnNo = psn_info.PsnNo
  3584. PsnCertType = psn_info.PsnCertType
  3585. Certno = psn_info.Certno
  3586. PsnName = psn_info.PsnName
  3587. Gend = psn_info.Gend
  3588. Naty = psn_info.Naty
  3589. Brdy = psn_info.Brdy
  3590. Age = psn_info.Age
  3591. infoStr = psn_info.Insuinfo
  3592. idetinfoStr = psn_info.Idetinfo
  3593. infocode = 0
  3594. verify_number = psn_info.VerifyNumber
  3595. } else {
  3596. var result string
  3597. var requestLog string
  3598. if miConfig.UserOrgId == 10138 {
  3599. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3600. } else {
  3601. 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)
  3602. }
  3603. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3604. if miConfig.Code == "H15049901371" {
  3605. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3606. utils.ErrorLog("解析失败:%v", err)
  3607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3608. return
  3609. }
  3610. res.ErrMsg = res10265.ErrMsg
  3611. res.Output = res10265.Output
  3612. res.InfRefmsgid = res10265.InfRefmsgid
  3613. } else {
  3614. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3615. utils.ErrorLog("解析失败:%v", err)
  3616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3617. return
  3618. }
  3619. }
  3620. PsnNo = res.Output.Baseinfo.PsnNo
  3621. PsnCertType = res.Output.Baseinfo.PsnCertType
  3622. Certno = res.Output.Baseinfo.Certno
  3623. PsnName = res.Output.Baseinfo.PsnName
  3624. Gend = res.Output.Baseinfo.Gend
  3625. Naty = res.Output.Baseinfo.Naty
  3626. Brdy = res.Output.Baseinfo.Brdy
  3627. Age = res.Output.Baseinfo.Age
  3628. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3629. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3630. infoStr = string(Iinfos)
  3631. idetinfoStr = string(Idetinfos)
  3632. if miConfig.Code == "H15049901371" {
  3633. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3634. } else {
  3635. infocode = res.Infcode
  3636. }
  3637. }
  3638. if infocode == 0 {
  3639. his := models.VMHisPatient{
  3640. Name: name,
  3641. Gender: gender,
  3642. Birthday: birthUnix,
  3643. MedicalTreatmentType: medical_care,
  3644. IdType: certificates,
  3645. IdCardNo: id_card,
  3646. BalanceAccountsType: settlementValue,
  3647. SocialType: social_type,
  3648. MedicalInsuranceNumber: medical_insurance_card,
  3649. RegisterType: register_type,
  3650. RegisterCost: registration_fee,
  3651. TreatmentCost: medical_expenses,
  3652. Status: 1,
  3653. Ctime: time.Now().Unix(),
  3654. Mtime: time.Now().Unix(),
  3655. PsnNo: PsnNo,
  3656. PsnCertType: PsnCertType,
  3657. Certno: Certno,
  3658. PsnName: PsnName,
  3659. Gend: Gend,
  3660. Naty: Naty,
  3661. Brdy: Brdy,
  3662. Age: Age,
  3663. Iinfo: infoStr,
  3664. Idetinfo: idetinfoStr,
  3665. PatientId: patient.ID,
  3666. RecordDate: theTime.Unix(),
  3667. UserOrgId: adminInfo.CurrentOrgId,
  3668. AdminUserId: admin_user_id,
  3669. IsReturn: 1,
  3670. IdCardType: id_card_type,
  3671. Doctor: doctor,
  3672. Departments: department,
  3673. }
  3674. timestamp := time.Now().Unix()
  3675. tempTime := time.Unix(timestamp, 0)
  3676. timeFormat := tempTime.Format("20060102150405")
  3677. chrgBchno := rand.Intn(100000) + 10000
  3678. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3679. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3680. department, _ := service.GetDepartMentDetail(department)
  3681. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3682. IdCardNo := ""
  3683. if id_card_type == 1 {
  3684. // IdCardNo = medical_insurance_card
  3685. IdCardNo = patient.IdCardNo
  3686. } else {
  3687. IdCardNo = patient.IdCardNo
  3688. }
  3689. var rf []*ResultFive
  3690. json.Unmarshal([]byte(his.Iinfo), &rf)
  3691. var insutypes []*ResultFive
  3692. var insutype string
  3693. var insuplc_admdvs_temp string
  3694. var is390 int = 0
  3695. var is310 int = 0
  3696. for _, item := range rf {
  3697. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3698. insutypes = append(insutypes, item)
  3699. }
  3700. }
  3701. if len(insutypes) == 1 {
  3702. insutype = insutypes[0].Insutype
  3703. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3704. } else {
  3705. for _, i := range insutypes {
  3706. if i.Insutype == "390" {
  3707. is390 = 1
  3708. }
  3709. if i.Insutype == "310" {
  3710. is310 = 1
  3711. }
  3712. }
  3713. }
  3714. if is390 == 1 {
  3715. insutype = "390"
  3716. }
  3717. if is310 == 1 {
  3718. insutype = "310"
  3719. }
  3720. if len(insutypes) == 0 {
  3721. insutype = "310"
  3722. }
  3723. if len(insutypes) == 2 {
  3724. insutype = med_type
  3725. }
  3726. if len(med_type) > 0 {
  3727. insutype = med_type
  3728. }
  3729. //for _, item := range rf {
  3730. // if item.Insutype == insutype {
  3731. // insuplc_admdvs = item.InsuplcAdmdvs
  3732. // }
  3733. //}
  3734. var infocode int64
  3735. var resThree ResultThree
  3736. var resThree10265 ResultThree10265
  3737. if len(insuplc_admdvs) == 0 {
  3738. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3739. } else {
  3740. insuplc_admdvs_temp = insuplc_admdvs
  3741. }
  3742. if miConfig.MdtrtareaAdmvs == "421300" {
  3743. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3744. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3745. "&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
  3746. resp, requestErr := http.Get(api)
  3747. if requestErr != nil {
  3748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3749. return
  3750. }
  3751. body, ioErr := ioutil.ReadAll(resp.Body)
  3752. if ioErr != nil {
  3753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3755. return
  3756. }
  3757. var respJSON map[string]interface{}
  3758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. return
  3762. }
  3763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3764. result, _ := json.Marshal(respJSON)
  3765. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3766. utils.ErrorLog("解析失败:%v", err)
  3767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3768. return
  3769. }
  3770. infocode = resThree.Infcode
  3771. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3772. psn_info, _ := service.GetPsnByPatientId(id)
  3773. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3774. var cert_no string
  3775. if id_card_type == 3 {
  3776. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  3777. cert_no = IdCardNo
  3778. } else {
  3779. bas := strings.Split(psn_info.CardInfo, "|")
  3780. cert_no = bas[2]
  3781. }
  3782. var api string
  3783. if miConfig.MdtrtareaAdmvs == "320921" {
  3784. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3785. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3786. "&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
  3787. } else {
  3788. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3789. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3790. "&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
  3791. }
  3792. resp, requestErr := http.Get(api)
  3793. if requestErr != nil {
  3794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3795. return
  3796. }
  3797. body, ioErr := ioutil.ReadAll(resp.Body)
  3798. if ioErr != nil {
  3799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3801. return
  3802. }
  3803. var respJSON map[string]interface{}
  3804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3807. return
  3808. }
  3809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3810. result, _ := json.Marshal(respJSON)
  3811. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3812. utils.ErrorLog("解析失败:%v", err)
  3813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3814. return
  3815. }
  3816. resThree.ErrMsg = resThree10265.ErrMsg
  3817. resThree.Output = resThree10265.Output
  3818. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3819. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3820. } else {
  3821. 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)
  3822. saveLog(result, requestLog, "2201", "挂号")
  3823. if miConfig.Code == "H15049901371" {
  3824. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3825. utils.ErrorLog("解析失败:%v", err)
  3826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3827. return
  3828. }
  3829. resThree.ErrMsg = resThree10265.ErrMsg
  3830. resThree.Output = resThree10265.Output
  3831. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3832. } else {
  3833. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3834. utils.ErrorLog("解析失败:%v", err)
  3835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3836. return
  3837. }
  3838. }
  3839. if miConfig.Code == "H15049901371" {
  3840. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3841. } else {
  3842. infocode = resThree.Infcode
  3843. }
  3844. }
  3845. if infocode != 0 {
  3846. adminUser := c.GetAdminUserInfo()
  3847. errlog := &models.HisOrderError{
  3848. UserOrgId: adminUser.CurrentOrgId,
  3849. Ctime: time.Now().Unix(),
  3850. Mtime: time.Now().Unix(),
  3851. ErrMsg: resThree.ErrMsg,
  3852. Status: 1,
  3853. PatientId: id,
  3854. RecordTime: recordDateTime,
  3855. Stage: 2,
  3856. }
  3857. service.CreateErrMsgLog(errlog)
  3858. c.ServeSuccessJSON(map[string]interface{}{
  3859. "failed_code": -10,
  3860. "msg": resThree.ErrMsg,
  3861. })
  3862. return
  3863. }
  3864. his.Number = resThree.Output.Data.MdtrtID
  3865. his.PsnNo = resThree.Output.Data.PsnNo
  3866. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3867. his.IdCardNo = patient.IdCardNo
  3868. his.PhoneNumber = patient.Phone
  3869. his.UserOrgId = adminInfo.CurrentOrgId
  3870. his.Insutype = insutype
  3871. his.Ctime = time.Now().Unix()
  3872. his.Mtime = time.Now().Unix()
  3873. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3874. his.Status = 1
  3875. service.UpdateHisPatientStatus(&his)
  3876. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3877. c.ServeSuccessJSON(map[string]interface{}{
  3878. "his_info": his,
  3879. })
  3880. } else {
  3881. adminUser := c.GetAdminUserInfo()
  3882. errlog := &models.HisOrderError{
  3883. UserOrgId: adminUser.CurrentOrgId,
  3884. Ctime: time.Now().Unix(),
  3885. Mtime: time.Now().Unix(),
  3886. ErrMsg: res.ErrMsg,
  3887. Status: 1,
  3888. PatientId: id,
  3889. RecordTime: recordDateTime,
  3890. Stage: 1,
  3891. }
  3892. service.CreateErrMsgLog(errlog)
  3893. c.ServeSuccessJSON(map[string]interface{}{
  3894. "failed_code": -10,
  3895. "msg": res.ErrMsg,
  3896. })
  3897. return
  3898. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3899. }
  3900. }
  3901. }
  3902. //上传明细----预结算----确认订单
  3903. func (c *HisApiController) GetUploadInfo() {
  3904. id, _ := c.GetInt64("id")
  3905. record_time := c.GetString("record_time")
  3906. his_patient_id, _ := c.GetInt64("his_patient_id")
  3907. order_id, _ := c.GetInt64("order_id")
  3908. pay_way, _ := c.GetInt64("pay_way")
  3909. pay_price, _ := c.GetFloat("pay_price")
  3910. pay_card_no := c.GetString("pay_card_no")
  3911. discount_price, _ := c.GetFloat("discount_price")
  3912. preferential_price, _ := c.GetFloat("preferential_price")
  3913. reality_price, _ := c.GetFloat("reality_price")
  3914. found_price, _ := c.GetFloat("found_price")
  3915. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3916. private_price, _ := c.GetFloat("private_price")
  3917. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3918. admin_user_id, _ := c.GetInt64("admin_user_id")
  3919. fapiao_code := c.GetString("fapiao_code")
  3920. fapiao_number := c.GetString("fapiao_number")
  3921. diagnosis_id := c.GetString("diagnosis")
  3922. sick_type, _ := c.GetInt64("sick_type")
  3923. reg_type, _ := c.GetInt64("p_type")
  3924. begin_time := c.GetString("begin_time")
  3925. id_str := c.GetString("ids")
  3926. ids_arr := strings.Split(id_str, ",")
  3927. timeLayout := "2006-01-02"
  3928. loc, _ := time.LoadLocation("Local")
  3929. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3930. if err != nil {
  3931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3932. return
  3933. }
  3934. recordDateTime := theTime.Unix()
  3935. adminUser := c.GetAdminUserInfo()
  3936. var tempOrder models.HisOrder
  3937. tempOrder, _ = service.GetHisOrderByID(order_id)
  3938. var prescriptions []*models.HisPrescription
  3939. var start_time int64
  3940. var end_time int64
  3941. //if adminUser.CurrentOrgId == 10106{
  3942. // if len(fapiao_code) == 0{
  3943. // fapiao_code = "144072080589"
  3944. // }
  3945. // if len(fapiao_number) == 0{
  3946. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3947. // if order.ID == 0{
  3948. // fapiao_number = "00001520"
  3949. // }else{
  3950. // //fapiao_code = "00001520"
  3951. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3952. // var zero string
  3953. // if fpNumber >= 1000{
  3954. // zero = "0000" + strconv.Itoa(fpNumber)
  3955. // }else if fpNumber >= 10000{
  3956. // zero = "000" + strconv.Itoa(fpNumber)
  3957. // } else if fpNumber >= 100000{
  3958. // zero = "00" + strconv.Itoa(fpNumber)
  3959. // } else if fpNumber >= 1000000{
  3960. // zero = "0" + strconv.Itoa(fpNumber)
  3961. // }else {
  3962. // zero = strconv.Itoa(fpNumber)
  3963. // }
  3964. // fapiao_number = zero
  3965. // }
  3966. // }
  3967. //}
  3968. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3969. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3970. var patientPrescription models.HisPrescriptionInfo
  3971. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3972. if patientPrescription.ID == 0 {
  3973. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3974. }
  3975. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3976. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3977. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3978. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3979. var config []*models.HisXtDiagnoseConfig
  3980. for _, item := range diagnosis_ids {
  3981. id, _ := strconv.ParseInt(item, 10, 64)
  3982. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3983. config = append(config, &diagnosisConfig)
  3984. }
  3985. sickConfig, _ := service.FindSickById(sick_type)
  3986. //if tempOrder.ID == 0 {
  3987. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3988. //}
  3989. if tempOrder.ID == 0 {
  3990. var result string
  3991. var requestLog string
  3992. var res2 ResultSix
  3993. var ressix10265 ResultSix10265
  3994. if miConfig.MdtrtareaAdmvs == "421300" {
  3995. data := make(map[string]interface{})
  3996. client := &http.Client{}
  3997. data["psn_no"] = his.PsnNo
  3998. data["mdtrt_id"] = his.Number
  3999. data["doctor"] = roles.UserName
  4000. data["department"] = department.Name
  4001. data["org_name"] = miConfig.OrgName
  4002. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4003. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4004. data["fixmedins_code"] = miConfig.Code
  4005. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4006. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4007. data["secret_key"] = miConfig.SecretKey
  4008. data["sick_code"] = sickConfig.CountryCode
  4009. data["sick_name"] = sickConfig.ClassName
  4010. data["dept"] = strconv.FormatInt(department.ID, 10)
  4011. data["config"] = config
  4012. data["begin_time"] = begin_time
  4013. bytesData, _ := json.Marshal(data)
  4014. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4015. resp, _ := client.Do(req)
  4016. defer resp.Body.Close()
  4017. body, ioErr := ioutil.ReadAll(resp.Body)
  4018. if ioErr != nil {
  4019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4021. return
  4022. }
  4023. var respJSON map[string]interface{}
  4024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4027. return
  4028. }
  4029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4030. userJSONBytes, _ := json.Marshal(respJSON)
  4031. fmt.Println("log")
  4032. fmt.Println(string(userJSONBytes))
  4033. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4034. utils.ErrorLog("解析失败:%v", err)
  4035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4036. return
  4037. }
  4038. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4039. //江苏地区国家医保医疗类别
  4040. //职工透析:医疗类别选特殊情况门诊9933
  4041. //居民血透门慢: 医疗类别选门诊慢病1402
  4042. //var med_type string
  4043. //if his.Insutype == "310" {
  4044. // if reg_type == 14 {
  4045. // med_type = "9933"
  4046. // } else if reg_type == 11 {
  4047. // med_type = "11"
  4048. //
  4049. // }
  4050. //} else if his.Insutype == "390" {
  4051. // if reg_type == 14 {
  4052. // med_type = "1402"
  4053. // } else if reg_type == 11 {
  4054. // med_type = "11"
  4055. // }
  4056. //}
  4057. data := make(map[string]interface{})
  4058. client := &http.Client{}
  4059. data["psn_no"] = his.PsnNo
  4060. data["mdtrt_id"] = his.Number
  4061. data["doctor"] = roles.UserName
  4062. data["department"] = department.Name
  4063. data["org_name"] = miConfig.OrgName
  4064. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4065. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4066. data["fixmedins_code"] = miConfig.Code
  4067. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4068. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4069. data["secret_key"] = miConfig.SecretKey
  4070. data["sick_code"] = sickConfig.CountryCode
  4071. data["sick_name"] = sickConfig.ClassName
  4072. data["url"] = miConfig.Url
  4073. data["ak"] = miConfig.AccessKey
  4074. data["begin_time"] = begin_time
  4075. data["cainfo"] = miConfig.Cainfo
  4076. data["dept"] = strconv.FormatInt(department.ID, 10)
  4077. data["config"] = config
  4078. bytesData, _ := json.Marshal(data)
  4079. var req *http.Request
  4080. if miConfig.MdtrtareaAdmvs == "320921" {
  4081. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4082. //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 +
  4083. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4084. } else {
  4085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4086. }
  4087. resp, _ := client.Do(req)
  4088. defer resp.Body.Close()
  4089. body, ioErr := ioutil.ReadAll(resp.Body)
  4090. if ioErr != nil {
  4091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4093. return
  4094. }
  4095. var respJSON map[string]interface{}
  4096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4099. return
  4100. }
  4101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4102. userJSONBytes, _ := json.Marshal(respJSON)
  4103. fmt.Println("log")
  4104. fmt.Println(string(userJSONBytes))
  4105. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4106. utils.ErrorLog("解析失败:%v", err)
  4107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4108. return
  4109. }
  4110. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4111. res2.Output = ressix10265.Output
  4112. res2.ErrMsg = ressix10265.ErrMsg
  4113. res2.Cainfo = ressix10265.Cainfo
  4114. res2.WarnMsg = ressix10265.WarnMsg
  4115. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4116. res2.Infcode = infocode
  4117. } else {
  4118. if miConfig.MdtrtareaAdmvs == "440781" { //
  4119. 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)
  4120. } else {
  4121. if miConfig.Code == "H15049901371" {
  4122. //赤峰地区国家医保医疗类别
  4123. //职工透析:医疗类别选特殊情况门诊990502
  4124. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4125. var med_type string
  4126. if his.Insutype == "390" {
  4127. if reg_type == 14 {
  4128. med_type = "9933"
  4129. } else if reg_type == 11 {
  4130. med_type = "11"
  4131. }
  4132. } else if his.Insutype == "310" {
  4133. if reg_type == 14 {
  4134. med_type = "990502"
  4135. } else if reg_type == 11 {
  4136. med_type = "11"
  4137. }
  4138. }
  4139. 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)
  4140. } else {
  4141. 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)
  4142. }
  4143. }
  4144. saveLog(result, requestLog, "2203", "上传就诊信息")
  4145. var respJSON2 map[string]interface{}
  4146. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4149. return
  4150. }
  4151. userJSONBytes2, _ := json.Marshal(respJSON2)
  4152. if miConfig.Code == "H15049901371" {
  4153. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4154. utils.ErrorLog("解析失败:%v", err)
  4155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4156. return
  4157. }
  4158. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4159. res2.Output = ressix10265.Output
  4160. res2.ErrMsg = ressix10265.ErrMsg
  4161. res2.Cainfo = ressix10265.Cainfo
  4162. res2.WarnMsg = ressix10265.WarnMsg
  4163. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4164. res2.Infcode = infocode
  4165. } else {
  4166. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4167. utils.ErrorLog("解析失败:%v", err)
  4168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4169. return
  4170. }
  4171. }
  4172. }
  4173. if res2.Infcode != 0 {
  4174. adminUser := c.GetAdminUserInfo()
  4175. errlog := &models.HisOrderError{
  4176. UserOrgId: adminUser.CurrentOrgId,
  4177. Ctime: time.Now().Unix(),
  4178. Mtime: time.Now().Unix(),
  4179. ErrMsg: res2.ErrMsg,
  4180. Status: 1,
  4181. PatientId: id,
  4182. RecordTime: recordDateTime,
  4183. Stage: 3,
  4184. }
  4185. service.CreateErrMsgLog(errlog)
  4186. c.ServeSuccessJSON(map[string]interface{}{
  4187. "failed_code": -10,
  4188. "msg": res2.ErrMsg,
  4189. })
  4190. return
  4191. } else {
  4192. his.Diagnosis = diagnosis_id
  4193. his.SickType = sickConfig.ID
  4194. //var p_type int64
  4195. //if reg_type == 1111 || reg_type == 1112 {
  4196. // p_type = 11
  4197. //
  4198. //}
  4199. his.PType = fmt.Sprintf("%d", reg_type)
  4200. service.UpdateHisPatientThree(&his)
  4201. data := make(map[string]interface{})
  4202. if settle_accounts_type == 1 { //日结
  4203. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4204. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4205. } else {
  4206. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4207. }
  4208. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4209. data["pre"] = prescriptions
  4210. } else { //月结
  4211. start_time_str := c.GetString("start_time")
  4212. end_time_str := c.GetString("end_time")
  4213. timeLayout := "2006-01-02"
  4214. loc, _ := time.LoadLocation("Local")
  4215. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4216. if err != nil {
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4218. return
  4219. }
  4220. recordStartTime := theStartTime.Unix()
  4221. start_time = recordStartTime
  4222. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4223. if err != nil {
  4224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4225. return
  4226. }
  4227. recordEndTime := theEndTime.Unix()
  4228. end_time = recordEndTime
  4229. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4230. data["pre"] = prescriptions
  4231. }
  4232. timestamp := time.Now().Unix()
  4233. tempTime := time.Unix(timestamp, 0)
  4234. timeFormat := tempTime.Format("20060102150405")
  4235. chrgBchno := rand.Intn(100000) + 10000
  4236. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4237. strconv.FormatInt(his.PatientId, 10)
  4238. client := &http.Client{}
  4239. data["psn_no"] = his.PsnNo
  4240. data["mdtrt_id"] = his.Number
  4241. data["chrg_bchno"] = chrg_bchno
  4242. data["org_name"] = miConfig.OrgName
  4243. data["doctor"] = roles.UserName
  4244. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4245. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4246. data["fixmedins_code"] = miConfig.Code
  4247. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4248. // data["dept_code"] = "15"
  4249. //} else {
  4250. data["dept_code"] = department.Number
  4251. //}
  4252. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4253. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4254. data["secret_key"] = miConfig.SecretKey
  4255. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4256. data["url"] = miConfig.Url
  4257. data["ak"] = miConfig.AccessKey
  4258. data["new_doctor_name"] = patientPrescription.Doctor
  4259. data["diag_code"] = sickConfig.CountryCode
  4260. data["cainfo"] = miConfig.Cainfo
  4261. var ids []int64
  4262. for _, item := range prescriptions {
  4263. ids = append(ids, item.ID)
  4264. }
  4265. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4266. if config.IsOpen == 1 { //对接了医保,走医保流程
  4267. var res ResultFour
  4268. var resFour10265 ResultFour10265
  4269. if miConfig.MdtrtareaAdmvs == "421300" {
  4270. bytesData, _ := json.Marshal(data)
  4271. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4272. resp, _ := client.Do(req)
  4273. defer resp.Body.Close()
  4274. body, ioErr := ioutil.ReadAll(resp.Body)
  4275. if ioErr != nil {
  4276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4278. return
  4279. }
  4280. var respJSON map[string]interface{}
  4281. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4284. return
  4285. }
  4286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4287. userJSONBytes, _ := json.Marshal(respJSON)
  4288. fmt.Println("log")
  4289. fmt.Println(string(userJSONBytes))
  4290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4291. utils.ErrorLog("解析失败:%v", err)
  4292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4293. return
  4294. }
  4295. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4296. bytesData, _ := json.Marshal(data)
  4297. var req *http.Request
  4298. if miConfig.MdtrtareaAdmvs == "320921" {
  4299. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4300. } else {
  4301. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4302. }
  4303. resp, _ := client.Do(req)
  4304. defer resp.Body.Close()
  4305. body, ioErr := ioutil.ReadAll(resp.Body)
  4306. if ioErr != nil {
  4307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. return
  4310. }
  4311. var respJSON map[string]interface{}
  4312. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4315. return
  4316. }
  4317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4318. userJSONBytes, _ := json.Marshal(respJSON)
  4319. fmt.Println("log")
  4320. fmt.Println(string(userJSONBytes))
  4321. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4322. utils.ErrorLog("解析失败:%v", err)
  4323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4324. return
  4325. }
  4326. res.InfRefmsgid = resFour10265.InfRefmsgid
  4327. res.Output = resFour10265.Output
  4328. res.ErrMsg = resFour10265.ErrMsg
  4329. res.Cainfo = resFour10265.Cainfo
  4330. res.WarnMsg = resFour10265.WarnMsg
  4331. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4332. res.Infcode = infocode
  4333. } else {
  4334. if miConfig.Code == "H15049901371" {
  4335. 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)
  4336. var dat map[string]interface{}
  4337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4338. fmt.Println(dat)
  4339. } else {
  4340. fmt.Println(err)
  4341. }
  4342. saveLog(result, request_log, "2204", "上传费用明细")
  4343. userJSONBytes, _ := json.Marshal(dat)
  4344. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4345. utils.ErrorLog("解析失败:%v", err)
  4346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4347. return
  4348. }
  4349. res.InfRefmsgid = resFour10265.InfRefmsgid
  4350. res.Output = resFour10265.Output
  4351. res.ErrMsg = resFour10265.ErrMsg
  4352. res.Cainfo = resFour10265.Cainfo
  4353. res.WarnMsg = resFour10265.WarnMsg
  4354. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4355. res.Infcode = infocode
  4356. } else {
  4357. 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)
  4358. var dat map[string]interface{}
  4359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4360. fmt.Println(dat)
  4361. } else {
  4362. fmt.Println(err)
  4363. }
  4364. saveLog(result, request_log, "2204", "上传费用明细")
  4365. userJSONBytes, _ := json.Marshal(dat)
  4366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4367. utils.ErrorLog("解析失败:%v", err)
  4368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4369. return
  4370. }
  4371. }
  4372. }
  4373. if res.Infcode == 0 {
  4374. order := &models.HisOrder{
  4375. UserOrgId: adminUser.CurrentOrgId,
  4376. HisPatientId: his.ID,
  4377. PatientId: his.PatientId,
  4378. SettleAccountsDate: recordDateTime,
  4379. MdtrtId: his.Number,
  4380. PsnNo: his.PsnNo,
  4381. MedType: strconv.FormatInt(reg_type, 10),
  4382. Ctime: time.Now().Unix(),
  4383. Mtime: time.Now().Unix(),
  4384. Status: 1,
  4385. Number: chrg_bchno,
  4386. Infcode: res.Infcode,
  4387. WarnMsg: res.WarnMsg,
  4388. Cainfo: res.Cainfo,
  4389. ErrMsg: res.ErrMsg,
  4390. RespondTime: res.RefmsgTime,
  4391. InfRefmsgid: res.InfRefmsgid,
  4392. OrderStatus: 1,
  4393. PayWay: pay_way,
  4394. PayPrice: pay_price,
  4395. PayCardNo: pay_card_no,
  4396. DiscountPrice: discount_price,
  4397. PreferentialPrice: preferential_price,
  4398. RealityPrice: reality_price,
  4399. FoundPrice: found_price,
  4400. MedicalInsurancePrice: medical_insurance_price,
  4401. PrivatePrice: private_price,
  4402. IsMedicineInsurance: 1,
  4403. SettleType: settle_accounts_type,
  4404. SettleStartTime: start_time,
  4405. SettleEndTime: end_time,
  4406. Creator: roles.AdminUserId,
  4407. Modify: roles.AdminUserId,
  4408. FaPiaoNumber: fapiao_number,
  4409. FaPiaoCode: fapiao_code,
  4410. PType: 2,
  4411. Diagnosis: diagnosis_id,
  4412. }
  4413. err = service.CreateOrder(order)
  4414. if err != nil {
  4415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4416. return
  4417. }
  4418. for _, item := range res.Output.Result {
  4419. temp := strings.Split(item.FeedetlSn, "-")
  4420. var advice_id int64 = 0
  4421. var project_id int64 = 0
  4422. var types int64 = 0
  4423. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4424. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4425. if temp[1] == "1" {
  4426. advice_id = id
  4427. project_id = 0
  4428. } else if temp[1] == "2" {
  4429. advice_id = 0
  4430. project_id = id
  4431. }
  4432. info := &models.HisOrderInfo{
  4433. OrderNumber: order.Number,
  4434. FeedetlSn: item.FeedetlSn,
  4435. UploadDate: time.Now().Unix(),
  4436. AdviceId: advice_id,
  4437. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4438. Cnt: item.Cnt,
  4439. Pric: float64(item.Pric),
  4440. PatientId: his.PatientId,
  4441. PricUplmtAmt: item.PricUplmtAmt,
  4442. SelfpayProp: item.SelfpayProp,
  4443. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4444. OverlmtAmt: item.OverlmtAmt,
  4445. PreselfpayAmt: item.PreselfpayAmt,
  4446. BasMednFlag: item.BasMednFlag,
  4447. MedChrgitmType: item.MedChrgitmType,
  4448. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4449. Status: 1,
  4450. Memo: item.Memo,
  4451. Mtime: time.Now().Unix(),
  4452. InscpScpAmt: item.InscpScpAmt,
  4453. DrtReimFlag: item.DrtReimFlag,
  4454. Ctime: time.Now().Unix(),
  4455. ListSpItemFlag: item.ListSpItemFlag,
  4456. ChldMedcFlag: item.ChldMedcFlag,
  4457. LmtUsedFlag: item.LmtUsedFlag,
  4458. ChrgitmLv: item.ChrgitmLv,
  4459. UserOrgId: adminUser.CurrentOrgId,
  4460. HisPatientId: his.ID,
  4461. OrderId: order.ID,
  4462. ProjectId: project_id,
  4463. Type: types,
  4464. }
  4465. service.CreateOrderInfo(info)
  4466. }
  4467. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4468. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4469. var total float64
  4470. for _, item := range prescriptions {
  4471. if item.Type == 1 { //药品
  4472. for _, subItem := range item.HisDoctorAdviceInfo {
  4473. total = total + (subItem.Price * subItem.PrescribingNumber)
  4474. }
  4475. }
  4476. if item.Type == 2 { //项目
  4477. for _, subItem := range item.HisPrescriptionProject {
  4478. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4479. total = total + (subItem.Price * cnt)
  4480. }
  4481. }
  4482. }
  4483. for _, item := range prescriptions {
  4484. for _, subItem := range item.HisAdditionalCharge {
  4485. total = total + (subItem.Price * float64(subItem.Count))
  4486. }
  4487. }
  4488. var allTotal string
  4489. if adminUser.CurrentOrgId == 9919 {
  4490. allTotal = fmt.Sprintf("%.4f", total)
  4491. } else {
  4492. allTotal = fmt.Sprintf("%.4f", total)
  4493. }
  4494. if res.Infcode == 0 {
  4495. var rf []*ResultFive
  4496. json.Unmarshal([]byte(his.Iinfo), &rf)
  4497. chrg_bchno := chrg_bchno
  4498. cert_no := his.Certno
  4499. var insutypes []string
  4500. var insutype string
  4501. var is390 int = 0
  4502. var is310 int = 0
  4503. for _, item := range rf {
  4504. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4505. insutypes = append(insutypes, item.Insutype)
  4506. }
  4507. }
  4508. if len(insutypes) == 1 {
  4509. insutype = insutypes[0]
  4510. } else {
  4511. for _, i := range insutypes {
  4512. if i == "390" {
  4513. is390 = 1
  4514. }
  4515. if i == "310" {
  4516. is310 = 1
  4517. }
  4518. }
  4519. }
  4520. if is390 == 1 {
  4521. insutype = "390"
  4522. }
  4523. if is310 == 1 {
  4524. insutype = "310"
  4525. }
  4526. if len(insutypes) == 0 {
  4527. insutype = "310"
  4528. }
  4529. if len(insutypes) == 2 {
  4530. insutype = strconv.FormatInt(his.SocialType, 10)
  4531. }
  4532. insutype = strconv.FormatInt(his.SocialType, 10)
  4533. //insutype = "390"
  4534. if his.IdCardType == 1 {
  4535. // cert_no = his.MedicalInsuranceNumber
  4536. cert_no = his.Certno
  4537. } else {
  4538. cert_no = his.Certno
  4539. }
  4540. var res ResultSeven
  4541. var resSeven10265 ResultSeven10265
  4542. var src_resquest string
  4543. var result2 string
  4544. var acct_used_flag string
  4545. fmt.Println("pay_way")
  4546. fmt.Println(pay_way)
  4547. fmt.Println("pay_way")
  4548. if pay_way == 4 {
  4549. acct_used_flag = "1"
  4550. } else {
  4551. acct_used_flag = "0"
  4552. }
  4553. if miConfig.MdtrtareaAdmvs == "421300" {
  4554. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4555. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4556. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4557. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4558. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4559. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4560. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4561. resp, requestErr := http.Get(api)
  4562. if requestErr != nil {
  4563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4564. return
  4565. }
  4566. body, ioErr := ioutil.ReadAll(resp.Body)
  4567. if ioErr != nil {
  4568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4570. return
  4571. }
  4572. var respJSON map[string]interface{}
  4573. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4576. return
  4577. }
  4578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4579. result, _ := json.Marshal(respJSON)
  4580. if miConfig.Code == "H15049901371" {
  4581. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4582. utils.ErrorLog("解析失败:%v", err)
  4583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4584. return
  4585. }
  4586. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4587. res.Output = resSeven10265.Output
  4588. res.ErrMsg = resSeven10265.ErrMsg
  4589. res.Cainfo = resSeven10265.Cainfo
  4590. res.WarnMsg = resSeven10265.WarnMsg
  4591. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4592. res.Infcode = infocode
  4593. } else {
  4594. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4595. utils.ErrorLog("解析失败:%v", err)
  4596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4597. return
  4598. }
  4599. }
  4600. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4601. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4602. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4603. //psn_info, _ := service.GetPsnByPatientId(id)
  4604. bas := strings.Split(psn_info.CardInfo, "|")
  4605. if his.IdCardType == 1 {
  4606. cert_no = bas[2]
  4607. } else if his.IdCardType == 3 {
  4608. cert_no = his.Certno
  4609. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  4610. } else {
  4611. cert_no = bas[1]
  4612. }
  4613. //江苏地区国家医保医疗类别
  4614. //职工透析:医疗类别选特殊情况门诊9933
  4615. //居民血透门慢: 医疗类别选门诊慢病1402
  4616. //var med_type string
  4617. //if his.Insutype == "310" {
  4618. // if reg_type == 14 {
  4619. // med_type = "9933"
  4620. // } else if reg_type == 11 {
  4621. // med_type = "11"
  4622. //
  4623. // }
  4624. //} else if his.Insutype == "390" {
  4625. // if reg_type == 14 {
  4626. // med_type = "1402"
  4627. // } else if reg_type == 11 {
  4628. // med_type = "11"
  4629. // }
  4630. //}
  4631. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4632. var api string
  4633. if miConfig.MdtrtareaAdmvs == "320921" {
  4634. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4635. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4636. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4638. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4639. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4640. "&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
  4641. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4642. } else {
  4643. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4644. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4645. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4646. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4647. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4648. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4649. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4650. "&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
  4651. }
  4652. resp, requestErr := http.Get(api)
  4653. if requestErr != nil {
  4654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4655. return
  4656. }
  4657. body, ioErr := ioutil.ReadAll(resp.Body)
  4658. if ioErr != nil {
  4659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4661. return
  4662. }
  4663. var respJSON map[string]interface{}
  4664. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4667. return
  4668. }
  4669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4670. result, _ := json.Marshal(respJSON)
  4671. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4672. utils.ErrorLog("解析失败:%v", err)
  4673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4674. return
  4675. }
  4676. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4677. res.Output = resSeven10265.Output
  4678. res.ErrMsg = resSeven10265.ErrMsg
  4679. res.Cainfo = resSeven10265.Cainfo
  4680. res.WarnMsg = resSeven10265.WarnMsg
  4681. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4682. res.Infcode = infocode
  4683. } else {
  4684. if miConfig.Code == "H15049901371" {
  4685. //赤峰地区国家医保医疗类别
  4686. //职工透析:医疗类别选特殊情况门诊990502
  4687. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4688. var med_type string
  4689. if his.Insutype == "390" {
  4690. if reg_type == 14 {
  4691. med_type = "9933"
  4692. } else if reg_type == 11 {
  4693. med_type = "11"
  4694. }
  4695. } else if his.Insutype == "310" {
  4696. if reg_type == 14 {
  4697. med_type = "990502"
  4698. } else if reg_type == 11 {
  4699. med_type = "11"
  4700. }
  4701. }
  4702. 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)
  4703. } else {
  4704. 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)
  4705. }
  4706. //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)
  4707. var dat map[string]interface{}
  4708. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4709. fmt.Println(dat)
  4710. } else {
  4711. fmt.Println(err)
  4712. }
  4713. saveLog(result2, src_resquest, "2207", "结算")
  4714. userJSONBytes, _ := json.Marshal(dat)
  4715. if miConfig.Code == "H15049901371" {
  4716. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4717. utils.ErrorLog("解析失败:%v", err)
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4719. return
  4720. }
  4721. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4722. res.Output = resSeven10265.Output
  4723. res.ErrMsg = resSeven10265.ErrMsg
  4724. res.Cainfo = resSeven10265.Cainfo
  4725. res.WarnMsg = resSeven10265.WarnMsg
  4726. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4727. res.Infcode = infocode
  4728. } else {
  4729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4730. utils.ErrorLog("解析失败:%v", err)
  4731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4732. return
  4733. }
  4734. }
  4735. }
  4736. if res.Infcode != 0 {
  4737. errlog := &models.HisOrderError{
  4738. UserOrgId: adminUser.CurrentOrgId,
  4739. Ctime: time.Now().Unix(),
  4740. Mtime: time.Now().Unix(),
  4741. Number: chrg_bchno,
  4742. ErrMsg: res.ErrMsg,
  4743. Status: 1,
  4744. PatientId: id,
  4745. RecordTime: recordDateTime,
  4746. Stage: 6,
  4747. }
  4748. service.CreateErrMsgLog(errlog)
  4749. c.ServeSuccessJSON(map[string]interface{}{
  4750. "failed_code": -10,
  4751. "msg": res.ErrMsg,
  4752. })
  4753. return
  4754. } else {
  4755. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4756. order.OrderStatus = 2
  4757. order.Status = 1
  4758. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4759. order.SetlId = res.Output.Setlinfo.SetlID
  4760. order.PsnNo = res.Output.Setlinfo.PsnNo
  4761. order.PsnName = res.Output.Setlinfo.PsnName
  4762. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4763. order.Certno = res.Output.Setlinfo.Certno
  4764. order.Gend = res.Output.Setlinfo.Gend
  4765. order.Naty = res.Output.Setlinfo.Naty
  4766. order.Age = res.Output.Setlinfo.Age
  4767. order.Insutype = res.Output.Setlinfo.Insutype
  4768. order.PsnType = res.Output.Setlinfo.PsnType
  4769. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4770. order.SetlTime = res.Output.Setlinfo.SetlTime
  4771. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4772. if res.Output.Setlinfo.MedType == "140101" {
  4773. order.MedType = "14"
  4774. } else {
  4775. order.MedType = res.Output.Setlinfo.MedType
  4776. }
  4777. if reg_type == 1112 {
  4778. order.MedType = "1112"
  4779. }
  4780. if reg_type == 1111 {
  4781. order.MedType = "1111"
  4782. }
  4783. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4784. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4785. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4786. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4787. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4788. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4789. order.HifpPay = res.Output.Setlinfo.HifpPay
  4790. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4791. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4792. order.HifesPay = res.Output.Setlinfo.HifesPay
  4793. order.HifobPay = res.Output.Setlinfo.HifobPay
  4794. order.MafPay = res.Output.Setlinfo.MafPay
  4795. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4796. order.OthPay = res.Output.Setlinfo.OthPay
  4797. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4798. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4799. order.AcctPay = res.Output.Setlinfo.AcctPay
  4800. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4801. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4802. order.Balc = res.Output.Setlinfo.Balc
  4803. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4804. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4805. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4806. order.ClrType = res.Output.Setlinfo.ClrType
  4807. order.ClrWay = res.Output.Setlinfo.ClrWay
  4808. order.Creator = order.Creator
  4809. order.Modify = roles.AdminUserId
  4810. order.RequestLog = src_resquest
  4811. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4812. detailStr := string(setlDetail)
  4813. order.SetlDetail = detailStr
  4814. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4815. err = service.UpDateOrder(order)
  4816. if err == nil {
  4817. c.ServeSuccessJSON(map[string]interface{}{
  4818. "msg": "结算成功",
  4819. })
  4820. } else {
  4821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4822. return
  4823. }
  4824. }
  4825. } else {
  4826. adminUser := c.GetAdminUserInfo()
  4827. errlog := &models.HisOrderError{
  4828. UserOrgId: adminUser.CurrentOrgId,
  4829. Ctime: time.Now().Unix(),
  4830. Mtime: time.Now().Unix(),
  4831. ErrMsg: res.ErrMsg,
  4832. Status: 1,
  4833. PatientId: id,
  4834. RecordTime: recordDateTime,
  4835. Stage: 4,
  4836. }
  4837. service.CreateErrMsgLog(errlog)
  4838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4839. return
  4840. }
  4841. } else {
  4842. adminUser := c.GetAdminUserInfo()
  4843. errlog := &models.HisOrderError{
  4844. UserOrgId: adminUser.CurrentOrgId,
  4845. Ctime: time.Now().Unix(),
  4846. Mtime: time.Now().Unix(),
  4847. ErrMsg: res.ErrMsg,
  4848. Status: 1,
  4849. PatientId: id,
  4850. RecordTime: recordDateTime,
  4851. Stage: 4,
  4852. }
  4853. service.CreateErrMsgLog(errlog)
  4854. c.ServeSuccessJSON(map[string]interface{}{
  4855. "failed_code": -10,
  4856. "msg": res.ErrMsg,
  4857. })
  4858. return
  4859. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4860. //return
  4861. }
  4862. }
  4863. }
  4864. } else if tempOrder.ID > 0 {
  4865. if tempOrder.IsPre == 1 {
  4866. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4867. var rf []*ResultFive
  4868. json.Unmarshal([]byte(his.Iinfo), &rf)
  4869. chrg_bchno := tempOrder.Number
  4870. cert_no := his.Certno
  4871. var insutypes []string
  4872. var insutype string
  4873. var is390 int = 0
  4874. var is310 int = 0
  4875. for _, item := range rf {
  4876. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4877. insutypes = append(insutypes, item.Insutype)
  4878. }
  4879. }
  4880. if len(insutypes) == 1 {
  4881. insutype = insutypes[0]
  4882. } else {
  4883. for _, i := range insutypes {
  4884. if i == "390" {
  4885. is390 = 1
  4886. }
  4887. if i == "310" {
  4888. is310 = 1
  4889. }
  4890. }
  4891. }
  4892. if is390 == 1 {
  4893. insutype = "390"
  4894. }
  4895. if is310 == 1 {
  4896. insutype = "310"
  4897. }
  4898. if len(insutypes) == 0 {
  4899. insutype = "310"
  4900. }
  4901. if len(insutypes) == 2 {
  4902. insutype = strconv.FormatInt(his.SocialType, 64)
  4903. }
  4904. //insutype = "390"
  4905. if his.IdCardType == 1 {
  4906. // cert_no = his.MedicalInsuranceNumber
  4907. cert_no = his.Certno
  4908. } else {
  4909. cert_no = his.Certno
  4910. }
  4911. var res ResultSeven
  4912. var resSeven10265 ResultSeven10265
  4913. var src_resquest string
  4914. var result2 string
  4915. var acct_used_flag string
  4916. fmt.Println("pay_way")
  4917. fmt.Println(pay_way)
  4918. fmt.Println("pay_way")
  4919. if pay_way == 4 {
  4920. acct_used_flag = "1"
  4921. } else {
  4922. acct_used_flag = "0"
  4923. }
  4924. if miConfig.MdtrtareaAdmvs == "421300" {
  4925. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4926. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4927. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4928. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4929. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4930. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4931. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4932. resp, requestErr := http.Get(api)
  4933. if requestErr != nil {
  4934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4935. return
  4936. }
  4937. body, ioErr := ioutil.ReadAll(resp.Body)
  4938. if ioErr != nil {
  4939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4941. return
  4942. }
  4943. var respJSON map[string]interface{}
  4944. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4947. return
  4948. }
  4949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4950. result, _ := json.Marshal(respJSON)
  4951. fmt.Println("log")
  4952. fmt.Println(string(result))
  4953. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4954. utils.ErrorLog("解析失败:%v", err)
  4955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4956. return
  4957. }
  4958. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4959. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4960. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4961. //psn_info, _ := service.GetPsnByPatientId(id)
  4962. bas := strings.Split(psn_info.CardInfo, "|")
  4963. if his.IdCardType == 1 {
  4964. cert_no = bas[2]
  4965. } else {
  4966. cert_no = bas[1]
  4967. }
  4968. //江苏地区国家医保医疗类别
  4969. //职工透析:医疗类别选特殊情况门诊9933
  4970. //居民血透门慢: 医疗类别选门诊慢病1402
  4971. //var med_type string
  4972. //if his.Insutype == "310" {
  4973. // if reg_type == 14 {
  4974. // med_type = "9933"
  4975. // } else if reg_type == 11 {
  4976. // med_type = "11"
  4977. //
  4978. // }
  4979. //} else if his.Insutype == "390" {
  4980. // if reg_type == 14 {
  4981. // med_type = "1402"
  4982. // } else if reg_type == 11 {
  4983. // med_type = "11"
  4984. // }
  4985. //}
  4986. var api string
  4987. if miConfig.MdtrtareaAdmvs == "320921" {
  4988. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4989. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4990. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4991. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4992. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4993. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4994. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4995. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4996. } else {
  4997. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4998. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4999. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5000. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5001. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5002. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5003. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5004. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5005. }
  5006. resp, requestErr := http.Get(api)
  5007. if requestErr != nil {
  5008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5009. return
  5010. }
  5011. body, ioErr := ioutil.ReadAll(resp.Body)
  5012. if ioErr != nil {
  5013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5015. return
  5016. }
  5017. var respJSON map[string]interface{}
  5018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5021. return
  5022. }
  5023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5024. result, _ := json.Marshal(respJSON)
  5025. fmt.Println("log")
  5026. fmt.Println(string(result))
  5027. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5028. utils.ErrorLog("解析失败:%v", err)
  5029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5030. return
  5031. }
  5032. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5033. res.Output = resSeven10265.Output
  5034. res.ErrMsg = resSeven10265.ErrMsg
  5035. res.Cainfo = resSeven10265.Cainfo
  5036. res.WarnMsg = resSeven10265.WarnMsg
  5037. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5038. res.Infcode = infocode
  5039. } else {
  5040. var src_resquest string
  5041. if miConfig.Code == "H15049901371" {
  5042. //赤峰地区国家医保医疗类别
  5043. //职工透析:医疗类别选特殊情况门诊990502
  5044. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5045. var med_type string
  5046. if his.Insutype == "390" {
  5047. if reg_type == 14 {
  5048. med_type = "9933"
  5049. } else if reg_type == 11 {
  5050. med_type = "11"
  5051. }
  5052. } else if his.Insutype == "310" {
  5053. if reg_type == 14 {
  5054. med_type = "990502"
  5055. } else if reg_type == 11 {
  5056. med_type = "11"
  5057. }
  5058. }
  5059. 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)
  5060. } else {
  5061. 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)
  5062. }
  5063. var dat map[string]interface{}
  5064. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5065. fmt.Println(dat)
  5066. } else {
  5067. fmt.Println(err)
  5068. }
  5069. saveLog(result2, src_resquest, "2207", "结算")
  5070. userJSONBytes, _ := json.Marshal(dat)
  5071. if miConfig.Code == "H15049901371" {
  5072. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5073. utils.ErrorLog("解析失败:%v", err)
  5074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5075. return
  5076. }
  5077. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5078. res.Output = resSeven10265.Output
  5079. res.ErrMsg = resSeven10265.ErrMsg
  5080. res.Cainfo = resSeven10265.Cainfo
  5081. res.WarnMsg = resSeven10265.WarnMsg
  5082. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5083. res.Infcode = infocode
  5084. } else {
  5085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5086. utils.ErrorLog("解析失败:%v", err)
  5087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5088. return
  5089. }
  5090. }
  5091. }
  5092. if res.Infcode != 0 {
  5093. errlog := &models.HisOrderError{
  5094. UserOrgId: adminUser.CurrentOrgId,
  5095. Ctime: time.Now().Unix(),
  5096. Mtime: time.Now().Unix(),
  5097. Number: chrg_bchno,
  5098. ErrMsg: res.ErrMsg,
  5099. Status: 1,
  5100. PatientId: id,
  5101. RecordTime: recordDateTime,
  5102. Stage: 6,
  5103. }
  5104. service.CreateErrMsgLog(errlog)
  5105. c.ServeSuccessJSON(map[string]interface{}{
  5106. "failed_code": -10,
  5107. "msg": res.ErrMsg,
  5108. })
  5109. return
  5110. } else {
  5111. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5112. order.OrderStatus = 2
  5113. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5114. order.SetlId = res.Output.Setlinfo.SetlID
  5115. order.PsnNo = res.Output.Setlinfo.PsnNo
  5116. order.PsnName = res.Output.Setlinfo.PsnName
  5117. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5118. order.Certno = res.Output.Setlinfo.Certno
  5119. order.Gend = res.Output.Setlinfo.Gend
  5120. order.Naty = res.Output.Setlinfo.Naty
  5121. order.Age = res.Output.Setlinfo.Age
  5122. order.Insutype = res.Output.Setlinfo.Insutype
  5123. order.PsnType = res.Output.Setlinfo.PsnType
  5124. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5125. order.SetlTime = res.Output.Setlinfo.SetlTime
  5126. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5127. //order.MedType = res.Output.Setlinfo.MedType
  5128. if reg_type == 1112 {
  5129. order.MedType = "1112"
  5130. }
  5131. if reg_type == 1111 {
  5132. order.MedType = "1111"
  5133. }
  5134. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5135. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5136. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5137. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5138. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5139. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5140. order.HifpPay = res.Output.Setlinfo.HifpPay
  5141. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5142. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5143. order.HifesPay = res.Output.Setlinfo.HifesPay
  5144. order.HifobPay = res.Output.Setlinfo.HifobPay
  5145. order.MafPay = res.Output.Setlinfo.MafPay
  5146. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5147. order.OthPay = res.Output.Setlinfo.OthPay
  5148. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5149. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5150. order.AcctPay = res.Output.Setlinfo.AcctPay
  5151. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5152. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5153. order.Balc = res.Output.Setlinfo.Balc
  5154. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5155. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5156. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5157. order.ClrWay = res.Output.Setlinfo.ClrWay
  5158. order.Creator = order.Creator
  5159. order.Modify = roles.AdminUserId
  5160. order.RequestLog = src_resquest
  5161. order.Diagnosis = diagnosis_id
  5162. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5163. detailStr := string(setlDetail)
  5164. order.SetlDetail = detailStr
  5165. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5166. err = service.UpDateOrder(order)
  5167. if err == nil {
  5168. c.ServeSuccessJSON(map[string]interface{}{
  5169. "msg": "结算成功",
  5170. })
  5171. } else {
  5172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5173. return
  5174. }
  5175. }
  5176. }
  5177. }
  5178. }
  5179. //func (c *HisApiController) GetPreUploadInfo() {
  5180. // id, _ := c.GetInt64("id")
  5181. // record_time := c.GetString("record_time")
  5182. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5183. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5184. //
  5185. // timeLayout := "2006-01-02"
  5186. // loc, _ := time.LoadLocation("Local")
  5187. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5188. // if err != nil {
  5189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5190. // return
  5191. // }
  5192. // recordDateTime := theTime.Unix()
  5193. // adminUser := c.GetAdminUserInfo()
  5194. //
  5195. // var prescriptions []*models.HisPrescription
  5196. //
  5197. // var start_time int64
  5198. // var end_time int64
  5199. //
  5200. // data := make(map[string]interface{})
  5201. // if settle_accounts_type == 1 { //日结
  5202. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5203. // data["pre"] = prescriptions
  5204. //
  5205. // } else { //月结
  5206. // start_time_str := c.GetString("start_time")
  5207. // end_time_str := c.GetString("end_time")
  5208. // timeLayout := "2006-01-02"
  5209. // loc, _ := time.LoadLocation("Local")
  5210. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5211. // if err != nil {
  5212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5213. // return
  5214. // }
  5215. // recordStartTime := theStartTime.Unix()
  5216. // start_time = recordStartTime
  5217. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5218. // if err != nil {
  5219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5220. // return
  5221. // }
  5222. // recordEndTime := theEndTime.Unix()
  5223. // end_time = recordEndTime
  5224. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5225. // data["pre"] = prescriptions
  5226. //
  5227. // }
  5228. //
  5229. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5230. //
  5231. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5232. // timestamp := time.Now().Unix()
  5233. // tempTime := time.Unix(timestamp, 0)
  5234. // timeFormat := tempTime.Format("20060102150405")
  5235. // chrgBchno := rand.Intn(100000) + 10000
  5236. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5237. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5238. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5239. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5240. // strconv.FormatInt(his.PatientId, 10)
  5241. // client := &http.Client{}
  5242. // data["psn_no"] = his.PsnNo
  5243. // data["mdtrt_id"] = his.Number
  5244. // data["chrg_bchno"] = chrg_bchno
  5245. // data["org_name"] = miConfig.OrgName
  5246. // data["doctor"] = roles.UserName
  5247. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5248. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5249. // data["fixmedins_code"] = miConfig.Code
  5250. // data["dept_code"] = department.Number
  5251. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5252. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5253. // data["secret_key"] = miConfig.SecretKey
  5254. // var ids []int64
  5255. //
  5256. // for _, item := range prescriptions {
  5257. // ids = append(ids, item.ID)
  5258. // }
  5259. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5260. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5261. // bytesData, _ := json.Marshal(data)
  5262. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5263. // resp, _ := client.Do(req)
  5264. // defer resp.Body.Close()
  5265. // body, ioErr := ioutil.ReadAll(resp.Body)
  5266. // if ioErr != nil {
  5267. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5269. // return
  5270. // }
  5271. // var respJSON map[string]interface{}
  5272. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5273. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5275. // return
  5276. // }
  5277. //
  5278. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5279. // userJSONBytes, _ := json.Marshal(respJSON)
  5280. // var res ResultFour
  5281. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5282. // utils.ErrorLog("解析失败:%v", err)
  5283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5284. // return
  5285. // }
  5286. //
  5287. // if res.Infcode == 0 {
  5288. // order := &models.HisOrder{
  5289. // UserOrgId: adminUser.CurrentOrgId,
  5290. // HisPatientId: his.ID,
  5291. // PatientId: his.PatientId,
  5292. // SettleAccountsDate: recordDateTime,
  5293. // Ctime: time.Now().Unix(),
  5294. // Mtime: time.Now().Unix(),
  5295. // Status: 1,
  5296. // Number: chrg_bchno,
  5297. // Infcode: res.Infcode,
  5298. // WarnMsg: res.WarnMsg,
  5299. // Cainfo: res.Cainfo,
  5300. // ErrMsg: res.ErrMsg,
  5301. // RespondTime: res.RefmsgTime,
  5302. // InfRefmsgid: res.InfRefmsgid,
  5303. // OrderStatus: 1,
  5304. // IsMedicineInsurance: 1,
  5305. // SettleType: settle_accounts_type,
  5306. // SettleStartTime: start_time,
  5307. // SettleEndTime: end_time,
  5308. // Creator: roles.ID,
  5309. // Modify: roles.ID,
  5310. // PType: 2,
  5311. // }
  5312. // err = service.CreateOrder(order)
  5313. // if err != nil {
  5314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5315. // return
  5316. // }
  5317. //
  5318. // for _, item := range res.Output.Result {
  5319. // temp := strings.Split(item.FeedetlSn, "-")
  5320. // var advice_id int64 = 0
  5321. // var project_id int64 = 0
  5322. // var types int64 = 0
  5323. //
  5324. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5325. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5326. //
  5327. // if temp[1] == "1" {
  5328. // advice_id = id
  5329. // project_id = 0
  5330. // } else if temp[1] == "2" {
  5331. // advice_id = 0
  5332. // project_id = id
  5333. // }
  5334. //
  5335. // info := &models.HisOrderInfo{
  5336. // OrderNumber: order.Number,
  5337. // FeedetlSn: item.FeedetlSn,
  5338. // UploadDate: time.Now().Unix(),
  5339. // AdviceId: advice_id,
  5340. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5341. // Cnt: item.Cnt,
  5342. // Pric: float64(item.Pric),
  5343. // PatientId: his.PatientId,
  5344. // PricUplmtAmt: item.PricUplmtAmt,
  5345. // SelfpayProp: item.SelfpayProp,
  5346. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5347. // OverlmtAmt: item.OverlmtAmt,
  5348. // PreselfpayAmt: item.PreselfpayAmt,
  5349. // BasMednFlag: item.BasMednFlag,
  5350. // MedChrgitmType: item.MedChrgitmType,
  5351. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5352. // Status: 1,
  5353. // Memo: item.Memo,
  5354. // Mtime: time.Now().Unix(),
  5355. // InscpScpAmt: item.InscpScpAmt,
  5356. // DrtReimFlag: item.DrtReimFlag,
  5357. // Ctime: time.Now().Unix(),
  5358. // ListSpItemFlag: item.ListSpItemFlag,
  5359. // ChldMedcFlag: item.ChldMedcFlag,
  5360. // LmtUsedFlag: item.LmtUsedFlag,
  5361. // ChrgitmLv: item.ChrgitmLv,
  5362. // UserOrgId: adminUser.CurrentOrgId,
  5363. // HisPatientId: his.ID,
  5364. // OrderId: order.ID,
  5365. // ProjectId: project_id,
  5366. // Type: types,
  5367. // }
  5368. // service.CreateOrderInfo(info)
  5369. //
  5370. // }
  5371. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5372. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5373. //
  5374. // var total float64
  5375. // for _, item := range prescriptions {
  5376. // if item.Type == 1 { //药品
  5377. // for _, subItem := range item.HisDoctorAdviceInfo {
  5378. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5379. // }
  5380. // }
  5381. // if item.Type == 2 { //项目
  5382. // for _, subItem := range item.HisPrescriptionProject {
  5383. // total = total + (subItem.Price * float64(subItem.Count))
  5384. // }
  5385. // }
  5386. // }
  5387. //
  5388. // for _, item := range prescriptions {
  5389. // for _, subItem := range item.HisAdditionalCharge {
  5390. // total = total + (subItem.Price * float64(subItem.Count))
  5391. // }
  5392. // }
  5393. //
  5394. // allTotal := fmt.Sprintf("%.2f", total)
  5395. // if res.Infcode == 0 {
  5396. // var rf []*ResultFive
  5397. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5398. // psn_no := his.PsnNo
  5399. // mdtrt_id := his.Number
  5400. // chrg_bchno := chrg_bchno
  5401. // cert_no := his.Certno
  5402. // insutype := rf[0].Insutype
  5403. //
  5404. // if his.IdCardType == 1 {
  5405. // cert_no = his.MedicalInsuranceNumber
  5406. //
  5407. // } else {
  5408. //
  5409. // cert_no = his.Certno
  5410. //
  5411. // }
  5412. //
  5413. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5414. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5415. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5416. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5417. // resp, requestErr := http.Get(api)
  5418. // if requestErr != nil {
  5419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5420. // return
  5421. // }
  5422. // defer resp.Body.Close()
  5423. // body, ioErr := ioutil.ReadAll(resp.Body)
  5424. // if ioErr != nil {
  5425. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5427. // return
  5428. // }
  5429. // var respJSON map[string]interface{}
  5430. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5431. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5433. // return
  5434. // }
  5435. // fmt.Println(respJSON)
  5436. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5437. // userJSONBytes, _ := json.Marshal(respJSON)
  5438. // var res ResultSeven
  5439. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5440. // utils.ErrorLog("解析失败:%v", err)
  5441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5442. // return
  5443. // }
  5444. // if res.Infcode != 0 {
  5445. // errlog := &models.HisOrderError{
  5446. // UserOrgId: adminUser.CurrentOrgId,
  5447. // Ctime: time.Now().Unix(),
  5448. // Mtime: time.Now().Unix(),
  5449. // Number: chrg_bchno,
  5450. // ErrMsg: res.ErrMsg,
  5451. // Status: 1,
  5452. // PatientId: id,
  5453. // RecordTime: recordDateTime,
  5454. // Stage: 7,
  5455. // }
  5456. // service.CreateErrMsgLog(errlog)
  5457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5458. // return
  5459. // } else {
  5460. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5461. // order.OrderStatus = 1
  5462. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5463. // order.SetlId = res.Output.Setlinfo.SetlID
  5464. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5465. // order.PsnName = res.Output.Setlinfo.PsnName
  5466. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5467. // order.Certno = res.Output.Setlinfo.Certno
  5468. // order.Gend = res.Output.Setlinfo.Gend
  5469. // order.Naty = res.Output.Setlinfo.Naty
  5470. // order.Age = res.Output.Setlinfo.Age
  5471. // order.Insutype = res.Output.Setlinfo.Insutype
  5472. // order.PsnType = res.Output.Setlinfo.PsnType
  5473. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5474. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5475. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5476. // order.MedType = res.Output.Setlinfo.MedType
  5477. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5478. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5479. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5480. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5481. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5482. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5483. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5484. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5485. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5486. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5487. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5488. // order.MafPay = res.Output.Setlinfo.MafPay
  5489. // order.OthPay = res.Output.Setlinfo.OthPay
  5490. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5491. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5492. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5493. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5494. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5495. // order.Balc = res.Output.Setlinfo.Balc
  5496. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5497. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5498. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5499. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5500. // order.Creator = order.Creator
  5501. // order.Modify = roles.ID
  5502. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5503. // detailStr := string(setlDetail)
  5504. // order.SetlDetail = detailStr
  5505. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5506. // err = service.UpDateOrder(order)
  5507. // if err == nil {
  5508. // c.ServeSuccessJSON(map[string]interface{}{
  5509. // "msg": "预结算成功",
  5510. // })
  5511. // } else {
  5512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5513. // return
  5514. // }
  5515. // }
  5516. // } else {
  5517. // adminUser := c.GetAdminUserInfo()
  5518. // errlog := &models.HisOrderError{
  5519. // UserOrgId: adminUser.CurrentOrgId,
  5520. // Ctime: time.Now().Unix(),
  5521. // Mtime: time.Now().Unix(),
  5522. // ErrMsg: res.ErrMsg,
  5523. // Status: 1,
  5524. // PatientId: id,
  5525. // RecordTime: recordDateTime,
  5526. // Stage: 4,
  5527. // }
  5528. // service.CreateErrMsgLog(errlog)
  5529. //
  5530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5531. // return
  5532. // }
  5533. // } else {
  5534. // adminUser := c.GetAdminUserInfo()
  5535. // errlog := &models.HisOrderError{
  5536. // UserOrgId: adminUser.CurrentOrgId,
  5537. // Ctime: time.Now().Unix(),
  5538. // Mtime: time.Now().Unix(),
  5539. // ErrMsg: res.ErrMsg,
  5540. // Status: 1,
  5541. // PatientId: id,
  5542. // RecordTime: recordDateTime,
  5543. // Stage: 4,
  5544. // }
  5545. // service.CreateErrMsgLog(errlog)
  5546. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5547. // return
  5548. // }
  5549. //
  5550. // } else {
  5551. // var total float64
  5552. // for _, item := range prescriptions {
  5553. // if item.Type == 1 { //药品
  5554. // for _, subItem := range item.HisDoctorAdviceInfo {
  5555. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5556. // }
  5557. // }
  5558. // if item.Type == 2 { //项目
  5559. // for _, subItem := range item.HisPrescriptionProject {
  5560. // total = total + (subItem.Price * float64(subItem.Count))
  5561. // }
  5562. // }
  5563. //
  5564. // for _, subItem := range item.HisAdditionalCharge {
  5565. // total = total + (subItem.Price * float64(subItem.Count))
  5566. // }
  5567. // }
  5568. //
  5569. // allTotal := fmt.Sprintf("%.2f", total)
  5570. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5571. // order := &models.HisOrder{
  5572. // UserOrgId: adminUser.CurrentOrgId,
  5573. // HisPatientId: his.ID,
  5574. // PatientId: id,
  5575. // SettleAccountsDate: recordDateTime,
  5576. // Ctime: time.Now().Unix(),
  5577. // Mtime: time.Now().Unix(),
  5578. // Status: 1,
  5579. // OrderStatus: 2,
  5580. // Number: chrg_bchno,
  5581. // MedfeeSumamt: totals,
  5582. // }
  5583. // err = service.CreateOrder(order)
  5584. // if err != nil {
  5585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5586. // return
  5587. // }
  5588. //
  5589. // var customs []*Custom
  5590. // for _, item := range prescriptions {
  5591. //
  5592. // if item.Type == 1 { //药品
  5593. // for _, subItem := range item.HisDoctorAdviceInfo {
  5594. // cus := &Custom{
  5595. // AdviceId: subItem.ID,
  5596. // ProjectId: 0,
  5597. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5598. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5599. // FeedetlSn: subItem.FeedetlSn,
  5600. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5601. // MedListCodg: subItem.MedListCodg,
  5602. // Type: 1,
  5603. // }
  5604. // customs = append(customs, cus)
  5605. // }
  5606. // }
  5607. //
  5608. // if item.Type == 2 { //项目
  5609. // for _, subItem := range item.HisPrescriptionProject {
  5610. //
  5611. // cus := &Custom{
  5612. // AdviceId: 0,
  5613. // ProjectId: subItem.ID,
  5614. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5615. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5616. // FeedetlSn: subItem.FeedetlSn,
  5617. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5618. // MedListCodg: subItem.MedListCodg,
  5619. // Type: 2,
  5620. // }
  5621. //
  5622. // customs = append(customs, cus)
  5623. // }
  5624. // }
  5625. //
  5626. // for _, item := range item.HisAdditionalCharge {
  5627. // cus := &Custom{
  5628. // ItemId: item.ID,
  5629. // AdviceId: 0,
  5630. // ProjectId: 0,
  5631. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5632. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5633. // FeedetlSn: item.FeedetlSn,
  5634. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5635. // MedListCodg: item.XtHisAddtionConfig.Code,
  5636. // Type: 3,
  5637. // }
  5638. //
  5639. // customs = append(customs, cus)
  5640. // }
  5641. //
  5642. // }
  5643. //
  5644. // for _, item := range customs {
  5645. // var advice_id int64 = 0
  5646. // var project_id int64 = 0
  5647. // var item_id int64 = 0
  5648. //
  5649. // var types int64 = 0
  5650. //
  5651. // if item.Type == 1 {
  5652. // advice_id = item.AdviceId
  5653. // project_id = 0
  5654. // item_id = 0
  5655. // } else if item.Type == 2 {
  5656. // advice_id = 0
  5657. // item_id = 0
  5658. //
  5659. // project_id = item.ProjectId
  5660. // } else if item.Type == 3 {
  5661. // advice_id = 0
  5662. // item_id = item.ItemId
  5663. // project_id = 0
  5664. // }
  5665. //
  5666. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5667. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5668. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5669. //
  5670. // info := &models.HisOrderInfo{
  5671. // OrderNumber: order.Number,
  5672. // UploadDate: time.Now().Unix(),
  5673. // AdviceId: advice_id,
  5674. // DetItemFeeSumamt: detItemFeeSumamt,
  5675. // Cnt: cut,
  5676. // Pric: pric,
  5677. // PatientId: id,
  5678. // Status: 1,
  5679. // Mtime: time.Now().Unix(),
  5680. // Ctime: time.Now().Unix(),
  5681. // UserOrgId: adminUser.CurrentOrgId,
  5682. // HisPatientId: his.ID,
  5683. // OrderId: order.ID,
  5684. // ProjectId: project_id,
  5685. // Type: types,
  5686. // ItemId: item_id,
  5687. // }
  5688. // service.CreateOrderInfo(info)
  5689. // }
  5690. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5691. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5692. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5693. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5694. // if err == nil {
  5695. // c.ServeSuccessJSON(map[string]interface{}{
  5696. // "msg": "结算成功",
  5697. // })
  5698. // } else {
  5699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5700. // return
  5701. // }
  5702. // }
  5703. //}
  5704. //上传明细-预结算-
  5705. func (c *HisApiController) GetPreUploadInfo() {
  5706. id, _ := c.GetInt64("id")
  5707. record_time := c.GetString("record_time")
  5708. his_patient_id, _ := c.GetInt64("his_patient_id")
  5709. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5710. admin_user_id, _ := c.GetInt64("admin_user_id")
  5711. diagnosis_id := c.GetString("diagnosis")
  5712. sick_type, _ := c.GetInt64("sick_type")
  5713. reg_type, _ := c.GetInt64("p_type")
  5714. begin_time := c.GetString("begin_time")
  5715. id_str := c.GetString("ids")
  5716. ids_arr := strings.Split(id_str, ",")
  5717. timeLayout := "2006-01-02"
  5718. loc, _ := time.LoadLocation("Local")
  5719. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5720. if err != nil {
  5721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5722. return
  5723. }
  5724. recordDateTime := theTime.Unix()
  5725. adminUser := c.GetAdminUserInfo()
  5726. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5727. var config []*models.HisXtDiagnoseConfig
  5728. for _, item := range diagnosis_ids {
  5729. id, _ := strconv.ParseInt(item, 10, 64)
  5730. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5731. config = append(config, &diagnosisConfig)
  5732. }
  5733. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5734. sickConfig, _ := service.FindSickById(sick_type)
  5735. var prescriptions []*models.HisPrescription
  5736. var start_time int64
  5737. var end_time int64
  5738. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5739. fmt.Println(his_patient_id)
  5740. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5741. timestamp := time.Now().Unix()
  5742. tempTime := time.Unix(timestamp, 0)
  5743. timeFormat := tempTime.Format("20060102150405")
  5744. chrgBchno := rand.Intn(100000) + 10000
  5745. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5746. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5747. var patientPrescription models.HisPrescriptionInfo
  5748. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5749. if patientPrescription.ID == 0 {
  5750. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5751. }
  5752. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5753. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5754. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5755. strconv.FormatInt(his.PatientId, 10)
  5756. var res2 ResultSix
  5757. var resSix10265 ResultSix10265
  5758. var time_stamp string
  5759. if miConfig.MdtrtareaAdmvs == "421300" {
  5760. data := make(map[string]interface{})
  5761. client := &http.Client{}
  5762. data["psn_no"] = his.PsnNo
  5763. data["mdtrt_id"] = his.Number
  5764. data["doctor"] = roles.UserName
  5765. data["department"] = department.Name
  5766. data["org_name"] = miConfig.OrgName
  5767. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5768. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5769. data["fixmedins_code"] = miConfig.Code
  5770. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5771. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5772. data["secret_key"] = miConfig.SecretKey
  5773. data["sick_code"] = sickConfig.CountryCode
  5774. data["sick_name"] = sickConfig.ClassName
  5775. data["begin_time"] = begin_time
  5776. data["dept"] = strconv.FormatInt(department.ID, 10)
  5777. data["config"] = config
  5778. fmt.Println(data)
  5779. bytesData, _ := json.Marshal(data)
  5780. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5781. resp, _ := client.Do(req)
  5782. defer resp.Body.Close()
  5783. body, ioErr := ioutil.ReadAll(resp.Body)
  5784. if ioErr != nil {
  5785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5787. return
  5788. }
  5789. var respJSON map[string]interface{}
  5790. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5793. return
  5794. }
  5795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5796. userJSONBytes, _ := json.Marshal(respJSON)
  5797. fmt.Println("log")
  5798. fmt.Println(string(userJSONBytes))
  5799. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5800. utils.ErrorLog("解析失败:%v", err)
  5801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5802. return
  5803. }
  5804. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5805. //江苏地区国家医保医疗类别
  5806. //职工透析:医疗类别选特殊情况门诊9933
  5807. //居民血透门慢: 医疗类别选门诊慢病1402
  5808. //var med_type string
  5809. //if his.Insutype == "310" {
  5810. // if reg_type == 14 {
  5811. // med_type = "9933"
  5812. // } else if reg_type == 11 {
  5813. // med_type = "11"
  5814. //
  5815. // }
  5816. //} else if his.Insutype == "390" {
  5817. // if reg_type == 14 {
  5818. // med_type = "1402"
  5819. // } else if reg_type == 11 {
  5820. // med_type = "11"
  5821. // }
  5822. //}
  5823. data := make(map[string]interface{})
  5824. client := &http.Client{}
  5825. data["psn_no"] = his.PsnNo
  5826. data["mdtrt_id"] = his.Number
  5827. data["doctor"] = roles.UserName
  5828. data["department"] = department.Name
  5829. data["org_name"] = miConfig.OrgName
  5830. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5831. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5832. data["fixmedins_code"] = miConfig.Code
  5833. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5834. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5835. data["secret_key"] = miConfig.SecretKey
  5836. data["sick_code"] = sickConfig.CountryCode
  5837. data["sick_name"] = sickConfig.ClassName
  5838. data["begin_time"] = begin_time
  5839. data["dept"] = strconv.FormatInt(department.ID, 10)
  5840. data["config"] = config
  5841. data["url"] = miConfig.Url
  5842. data["ak"] = miConfig.AccessKey
  5843. data["cainfo"] = miConfig.Cainfo
  5844. bytesData, _ := json.Marshal(data)
  5845. var req *http.Request
  5846. if miConfig.MdtrtareaAdmvs == "320921" {
  5847. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5848. //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 +
  5849. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5850. } else {
  5851. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5852. }
  5853. resp, _ := client.Do(req)
  5854. defer resp.Body.Close()
  5855. body, ioErr := ioutil.ReadAll(resp.Body)
  5856. if ioErr != nil {
  5857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5859. return
  5860. }
  5861. var respJSON map[string]interface{}
  5862. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5865. return
  5866. }
  5867. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5868. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5869. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5871. userJSONBytes, _ := json.Marshal(respJSON)
  5872. fmt.Println("log")
  5873. fmt.Println(string(userJSONBytes))
  5874. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5875. utils.ErrorLog("解析失败:%v", err)
  5876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5877. return
  5878. }
  5879. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5880. res2.Output = resSix10265.Output
  5881. res2.ErrMsg = resSix10265.ErrMsg
  5882. res2.Cainfo = resSix10265.Cainfo
  5883. res2.WarnMsg = resSix10265.WarnMsg
  5884. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5885. res2.Infcode = infocode
  5886. } else {
  5887. var result string
  5888. var requestLog string
  5889. if miConfig.MdtrtareaAdmvs == "440781" { //
  5890. 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)
  5891. } else {
  5892. if miConfig.Code == "H15049901371" {
  5893. //赤峰地区国家医保医疗类别
  5894. //职工透析:医疗类别选特殊情况门诊990502
  5895. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5896. var med_type string
  5897. if his.Insutype == "390" {
  5898. if reg_type == 14 {
  5899. med_type = "9933"
  5900. } else if reg_type == 11 {
  5901. med_type = "11"
  5902. }
  5903. } else if his.Insutype == "310" {
  5904. if reg_type == 14 {
  5905. med_type = "990502"
  5906. } else if reg_type == 11 {
  5907. med_type = "11"
  5908. }
  5909. }
  5910. 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)
  5911. } else {
  5912. 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)
  5913. }
  5914. saveLog(result, requestLog, "2203", "上传就诊信息")
  5915. var respJSON2 map[string]interface{}
  5916. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5919. return
  5920. }
  5921. userJSONBytes2, _ := json.Marshal(respJSON2)
  5922. if miConfig.Code == "H15049901371" {
  5923. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5924. utils.ErrorLog("解析失败:%v", err)
  5925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5926. return
  5927. }
  5928. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5929. res2.Output = resSix10265.Output
  5930. res2.ErrMsg = resSix10265.ErrMsg
  5931. res2.Cainfo = resSix10265.Cainfo
  5932. res2.WarnMsg = resSix10265.WarnMsg
  5933. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5934. res2.Infcode = infocode
  5935. } else {
  5936. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5937. utils.ErrorLog("解析失败:%v", err)
  5938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5939. return
  5940. }
  5941. }
  5942. }
  5943. }
  5944. if res2.Infcode != 0 {
  5945. adminUser := c.GetAdminUserInfo()
  5946. errlog := &models.HisOrderError{
  5947. UserOrgId: adminUser.CurrentOrgId,
  5948. Ctime: time.Now().Unix(),
  5949. Mtime: time.Now().Unix(),
  5950. ErrMsg: res2.ErrMsg,
  5951. Status: 1,
  5952. PatientId: id,
  5953. RecordTime: recordDateTime,
  5954. Stage: 3,
  5955. }
  5956. service.CreateErrMsgLog(errlog)
  5957. c.ServeSuccessJSON(map[string]interface{}{
  5958. "failed_code": -10,
  5959. "msg": res2.ErrMsg,
  5960. })
  5961. return
  5962. } else {
  5963. his.Diagnosis = diagnosis_id
  5964. his.SickType = sickConfig.ID
  5965. his.PType = fmt.Sprintf("%d", reg_type)
  5966. service.UpdateHisPatientThree(&his)
  5967. data := make(map[string]interface{})
  5968. if settle_accounts_type == 1 { //日结
  5969. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5970. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5971. } else {
  5972. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5973. }
  5974. data["pre"] = prescriptions
  5975. } else { //月结
  5976. start_time_str := c.GetString("start_time")
  5977. end_time_str := c.GetString("end_time")
  5978. timeLayout := "2006-01-02"
  5979. loc, _ := time.LoadLocation("Local")
  5980. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5981. if err != nil {
  5982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5983. return
  5984. }
  5985. recordStartTime := theStartTime.Unix()
  5986. start_time = recordStartTime
  5987. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5988. if err != nil {
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5990. return
  5991. }
  5992. recordEndTime := theEndTime.Unix()
  5993. end_time = recordEndTime
  5994. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5995. data["pre"] = prescriptions
  5996. }
  5997. client := &http.Client{}
  5998. data["psn_no"] = his.PsnNo
  5999. data["mdtrt_id"] = his.Number
  6000. data["chrg_bchno"] = chrg_bchno
  6001. data["org_name"] = miConfig.OrgName
  6002. data["doctor"] = roles.UserName
  6003. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6004. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6005. data["fixmedins_code"] = miConfig.Code
  6006. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6007. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6008. data["dept_code"] = "15"
  6009. } else {
  6010. data["dept_code"] = department.Number
  6011. }
  6012. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6013. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6014. data["secret_key"] = miConfig.SecretKey
  6015. data["url"] = miConfig.Url
  6016. data["ak"] = miConfig.AccessKey
  6017. data["new_doctor_name"] = patientPrescription.Doctor
  6018. data["diag_code"] = sickConfig.CountryCode
  6019. data["time_stamp"] = time_stamp
  6020. data["cainfo"] = miConfig.Cainfo
  6021. var ids []int64
  6022. for _, item := range prescriptions {
  6023. ids = append(ids, item.ID)
  6024. }
  6025. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6026. if config.IsOpen == 1 { //对接了医保,走医保流程
  6027. var res ResultFour
  6028. var resFour10265 ResultFour10265
  6029. if miConfig.MdtrtareaAdmvs == "421300" {
  6030. bytesData, _ := json.Marshal(data)
  6031. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6032. resp, _ := client.Do(req)
  6033. defer resp.Body.Close()
  6034. body, ioErr := ioutil.ReadAll(resp.Body)
  6035. if ioErr != nil {
  6036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6038. return
  6039. }
  6040. var respJSON map[string]interface{}
  6041. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6044. return
  6045. }
  6046. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6047. userJSONBytes, _ := json.Marshal(respJSON)
  6048. fmt.Println("log")
  6049. fmt.Println(string(userJSONBytes))
  6050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6051. utils.ErrorLog("解析失败:%v", err)
  6052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6053. return
  6054. }
  6055. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6056. bytesData, _ := json.Marshal(data)
  6057. var req *http.Request
  6058. if miConfig.MdtrtareaAdmvs == "320921" {
  6059. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6060. } else {
  6061. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6062. }
  6063. resp, _ := client.Do(req)
  6064. defer resp.Body.Close()
  6065. body, ioErr := ioutil.ReadAll(resp.Body)
  6066. if ioErr != nil {
  6067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6069. return
  6070. }
  6071. var respJSON map[string]interface{}
  6072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6075. return
  6076. }
  6077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6078. userJSONBytes, _ := json.Marshal(respJSON)
  6079. fmt.Println("log")
  6080. fmt.Println(string(userJSONBytes))
  6081. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6082. utils.ErrorLog("解析失败:%v", err)
  6083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6084. return
  6085. }
  6086. res.InfRefmsgid = resFour10265.InfRefmsgid
  6087. res.Output = resFour10265.Output
  6088. res.ErrMsg = resFour10265.ErrMsg
  6089. res.Cainfo = resFour10265.Cainfo
  6090. res.WarnMsg = resFour10265.WarnMsg
  6091. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6092. res.Infcode = infocode
  6093. } else {
  6094. if miConfig.Code == "H15049901371" {
  6095. 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)
  6096. var dat map[string]interface{}
  6097. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6098. fmt.Println(dat)
  6099. } else {
  6100. fmt.Println(err)
  6101. }
  6102. saveLog(result, request_log, "2204", "上传费用明细")
  6103. userJSONBytes, _ := json.Marshal(dat)
  6104. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6105. utils.ErrorLog("解析失败:%v", err)
  6106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6107. return
  6108. }
  6109. res.InfRefmsgid = resFour10265.InfRefmsgid
  6110. res.Output = resFour10265.Output
  6111. res.ErrMsg = resFour10265.ErrMsg
  6112. res.Cainfo = resFour10265.Cainfo
  6113. res.WarnMsg = resFour10265.WarnMsg
  6114. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6115. res.Infcode = infocode
  6116. } else {
  6117. 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)
  6118. var dat map[string]interface{}
  6119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6120. fmt.Println(dat)
  6121. } else {
  6122. fmt.Println(err)
  6123. }
  6124. saveLog(result, request_log, "2204", "上传费用明细")
  6125. userJSONBytes, _ := json.Marshal(dat)
  6126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6127. utils.ErrorLog("解析失败:%v", err)
  6128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6129. return
  6130. }
  6131. }
  6132. }
  6133. if res.Infcode == 0 {
  6134. order := &models.HisOrder{
  6135. UserOrgId: adminUser.CurrentOrgId,
  6136. HisPatientId: his.ID,
  6137. PatientId: his.PatientId,
  6138. SettleAccountsDate: recordDateTime,
  6139. Ctime: time.Now().Unix(),
  6140. Mtime: time.Now().Unix(),
  6141. MdtrtId: his.Number,
  6142. PsnNo: his.PsnNo,
  6143. MedType: strconv.FormatInt(reg_type, 10),
  6144. Status: 1,
  6145. Number: chrg_bchno,
  6146. Infcode: res.Infcode,
  6147. WarnMsg: res.WarnMsg,
  6148. Cainfo: res.Cainfo,
  6149. ErrMsg: res.ErrMsg,
  6150. RespondTime: res.RefmsgTime,
  6151. InfRefmsgid: res.InfRefmsgid,
  6152. OrderStatus: 1,
  6153. IsMedicineInsurance: 1,
  6154. SettleType: settle_accounts_type,
  6155. SettleStartTime: start_time,
  6156. SettleEndTime: end_time,
  6157. Creator: roles.AdminUserId,
  6158. Modify: roles.AdminUserId,
  6159. PType: 2,
  6160. Diagnosis: diagnosis_id,
  6161. }
  6162. err = service.CreateOrder(order)
  6163. if err != nil {
  6164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6165. return
  6166. }
  6167. for _, item := range res.Output.Result {
  6168. temp := strings.Split(item.FeedetlSn, "-")
  6169. var advice_id int64 = 0
  6170. var project_id int64 = 0
  6171. var types int64 = 0
  6172. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6173. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6174. if temp[1] == "1" {
  6175. advice_id = id
  6176. project_id = 0
  6177. } else if temp[1] == "2" {
  6178. advice_id = 0
  6179. project_id = id
  6180. }
  6181. info := &models.HisOrderInfo{
  6182. OrderNumber: order.Number,
  6183. FeedetlSn: item.FeedetlSn,
  6184. UploadDate: time.Now().Unix(),
  6185. AdviceId: advice_id,
  6186. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6187. Cnt: item.Cnt,
  6188. Pric: float64(item.Pric),
  6189. PatientId: his.PatientId,
  6190. PricUplmtAmt: item.PricUplmtAmt,
  6191. SelfpayProp: item.SelfpayProp,
  6192. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6193. OverlmtAmt: item.OverlmtAmt,
  6194. PreselfpayAmt: item.PreselfpayAmt,
  6195. BasMednFlag: item.BasMednFlag,
  6196. MedChrgitmType: item.MedChrgitmType,
  6197. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6198. Status: 1,
  6199. Memo: item.Memo,
  6200. Mtime: time.Now().Unix(),
  6201. InscpScpAmt: item.InscpScpAmt,
  6202. DrtReimFlag: item.DrtReimFlag,
  6203. Ctime: time.Now().Unix(),
  6204. ListSpItemFlag: item.ListSpItemFlag,
  6205. ChldMedcFlag: item.ChldMedcFlag,
  6206. LmtUsedFlag: item.LmtUsedFlag,
  6207. ChrgitmLv: item.ChrgitmLv,
  6208. UserOrgId: adminUser.CurrentOrgId,
  6209. HisPatientId: his.ID,
  6210. OrderId: order.ID,
  6211. ProjectId: project_id,
  6212. Type: types,
  6213. }
  6214. service.CreateOrderInfo(info)
  6215. }
  6216. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6217. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6218. var total float64
  6219. for _, item := range prescriptions {
  6220. if item.Type == 1 { //药品
  6221. for _, subItem := range item.HisDoctorAdviceInfo {
  6222. total = total + (subItem.Price * subItem.PrescribingNumber)
  6223. }
  6224. }
  6225. if item.Type == 2 { //项目
  6226. for _, subItem := range item.HisPrescriptionProject {
  6227. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6228. total = total + (subItem.Price * cnt)
  6229. }
  6230. }
  6231. }
  6232. for _, item := range prescriptions {
  6233. for _, subItem := range item.HisAdditionalCharge {
  6234. total = total + (subItem.Price * float64(subItem.Count))
  6235. }
  6236. }
  6237. allTotal := fmt.Sprintf("%.4f", total)
  6238. if res.Infcode == 0 {
  6239. var rf []*ResultFive
  6240. json.Unmarshal([]byte(his.Iinfo), &rf)
  6241. chrg_bchno := chrg_bchno
  6242. cert_no := his.Certno
  6243. var insutypes []string
  6244. var insutype string
  6245. var is390 int = 0
  6246. var is310 int = 0
  6247. for _, item := range rf {
  6248. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6249. insutypes = append(insutypes, item.Insutype)
  6250. }
  6251. }
  6252. if len(insutypes) == 1 {
  6253. insutype = insutypes[0]
  6254. } else {
  6255. for _, i := range insutypes {
  6256. if i == "390" {
  6257. is390 = 1
  6258. }
  6259. if i == "310" {
  6260. is310 = 1
  6261. }
  6262. }
  6263. }
  6264. if is390 == 1 {
  6265. insutype = "390"
  6266. }
  6267. if is310 == 1 {
  6268. insutype = "310"
  6269. }
  6270. if len(insutypes) == 0 {
  6271. insutype = "310"
  6272. }
  6273. if len(insutypes) == 2 {
  6274. insutype = strconv.FormatInt(his.SocialType, 64)
  6275. }
  6276. //insutype = "390"
  6277. if his.IdCardType == 1 {
  6278. cert_no = his.MedicalInsuranceNumber
  6279. } else {
  6280. cert_no = his.Certno
  6281. }
  6282. var res ResultSeven
  6283. var resSeven10265 ResultSeven10265
  6284. if miConfig.MdtrtareaAdmvs == "421300" {
  6285. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6286. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6287. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6288. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6289. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6290. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6291. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6292. resp, requestErr := http.Get(api)
  6293. if requestErr != nil {
  6294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6295. return
  6296. }
  6297. body, ioErr := ioutil.ReadAll(resp.Body)
  6298. if ioErr != nil {
  6299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6301. return
  6302. }
  6303. var respJSON map[string]interface{}
  6304. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6307. return
  6308. }
  6309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6310. result, _ := json.Marshal(respJSON)
  6311. fmt.Println("log")
  6312. fmt.Println(string(result))
  6313. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6314. utils.ErrorLog("解析失败:%v", err)
  6315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6316. return
  6317. }
  6318. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6319. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6320. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6321. bas := strings.Split(psn_info.CardInfo, "|")
  6322. if his.IdCardType == 1 {
  6323. cert_no = bas[2]
  6324. } else {
  6325. cert_no = bas[1]
  6326. }
  6327. //江苏地区国家医保医疗类别
  6328. //职工透析:医疗类别选特殊情况门诊9933
  6329. //居民血透门慢: 医疗类别选门诊慢病1402
  6330. //var med_type string
  6331. //if his.Insutype == "310" {
  6332. // if reg_type == 14 {
  6333. // med_type = "9933"
  6334. // } else if reg_type == 11 {
  6335. // med_type = "11"
  6336. //
  6337. // }
  6338. //} else if his.Insutype == "390" {
  6339. // if reg_type == 14 {
  6340. // med_type = "1402"
  6341. // } else if reg_type == 11 {
  6342. // med_type = "11"
  6343. // }
  6344. //}
  6345. var api string
  6346. if miConfig.MdtrtareaAdmvs == "320921" {
  6347. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6348. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6349. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6350. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6351. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6352. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6353. "&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
  6354. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6355. } else {
  6356. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6357. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6358. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6359. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6360. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6361. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6362. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6363. "&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
  6364. }
  6365. resp, requestErr := http.Get(api)
  6366. if requestErr != nil {
  6367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6368. return
  6369. }
  6370. body, ioErr := ioutil.ReadAll(resp.Body)
  6371. if ioErr != nil {
  6372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. return
  6375. }
  6376. var respJSON map[string]interface{}
  6377. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6380. return
  6381. }
  6382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6383. result, _ := json.Marshal(respJSON)
  6384. fmt.Println("log")
  6385. fmt.Println(string(result))
  6386. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6387. utils.ErrorLog("解析失败:%v", err)
  6388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6389. return
  6390. }
  6391. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6392. res.Output = resSeven10265.Output
  6393. res.ErrMsg = resSeven10265.ErrMsg
  6394. res.Cainfo = resSeven10265.Cainfo
  6395. res.WarnMsg = resSeven10265.WarnMsg
  6396. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6397. res.Infcode = infocode
  6398. } else {
  6399. var result string
  6400. var request_log string
  6401. if miConfig.Code == "H15049901371" {
  6402. //赤峰地区国家医保医疗类别
  6403. //职工透析:医疗类别选特殊情况门诊990502
  6404. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6405. var med_type string
  6406. if his.Insutype == "390" {
  6407. if reg_type == 14 {
  6408. med_type = "9933"
  6409. } else if reg_type == 11 {
  6410. med_type = "11"
  6411. }
  6412. } else if his.Insutype == "310" {
  6413. if reg_type == 14 {
  6414. med_type = "990502"
  6415. } else if reg_type == 11 {
  6416. med_type = "11"
  6417. }
  6418. }
  6419. 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)
  6420. } else {
  6421. 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)
  6422. }
  6423. var dat map[string]interface{}
  6424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6425. fmt.Println(dat)
  6426. } else {
  6427. fmt.Println(err)
  6428. }
  6429. saveLog(result, request_log, "2206", "预结算")
  6430. //userJSONBytes, _ := json.Marshal(dat)
  6431. //
  6432. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6433. // utils.ErrorLog("解析失败:%v", err)
  6434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. // return
  6436. //}
  6437. userJSONBytes, _ := json.Marshal(dat)
  6438. if miConfig.Code == "H15049901371" {
  6439. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6440. utils.ErrorLog("解析失败:%v", err)
  6441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6442. return
  6443. }
  6444. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6445. res.Output = resSeven10265.Output
  6446. res.ErrMsg = resSeven10265.ErrMsg
  6447. res.Cainfo = resSeven10265.Cainfo
  6448. res.WarnMsg = resSeven10265.WarnMsg
  6449. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6450. res.Infcode = infocode
  6451. } else {
  6452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6453. utils.ErrorLog("解析失败:%v", err)
  6454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6455. return
  6456. }
  6457. }
  6458. }
  6459. if res.Infcode != 0 {
  6460. errlog := &models.HisOrderError{
  6461. UserOrgId: adminUser.CurrentOrgId,
  6462. Ctime: time.Now().Unix(),
  6463. Mtime: time.Now().Unix(),
  6464. Number: chrg_bchno,
  6465. ErrMsg: res.ErrMsg,
  6466. Status: 1,
  6467. PatientId: id,
  6468. RecordTime: recordDateTime,
  6469. Stage: 20,
  6470. }
  6471. service.CreateErrMsgLog(errlog)
  6472. c.ServeSuccessJSON(map[string]interface{}{
  6473. "failed_code": -10,
  6474. "msg": res.ErrMsg,
  6475. })
  6476. return
  6477. } else {
  6478. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6479. order.OrderStatus = 1
  6480. order.IsPre = 1
  6481. order.Status = 1
  6482. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6483. order.SetlId = res.Output.Setlinfo.SetlID
  6484. order.PsnNo = res.Output.Setlinfo.PsnNo
  6485. order.PsnName = res.Output.Setlinfo.PsnName
  6486. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6487. order.Certno = res.Output.Setlinfo.Certno
  6488. order.Gend = res.Output.Setlinfo.Gend
  6489. order.Naty = res.Output.Setlinfo.Naty
  6490. order.Age = res.Output.Setlinfo.Age
  6491. order.Insutype = res.Output.Setlinfo.Insutype
  6492. order.PsnType = res.Output.Setlinfo.PsnType
  6493. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6494. order.SetlTime = res.Output.Setlinfo.SetlTime
  6495. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6496. if res.Output.Setlinfo.MedType == "140101" {
  6497. order.MedType = "14"
  6498. } else {
  6499. order.MedType = res.Output.Setlinfo.MedType
  6500. }
  6501. if reg_type == 1112 {
  6502. order.MedType = "1112"
  6503. }
  6504. if reg_type == 1111 {
  6505. order.MedType = "1111"
  6506. }
  6507. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6508. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6509. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6510. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6511. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6512. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6513. order.HifpPay = res.Output.Setlinfo.HifpPay
  6514. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6515. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6516. order.HifesPay = res.Output.Setlinfo.HifesPay
  6517. order.HifobPay = res.Output.Setlinfo.HifobPay
  6518. order.MafPay = res.Output.Setlinfo.MafPay
  6519. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6520. order.OthPay = res.Output.Setlinfo.OthPay
  6521. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6522. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6523. order.AcctPay = res.Output.Setlinfo.AcctPay
  6524. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6525. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6526. order.Balc = res.Output.Setlinfo.Balc
  6527. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6528. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6529. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6530. order.ClrWay = res.Output.Setlinfo.ClrWay
  6531. order.Creator = order.Creator
  6532. order.Modify = roles.AdminUserId
  6533. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6534. detailStr := string(setlDetail)
  6535. order.SetlDetail = detailStr
  6536. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6537. err = service.UpDateOrder(order)
  6538. if err == nil {
  6539. c.ServeSuccessJSON(map[string]interface{}{
  6540. "msg": "预结算成功",
  6541. })
  6542. } else {
  6543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6544. return
  6545. }
  6546. }
  6547. } else {
  6548. adminUser := c.GetAdminUserInfo()
  6549. errlog := &models.HisOrderError{
  6550. UserOrgId: adminUser.CurrentOrgId,
  6551. Ctime: time.Now().Unix(),
  6552. Mtime: time.Now().Unix(),
  6553. ErrMsg: res.ErrMsg,
  6554. Status: 1,
  6555. PatientId: id,
  6556. RecordTime: recordDateTime,
  6557. Stage: 4,
  6558. }
  6559. service.CreateErrMsgLog(errlog)
  6560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6561. return
  6562. }
  6563. } else {
  6564. adminUser := c.GetAdminUserInfo()
  6565. errlog := &models.HisOrderError{
  6566. UserOrgId: adminUser.CurrentOrgId,
  6567. Ctime: time.Now().Unix(),
  6568. Mtime: time.Now().Unix(),
  6569. ErrMsg: res.ErrMsg,
  6570. Status: 1,
  6571. PatientId: id,
  6572. RecordTime: recordDateTime,
  6573. Stage: 4,
  6574. }
  6575. service.CreateErrMsgLog(errlog)
  6576. c.ServeSuccessJSON(map[string]interface{}{
  6577. "failed_code": -10,
  6578. "msg": res.ErrMsg,
  6579. })
  6580. return
  6581. }
  6582. }
  6583. }
  6584. }
  6585. //func (c *HisApiController) GetSettleInfo() {
  6586. // id, _ := c.GetInt64("id")
  6587. // order_id, _ := c.GetInt64("order_id")
  6588. //
  6589. // record_time := c.GetString("record_time")
  6590. // pay_way, _ := c.GetInt64("pay_way")
  6591. // pay_price, _ := c.GetFloat("pay_price")
  6592. // pay_card_no := c.GetString("pay_card_no")
  6593. // discount_price, _ := c.GetFloat("discount_price")
  6594. // preferential_price, _ := c.GetFloat("preferential_price")
  6595. // reality_price, _ := c.GetFloat("reality_price")
  6596. // found_price, _ := c.GetFloat("found_price")
  6597. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6598. // private_price, _ := c.GetFloat("private_price")
  6599. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6600. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6601. //
  6602. // timeLayout := "2006-01-02"
  6603. // loc, _ := time.LoadLocation("Local")
  6604. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6605. // if err != nil {
  6606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6607. // return
  6608. // }
  6609. // recordDateTime := theTime.Unix()
  6610. // adminUser := c.GetAdminUserInfo()
  6611. //
  6612. // var prescriptions []*models.HisPrescription
  6613. //
  6614. // data := make(map[string]interface{})
  6615. // if settle_accounts_type == 1 { //日结
  6616. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6617. // data["pre"] = prescriptions
  6618. //
  6619. // } else { //月结
  6620. // start_time_str := c.GetString("start_time")
  6621. // end_time_str := c.GetString("end_time")
  6622. // timeLayout := "2006-01-02"
  6623. // loc, _ := time.LoadLocation("Local")
  6624. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6625. // if err != nil {
  6626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6627. // return
  6628. // }
  6629. // recordStartTime := theStartTime.Unix()
  6630. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6631. // if err != nil {
  6632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6633. // return
  6634. // }
  6635. // recordEndTime := theEndTime.Unix()
  6636. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6637. // data["pre"] = prescriptions
  6638. //
  6639. // }
  6640. //
  6641. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6642. //
  6643. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6644. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6645. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6646. // strconv.FormatInt(his.PatientId, 10)
  6647. //
  6648. // order_src, _ := service.GetHisOrderByID(order_id)
  6649. //
  6650. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6651. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6652. //
  6653. // var total float64
  6654. // for _, item := range prescriptions {
  6655. // if item.Type == 1 { //药品
  6656. // for _, subItem := range item.HisDoctorAdviceInfo {
  6657. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6658. // }
  6659. // }
  6660. // if item.Type == 2 { //项目
  6661. // for _, subItem := range item.HisPrescriptionProject {
  6662. // total = total + (subItem.Price * float64(subItem.Count))
  6663. // }
  6664. // }
  6665. // }
  6666. //
  6667. // for _, item := range prescriptions {
  6668. // for _, subItem := range item.HisAdditionalCharge {
  6669. // total = total + (subItem.Price * float64(subItem.Count))
  6670. // }
  6671. // }
  6672. //
  6673. // allTotal := fmt.Sprintf("%.2f", total)
  6674. // var rf []*ResultFive
  6675. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6676. // psn_no := order_src.PsnNo
  6677. // mdtrt_id := order_src.MdtrtId
  6678. // chrg_bchno := order_src.Number
  6679. // cert_no := order_src.Certno
  6680. // insutype := rf[0].Insutype
  6681. //
  6682. // if his.IdCardType == 1 {
  6683. // cert_no = his.MedicalInsuranceNumber
  6684. // } else {
  6685. // cert_no = his.Certno
  6686. // }
  6687. //
  6688. // 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)
  6689. // var dat map[string]interface{}
  6690. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6691. // fmt.Println(dat)
  6692. // } else {
  6693. // fmt.Println(err)
  6694. // }
  6695. //
  6696. // userJSONBytes, _ := json.Marshal(dat)
  6697. //
  6698. //
  6699. //
  6700. // var res ResultSeven
  6701. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6702. // utils.ErrorLog("解析失败:%v", err)
  6703. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6704. // return
  6705. // }
  6706. // if res.Infcode == -1 {
  6707. // errlog := &models.HisOrderError{
  6708. // UserOrgId: adminUser.CurrentOrgId,
  6709. // Ctime: time.Now().Unix(),
  6710. // Mtime: time.Now().Unix(),
  6711. // Number: chrg_bchno,
  6712. // ErrMsg: res.ErrMsg,
  6713. // Status: 1,
  6714. // PatientId: id,
  6715. // RecordTime: recordDateTime,
  6716. // Stage: 6,
  6717. // }
  6718. // service.CreateErrMsgLog(errlog)
  6719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6720. // return
  6721. // } else {
  6722. // order_src.OrderStatus = 2
  6723. // order_src.PayWay = pay_way
  6724. // order_src.PayPrice = pay_price
  6725. // order_src.PayCardNo = pay_card_no
  6726. // order_src.DiscountPrice = discount_price
  6727. // order_src.PreferentialPrice = preferential_price
  6728. // order_src.RealityPrice = reality_price
  6729. // order_src.FoundPrice = found_price
  6730. // order_src.MedicalInsurancePrice = medical_insurance_price
  6731. // order_src.PrivatePrice = private_price
  6732. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6733. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6734. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6735. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6736. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6737. // order_src.Certno = res.Output.Setlinfo.Certno
  6738. // order_src.Gend = res.Output.Setlinfo.Gend
  6739. // order_src.Naty = res.Output.Setlinfo.Naty
  6740. // order_src.Age = res.Output.Setlinfo.Age
  6741. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6742. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6743. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6744. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6745. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6746. // order_src.MedType = res.Output.Setlinfo.MedType
  6747. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6748. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6749. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6750. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6751. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6752. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6753. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6754. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6755. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6756. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6757. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6758. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6759. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6760. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6761. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6762. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6763. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6764. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6765. // order_src.Balc = res.Output.Setlinfo.Balc
  6766. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6767. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6768. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6769. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6770. // order_src.Creator = order_src.Creator
  6771. // order_src.Modify = roles.ID
  6772. // order_src.RequestLog = src_resquest
  6773. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6774. // detailStr := string(setlDetail)
  6775. // order_src.SetlDetail = detailStr
  6776. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6777. // err = service.UpDateOrder(order_src)
  6778. //
  6779. // if err == nil {
  6780. // c.ServeSuccessJSON(map[string]interface{}{
  6781. // "msg": "结算成功",
  6782. // })
  6783. // } else {
  6784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6785. // return
  6786. // }
  6787. // }
  6788. // }
  6789. //}
  6790. //退款
  6791. func (c *HisApiController) Refund() {
  6792. order_id, _ := c.GetInt64("order_id")
  6793. admin_user_id, _ := c.GetInt64("admin_user_id")
  6794. adminUser := c.GetAdminUserInfo()
  6795. var order models.HisOrder
  6796. order, _ = service.GetHisOrderByID(order_id)
  6797. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6798. if order.ID == 0 {
  6799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6800. return
  6801. }
  6802. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6803. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6804. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6805. if config.IsOpen == 1 { //对接了医保,走医保流程
  6806. var res ResultSixteen
  6807. var resSixteen10265 ResultSixteen10265
  6808. var src_resquest string
  6809. var result string
  6810. if miConfig.MdtrtareaAdmvs == "421300" {
  6811. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6812. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6813. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6814. resp3, requestErr3 := http.Get(api3)
  6815. if requestErr3 != nil {
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6817. return
  6818. }
  6819. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6820. if ioErr3 != nil {
  6821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6823. return
  6824. }
  6825. var respJSON3 map[string]interface{}
  6826. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6829. return
  6830. }
  6831. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6832. userJSONBytes3, _ := json.Marshal(respJSON3)
  6833. fmt.Println("log")
  6834. fmt.Println(string(userJSONBytes3))
  6835. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6836. utils.ErrorLog("解析失败:%v", err)
  6837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6838. return
  6839. }
  6840. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6841. var api3 string
  6842. if miConfig.MdtrtareaAdmvs == "320921" {
  6843. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6844. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6845. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6846. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6847. } else {
  6848. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6849. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6850. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6851. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6852. }
  6853. resp3, requestErr3 := http.Get(api3)
  6854. if requestErr3 != nil {
  6855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6856. return
  6857. }
  6858. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6859. if ioErr3 != nil {
  6860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6862. return
  6863. }
  6864. var respJSON3 map[string]interface{}
  6865. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6868. return
  6869. }
  6870. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6871. userJSONBytes3, _ := json.Marshal(respJSON3)
  6872. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6873. utils.ErrorLog("解析失败:%v", err)
  6874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6875. return
  6876. }
  6877. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6878. res.Output = resSixteen10265.Output
  6879. res.ErrMsg = resSixteen10265.ErrMsg
  6880. res.Cainfo = resSixteen10265.Cainfo
  6881. res.WarnMsg = resSixteen10265.WarnMsg
  6882. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6883. res.Infcode = infocode
  6884. } else {
  6885. if miConfig.Code == "H15049901371" {
  6886. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6887. var dat map[string]interface{}
  6888. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6889. fmt.Println(dat)
  6890. } else {
  6891. fmt.Println(err)
  6892. }
  6893. saveLog(result, src_resquest, "2208", "退费")
  6894. userJSONBytes, _ := json.Marshal(dat)
  6895. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6896. utils.ErrorLog("解析失败:%v", err)
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6898. return
  6899. }
  6900. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6901. res.Output = resSixteen10265.Output
  6902. res.ErrMsg = resSixteen10265.ErrMsg
  6903. res.Cainfo = resSixteen10265.Cainfo
  6904. res.WarnMsg = resSixteen10265.WarnMsg
  6905. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6906. res.Infcode = infocode
  6907. } else {
  6908. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6909. var dat map[string]interface{}
  6910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6911. fmt.Println(dat)
  6912. } else {
  6913. fmt.Println(err)
  6914. }
  6915. saveLog(result, src_resquest, "2208", "退费")
  6916. userJSONBytes, _ := json.Marshal(dat)
  6917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6918. utils.ErrorLog("解析失败:%v", err)
  6919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6920. return
  6921. }
  6922. }
  6923. }
  6924. if res.Infcode == 0 {
  6925. var res2 ResultSix
  6926. var resSix10265 ResultSix10265
  6927. if miConfig.MdtrtareaAdmvs == "421300" {
  6928. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6929. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6930. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6931. resp3, requestErr3 := http.Get(api3)
  6932. if requestErr3 != nil {
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. return
  6935. }
  6936. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6937. if ioErr3 != nil {
  6938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6940. return
  6941. }
  6942. var respJSON3 map[string]interface{}
  6943. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6946. return
  6947. }
  6948. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6949. userJSONBytes3, _ := json.Marshal(respJSON3)
  6950. fmt.Println("log")
  6951. fmt.Println(string(userJSONBytes3))
  6952. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6953. utils.ErrorLog("解析失败:%v", err)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6958. var api3 string
  6959. if miConfig.MdtrtareaAdmvs == "320921" {
  6960. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6961. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6963. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6964. } else {
  6965. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6966. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6967. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6968. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6969. }
  6970. resp3, requestErr3 := http.Get(api3)
  6971. if requestErr3 != nil {
  6972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6973. return
  6974. }
  6975. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6976. if ioErr3 != nil {
  6977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6979. return
  6980. }
  6981. var respJSON3 map[string]interface{}
  6982. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6985. return
  6986. }
  6987. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6988. userJSONBytes3, _ := json.Marshal(respJSON3)
  6989. fmt.Println("log")
  6990. fmt.Println(string(userJSONBytes3))
  6991. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6992. utils.ErrorLog("解析失败:%v", err)
  6993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6994. return
  6995. }
  6996. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6997. res2.Output = resSix10265.Output
  6998. res2.ErrMsg = resSix10265.ErrMsg
  6999. res2.Cainfo = resSix10265.Cainfo
  7000. res2.WarnMsg = resSix10265.WarnMsg
  7001. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7002. res2.Infcode = infocode
  7003. } else {
  7004. if miConfig.Code == "H15049901371" {
  7005. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7006. var dat map[string]interface{}
  7007. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7008. fmt.Println(dat)
  7009. } else {
  7010. fmt.Println(err)
  7011. }
  7012. saveLog(result2, src_request, "2205", "撤销明细")
  7013. userJSONBytes, _ := json.Marshal(dat)
  7014. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7015. utils.ErrorLog("解析失败:%v", err)
  7016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7017. return
  7018. }
  7019. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7020. res2.Output = resSix10265.Output
  7021. res2.ErrMsg = resSix10265.ErrMsg
  7022. res2.Cainfo = resSix10265.Cainfo
  7023. res2.WarnMsg = resSix10265.WarnMsg
  7024. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7025. res2.Infcode = infocode
  7026. } else {
  7027. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7028. var dat map[string]interface{}
  7029. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7030. fmt.Println(dat)
  7031. } else {
  7032. fmt.Println(err)
  7033. }
  7034. saveLog(result2, src_request, "2205", "撤销明细")
  7035. userJSONBytes, _ := json.Marshal(dat)
  7036. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7037. utils.ErrorLog("解析失败:%v", err)
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. return
  7040. }
  7041. }
  7042. }
  7043. if res2.Infcode == 0 {
  7044. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7045. if err == nil {
  7046. c.ServeSuccessJSON(map[string]interface{}{
  7047. "msg": "退费成功",
  7048. })
  7049. } else {
  7050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7051. return
  7052. }
  7053. } else {
  7054. c.ServeSuccessJSON(map[string]interface{}{
  7055. "code": -10,
  7056. "msg": res2.ErrMsg,
  7057. })
  7058. }
  7059. } else {
  7060. c.ServeSuccessJSON(map[string]interface{}{
  7061. "code": -10,
  7062. "msg": res.ErrMsg,
  7063. })
  7064. }
  7065. }
  7066. }
  7067. func (c *HisApiController) RefundNumber() {
  7068. record_time := c.GetString("record_time")
  7069. //patient_id, _ := c.GetInt64("patient_id")
  7070. admin_user_id, _ := c.GetInt64("admin_user_id")
  7071. his_patient_id, _ := c.GetInt64("id")
  7072. timeLayout := "2006-01-02"
  7073. loc, _ := time.LoadLocation("Local")
  7074. adminUser := c.GetAdminUserInfo()
  7075. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7076. fmt.Println(err)
  7077. if err != nil {
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7079. return
  7080. }
  7081. recordDateTime := theTime.Unix()
  7082. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7083. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7084. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7085. //order, _ := service.GetHisOrderByID(order_id)
  7086. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7087. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7088. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7089. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7090. if count > 0 {
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7092. return
  7093. }
  7094. if config.IsOpen == 1 { //对接了医保,走医保流程
  7095. var res2 ResultSix
  7096. var resSix10265 ResultSix10265
  7097. if miConfig.MdtrtareaAdmvs == "421300" {
  7098. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7099. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7100. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7101. resp3, requestErr3 := http.Get(api3)
  7102. if requestErr3 != nil {
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. return
  7105. }
  7106. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7107. if ioErr3 != nil {
  7108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7110. return
  7111. }
  7112. var respJSON3 map[string]interface{}
  7113. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7116. return
  7117. }
  7118. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7119. userJSONBytes3, _ := json.Marshal(respJSON3)
  7120. fmt.Println("log")
  7121. fmt.Println(string(userJSONBytes3))
  7122. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7123. utils.ErrorLog("解析失败:%v", err)
  7124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7125. return
  7126. }
  7127. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7128. var api3 string
  7129. if miConfig.MdtrtareaAdmvs == "320921" {
  7130. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7131. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7133. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7134. } else {
  7135. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7136. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7137. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7139. }
  7140. resp3, requestErr3 := http.Get(api3)
  7141. if requestErr3 != nil {
  7142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7143. return
  7144. }
  7145. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7146. if ioErr3 != nil {
  7147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. return
  7150. }
  7151. var respJSON3 map[string]interface{}
  7152. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7155. return
  7156. }
  7157. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7158. userJSONBytes3, _ := json.Marshal(respJSON3)
  7159. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7160. utils.ErrorLog("解析失败:%v", err)
  7161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7162. return
  7163. }
  7164. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7165. res2.Output = resSix10265.Output
  7166. res2.ErrMsg = resSix10265.ErrMsg
  7167. res2.Cainfo = resSix10265.Cainfo
  7168. res2.WarnMsg = resSix10265.WarnMsg
  7169. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7170. res2.Infcode = infocode
  7171. } else {
  7172. var api3 string
  7173. if miConfig.Code == "H15049901371" {
  7174. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7175. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7176. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7177. } else {
  7178. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7179. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7180. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7181. }
  7182. resp3, requestErr3 := http.Get(api3)
  7183. if requestErr3 != nil {
  7184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7185. return
  7186. }
  7187. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7188. if ioErr3 != nil {
  7189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. return
  7192. }
  7193. var respJSON3 map[string]interface{}
  7194. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7200. userJSONBytes3, _ := json.Marshal(respJSON3)
  7201. if miConfig.Code == "H15049901371" {
  7202. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7203. utils.ErrorLog("解析失败:%v", err)
  7204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7205. return
  7206. }
  7207. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7208. res2.Output = resSix10265.Output
  7209. res2.ErrMsg = resSix10265.ErrMsg
  7210. res2.Cainfo = resSix10265.Cainfo
  7211. res2.WarnMsg = resSix10265.WarnMsg
  7212. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7213. res2.Infcode = infocode
  7214. } else {
  7215. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7216. utils.ErrorLog("解析失败:%v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. return
  7219. }
  7220. }
  7221. }
  7222. if res2.Infcode == 0 {
  7223. if err == nil {
  7224. c.ServeSuccessJSON(map[string]interface{}{
  7225. "msg": "退号成功",
  7226. })
  7227. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7228. } else {
  7229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7230. return
  7231. }
  7232. } else {
  7233. c.ServeSuccessJSON(map[string]interface{}{
  7234. "code": -10,
  7235. "msg": res2.ErrMsg,
  7236. })
  7237. }
  7238. } else {
  7239. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7240. //if err == nil {
  7241. // c.ServeSuccessJSON(map[string]interface{}{
  7242. // "msg": "退费成功",
  7243. // })
  7244. //} else {
  7245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7246. // return
  7247. //}
  7248. }
  7249. }
  7250. func (c *HisApiController) RefundDetail() {
  7251. order_id, _ := c.GetInt64("order_id")
  7252. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7253. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7254. number := c.GetString("number")
  7255. record_time := c.GetString("record_time")
  7256. patient_id, _ := c.GetInt64("patient_id")
  7257. //med_type, _ := c.GetInt64("med_type")
  7258. timeLayout := "2006-01-02"
  7259. loc, _ := time.LoadLocation("Local")
  7260. adminUser := c.GetAdminUserInfo()
  7261. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7262. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7263. fmt.Println(err)
  7264. if err != nil {
  7265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7266. return
  7267. }
  7268. recordDateTime := theTime.Unix()
  7269. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7270. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7271. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7272. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7273. var order models.HisOrder
  7274. order, _ = service.GetHisOrderByID(order_id)
  7275. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7276. if config.IsOpen == 1 { //对接了医保,走医保流程
  7277. var res2 ResultSix
  7278. if miConfig.MdtrtareaAdmvs == "421300" {
  7279. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7280. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7282. resp3, requestErr3 := http.Get(api3)
  7283. if requestErr3 != nil {
  7284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7285. return
  7286. }
  7287. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7288. if ioErr3 != nil {
  7289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7291. return
  7292. }
  7293. var respJSON3 map[string]interface{}
  7294. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7297. return
  7298. }
  7299. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7300. userJSONBytes3, _ := json.Marshal(respJSON3)
  7301. fmt.Println("log")
  7302. fmt.Println(string(userJSONBytes3))
  7303. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7304. utils.ErrorLog("解析失败:%v", err)
  7305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7306. return
  7307. }
  7308. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7309. if err == nil {
  7310. c.ServeSuccessJSON(map[string]interface{}{
  7311. "msg": "撤销明细成功",
  7312. })
  7313. return
  7314. } else {
  7315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7316. return
  7317. }
  7318. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7319. var resSix10265 ResultSix10265
  7320. var api3 string
  7321. if miConfig.MdtrtareaAdmvs == "320921" {
  7322. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7323. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7325. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7326. } else {
  7327. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7328. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7329. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7330. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7331. }
  7332. resp3, requestErr3 := http.Get(api3)
  7333. if requestErr3 != nil {
  7334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7335. return
  7336. }
  7337. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7338. if ioErr3 != nil {
  7339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7341. return
  7342. }
  7343. var respJSON3 map[string]interface{}
  7344. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7347. return
  7348. }
  7349. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7350. userJSONBytes3, _ := json.Marshal(respJSON3)
  7351. fmt.Println("log")
  7352. fmt.Println(string(userJSONBytes3))
  7353. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7354. utils.ErrorLog("解析失败:%v", err)
  7355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. return
  7357. }
  7358. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7359. res2.Output = resSix10265.Output
  7360. res2.ErrMsg = resSix10265.ErrMsg
  7361. res2.Cainfo = resSix10265.Cainfo
  7362. res2.WarnMsg = resSix10265.WarnMsg
  7363. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7364. res2.Infcode = infocode
  7365. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7366. if err == nil {
  7367. c.ServeSuccessJSON(map[string]interface{}{
  7368. "msg": "撤销明细成功",
  7369. })
  7370. return
  7371. } else {
  7372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7373. return
  7374. }
  7375. } else {
  7376. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7377. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7378. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7379. resp2, requestErr2 := http.Get(api2)
  7380. if requestErr2 != nil {
  7381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7382. return
  7383. }
  7384. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7385. if ioErr2 != nil {
  7386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7388. return
  7389. }
  7390. var respJSON2 map[string]interface{}
  7391. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7394. return
  7395. }
  7396. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7397. if err == nil {
  7398. c.ServeSuccessJSON(map[string]interface{}{
  7399. "msg": "撤销明细成功",
  7400. })
  7401. return
  7402. } else {
  7403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7404. return
  7405. }
  7406. }
  7407. } else {
  7408. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7409. if err == nil {
  7410. c.ServeSuccessJSON(map[string]interface{}{
  7411. "msg": "退费成功",
  7412. })
  7413. } else {
  7414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. return
  7416. }
  7417. }
  7418. }
  7419. //对账
  7420. func (c *HisApiController) GetCheckAccount() {
  7421. start_time := c.GetString("start_time")
  7422. end_time := c.GetString("end_time")
  7423. insutype := c.GetString("insutype")
  7424. clr_type := c.GetString("clr_type")
  7425. clr_org := c.GetString("clr_optins")
  7426. admin_user_id, _ := c.GetInt64("admin_user_id")
  7427. adminUser := c.GetAdminUserInfo()
  7428. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7429. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7430. if len(clr_org) == 0 {
  7431. clr_org = miConfig.MdtrtareaAdmvs
  7432. }
  7433. timeLayout := "2006-01-02"
  7434. loc, _ := time.LoadLocation("Local")
  7435. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7436. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7437. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7438. fixmedins_setl_cnt := int64(len(orders))
  7439. var medfee_sumamt float64
  7440. var acct_pay float64
  7441. var fund_pay_sumamt float64
  7442. for _, item := range orders {
  7443. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7444. acct_pay = acct_pay + item.AcctPay
  7445. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7446. }
  7447. var user_name string
  7448. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7449. if role.ID == 0 {
  7450. user_name = "xxx"
  7451. } else {
  7452. user_name = role.UserName
  7453. }
  7454. var res ResultEight
  7455. var res10188 ResultEightFor10188
  7456. if config.IsOpen == 1 {
  7457. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7458. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7459. "insutype=" + insutype +
  7460. "&clr_type=" + "11" +
  7461. "&setl_optins=" + clr_org +
  7462. "&stmt_begndate=" + start_time +
  7463. "&stm_enddate=" + end_time +
  7464. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7465. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7466. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7467. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7468. "&fixmedins_code=" + miConfig.Code +
  7469. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7470. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7471. "&secret_key=" + miConfig.SecretKey +
  7472. "&org_name=" + miConfig.OrgName +
  7473. "&doctor=" + user_name +
  7474. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7475. fmt.Println(api)
  7476. resp, requestErr := http.Get(api)
  7477. if requestErr != nil {
  7478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7479. return
  7480. }
  7481. body, ioErr := ioutil.ReadAll(resp.Body)
  7482. fmt.Println(body)
  7483. if ioErr != nil {
  7484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7486. return
  7487. }
  7488. var respJSON map[string]interface{}
  7489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7492. return
  7493. }
  7494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7495. userJSONBytes, _ := json.Marshal(respJSON)
  7496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7497. utils.ErrorLog("解析失败:%v", err)
  7498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7499. return
  7500. }
  7501. res.InfRefmsgid = res10188.InfRefmsgid
  7502. res.Output = res10188.Output
  7503. res.ErrMsg = res10188.ErrMsg
  7504. res.Cainfo = res10188.Cainfo
  7505. res.WarnMsg = res10188.WarnMsg
  7506. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7507. res.Infcode = infocode
  7508. } else {
  7509. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7510. "insutype=" + insutype +
  7511. "&clr_type=" + clr_type +
  7512. "&setl_optins=" + clr_org +
  7513. "&stmt_begndate=" + start_time +
  7514. "&stm_enddate=" + end_time +
  7515. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7516. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7517. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7518. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7519. "&fixmedins_code=" + miConfig.Code +
  7520. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7521. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7522. "&secret_key=" + miConfig.SecretKey +
  7523. "&org_name=" + miConfig.OrgName +
  7524. "&doctor=" + user_name
  7525. fmt.Println(api)
  7526. resp, requestErr := http.Get(api)
  7527. if requestErr != nil {
  7528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7529. return
  7530. }
  7531. body, ioErr := ioutil.ReadAll(resp.Body)
  7532. fmt.Println(body)
  7533. if ioErr != nil {
  7534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7536. return
  7537. }
  7538. var respJSON map[string]interface{}
  7539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. return
  7543. }
  7544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7545. userJSONBytes, _ := json.Marshal(respJSON)
  7546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7547. utils.ErrorLog("解析失败:%v", err)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7549. return
  7550. }
  7551. }
  7552. if res.Infcode == 0 {
  7553. if res.Output.Stmtinfo.StmtRslt == "0" {
  7554. micc := &models.MedicalInsuranceCostCompare{
  7555. StartTime: startime.Unix(),
  7556. EndTime: endtime.Unix(),
  7557. Insutype: insutype,
  7558. CheckType: 1,
  7559. Num: fixmedins_setl_cnt,
  7560. Mtime: time.Now().Unix(),
  7561. Status: 1,
  7562. UserOrgId: adminUser.CurrentOrgId,
  7563. CostTotal: medfee_sumamt,
  7564. FuncTotal: fund_pay_sumamt,
  7565. PsnPay: acct_pay,
  7566. Creator: admin_user_id,
  7567. Ctime: time.Now().Unix(),
  7568. ClrType: clr_type,
  7569. }
  7570. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7571. if err == nil {
  7572. c.ServeSuccessJSON(map[string]interface{}{
  7573. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7574. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7575. })
  7576. } else {
  7577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7578. }
  7579. } else {
  7580. c.ServeSuccessJSON(map[string]interface{}{
  7581. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7582. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7583. })
  7584. }
  7585. } else {
  7586. c.ServeSuccessJSON(map[string]interface{}{
  7587. "code": -10,
  7588. "msg": res.ErrMsg,
  7589. })
  7590. }
  7591. }
  7592. }
  7593. func (c *HisApiController) Check310() {
  7594. adminUser := c.GetAdminUserInfo()
  7595. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7596. var user_name string
  7597. user_name = "高慧裕"
  7598. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7599. "insutype=" + "310" +
  7600. "&clr_type=" + "" +
  7601. "&setl_optins=" + "441202" +
  7602. "&stmt_begndate=" + "2022-03-01" +
  7603. "&stm_enddate=" + "2022-03-31" +
  7604. "&medfee_sumamt=" + "194930.12" +
  7605. "&fund_pay_sumamt=" + "188741.46" +
  7606. "&acct_pay=" + "0" +
  7607. "&fixmedins_setl_cnt=" + "452" +
  7608. "&fixmedins_code=" + miConfig.Code +
  7609. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7610. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7611. "&secret_key=" + miConfig.SecretKey +
  7612. "&org_name=" + miConfig.OrgName +
  7613. "&doctor=" + user_name
  7614. fmt.Println(api)
  7615. resp, requestErr := http.Get(api)
  7616. if requestErr != nil {
  7617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7618. return
  7619. }
  7620. body, ioErr := ioutil.ReadAll(resp.Body)
  7621. fmt.Println(body)
  7622. if ioErr != nil {
  7623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7625. return
  7626. }
  7627. var respJSON map[string]interface{}
  7628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7631. return
  7632. }
  7633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7634. userJSONBytes, _ := json.Marshal(respJSON)
  7635. var res ResultEight
  7636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7637. utils.ErrorLog("解析失败:%v", err)
  7638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7639. return
  7640. }
  7641. }
  7642. func (c *HisApiController) Check390() {
  7643. adminUser := c.GetAdminUserInfo()
  7644. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7645. var user_name string
  7646. user_name = "高慧裕"
  7647. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7648. "insutype=" + "390" +
  7649. "&clr_type=" + "" +
  7650. "&setl_optins=" + "441202" +
  7651. "&stmt_begndate=" + "2022-03-01" +
  7652. "&stm_enddate=" + "2022-03-31" +
  7653. "&medfee_sumamt=" + "1068448.89" +
  7654. "&fund_pay_sumamt=" + "1014677.62" +
  7655. "&acct_pay=" + "0" +
  7656. "&fixmedins_setl_cnt=" + "1950" +
  7657. "&fixmedins_code=" + miConfig.Code +
  7658. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7659. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7660. "&secret_key=" + miConfig.SecretKey +
  7661. "&org_name=" + miConfig.OrgName +
  7662. "&doctor=" + user_name
  7663. fmt.Println(api)
  7664. resp, requestErr := http.Get(api)
  7665. if requestErr != nil {
  7666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7667. return
  7668. }
  7669. body, ioErr := ioutil.ReadAll(resp.Body)
  7670. fmt.Println(body)
  7671. if ioErr != nil {
  7672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7674. return
  7675. }
  7676. var respJSON map[string]interface{}
  7677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7680. return
  7681. }
  7682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7683. userJSONBytes, _ := json.Marshal(respJSON)
  7684. var res ResultEight
  7685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7686. utils.ErrorLog("解析失败:%v", err)
  7687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7688. return
  7689. }
  7690. }
  7691. //对账明细
  7692. func (c *HisApiController) GetCheckDetailAccount() {
  7693. start_time := c.GetString("start_time")
  7694. end_time := c.GetString("end_time")
  7695. admin_user_id, _ := c.GetInt64("admin_user_id")
  7696. adminUser := c.GetAdminUserInfo()
  7697. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7698. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7699. timeLayout := "2006-01-02"
  7700. loc, _ := time.LoadLocation("Local")
  7701. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7702. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7703. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7704. Mkdir(miConfig.OrgName)
  7705. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7706. file_name := file + ".txt"
  7707. zip_name := file + ".zip"
  7708. zip_path := miConfig.OrgName + "/" + zip_name
  7709. file_path := miConfig.OrgName + "/" + file_name
  7710. decimal.DivisionPrecision = 2
  7711. var medfee_sumamt float64
  7712. var psn_cash_pay float64
  7713. var fund_pay_sumamt float64
  7714. fixmedins_setl_cnt := int64(len(orders))
  7715. for _, item := range orders {
  7716. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7717. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7718. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7719. }
  7720. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7721. defer f.Close()
  7722. if err != nil {
  7723. fmt.Println(err.Error())
  7724. } else {
  7725. for _, item := range orders {
  7726. var refd_setl_flag string
  7727. if item.OrderStatus == 2 {
  7728. refd_setl_flag = "0"
  7729. var str string
  7730. str = item.SetlId + " " +
  7731. item.MdtrtId + " " +
  7732. item.PsnNo + " " +
  7733. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7734. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7735. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7736. _, err = f.Write([]byte(str))
  7737. }
  7738. if item.OrderStatus == 3 {
  7739. var str string
  7740. str = item.SetlId + " " +
  7741. item.MdtrtId + " " +
  7742. item.PsnNo + " " +
  7743. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7744. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7745. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7746. _, err = f.Write([]byte(str))
  7747. var str2 string
  7748. str2 = item.SetlId + " " +
  7749. item.MdtrtId + " " +
  7750. item.PsnNo + " " +
  7751. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7752. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7753. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7754. _, err = f.Write([]byte(str2))
  7755. }
  7756. }
  7757. }
  7758. Zip(file_path, zip_path)
  7759. fmt.Println(ReadFile(zip_path))
  7760. fmt.Println(string(ReadFile(zip_path)))
  7761. if config.IsOpen == 1 {
  7762. var user_name string
  7763. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7764. if role.ID == 0 {
  7765. user_name = "管理员"
  7766. } else {
  7767. user_name = role.UserName
  7768. }
  7769. baseParams := models.BaseParams{
  7770. SecretKey: miConfig.SecretKey,
  7771. FixmedinsCode: miConfig.Code,
  7772. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7773. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7774. OrgName: miConfig.OrgName,
  7775. Doctor: user_name,
  7776. }
  7777. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7778. var dat map[string]interface{}
  7779. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7780. fmt.Println(dat)
  7781. } else {
  7782. fmt.Println(err)
  7783. }
  7784. userJSONBytes, _ := json.Marshal(dat)
  7785. var res ResultNine
  7786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7787. utils.ErrorLog("解析失败:%v", err)
  7788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7789. return
  7790. }
  7791. if res.Infcode == 0 {
  7792. fileNo := res.Output.FileQuryNo
  7793. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7794. "file_qury_no=" + fileNo +
  7795. "&setl_optins=" + "定点医保中心" +
  7796. "&stmt_begndate=" + start_time +
  7797. "&stm_enddate=" + end_time +
  7798. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7799. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7800. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7801. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7802. "&fixmedins_code=" + miConfig.Code +
  7803. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7804. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7805. "&secret_key=" + miConfig.SecretKey +
  7806. "&org_name=" + miConfig.OrgName +
  7807. "&doctor=" + user_name
  7808. resp, requestErr := http.Get(api)
  7809. if requestErr != nil {
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7811. return
  7812. }
  7813. body, ioErr := ioutil.ReadAll(resp.Body)
  7814. if ioErr != nil {
  7815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7817. return
  7818. }
  7819. var respJSON map[string]interface{}
  7820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7823. return
  7824. }
  7825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7826. userJSONBytes, _ := json.Marshal(respJSON)
  7827. var res ResultTen
  7828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7829. utils.ErrorLog("解析失败:%v", err)
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. if res.Infcode == 0 {
  7834. service.Gdyb9102(baseParams, zip_name, fileNo)
  7835. micc := &models.MedicalInsuranceCostCompare{
  7836. StartTime: startime.Unix(),
  7837. EndTime: endtime.Unix(),
  7838. Insutype: "0",
  7839. CheckType: 2,
  7840. Num: fixmedins_setl_cnt,
  7841. Mtime: time.Now().Unix(),
  7842. Status: 1,
  7843. UserOrgId: adminUser.CurrentOrgId,
  7844. CostTotal: medfee_sumamt,
  7845. FuncTotal: fund_pay_sumamt,
  7846. PsnPay: psn_cash_pay,
  7847. Creator: admin_user_id,
  7848. Ctime: time.Now().Unix(),
  7849. }
  7850. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7851. c.ServeSuccessJSON(map[string]interface{}{
  7852. "msg": "明细对账成功",
  7853. })
  7854. }
  7855. } else {
  7856. }
  7857. }
  7858. }
  7859. type CustomOrderInfo struct {
  7860. Name string
  7861. Spec string
  7862. Unit string
  7863. Count float64
  7864. Price float64
  7865. Total float64
  7866. }
  7867. func (c *HisApiController) GetSettleAccounts() {
  7868. //id, _ := c.GetInt64("id")
  7869. //record_time := c.GetString("record_time")
  7870. order_id, _ := c.GetInt64("order_id")
  7871. admin_user_id, _ := c.GetInt64("admin_user_id")
  7872. //timeLayout := "2006-01-02"
  7873. //loc, _ := time.LoadLocation("Local")
  7874. //
  7875. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7876. //if err != nil {
  7877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7878. // return
  7879. //}
  7880. //recordDateTime := theTime.Unix()
  7881. adminUser := c.GetAdminUserInfo()
  7882. order, _ := service.GetHisOrderByID(order_id)
  7883. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7884. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7885. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7886. orderInfos = append(orderInfos, orderInfos_two...)
  7887. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7888. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7889. var diagnosis_ids []string
  7890. if his.ID > 0 {
  7891. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  7892. } else {
  7893. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  7894. }
  7895. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7896. var dia_config []*models.HisXtDiagnoseConfig
  7897. var name string
  7898. for _, item := range diagnosis_ids {
  7899. id, _ := strconv.ParseInt(item, 10, 64)
  7900. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7901. dia_config = append(dia_config, &diagnosisConfig)
  7902. if len(name) == 0 {
  7903. name = diagnosisConfig.ClassName
  7904. } else {
  7905. name = name + "," + diagnosisConfig.ClassName
  7906. }
  7907. }
  7908. var bedCostTotal float64 = 0 //床位总费
  7909. var bedCostSelfTotal float64 = 0 //床位自费
  7910. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7911. var operationCostTotal float64 = 0 //手术费
  7912. var operationCostSelfTotal float64 = 0 //手术费
  7913. var operationCostPartSelfTotal float64 = 0 //手术费
  7914. var otherCostTotal float64 = 0 //其他费用
  7915. var otherCostSelfTotal float64 = 0 //其他费用
  7916. var otherCostPartSelfTotal float64 = 0 //其他费用
  7917. var materialCostTotal float64 = 0 //材料费
  7918. var materialCostSelfTotal float64 = 0 //材料费
  7919. var materialCostPartSelfTotal float64 = 0 //材料费
  7920. var westernMedicineCostTotal float64 = 0 //西药费
  7921. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7922. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7923. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7924. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7925. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7926. var checkCostTotal float64 = 0 //检查费
  7927. var checkCostSelfTotal float64 = 0 //检查费
  7928. var checkCostPartSelfTotal float64 = 0 //检查费
  7929. var laboratoryCostTotal float64 = 0 //化验费
  7930. var laboratoryCostSelfTotal float64 = 0 //化验费
  7931. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7932. var treatCostTotal float64 = 0 //治疗费用
  7933. var treatCostSelfTotal float64 = 0 //治疗费用
  7934. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7935. decimal.DivisionPrecision = 2
  7936. for _, item := range orderInfos {
  7937. if item.MedChrgitmType == "01" { //床位费
  7938. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7939. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7940. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7941. }
  7942. if item.MedChrgitmType == "03" { //检查费
  7943. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7944. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7945. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7946. }
  7947. if item.MedChrgitmType == "04" { //化验费
  7948. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7949. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7950. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7951. }
  7952. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7953. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7954. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7955. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7956. }
  7957. if item.MedChrgitmType == "06" { //手术费
  7958. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7959. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7960. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7961. }
  7962. if item.MedChrgitmType == "08" { //材料费
  7963. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7964. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7965. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7966. }
  7967. if item.MedChrgitmType == "09" { //西药费
  7968. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7969. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7970. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7971. }
  7972. if item.MedChrgitmType == "11" { //中成费
  7973. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7974. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7975. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7976. }
  7977. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  7978. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7979. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7980. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7981. }
  7982. }
  7983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7984. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7985. var user_name string
  7986. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7987. if role.ID == 0 {
  7988. user_name = "管理员"
  7989. } else {
  7990. user_name = role.UserName
  7991. }
  7992. baseParams := models.BaseParams{
  7993. SecretKey: miConfig.SecretKey,
  7994. FixmedinsCode: miConfig.Code,
  7995. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7996. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7997. OrgName: miConfig.OrgName,
  7998. Doctor: user_name,
  7999. }
  8000. businessParams := models.BusinessParams{
  8001. PsnNo: order.PsnNo,
  8002. MdtrtId: order.MdtrtId,
  8003. SetlId: order.SetlId,
  8004. }
  8005. var res ResultEleven
  8006. var resEleven10265 ResultEleven10265
  8007. if config.IsOpen == 1 {
  8008. if miConfig.MdtrtareaAdmvs == "421300" {
  8009. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8010. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8011. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8012. resp, requestErr := http.Get(api)
  8013. if requestErr != nil {
  8014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8015. return
  8016. }
  8017. body, ioErr := ioutil.ReadAll(resp.Body)
  8018. if ioErr != nil {
  8019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8021. return
  8022. }
  8023. var respJSON map[string]interface{}
  8024. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8027. return
  8028. }
  8029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8030. result, _ := json.Marshal(respJSON)
  8031. fmt.Println("log")
  8032. fmt.Println(string(result))
  8033. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8034. utils.ErrorLog("解析失败:%v", err)
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8036. return
  8037. }
  8038. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8039. var api string
  8040. if miConfig.MdtrtareaAdmvs == "320921" {
  8041. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8042. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8043. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8044. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8045. } else {
  8046. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8047. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8048. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8049. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8050. }
  8051. resp, requestErr := http.Get(api)
  8052. if requestErr != nil {
  8053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8054. return
  8055. }
  8056. body, ioErr := ioutil.ReadAll(resp.Body)
  8057. if ioErr != nil {
  8058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8060. return
  8061. }
  8062. var respJSON map[string]interface{}
  8063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8066. return
  8067. }
  8068. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8069. result, _ := json.Marshal(respJSON)
  8070. fmt.Println("log")
  8071. fmt.Println(string(result))
  8072. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8073. utils.ErrorLog("解析失败:%v", err)
  8074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. return
  8076. }
  8077. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8078. res.Output = resEleven10265.Output
  8079. res.ErrMsg = resEleven10265.ErrMsg
  8080. res.Cainfo = resEleven10265.Cainfo
  8081. res.WarnMsg = resEleven10265.WarnMsg
  8082. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8083. res.Infcode = infocode
  8084. } else {
  8085. //result2 := service.Gdyb1101()
  8086. //result2 := service.Gdyb5204(baseParams, businessParams)
  8087. //saveLog(result2, "", "5204", "查询")
  8088. result := service.Gdyb5203(baseParams, businessParams)
  8089. var dat map[string]interface{}
  8090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8091. fmt.Println(dat)
  8092. } else {
  8093. fmt.Println(err)
  8094. }
  8095. userJSONBytes, _ := json.Marshal(dat)
  8096. if miConfig.Code == "H15049901371" {
  8097. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8103. res.Output = resEleven10265.Output
  8104. res.ErrMsg = resEleven10265.ErrMsg
  8105. res.Cainfo = resEleven10265.Cainfo
  8106. res.WarnMsg = resEleven10265.WarnMsg
  8107. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8108. res.Infcode = infocode
  8109. } else {
  8110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8111. utils.ErrorLog("解析失败:%v", err)
  8112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8113. return
  8114. }
  8115. }
  8116. }
  8117. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8118. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8119. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8120. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8121. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8122. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8123. var doctor_name string
  8124. if roles.ID == 0 {
  8125. doctor_name = "管理员"
  8126. } else {
  8127. doctor_name = roles.UserName
  8128. }
  8129. yiliao_leibie := ""
  8130. switch order.MedType {
  8131. case "11":
  8132. yiliao_leibie = "普通门诊"
  8133. break
  8134. case "12":
  8135. yiliao_leibie = "门诊挂号"
  8136. break
  8137. case "13":
  8138. yiliao_leibie = "急诊"
  8139. break
  8140. case "14":
  8141. yiliao_leibie = "门诊特殊病"
  8142. break
  8143. case "15":
  8144. yiliao_leibie = "门诊统筹"
  8145. break
  8146. case "16":
  8147. yiliao_leibie = "门诊慢性病"
  8148. break
  8149. case "21":
  8150. yiliao_leibie = "普通住院"
  8151. break
  8152. }
  8153. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8154. if res.Infcode == 0 {
  8155. c.ServeSuccessJSON(map[string]interface{}{
  8156. "diagnosis": name,
  8157. "order_infos": orderInfos,
  8158. "number": order.MdtrtId,
  8159. "date": order.SettleAccountsDate,
  8160. "charge_admin": charge_admin,
  8161. "printor_admin": printor_admin,
  8162. "info": res.Output.Setlinfo,
  8163. "order": order,
  8164. "bedCostTotal": bedCostTotal,
  8165. "bedCostSelfTotal": bedCostSelfTotal,
  8166. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8167. "operationCostTotal": operationCostTotal,
  8168. "operationCostSelfTotal": operationCostSelfTotal,
  8169. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8170. "otherCostTotal": otherCostTotal,
  8171. "otherCostSelfTotal": otherCostSelfTotal,
  8172. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8173. "materialCostTotal": materialCostTotal,
  8174. "materialCostSelfTotal": materialCostSelfTotal,
  8175. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8176. "westernMedicineCostTotal": westernMedicineCostTotal,
  8177. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8178. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8179. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8180. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8181. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8182. "checkCostTotal": checkCostTotal,
  8183. "checkCostSelfTotal": checkCostSelfTotal,
  8184. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8185. "laboratoryCostTotal": laboratoryCostTotal,
  8186. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8187. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8188. "treatCostTotal": treatCostTotal,
  8189. "treatCostSelfTotal": treatCostSelfTotal,
  8190. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8191. "doctor_info": doctor_info,
  8192. "doctor_code": adminRole_two.DoctorCode,
  8193. "doctor_name": doctor_name,
  8194. "health_card_no": order.PsnNo,
  8195. "department": departments.Name,
  8196. "yiliao_leibie": yiliao_leibie,
  8197. "after_money": order.AccountPrice,
  8198. "patient": patient,
  8199. "org_name": miConfig.OrgName,
  8200. "org_code": miConfig.Code,
  8201. "order_number": order.Number,
  8202. "his_hospital": his_hospital,
  8203. "his": his,
  8204. "dia_config": dia_config,
  8205. //"check_order_info": cus_slice,
  8206. })
  8207. }
  8208. }
  8209. }
  8210. func (c *HisApiController) CheckTreatment() {
  8211. patient_id, _ := c.GetInt64("patient_id")
  8212. id_card_no := c.GetString("id_card_no")
  8213. insutype := c.GetString("insutype")
  8214. med_type := c.GetString("med_type")
  8215. admin_user_id, _ := c.GetInt64("admin_user_id")
  8216. adminUser := c.GetAdminUserInfo()
  8217. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8218. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8219. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8220. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8221. if miConfig.MdtrtareaAdmvs == "421300" {
  8222. var res ResultTwo
  8223. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8224. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8225. "&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)
  8226. resp, requestErr := http.Get(api)
  8227. if requestErr != nil {
  8228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8229. return
  8230. }
  8231. body, ioErr := ioutil.ReadAll(resp.Body)
  8232. if ioErr != nil {
  8233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8235. return
  8236. }
  8237. var respJSON map[string]interface{}
  8238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8241. return
  8242. }
  8243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8244. result, _ := json.Marshal(respJSON)
  8245. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8246. utils.ErrorLog("解析失败:%v", err)
  8247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8248. return
  8249. }
  8250. if res.Infcode == 0 {
  8251. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8252. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8254. resp, requestErr := http.Get(api)
  8255. if requestErr != nil {
  8256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8257. return
  8258. }
  8259. body, ioErr := ioutil.ReadAll(resp.Body)
  8260. if ioErr != nil {
  8261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8263. return
  8264. }
  8265. var respJSON map[string]interface{}
  8266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8269. return
  8270. }
  8271. var res Result2001
  8272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8273. result2, _ := json.Marshal(respJSON)
  8274. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8275. utils.ErrorLog("解析失败:%v", err)
  8276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8277. return
  8278. }
  8279. if res.Infcode == 0 {
  8280. c.ServeSuccessJSON(map[string]interface{}{
  8281. "msg": res.Output.Trtinfo,
  8282. })
  8283. }
  8284. } else {
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8286. return
  8287. }
  8288. } else {
  8289. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8290. var dat map[string]interface{}
  8291. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8292. fmt.Println(dat)
  8293. } else {
  8294. fmt.Println(err)
  8295. }
  8296. userJSONBytes, _ := json.Marshal(dat)
  8297. var res ResultTwo
  8298. var res10265 ResultTwo10265
  8299. if miConfig.Code == "H15049901371" {
  8300. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8301. utils.ErrorLog("解析失败:%v", err)
  8302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8303. return
  8304. }
  8305. res.ErrMsg = res10265.ErrMsg
  8306. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8307. res.Infcode = infocode
  8308. res.Output = res10265.Output
  8309. res.InfRefmsgid = res10265.InfRefmsgid
  8310. } else {
  8311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8312. utils.ErrorLog("解析失败:%v", err)
  8313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8314. return
  8315. }
  8316. }
  8317. var user_name string
  8318. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8319. if role.ID == 0 {
  8320. user_name = "xxx"
  8321. } else {
  8322. user_name = role.UserName
  8323. }
  8324. baseParams := models.BaseParams{
  8325. SecretKey: miConfig.SecretKey,
  8326. FixmedinsCode: miConfig.Code,
  8327. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8328. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8329. OrgName: miConfig.OrgName,
  8330. Doctor: user_name,
  8331. }
  8332. if config.IsOpen == 1 {
  8333. if miConfig.Code == "H15049901371" {
  8334. if med_type == "14" {
  8335. if insutype == "390" {
  8336. med_type = "9933"
  8337. } else if insutype == "310" {
  8338. med_type = "990502"
  8339. }
  8340. } else if med_type == "11" {
  8341. med_type = "11"
  8342. }
  8343. }
  8344. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8345. var dat map[string]interface{}
  8346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8347. fmt.Println(dat)
  8348. } else {
  8349. fmt.Println(err)
  8350. }
  8351. var res Result2001
  8352. var res10265 Result2001Org10265
  8353. if miConfig.Code == "H15049901371" {
  8354. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8355. utils.ErrorLog("解析失败:%v", err)
  8356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8357. return
  8358. }
  8359. res.ErrMsg = res10265.ErrMsg
  8360. res.Output = res10265.Output
  8361. res.InfRefmsgid = res10265.InfRefmsgid
  8362. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8363. res.Infcode = infocode
  8364. } else {
  8365. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8366. utils.ErrorLog("解析失败:%v", err)
  8367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8368. return
  8369. }
  8370. }
  8371. if res.Infcode == 0 {
  8372. c.ServeSuccessJSON(map[string]interface{}{
  8373. "msg": res.Output.Trtinfo,
  8374. })
  8375. }
  8376. }
  8377. }
  8378. }
  8379. //func (c *HisApiController) PutRecord() {
  8380. // id, _ := c.GetInt64("id")
  8381. // record_time := c.GetString("record_time")
  8382. // timeLayout := "2006-01-02"
  8383. // loc, _ := time.LoadLocation("Local")
  8384. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8385. // if err != nil {
  8386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8387. // return
  8388. // }
  8389. // recordDateTime := theTime.Unix()
  8390. //
  8391. // adminInfo := c.GetAdminUserInfo()
  8392. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8393. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8394. //
  8395. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8396. //
  8397. // fmt.Println(miConfig.SecretKey)
  8398. //
  8399. // if patient == nil {
  8400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8401. // return
  8402. // }
  8403. // if len(patient.IdCardNo) == 0 {
  8404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8405. // return
  8406. // }
  8407. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8408. // if config.IsOpen == 1 {
  8409. // 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
  8410. // resp, requestErr := http.Get(api)
  8411. // if requestErr != nil {
  8412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8413. // return
  8414. // }
  8415. // defer resp.Body.Close()
  8416. // body, ioErr := ioutil.ReadAll(resp.Body)
  8417. // if ioErr != nil {
  8418. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8420. // return
  8421. // }
  8422. // var respJSON map[string]interface{}
  8423. //
  8424. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8425. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8427. // return
  8428. // }
  8429. //
  8430. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8431. // userJSONBytes, _ := json.Marshal(userJSON)
  8432. // var res ResultTwo
  8433. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8434. // utils.ErrorLog("解析失败:%v", err)
  8435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8436. // return
  8437. // }
  8438. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8439. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8440. // infoStr := string(Iinfos)
  8441. // idetinfoStr := string(Idetinfos)
  8442. //
  8443. // if res.Infcode == 0 {
  8444. // his := models.VMHisPatient{
  8445. // Status: 1,
  8446. // Ctime: time.Now().Unix(),
  8447. // Mtime: time.Now().Unix(),
  8448. // PsnNo: res.Output.Baseinfo.PsnNo,
  8449. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8450. // Certno: res.Output.Baseinfo.Certno,
  8451. // PsnName: res.Output.Baseinfo.PsnName,
  8452. // Gend: res.Output.Baseinfo.Gend,
  8453. // Naty: res.Output.Baseinfo.Naty,
  8454. // Brdy: res.Output.Baseinfo.Brdy,
  8455. // Age: res.Output.Baseinfo.Age,
  8456. // Iinfo: infoStr,
  8457. // Idetinfo: idetinfoStr,
  8458. // PatientId: patient.ID,
  8459. // RecordDate: theTime.Unix(),
  8460. // UserOrgId: adminInfo.CurrentOrgId,
  8461. // AdminUserId: adminInfo.AdminUser.Id,
  8462. // IsReturn: 1,
  8463. // }
  8464. //
  8465. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8466. // //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")
  8467. // //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")
  8468. //
  8469. // //var dat map[string]interface{}
  8470. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8471. // // fmt.Println(dat)
  8472. // //} else {
  8473. // // fmt.Println(err)
  8474. // //}
  8475. //
  8476. // var dat2 map[string]interface{}
  8477. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8478. // fmt.Println(dat2)
  8479. // } else {
  8480. // fmt.Println(err)
  8481. // }
  8482. //
  8483. // } else {
  8484. // adminUser := c.GetAdminUserInfo()
  8485. // errlog := &models.HisOrderError{
  8486. // UserOrgId: adminUser.CurrentOrgId,
  8487. // Ctime: time.Now().Unix(),
  8488. // Mtime: time.Now().Unix(),
  8489. // ErrMsg: res.ErrMsg,
  8490. // Status: 1,
  8491. // PatientId: id,
  8492. // RecordTime: recordDateTime,
  8493. // Stage: 1,
  8494. // }
  8495. // service.CreateErrMsgLog(errlog)
  8496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8497. // return
  8498. // }
  8499. // }
  8500. //
  8501. //}
  8502. //func (c *HisApiController) GetUploadDiag() {
  8503. // id, _ := c.GetInt64("id")
  8504. // record_time := c.GetString("record_time")
  8505. //
  8506. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8507. // sick_type, _ := c.GetInt64("sick_type")
  8508. // reg_type, _ := c.GetInt64("reg_type")
  8509. //
  8510. // timeLayout := "2006-01-02"
  8511. // loc, _ := time.LoadLocation("Local")
  8512. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8513. // if err != nil {
  8514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8515. // return
  8516. // }
  8517. //
  8518. // var patientPrescription models.HisPrescriptionInfo
  8519. // recordDateTime := theTime.Unix()
  8520. // adminInfo := c.GetAdminUserInfo()
  8521. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8522. //
  8523. // if patientPrescription.ID == 0 {
  8524. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8525. // }
  8526. //
  8527. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8528. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8529. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8530. // sickConfig, _ := service.FindSickById(sick_type)
  8531. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8532. //
  8533. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8534. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8535. // "&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 +
  8536. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8537. // resp2, requestErr2 := http.Get(api2)
  8538. // if requestErr2 != nil {
  8539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8540. // return
  8541. // }
  8542. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8543. // if ioErr2 != nil {
  8544. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8546. // return
  8547. // }
  8548. // var respJSON2 map[string]interface{}
  8549. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8550. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8552. // return
  8553. // }
  8554. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8555. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8556. //
  8557. // var res2 ResultSix
  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. // adminUser := c.GetAdminUserInfo()
  8565. // errlog := &models.HisOrderError{
  8566. // UserOrgId: adminUser.CurrentOrgId,
  8567. // Ctime: time.Now().Unix(),
  8568. // Mtime: time.Now().Unix(),
  8569. // ErrMsg: res2.ErrMsg,
  8570. // Status: 1,
  8571. // PatientId: id,
  8572. // RecordTime: recordDateTime,
  8573. // Stage: 3,
  8574. // }
  8575. // service.CreateErrMsgLog(errlog)
  8576. //
  8577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8578. // return
  8579. // }
  8580. //
  8581. // c.ServeSuccessJSON(map[string]interface{}{
  8582. // "msg": "上传成功",
  8583. // })
  8584. //
  8585. //}
  8586. type QueryResult struct {
  8587. ID int64
  8588. Name string
  8589. Code string
  8590. List_type_code string
  8591. }
  8592. func (c *HisApiController) GetCheckCode() {
  8593. ids_str := c.GetString("ids")
  8594. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8595. ids_arr := strings.Split(ids_str, ",")
  8596. var queryResult []QueryResult
  8597. ids := make([]int64, 0)
  8598. for _, item := range ids_arr {
  8599. id, _ := strconv.ParseInt(item, 10, 64)
  8600. ids = append(ids, id)
  8601. }
  8602. if record_type == 1 {
  8603. drugs, _ := service.GetBatchDrugList(ids)
  8604. for _, item := range drugs {
  8605. result := QueryResult{
  8606. ID: item.ID,
  8607. Name: item.DrugName,
  8608. Code: item.MedicalInsuranceNumber,
  8609. List_type_code: "101",
  8610. }
  8611. queryResult = append(queryResult, result)
  8612. }
  8613. } else if record_type == 2 {
  8614. goods, _ := service.GetBatchGoodInformationList(ids)
  8615. for _, item := range goods {
  8616. result := QueryResult{
  8617. ID: item.ID,
  8618. Name: item.GoodName,
  8619. Code: item.MedicalInsuranceNumber,
  8620. List_type_code: "301",
  8621. }
  8622. queryResult = append(queryResult, result)
  8623. }
  8624. } else if record_type == 3 {
  8625. projects, _ := service.GetBathchMyPorjecgList(ids)
  8626. for _, item := range projects {
  8627. result := QueryResult{
  8628. ID: item.ID,
  8629. Name: item.ProjectName,
  8630. Code: item.MedicalCode,
  8631. List_type_code: "201",
  8632. }
  8633. queryResult = append(queryResult, result)
  8634. }
  8635. }
  8636. admin_user_id, _ := c.GetInt64("admin_user_id")
  8637. adminUser := c.GetAdminUserInfo()
  8638. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8639. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8640. var user_name string
  8641. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8642. if role.ID == 0 {
  8643. user_name = "xxx"
  8644. } else {
  8645. user_name = role.UserName
  8646. }
  8647. baseParams := &models.BaseParams{
  8648. SecretKey: miConfig.SecretKey,
  8649. FixmedinsCode: miConfig.Code,
  8650. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8651. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8652. OrgName: miConfig.OrgName,
  8653. Doctor: user_name,
  8654. }
  8655. if config.IsOpen == 1 {
  8656. for _, item := range queryResult {
  8657. var result string
  8658. if record_type == 1 {
  8659. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8660. } else if record_type == 2 {
  8661. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8662. } else if record_type == 3 {
  8663. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8664. }
  8665. var dat map[string]interface{}
  8666. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8667. fmt.Println(dat)
  8668. } else {
  8669. fmt.Println(err)
  8670. }
  8671. userJSONBytes, _ := json.Marshal(dat)
  8672. var res ResultSix
  8673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8674. utils.ErrorLog("解析失败:%v", err)
  8675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8676. return
  8677. }
  8678. if res.Infcode == 0 {
  8679. if record_type == 1 {
  8680. service.UpdateBaseDrugById(item.ID)
  8681. } else if record_type == 2 {
  8682. service.UpdateGoodInformaitonByDetail(item.ID)
  8683. } else if record_type == 3 {
  8684. service.UpdateProjectById(item.ID)
  8685. }
  8686. c.ServeSuccessJSON(map[string]interface{}{
  8687. "failed_code": 0,
  8688. "msg": "目录对照成功",
  8689. })
  8690. } else {
  8691. c.ServeSuccessJSON(map[string]interface{}{
  8692. "failed_code": -10,
  8693. "msg": res.ErrMsg,
  8694. })
  8695. }
  8696. }
  8697. }
  8698. }
  8699. func (c *HisApiController) UnCheckCode() {
  8700. ids_str := c.GetString("ids")
  8701. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8702. admin_user_id, _ := c.GetInt64("admin_user_id")
  8703. ids_arr := strings.Split(ids_str, ",")
  8704. var queryResult []QueryResult
  8705. ids := make([]int64, 0)
  8706. for _, item := range ids_arr {
  8707. id, _ := strconv.ParseInt(item, 10, 64)
  8708. ids = append(ids, id)
  8709. }
  8710. if record_type == 1 {
  8711. drugs, _ := service.GetBatchDrugList(ids)
  8712. for _, item := range drugs {
  8713. result := QueryResult{
  8714. ID: item.ID,
  8715. Name: item.DrugName,
  8716. Code: item.MedicalInsuranceNumber,
  8717. List_type_code: "101",
  8718. }
  8719. queryResult = append(queryResult, result)
  8720. }
  8721. } else if record_type == 2 {
  8722. goods, _ := service.GetBatchGoodInformationList(ids)
  8723. for _, item := range goods {
  8724. result := QueryResult{
  8725. ID: item.ID,
  8726. Name: item.GoodName,
  8727. Code: item.MedicalInsuranceNumber,
  8728. List_type_code: "301",
  8729. }
  8730. queryResult = append(queryResult, result)
  8731. }
  8732. } else if record_type == 3 {
  8733. projects, _ := service.GetBathchMyPorjecgList(ids)
  8734. for _, item := range projects {
  8735. result := QueryResult{
  8736. ID: item.ID,
  8737. Name: item.ProjectName,
  8738. Code: item.MedicalCode,
  8739. List_type_code: "201",
  8740. }
  8741. queryResult = append(queryResult, result)
  8742. }
  8743. }
  8744. adminUser := c.GetAdminUserInfo()
  8745. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8746. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8747. var user_name string
  8748. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8749. if role.ID == 0 {
  8750. user_name = "xxx"
  8751. } else {
  8752. user_name = role.UserName
  8753. }
  8754. baseParams := &models.BaseParams{
  8755. SecretKey: miConfig.SecretKey,
  8756. FixmedinsCode: miConfig.Code,
  8757. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8758. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8759. OrgName: miConfig.OrgName,
  8760. Doctor: user_name,
  8761. }
  8762. if config.IsOpen == 1 {
  8763. for _, item := range queryResult {
  8764. var result string
  8765. if record_type == 1 {
  8766. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8767. } else if record_type == 2 {
  8768. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8769. } else if record_type == 3 {
  8770. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8771. }
  8772. var dat2 map[string]interface{}
  8773. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8774. fmt.Println(dat2)
  8775. } else {
  8776. fmt.Println(err)
  8777. }
  8778. userJSONBytes, _ := json.Marshal(dat2)
  8779. var res ResultSix
  8780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8781. utils.ErrorLog("解析失败:%v", err)
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8783. return
  8784. }
  8785. if res.Infcode == 0 {
  8786. if record_type == 1 {
  8787. service.UpdateDrugByIdDetail(item.ID)
  8788. } else if record_type == 2 {
  8789. service.UpdateGoodInfoById(item.ID)
  8790. } else if record_type == 3 {
  8791. service.UpdateMyProjectById(item.ID)
  8792. }
  8793. c.ServeSuccessJSON(map[string]interface{}{
  8794. "failed_code": 0,
  8795. "msg": "撤销目录对照成功",
  8796. })
  8797. } else {
  8798. c.ServeSuccessJSON(map[string]interface{}{
  8799. "failed_code": -10,
  8800. "msg": res.ErrMsg,
  8801. })
  8802. }
  8803. }
  8804. }
  8805. }
  8806. func (c *HisApiController) GetPatientInfo() {
  8807. id_card_no := c.GetString("id_card_no")
  8808. admin_user_id, _ := c.GetInt64("admin_user_id")
  8809. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8810. if patient.ID == 0 {
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8812. return
  8813. }
  8814. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8815. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8816. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8817. if config.IsOpen == 1 {
  8818. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8819. var dat map[string]interface{}
  8820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8821. fmt.Println(dat)
  8822. } else {
  8823. fmt.Println(err)
  8824. }
  8825. userJSONBytes, _ := json.Marshal(dat)
  8826. var res ResultTwo
  8827. var res10265 ResultTwo10265
  8828. if miConfig.Code == "H15049901371" {
  8829. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8830. utils.ErrorLog("解析失败:%v", err)
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8832. return
  8833. }
  8834. res.ErrMsg = res10265.ErrMsg
  8835. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8836. res.Infcode = infocode
  8837. res.Output = res10265.Output
  8838. res.InfRefmsgid = res10265.InfRefmsgid
  8839. } else {
  8840. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8841. utils.ErrorLog("解析失败:%v", err)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. }
  8846. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8847. // utils.ErrorLog("解析失败:%v", err)
  8848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. // return
  8850. //}
  8851. if res.Infcode != 0 {
  8852. c.ServeSuccessJSON(map[string]interface{}{
  8853. "failed_code": -10,
  8854. "msg": res.ErrMsg,
  8855. })
  8856. } else {
  8857. c.ServeSuccessJSON(map[string]interface{}{
  8858. "failed_code": 0,
  8859. "info": res,
  8860. })
  8861. }
  8862. }
  8863. }
  8864. func (c *HisApiController) PsnPutOnRecord() {
  8865. record_type, _ := c.GetInt64("type")
  8866. patient_id, _ := c.GetInt64("patient_id")
  8867. admin_user_id, _ := c.GetInt64("admin_user_id")
  8868. start_time := c.GetString("start_time")
  8869. end_time := c.GetString("end_time")
  8870. adminUser := c.GetAdminUserInfo()
  8871. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8872. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8873. var patients []*models.Patients
  8874. if record_type == 1 { //全部备案
  8875. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8876. patients = append(patients, patient...)
  8877. } else { //单个备案
  8878. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8879. patients = append(patients, patient)
  8880. }
  8881. var user_name string
  8882. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8883. if role.ID == 0 {
  8884. user_name = "xxx"
  8885. } else {
  8886. user_name = role.UserName
  8887. }
  8888. if config.IsOpen == 1 {
  8889. for _, item := range patients {
  8890. 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
  8891. resp, requestErr := http.Get(api)
  8892. if requestErr != nil {
  8893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8894. return
  8895. }
  8896. defer resp.Body.Close()
  8897. body, ioErr := ioutil.ReadAll(resp.Body)
  8898. if ioErr != nil {
  8899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. var respJSON map[string]interface{}
  8904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8910. userJSONBytes, _ := json.Marshal(userJSON)
  8911. var res ResultTwo
  8912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8913. utils.ErrorLog("解析失败:%v", err)
  8914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8915. return
  8916. }
  8917. if res.Infcode == 0 {
  8918. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8919. var dat map[string]interface{}
  8920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8921. fmt.Println(dat)
  8922. } else {
  8923. fmt.Println(err)
  8924. }
  8925. userJSONBytes, _ := json.Marshal(dat)
  8926. var res2 ResultThirteen
  8927. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8928. utils.ErrorLog("解析失败:%v", err)
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8930. return
  8931. }
  8932. if res2.Infcode == 0 {
  8933. psnResult := &models.GdybPsnRecord{
  8934. UserOrgId: adminUser.CurrentOrgId,
  8935. PatientId: item.ID,
  8936. PsnNo: res.Output.Baseinfo.PsnNo,
  8937. Ctime: time.Now().Unix(),
  8938. Mtime: time.Now().Unix(),
  8939. Status: 1,
  8940. IsCancel: 1,
  8941. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8942. }
  8943. service.CreatePsnRecord(psnResult)
  8944. } else {
  8945. c.ServeSuccessJSON(map[string]interface{}{
  8946. "failed_code": -10,
  8947. "msg": res2.ErrMsg,
  8948. })
  8949. return
  8950. }
  8951. }
  8952. }
  8953. }
  8954. }
  8955. func (c *HisApiController) PsnUnPutOnRecord() {
  8956. id, _ := c.GetInt64("id")
  8957. //record_type, _ := c.GetInt64("type")
  8958. admin_user_id, _ := c.GetInt64("admin_user_id")
  8959. adminUser := c.GetAdminUserInfo()
  8960. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8961. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8962. var user_name string
  8963. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8964. if role.ID == 0 {
  8965. user_name = "xxx"
  8966. } else {
  8967. user_name = role.UserName
  8968. }
  8969. psn_record, _ := service.GetPsnRecordById(id)
  8970. if psn_record.ID == 0 {
  8971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8972. return
  8973. }
  8974. if config.IsOpen == 1 {
  8975. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8976. var dat map[string]interface{}
  8977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8978. fmt.Println(dat)
  8979. } else {
  8980. fmt.Println(err)
  8981. }
  8982. userJSONBytes, _ := json.Marshal(dat)
  8983. var res ResultFourteen
  8984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8985. utils.ErrorLog("解析失败:%v", err)
  8986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8987. return
  8988. }
  8989. if res.Infcode == 0 {
  8990. psn_record.IsCancel = 2
  8991. service.CreatePsnRecord(&psn_record)
  8992. } else {
  8993. c.ServeSuccessJSON(map[string]interface{}{
  8994. "failed_code": -10,
  8995. "msg": res.ErrMsg,
  8996. })
  8997. return
  8998. }
  8999. }
  9000. }
  9001. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9002. patient_id, _ := c.GetInt64("patient_id")
  9003. insutype_two := c.GetString("insutype")
  9004. psn_no := c.GetString("psn_no")
  9005. doctor_id, _ := c.GetInt64("doctor_id")
  9006. sick_id, _ := c.GetInt64("sick_id")
  9007. department_id, _ := c.GetInt64("department_id")
  9008. start_time := c.GetString("start_time")
  9009. end_time := c.GetString("end_time")
  9010. check_time := c.GetString("check_time")
  9011. adminUser := c.GetAdminUserInfo()
  9012. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9013. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9014. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9015. sick, _ := service.FindSickById(sick_id)
  9016. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9017. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9018. var res ResultTwo
  9019. var res10265 ResultTwo10265
  9020. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9021. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9022. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9023. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9024. "&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
  9025. resp, requestErr := http.Get(api)
  9026. if requestErr != nil {
  9027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9028. return
  9029. }
  9030. body, ioErr := ioutil.ReadAll(resp.Body)
  9031. if ioErr != nil {
  9032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9034. return
  9035. }
  9036. var respJSON map[string]interface{}
  9037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9040. return
  9041. }
  9042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9043. result, _ := json.Marshal(respJSON)
  9044. fmt.Println("log")
  9045. fmt.Println(string(result))
  9046. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9047. utils.ErrorLog("解析失败:%v", err)
  9048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9049. return
  9050. }
  9051. res.ErrMsg = res10265.ErrMsg
  9052. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9053. res.Infcode = infocode
  9054. res.Output = res10265.Output
  9055. res.InfRefmsgid = res10265.InfRefmsgid
  9056. } else {
  9057. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9058. if miConfig.Code == "H15049901371" {
  9059. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9060. utils.ErrorLog("解析失败:%v", err)
  9061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9062. return
  9063. }
  9064. res.ErrMsg = res10265.ErrMsg
  9065. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9066. res.Infcode = infocode
  9067. res.Output = res10265.Output
  9068. res.InfRefmsgid = res10265.InfRefmsgid
  9069. } else {
  9070. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9071. utils.ErrorLog("解析失败:%v", err)
  9072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9073. return
  9074. }
  9075. }
  9076. }
  9077. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9078. infoStr := string(Iinfos)
  9079. var rf []*ResultFive
  9080. json.Unmarshal([]byte(infoStr), &rf)
  9081. var insuplc_admdvs string
  9082. var insutype string
  9083. var is390 int = 0
  9084. var is310 int = 0
  9085. var insutypes []*ResultFive
  9086. for _, item := range rf {
  9087. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9088. insutypes = append(insutypes, item)
  9089. }
  9090. }
  9091. if len(insutypes) == 1 {
  9092. insutype = insutypes[0].Insutype
  9093. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9094. } else {
  9095. for _, i := range insutypes {
  9096. if i.Insutype == "390" {
  9097. is390 = 1
  9098. }
  9099. if i.Insutype == "310" {
  9100. is310 = 1
  9101. }
  9102. }
  9103. }
  9104. if is390 == 1 {
  9105. insutype = "390"
  9106. }
  9107. if is310 == 1 {
  9108. insutype = "310"
  9109. }
  9110. if len(insutypes) == 2 {
  9111. insutype = insutype_two
  9112. }
  9113. if len(insutypes) == 0 {
  9114. insutype = "310"
  9115. }
  9116. insutype = insutype_two
  9117. fmt.Println(insutype)
  9118. for _, item := range rf {
  9119. fmt.Println(item.Insutype)
  9120. fmt.Println(insutype)
  9121. if item.Insutype == insutype {
  9122. fmt.Println(item.Insutype)
  9123. fmt.Println(insutype)
  9124. insuplc_admdvs = item.InsuplcAdmdvs
  9125. }
  9126. }
  9127. fmt.Println(insuplc_admdvs)
  9128. var res2 ResultThirteen
  9129. var res10265_2 ResultThirteen10265
  9130. if config.IsOpen == 1 {
  9131. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9132. } else {
  9133. 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)
  9134. var dat map[string]interface{}
  9135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9136. fmt.Println(dat)
  9137. } else {
  9138. fmt.Println(err)
  9139. }
  9140. userJSONBytes, _ := json.Marshal(dat)
  9141. if miConfig.Code == "H15049901371" {
  9142. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9143. utils.ErrorLog("解析失败:%v", err)
  9144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9145. return
  9146. }
  9147. res2.ErrMsg = res10265_2.ErrMsg
  9148. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9149. res2.Infcode = infocode
  9150. res2.Output = res10265_2.Output
  9151. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9152. } else {
  9153. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9154. utils.ErrorLog("解析失败:%v", err)
  9155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9156. return
  9157. }
  9158. }
  9159. }
  9160. if res2.Infcode == 0 {
  9161. psnResult := &models.GdybPsnNcdsRecord{
  9162. UserOrgId: adminUser.CurrentOrgId,
  9163. PatientId: patient.ID,
  9164. PsnNo: psn_no,
  9165. DoctorId: doctor.AdminUserId,
  9166. DepartmentId: department_id,
  9167. SickType: sick_id,
  9168. Insutype: insutype,
  9169. Ctime: time.Now().Unix(),
  9170. Mtime: time.Now().Unix(),
  9171. Status: 1,
  9172. IsCancel: 1,
  9173. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9174. }
  9175. service.CreatePsnNCDSRecord(psnResult)
  9176. c.ServeSuccessJSON(map[string]interface{}{
  9177. "failed_code": 0,
  9178. "msg": "备案成功",
  9179. "result": psnResult,
  9180. })
  9181. } else {
  9182. c.ServeSuccessJSON(map[string]interface{}{
  9183. "failed_code": -10,
  9184. "msg": res2.ErrMsg,
  9185. })
  9186. return
  9187. }
  9188. }
  9189. }
  9190. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9191. id, _ := c.GetInt64("id")
  9192. admin_user_id, _ := c.GetInt64("admin_user_id")
  9193. adminUser := c.GetAdminUserInfo()
  9194. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9195. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9196. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9197. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9198. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9199. //var user_name string
  9200. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9201. //if role.ID == 0 {
  9202. // user_name = "xxx"
  9203. //} else {
  9204. // user_name = role.UserName
  9205. //}
  9206. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9207. if psn_record.ID == 0 {
  9208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9209. return
  9210. }
  9211. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9212. var res ResultTwo
  9213. var res10265 ResultTwo10265
  9214. if miConfig.Code == "H15049901371" {
  9215. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9216. utils.ErrorLog("解析失败:%v", err)
  9217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9218. return
  9219. }
  9220. res.ErrMsg = res10265.ErrMsg
  9221. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9222. res.Infcode = infocode
  9223. res.Output = res10265.Output
  9224. res.InfRefmsgid = res10265.InfRefmsgid
  9225. } else {
  9226. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9227. utils.ErrorLog("解析失败:%v", err)
  9228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9229. return
  9230. }
  9231. }
  9232. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9233. infoStr := string(Iinfos)
  9234. var rf []*ResultFive
  9235. json.Unmarshal([]byte(infoStr), &rf)
  9236. var insuplc_admdvs string
  9237. var insutype string
  9238. var is390 int = 0
  9239. var is310 int = 0
  9240. var insutypes []*ResultFive
  9241. for _, item := range rf {
  9242. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9243. insutypes = append(insutypes, item)
  9244. }
  9245. }
  9246. if len(insutypes) == 1 {
  9247. insutype = insutypes[0].Insutype
  9248. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9249. } else {
  9250. for _, i := range insutypes {
  9251. if i.Insutype == "390" {
  9252. is390 = 1
  9253. }
  9254. if i.Insutype == "310" {
  9255. is310 = 1
  9256. }
  9257. }
  9258. }
  9259. if is390 == 1 {
  9260. insutype = "390"
  9261. }
  9262. if is310 == 1 {
  9263. insutype = "310"
  9264. }
  9265. if len(insutypes) == 0 {
  9266. insutype = "310"
  9267. }
  9268. insutype = psn_record.Insutype
  9269. for _, item := range rf {
  9270. if item.Insutype == insutype {
  9271. insuplc_admdvs = item.InsuplcAdmdvs
  9272. }
  9273. }
  9274. if config.IsOpen == 1 {
  9275. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9276. var dat map[string]interface{}
  9277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9278. fmt.Println(dat)
  9279. } else {
  9280. fmt.Println(err)
  9281. }
  9282. userJSONBytes, _ := json.Marshal(dat)
  9283. var res ResultFourteen
  9284. var res10265 ResultFourteen10265
  9285. if miConfig.Code == "H15049901371" {
  9286. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9287. utils.ErrorLog("解析失败:%v", err)
  9288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9289. return
  9290. }
  9291. res.ErrMsg = res10265.ErrMsg
  9292. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9293. res.Infcode = infocode
  9294. res.Output = res10265.Output
  9295. res.InfRefmsgid = res10265.InfRefmsgid
  9296. } else {
  9297. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9298. utils.ErrorLog("解析失败:%v", err)
  9299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9300. return
  9301. }
  9302. }
  9303. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9304. // utils.ErrorLog("解析失败:%v", err)
  9305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9306. // return
  9307. //}
  9308. if res.Infcode == 0 {
  9309. psn_record.IsCancel = 2
  9310. service.CreatePsnNCDSRecord(&psn_record)
  9311. c.ServeSuccessJSON(map[string]interface{}{
  9312. "failed_code": 0,
  9313. "msg": "撤销备案成功",
  9314. })
  9315. } else {
  9316. c.ServeSuccessJSON(map[string]interface{}{
  9317. "failed_code": -10,
  9318. "msg": res.ErrMsg,
  9319. })
  9320. return
  9321. }
  9322. }
  9323. }
  9324. func (c *HisApiController) TestTest() {
  9325. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9326. fmt.Println(patient.Iinfo)
  9327. }
  9328. type CustomData struct {
  9329. MsgId string
  9330. PsnNo string
  9331. Info string
  9332. }
  9333. func (c *HisApiController) ReversalData() {
  9334. var customData []*CustomData
  9335. custom := &CustomData{
  9336. MsgId: "H44022900158202103301714472004",
  9337. PsnNo: "44020000001101329945",
  9338. Info: "2207",
  9339. }
  9340. customData = append(customData, custom)
  9341. custom1 := &CustomData{
  9342. MsgId: "H4402290015820210330172057803",
  9343. PsnNo: "44020000001101161813",
  9344. Info: "2207",
  9345. }
  9346. customData = append(customData, custom1)
  9347. custom2 := &CustomData{
  9348. MsgId: "H44022900158202103301705198813",
  9349. PsnNo: "44190000133097375417",
  9350. Info: "2207",
  9351. }
  9352. customData = append(customData, custom2)
  9353. custom3 := &CustomData{
  9354. MsgId: "H44022900158202103301715524756",
  9355. PsnNo: "44020000001100187221",
  9356. Info: "2207",
  9357. }
  9358. customData = append(customData, custom3)
  9359. custom4 := &CustomData{
  9360. MsgId: "H44022900158202103301730376224",
  9361. PsnNo: "44020000001101959155",
  9362. Info: "2207",
  9363. }
  9364. customData = append(customData, custom4)
  9365. custom5 := &CustomData{
  9366. MsgId: "H44022900158202103301748008725",
  9367. PsnNo: "44020000001104246641",
  9368. Info: "2207",
  9369. }
  9370. customData = append(customData, custom5)
  9371. custom6 := &CustomData{
  9372. MsgId: "H44022900158202103301718096755",
  9373. PsnNo: "44020000001102211860",
  9374. Info: "2207",
  9375. }
  9376. customData = append(customData, custom6)
  9377. custom7 := &CustomData{
  9378. MsgId: "H44022900158202103301736551640",
  9379. PsnNo: "44020000001102687718",
  9380. Info: "2207",
  9381. }
  9382. customData = append(customData, custom7)
  9383. custom8 := &CustomData{
  9384. MsgId: "H44022900158202103301743097676",
  9385. PsnNo: "44020000001102127785",
  9386. Info: "2207",
  9387. }
  9388. customData = append(customData, custom8)
  9389. custom9 := &CustomData{
  9390. MsgId: "H44022900158202103301712304203",
  9391. PsnNo: "44020000001101518097",
  9392. Info: "2207",
  9393. }
  9394. customData = append(customData, custom9)
  9395. custom10 := &CustomData{
  9396. MsgId: "H44022900158202103301738448785",
  9397. PsnNo: "44020000001100500813",
  9398. Info: "2207",
  9399. }
  9400. customData = append(customData, custom10)
  9401. custom11 := &CustomData{
  9402. MsgId: "H44022900158202103301732455843",
  9403. PsnNo: "44020000001102690557",
  9404. Info: "2207",
  9405. }
  9406. customData = append(customData, custom11)
  9407. custom12 := &CustomData{
  9408. MsgId: "H44022900158202103301745421708",
  9409. PsnNo: "44020000001102211928",
  9410. Info: "2207",
  9411. }
  9412. customData = append(customData, custom12)
  9413. custom1212 := &CustomData{
  9414. MsgId: "H440229001582021033017351627",
  9415. PsnNo: "44020000001102481733",
  9416. Info: "2207",
  9417. }
  9418. customData = append(customData, custom1212)
  9419. custom13 := &CustomData{
  9420. MsgId: "H44022900158202103301740327951",
  9421. PsnNo: "44020000001103174866",
  9422. Info: "2207",
  9423. }
  9424. customData = append(customData, custom13)
  9425. custom14 := &CustomData{
  9426. MsgId: "H4402290015820210330174922668",
  9427. PsnNo: "44020000001102927272",
  9428. Info: "2207",
  9429. }
  9430. customData = append(customData, custom14)
  9431. custom15 := &CustomData{
  9432. MsgId: "H44022900158202103301752362273",
  9433. PsnNo: "44020000001102942890",
  9434. Info: "2207",
  9435. }
  9436. customData = append(customData, custom15)
  9437. custom16 := &CustomData{
  9438. MsgId: "H44022900158202103301751082917",
  9439. PsnNo: "44020000001101662162",
  9440. Info: "2207",
  9441. }
  9442. customData = append(customData, custom16)
  9443. custom17 := &CustomData{
  9444. MsgId: "H44022900158202103301754147728",
  9445. PsnNo: "44020000000229014511",
  9446. Info: "2207",
  9447. }
  9448. customData = append(customData, custom17)
  9449. adminUser := c.GetAdminUserInfo()
  9450. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9451. for _, item := range customData {
  9452. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9453. fmt.Println(result)
  9454. }
  9455. }
  9456. func (c *HisApiController) GetAllopatry() {
  9457. year := c.GetString("year")
  9458. month := c.GetString("month")
  9459. admin_user_id, _ := c.GetInt64("admin_user_id")
  9460. adminUser := c.GetAdminUserInfo()
  9461. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9462. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9463. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9464. var dat map[string]interface{}
  9465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9466. fmt.Println(dat)
  9467. } else {
  9468. fmt.Println(err)
  9469. }
  9470. userJSONBytes, _ := json.Marshal(dat)
  9471. var res models.Result9001
  9472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9473. utils.ErrorLog("解析失败:%v", err)
  9474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9475. return
  9476. }
  9477. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9478. var dat2 map[string]interface{}
  9479. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9480. fmt.Println(dat)
  9481. } else {
  9482. fmt.Println(err)
  9483. }
  9484. userJSONBytes2, _ := json.Marshal(dat2)
  9485. var res2 models.Result3260
  9486. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9487. utils.ErrorLog("解析失败:%v", err)
  9488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9489. return
  9490. }
  9491. if res2.Infcode == 0 {
  9492. c.ServeSuccessJSON(map[string]interface{}{
  9493. "list": res2.Output.Data,
  9494. })
  9495. return
  9496. } else {
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9498. return
  9499. }
  9500. }
  9501. func (c *HisApiController) ComfirmAllopatry() {
  9502. year := c.GetString("year")
  9503. month := c.GetString("month")
  9504. admin_user_id, _ := c.GetInt64("admin_user_id")
  9505. adminUser := c.GetAdminUserInfo()
  9506. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9507. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9508. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9509. var dat map[string]interface{}
  9510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9511. fmt.Println(dat)
  9512. } else {
  9513. fmt.Println(err)
  9514. }
  9515. userJSONBytes, _ := json.Marshal(dat)
  9516. var res models.Result9001
  9517. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9518. utils.ErrorLog("解析失败:%v", err)
  9519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9520. return
  9521. }
  9522. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9523. var dat2 map[string]interface{}
  9524. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9525. fmt.Println(dat)
  9526. } else {
  9527. fmt.Println(err)
  9528. }
  9529. userJSONBytes2, _ := json.Marshal(dat2)
  9530. var res2 models.Result3260
  9531. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9532. utils.ErrorLog("解析失败:%v", err)
  9533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9534. return
  9535. }
  9536. if res2.Infcode == 0 {
  9537. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9538. var dat map[string]interface{}
  9539. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9540. fmt.Println(dat)
  9541. } else {
  9542. fmt.Println(err)
  9543. }
  9544. userJSONBytes, _ := json.Marshal(dat)
  9545. var res3 models.Result3261
  9546. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9547. utils.ErrorLog("解析失败:%v", err)
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9549. return
  9550. }
  9551. if res3.Infcode == 0 {
  9552. record := &models.HisYidiClearRecord{
  9553. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9554. Ctime: time.Now().Unix(),
  9555. Mtime: time.Now().Unix(),
  9556. Status: 1,
  9557. MsgId: msgId,
  9558. }
  9559. service.SaveClearRecord(record)
  9560. c.ServeSuccessJSON(map[string]interface{}{
  9561. "msg": "提取成功",
  9562. })
  9563. }
  9564. }
  9565. }
  9566. func (c *HisApiController) RefundAllopatry() {
  9567. year := c.GetString("year")
  9568. month := c.GetString("month")
  9569. id, _ := c.GetInt64("id")
  9570. admin_user_id, _ := c.GetInt64("admin_user_id")
  9571. adminUser := c.GetAdminUserInfo()
  9572. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9573. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9574. record, _ := service.GetClearRecordById(id)
  9575. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9576. var dat map[string]interface{}
  9577. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9578. fmt.Println(dat)
  9579. } else {
  9580. fmt.Println(err)
  9581. }
  9582. userJSONBytes, _ := json.Marshal(dat)
  9583. var empty ResultFourteen
  9584. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9585. utils.ErrorLog("解析失败:%v", err)
  9586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9587. return
  9588. }
  9589. if empty.Infcode == 0 {
  9590. c.ServeSuccessJSON(map[string]interface{}{
  9591. "msg": "撤销成功",
  9592. })
  9593. return
  9594. }
  9595. }
  9596. func (c *HisApiController) ReversalOtherData() {
  9597. var customData []*CustomData
  9598. custom := &CustomData{
  9599. MsgId: "H44022900158202103301714472004",
  9600. PsnNo: "44020000001101329945",
  9601. Info: "2208",
  9602. }
  9603. customData = append(customData, custom)
  9604. custom1 := &CustomData{
  9605. MsgId: "H4402290015820210330172057803",
  9606. PsnNo: "44020000001101161813",
  9607. Info: "2208",
  9608. }
  9609. customData = append(customData, custom1)
  9610. custom2 := &CustomData{
  9611. MsgId: "H44022900158202103301705198813",
  9612. PsnNo: "44190000133097375417",
  9613. Info: "2208",
  9614. }
  9615. customData = append(customData, custom2)
  9616. custom3 := &CustomData{
  9617. MsgId: "H44022900158202103301715524756",
  9618. PsnNo: "44020000001100187221",
  9619. Info: "2208",
  9620. }
  9621. customData = append(customData, custom3)
  9622. custom4 := &CustomData{
  9623. MsgId: "H44022900158202103301730376224",
  9624. PsnNo: "44020000001101959155",
  9625. Info: "2208",
  9626. }
  9627. customData = append(customData, custom4)
  9628. custom5 := &CustomData{
  9629. MsgId: "H44022900158202103301748008725",
  9630. PsnNo: "44020000001104246641",
  9631. Info: "2208",
  9632. }
  9633. customData = append(customData, custom5)
  9634. custom6 := &CustomData{
  9635. MsgId: "H44022900158202103301718096755",
  9636. PsnNo: "44020000001102211860",
  9637. Info: "2208",
  9638. }
  9639. customData = append(customData, custom6)
  9640. custom7 := &CustomData{
  9641. MsgId: "H44022900158202103301736551640",
  9642. PsnNo: "44020000001102687718",
  9643. Info: "2208",
  9644. }
  9645. customData = append(customData, custom7)
  9646. custom8 := &CustomData{
  9647. MsgId: "H44022900158202103301743097676",
  9648. PsnNo: "44020000001102127785",
  9649. Info: "2208",
  9650. }
  9651. customData = append(customData, custom8)
  9652. custom9 := &CustomData{
  9653. MsgId: "H44022900158202103301712304203",
  9654. PsnNo: "44020000001101518097",
  9655. Info: "2208",
  9656. }
  9657. customData = append(customData, custom9)
  9658. custom10 := &CustomData{
  9659. MsgId: "H44022900158202103301738448785",
  9660. PsnNo: "44020000001100500813",
  9661. Info: "2208",
  9662. }
  9663. customData = append(customData, custom10)
  9664. custom11 := &CustomData{
  9665. MsgId: "H44022900158202103301732455843",
  9666. PsnNo: "44020000001102690557",
  9667. Info: "2208",
  9668. }
  9669. customData = append(customData, custom11)
  9670. custom12 := &CustomData{
  9671. MsgId: "H44022900158202103301745421708",
  9672. PsnNo: "44020000001102211928",
  9673. Info: "2208",
  9674. }
  9675. customData = append(customData, custom12)
  9676. custom1212 := &CustomData{
  9677. MsgId: "H440229001582021033017351627",
  9678. PsnNo: "44020000001102481733",
  9679. Info: "2208",
  9680. }
  9681. customData = append(customData, custom1212)
  9682. custom13 := &CustomData{
  9683. MsgId: "H44022900158202103301740327951",
  9684. PsnNo: "44020000001103174866",
  9685. Info: "2208",
  9686. }
  9687. customData = append(customData, custom13)
  9688. custom14 := &CustomData{
  9689. MsgId: "H4402290015820210330174922668",
  9690. PsnNo: "44020000001102927272",
  9691. Info: "2208",
  9692. }
  9693. customData = append(customData, custom14)
  9694. custom15 := &CustomData{
  9695. MsgId: "H44022900158202103301752362273",
  9696. PsnNo: "44020000001102942890",
  9697. Info: "2208",
  9698. }
  9699. customData = append(customData, custom15)
  9700. custom16 := &CustomData{
  9701. MsgId: "H44022900158202103301751082917",
  9702. PsnNo: "44020000001101662162",
  9703. Info: "2208",
  9704. }
  9705. customData = append(customData, custom16)
  9706. custom17 := &CustomData{
  9707. MsgId: "H44022900158202103301754147728",
  9708. PsnNo: "44020000000229014511",
  9709. Info: "2208",
  9710. }
  9711. customData = append(customData, custom17)
  9712. adminUser := c.GetAdminUserInfo()
  9713. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9714. for _, item := range customData {
  9715. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9716. fmt.Println(result)
  9717. }
  9718. }
  9719. func PathExists(path string) (bool, error) {
  9720. _, err := os.Stat(path)
  9721. if err == nil {
  9722. return true, nil
  9723. }
  9724. if os.IsNotExist(err) {
  9725. return false, nil
  9726. }
  9727. return false, err
  9728. }
  9729. //创建文件夹
  9730. func Mkdir(dir string) {
  9731. // 创建文件夹
  9732. exist, err := PathExists(dir)
  9733. if err != nil {
  9734. fmt.Println(err.Error())
  9735. } else {
  9736. if exist {
  9737. fmt.Println(dir + "文件夹已存在!")
  9738. } else {
  9739. // 文件夹名称,权限
  9740. err := os.Mkdir(dir, os.ModePerm)
  9741. if err != nil {
  9742. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9743. } else {
  9744. fmt.Println(dir + "文件夹创建成功!")
  9745. }
  9746. }
  9747. }
  9748. }
  9749. //压缩文件
  9750. func Zip(srcFile string, destZip string) error {
  9751. zipfile, err := os.Create(destZip)
  9752. if err != nil {
  9753. return err
  9754. }
  9755. defer zipfile.Close()
  9756. archive := zip.NewWriter(zipfile)
  9757. defer archive.Close()
  9758. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9759. if err != nil {
  9760. return err
  9761. }
  9762. header, err := zip.FileInfoHeader(info)
  9763. if err != nil {
  9764. return err
  9765. }
  9766. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9767. // header.Name = path
  9768. if info.IsDir() {
  9769. header.Name += "/"
  9770. } else {
  9771. header.Method = zip.Deflate
  9772. }
  9773. writer, err := archive.CreateHeader(header)
  9774. if err != nil {
  9775. return err
  9776. }
  9777. if !info.IsDir() {
  9778. file, err := os.Open(path)
  9779. if err != nil {
  9780. return err
  9781. }
  9782. defer file.Close()
  9783. _, err = io.Copy(writer, file)
  9784. }
  9785. return err
  9786. })
  9787. return err
  9788. }
  9789. func ReadFile(filePath string) []byte {
  9790. f, err := os.Open(filePath)
  9791. if err != nil {
  9792. fmt.Println("read file fail", err)
  9793. return nil
  9794. }
  9795. defer f.Close()
  9796. fd, err := ioutil.ReadAll(f)
  9797. if err != nil {
  9798. fmt.Println("read to fd fail", err)
  9799. return nil
  9800. }
  9801. return fd
  9802. }
  9803. func saveLog(result string, request string, infno string, desc string) {
  9804. org_id, _ := beego.AppConfig.Int64("org_id")
  9805. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9806. dir := miConfig.OrgName + "日志"
  9807. utils.Mkdir(dir)
  9808. month := time.Unix(1557042972, 0).Format("1")
  9809. year := time.Now().Format("2006")
  9810. month = time.Now().Format("01")
  9811. day := time.Now().Format("02")
  9812. hour := time.Now().Format("15")
  9813. min := time.Now().Format("04")
  9814. sec := time.Now().Format("05")
  9815. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9816. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9817. file_name := file + ".txt"
  9818. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9819. exist, _ := utils.PathExists(file_path)
  9820. if exist { //存在
  9821. fmt.Println("存在")
  9822. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9823. if err != nil {
  9824. fmt.Println("read fail")
  9825. }
  9826. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9827. n, _ := f.Seek(0, 2)
  9828. _, err = f.WriteAt([]byte(content), n)
  9829. } else { //不存在
  9830. fmt.Println("文件不存在,创建文件")
  9831. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9832. defer f.Close()
  9833. if err != nil {
  9834. } else {
  9835. _, err = f.Write([]byte("记录日志"))
  9836. }
  9837. }
  9838. }
  9839. type Charset string
  9840. const (
  9841. UTF8 = Charset("UTF-8")
  9842. GB18030 = Charset("GB18030")
  9843. )
  9844. func ConvertToString(src string, srcCode string, tagCode string) string {
  9845. srcCoder := mahonia.NewDecoder(srcCode)
  9846. srcResult := srcCoder.ConvertString(src)
  9847. tagCoder := mahonia.NewDecoder(tagCode)
  9848. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9849. result := string(cdata)
  9850. return result
  9851. }