his_api_controller.go 465KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686
  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. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. type Result3101 struct {
  80. Infcode string `json:"infcode"`
  81. InfRefmsgid string `json:"inf_refmsgid"`
  82. RefmsgTime string `json:"refmsg_time"`
  83. RespondTime string `json:"respond_time"`
  84. Enctype string `json:"enctype"`
  85. Signtype string `json:"signtype"`
  86. ErrMsg interface{} `json:"err_msg"`
  87. Output struct {
  88. Result []struct {
  89. JudgeResultDetailDtos []struct {
  90. VolaItemType string `json:"vola_item_type"`
  91. MdtrtID string `json:"mdtrt_id"`
  92. JrdID string `json:"jrd_id"`
  93. PatnID string `json:"patn_id"`
  94. RxID string `json:"rx_id"`
  95. VolaAmt interface{} `json:"vola_amt"`
  96. } `json:"judge_result_detail_dtos"`
  97. RuleID string `json:"rule_id"`
  98. VolaEvid string `json:"vola_evid"`
  99. MdtrtID string `json:"mdtrt_id"`
  100. RuleName string `json:"rule_name"`
  101. VolaAmtStas string `json:"vola_amt_stas"`
  102. JrID string `json:"jr_id"`
  103. PatnID string `json:"patn_id"`
  104. SevDeg string `json:"sev_deg"`
  105. VolaAmt float64 `json:"vola_amt"`
  106. VolaBhvrType string `json:"vola_bhvr_type"`
  107. VolaCont string `json:"vola_cont"`
  108. } `json:"result"`
  109. } `json:"output"`
  110. }
  111. func (c *HisApiController) Get9001() {
  112. adminUser := c.GetAdminUserInfo()
  113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  114. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  115. if miConfig.MdtrtareaAdmvs == "350500" {
  116. service.GetFjAuthorizationInfo(miConfig.Code)
  117. } else {
  118. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  119. var dat map[string]interface{}
  120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  121. fmt.Println(dat)
  122. } else {
  123. fmt.Println(err)
  124. }
  125. userJSONBytes, _ := json.Marshal(dat)
  126. var res models.Result9001
  127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  128. utils.ErrorLog("解析失败:%v", err)
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  130. return
  131. }
  132. }
  133. }
  134. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  135. adminUser := c.GetAdminUserInfo()
  136. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  137. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  139. //record_time := c.GetString("record_time")
  140. //trig_scen := c.GetString("trig_scen")
  141. timeLayout := "2006-01-02"
  142. loc, _ := time.LoadLocation("Local")
  143. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  144. if err != nil {
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  146. return res
  147. }
  148. recordDateTime := theTime.Unix()
  149. var patientPrescription models.HisPrescriptionInfo
  150. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  151. if patientPrescription.ID == 0 {
  152. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  153. }
  154. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  155. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  156. //
  157. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  158. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  159. var pp models.PublicParams
  160. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  161. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  162. pp.FixmedinsName = miConfig.OrgName
  163. pp.FixmedinsCode = miConfig.Code
  164. pp.RequestUrl = miConfig.Url
  165. pp.Cainfo = miConfig.Cainfo
  166. pp.SecretKey = miConfig.SecretKey
  167. pp.AccessKey = miConfig.AccessKey
  168. pp.OpterName = roles.UserName
  169. var config []*models.HisXtDiagnoseConfig
  170. for _, item := range diagnosis_ids {
  171. id, _ := strconv.ParseInt(item, 10, 64)
  172. diagnosisConfig, _ := service.FindDiagnoseById(id)
  173. config = append(config, &diagnosisConfig)
  174. }
  175. var pd models.PatientDtos
  176. pd.PatnID = his.PsnNo
  177. pd.PatnName = his.Name
  178. pd.Gend = his.Gend
  179. pd.Brdy = his.Brdy
  180. pd.Poolarea = his.InsuplcAdmdvs
  181. pd.CurrMdtrtID = his.Number
  182. var fed models.FsiEncounterDtos
  183. fed.MdtrtID = his.Number
  184. fed.MedinsID = miConfig.Code
  185. fed.MedinsName = miConfig.OrgName
  186. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  187. fed.MedMdtrtType = "1"
  188. fed.MedinsType = "1"
  189. fed.MedinsLv = "11"
  190. tm := time.Unix(his.RecordDate, 0)
  191. s_tm := tm.Format("2006-01-02 15:04:05")
  192. fed.AdmDate = s_tm
  193. fed.DscgDate = s_tm
  194. fed.DscgMainDiseCodg = config[0].CountryCode
  195. fed.DscgMainDiseName = config[0].CountryContentName
  196. //诊断信息
  197. var fdds []*models.FsiDiagnoseDtos
  198. for index, item := range config {
  199. if index == 0 {
  200. var fdd models.FsiDiagnoseDtos
  201. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  202. fdd.InoutDiseType = "1"
  203. fdd.MaindiseFlag = "1"
  204. fdd.DiseDate = s_tm
  205. fdd.DiasSrtNo = "1"
  206. fdd.DiseName = item.CountryContentName
  207. fdd.DiseCodg = item.CountryCode
  208. fdds = append(fdds, &fdd)
  209. } else {
  210. var fdd models.FsiDiagnoseDtos
  211. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  212. fdd.InoutDiseType = "1"
  213. fdd.MaindiseFlag = "1"
  214. fdd.DiseDate = s_tm
  215. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  216. fdd.DiseName = item.CountryContentName
  217. fdd.DiseCodg = item.CountryCode
  218. fdds = append(fdds, &fdd)
  219. }
  220. }
  221. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  222. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  223. fed.AdmDeptName = department.Name
  224. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  225. fed.DscgDeptName = department.Name
  226. fed.MedMdtrtType = "1"
  227. fed.MedType = "11"
  228. //if his.Insutype == "390" {
  229. // fed.MedType = "1402"
  230. //} else {
  231. // fed.MedType = "9933"
  232. //}
  233. var orders []*models.FsiOrderDtos
  234. if trig_scen == "2" {
  235. //处方医嘱信息
  236. for _, item := range prescriptions {
  237. for _, subItem := range item.HisDoctorAdviceInfo {
  238. var order models.FsiOrderDtos
  239. order.RxID = strconv.FormatInt(item.ID, 10)
  240. order.Rxno = strconv.FormatInt(item.ID, 10)
  241. order.LongDrordFlag = "0"
  242. order.HilistType = "1"
  243. order.ChrgType = "1"
  244. order.DrordBhvr = "-"
  245. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  246. order.HosplistName = subItem.BaseDrugLib.DrugName
  247. order.HilistLv = "1"
  248. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  249. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  250. order.HosplistName = subItem.BaseDrugLib.DrugName
  251. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  252. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  254. order.OwnpayAmt = ""
  255. order.SelfpayAmt = ""
  256. order.Spec = ""
  257. order.SpecUnt = ""
  258. order.DrordBegnDate = s_tm
  259. order.DrordStopDate = ""
  260. order.DrordDrCodg = "1"
  261. order.DrordDeptName = department.Name
  262. order.DrordDrCodg = "1"
  263. order.DrordDrName = doctor_info.UserName
  264. order.DrordDrProfttl = ""
  265. order.CurrDrordFlag = "1"
  266. orders = append(orders, &order)
  267. }
  268. for _, subItem := range item.HisPrescriptionProject {
  269. if subItem.Type == 2 {
  270. var order models.FsiOrderDtos
  271. order.RxID = strconv.FormatInt(item.ID, 10)
  272. order.Rxno = strconv.FormatInt(item.ID, 10)
  273. order.LongDrordFlag = "0"
  274. order.HilistType = "1"
  275. order.ChrgType = "1"
  276. order.DrordBhvr = "-"
  277. order.HilistCode = subItem.HisProject.MedicalCode
  278. order.HosplistName = subItem.HisProject.ProjectName
  279. order.HilistLv = "1"
  280. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  281. order.HosplistCode = subItem.HisProject.MedicalCode
  282. order.HosplistName = subItem.HisProject.ProjectName
  283. order.Cnt = subItem.Count
  284. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  285. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  286. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  287. order.OwnpayAmt = ""
  288. order.SelfpayAmt = ""
  289. order.Spec = ""
  290. order.SpecUnt = ""
  291. order.DrordBegnDate = s_tm
  292. order.DrordStopDate = ""
  293. order.DrordDrCodg = "1"
  294. order.DrordDeptName = department.Name
  295. order.DrordDrCodg = "1"
  296. order.DrordDrName = doctor_info.UserName
  297. order.DrordDrProfttl = ""
  298. order.CurrDrordFlag = "1"
  299. orders = append(orders, &order)
  300. }
  301. if subItem.Type == 3 {
  302. var order models.FsiOrderDtos
  303. order.RxID = strconv.FormatInt(item.ID, 10)
  304. order.Rxno = strconv.FormatInt(item.ID, 10)
  305. order.LongDrordFlag = "0"
  306. order.HilistType = "1"
  307. order.ChrgType = "1"
  308. order.DrordBhvr = "-"
  309. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  310. order.HosplistName = subItem.GoodInfo.GoodName
  311. order.HilistLv = "1"
  312. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  313. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  314. order.HosplistName = subItem.GoodInfo.GoodName
  315. order.Cnt = subItem.Count
  316. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  317. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  318. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  319. order.OwnpayAmt = ""
  320. order.SelfpayAmt = ""
  321. order.Spec = ""
  322. order.SpecUnt = ""
  323. order.DrordBegnDate = s_tm
  324. order.DrordStopDate = ""
  325. order.DrordDrCodg = "1"
  326. order.DrordDeptName = department.Name
  327. order.DrordDrCodg = "1"
  328. order.DrordDrName = doctor_info.UserName
  329. order.DrordDrProfttl = ""
  330. order.CurrDrordFlag = "1"
  331. orders = append(orders, &order)
  332. }
  333. }
  334. }
  335. //处方医嘱信息
  336. }
  337. fed.MatnStas = "0"
  338. fed.MedfeeSumamt = "0"
  339. fed.OwnpayAmt = "0"
  340. fed.SelfpayAmt = "0"
  341. fed.AcctPayamt = "0"
  342. fed.MaAmt = "0"
  343. fed.HifpPayamt = "0"
  344. fed.SetlTotlnum = "1"
  345. fed.Insutype = his.Insutype
  346. fed.ReimFlag = "0"
  347. fed.OutSetlFlag = "0"
  348. var fopd []*models.FsiOperationDtosData
  349. data := make(map[string]interface{})
  350. data["fed"] = fed
  351. data["fdd"] = fdds
  352. data["fod"] = orders
  353. data["pd"] = pd
  354. data["pp"] = pp
  355. data["fopd"] = fopd
  356. data["trig_scen"] = trig_scen
  357. fmt.Println(data)
  358. fmt.Println(fed)
  359. fmt.Println(fdds)
  360. fmt.Println(orders)
  361. fmt.Println(pd)
  362. fmt.Println(pp)
  363. fmt.Println(fopd)
  364. client := &http.Client{}
  365. bytesData, _ := json.Marshal(data)
  366. var req *http.Request
  367. if miConfig.MdtrtareaAdmvs == "320921" {
  368. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  369. } else {
  370. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  371. }
  372. resp, _ := client.Do(req)
  373. defer resp.Body.Close()
  374. body, ioErr := ioutil.ReadAll(resp.Body)
  375. if ioErr != nil {
  376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return res
  379. }
  380. var respJSON map[string]interface{}
  381. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  384. return res
  385. }
  386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  387. result, _ := json.Marshal(respJSON)
  388. if err := json.Unmarshal([]byte(result), &res); err != nil {
  389. utils.ErrorLog("解析失败:%v", err)
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  391. return res
  392. }
  393. return res
  394. }
  395. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  396. ////patient_id, _ := c.GetInt64("patient_id")
  397. //order_id, _ := c.GetInt64("order_id")
  398. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  399. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  400. //trig_scen := c.GetString("trig_scen")
  401. adminUser := c.GetAdminUserInfo()
  402. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  403. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  405. record_time := c.GetString("record_time")
  406. order, _ := service.GetHisOrderByID(order_id)
  407. timeLayout := "2006-01-02"
  408. loc, _ := time.LoadLocation("Local")
  409. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  410. if err != nil {
  411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  412. return
  413. }
  414. recordDateTime := theTime.Unix()
  415. var patientPrescription models.HisPrescriptionInfo
  416. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  417. if patientPrescription.ID == 0 {
  418. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  419. }
  420. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  421. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  422. //
  423. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  424. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  425. var pp models.PublicParams
  426. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  427. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  428. pp.FixmedinsName = miConfig.OrgName
  429. pp.FixmedinsCode = miConfig.Code
  430. pp.RequestUrl = miConfig.Url
  431. pp.Cainfo = miConfig.Cainfo
  432. pp.SecretKey = miConfig.SecretKey
  433. pp.AccessKey = miConfig.AccessKey
  434. pp.OpterName = roles.UserName
  435. var config []*models.HisXtDiagnoseConfig
  436. for _, item := range diagnosis_ids {
  437. id, _ := strconv.ParseInt(item, 10, 64)
  438. diagnosisConfig, _ := service.FindDiagnoseById(id)
  439. config = append(config, &diagnosisConfig)
  440. }
  441. var pd models.PatientDtos
  442. pd.PatnID = his.PsnNo
  443. pd.PatnName = his.Name
  444. pd.Gend = his.Gend
  445. pd.Brdy = his.Brdy
  446. pd.Poolarea = his.InsuplcAdmdvs
  447. pd.CurrMdtrtID = his.Number
  448. var fed models.FsiEncounterDtos
  449. fed.MdtrtID = his.Number
  450. fed.MedinsID = miConfig.Code
  451. fed.MedinsName = miConfig.OrgName
  452. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  453. fed.MedMdtrtType = "1"
  454. fed.MedinsType = "1"
  455. fed.MedinsLv = "11"
  456. tm := time.Unix(his.RecordDate, 0)
  457. s_tm := tm.Format("2006-01-02 15:04:05")
  458. fed.AdmDate = s_tm
  459. fed.DscgDate = s_tm
  460. fed.DscgMainDiseCodg = config[0].CountryCode
  461. fed.DscgMainDiseName = config[0].CountryContentName
  462. //诊断信息
  463. var fdds []*models.FsiDiagnoseDtos
  464. for index, item := range config {
  465. if index == 0 {
  466. var fdd models.FsiDiagnoseDtos
  467. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  468. fdd.InoutDiseType = "1"
  469. fdd.MaindiseFlag = "1"
  470. fdd.DiseDate = s_tm
  471. fdd.DiasSrtNo = "1"
  472. fdd.DiseName = item.CountryContentName
  473. fdd.DiseCodg = item.CountryCode
  474. fdds = append(fdds, &fdd)
  475. } else {
  476. var fdd models.FsiDiagnoseDtos
  477. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  478. fdd.InoutDiseType = "1"
  479. fdd.MaindiseFlag = "1"
  480. fdd.DiseDate = s_tm
  481. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  482. fdd.DiseName = item.CountryContentName
  483. fdd.DiseCodg = item.CountryCode
  484. fdds = append(fdds, &fdd)
  485. }
  486. }
  487. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  488. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  489. fed.AdmDeptName = department.Name
  490. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  491. fed.DscgDeptName = department.Name
  492. fed.MedType = order.MedType
  493. //处方医嘱信息
  494. var orders []*models.FsiOrderDtos
  495. //for _, item := range prescriptions {
  496. // for _, subItem := range item.HisDoctorAdviceInfo {
  497. // var order models.FsiOrderDtos
  498. // order.RxID = strconv.FormatInt(item.ID, 10)
  499. // order.Rxno = strconv.FormatInt(item.ID, 10)
  500. // order.LongDrordFlag = "0"
  501. // order.HilistType = "1"
  502. // order.ChrgType = "1"
  503. // order.DrordBhvr = "-"
  504. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  505. // order.HosplistName = subItem.BaseDrugLib.DrugName
  506. // order.HilistLv = "1"
  507. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  508. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  509. // order.HosplistName = subItem.BaseDrugLib.DrugName
  510. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. // }
  527. // for _, subItem := range item.HisPrescriptionProject {
  528. // if subItem.Type == 2 {
  529. // var order models.FsiOrderDtos
  530. // order.RxID = strconv.FormatInt(item.ID, 10)
  531. // order.Rxno = strconv.FormatInt(item.ID, 10)
  532. // order.LongDrordFlag = "0"
  533. // order.HilistType = "1"
  534. // order.ChrgType = "1"
  535. // order.DrordBhvr = "-"
  536. // order.HilistCode = subItem.HisProject.MedicalCode
  537. // order.HosplistName = subItem.HisProject.ProjectName
  538. // order.HilistLv = "1"
  539. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  540. // order.HosplistCode = subItem.HisProject.MedicalCode
  541. // order.HosplistName = subItem.HisProject.ProjectName
  542. // order.Cnt = subItem.Count
  543. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  544. //
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // if subItem.Type == 3 {
  563. //
  564. // var order models.FsiOrderDtos
  565. // order.RxID = strconv.FormatInt(item.ID, 10)
  566. // order.Rxno = strconv.FormatInt(item.ID, 10)
  567. // order.LongDrordFlag = "0"
  568. // order.HilistType = "1"
  569. // order.ChrgType = "1"
  570. // order.DrordBhvr = "-"
  571. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  572. // order.HosplistName = subItem.GoodInfo.GoodName
  573. // order.HilistLv = "1"
  574. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  575. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  576. // order.HosplistName = subItem.GoodInfo.GoodName
  577. // order.Cnt = subItem.Count
  578. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  579. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  580. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  581. // order.OwnpayAmt = ""
  582. // order.SelfpayAmt = ""
  583. // order.Spec = ""
  584. // order.SpecUnt = ""
  585. // order.DrordBegnDate = s_tm
  586. // order.DrordStopDate = ""
  587. // order.DrordDrCodg = "1"
  588. // order.DrordDeptName = department.Name
  589. // order.DrordDrCodg = "1"
  590. // order.DrordDrName = doctor_info.UserName
  591. // order.DrordDrProfttl = ""
  592. // order.CurrDrordFlag = "1"
  593. // orders = append(orders, &order)
  594. //
  595. // }
  596. // }
  597. //}
  598. for _, item := range prescriptions {
  599. for _, subItem := range item.HisDoctorAdviceInfo {
  600. var order models.FsiOrderDtos
  601. order.RxID = strconv.FormatInt(item.ID, 10)
  602. order.Rxno = strconv.FormatInt(item.ID, 10)
  603. order.LongDrordFlag = "0"
  604. order.HilistType = "1"
  605. order.ChrgType = "1"
  606. order.DrordBhvr = "-"
  607. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  608. order.HosplistName = subItem.BaseDrugLib.DrugName
  609. order.HilistLv = "1"
  610. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  611. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  612. order.HosplistName = subItem.BaseDrugLib.DrugName
  613. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  614. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  615. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  616. order.OwnpayAmt = ""
  617. order.SelfpayAmt = ""
  618. order.Spec = ""
  619. order.SpecUnt = ""
  620. order.DrordBegnDate = s_tm
  621. order.DrordStopDate = ""
  622. order.DrordDrCodg = "1"
  623. order.DrordDeptName = department.Name
  624. order.DrordDrCodg = "1"
  625. order.DrordDrName = doctor_info.UserName
  626. order.DrordDrProfttl = ""
  627. order.CurrDrordFlag = "1"
  628. orders = append(orders, &order)
  629. }
  630. for _, subItem := range item.HisPrescriptionProject {
  631. if subItem.Type == 2 {
  632. var order models.FsiOrderDtos
  633. order.RxID = strconv.FormatInt(item.ID, 10)
  634. order.Rxno = strconv.FormatInt(item.ID, 10)
  635. order.LongDrordFlag = "0"
  636. order.HilistType = "1"
  637. order.ChrgType = "1"
  638. order.DrordBhvr = "-"
  639. order.HilistCode = subItem.HisProject.MedicalCode
  640. order.HosplistName = subItem.HisProject.ProjectName
  641. order.HilistLv = "1"
  642. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  643. order.HosplistCode = subItem.HisProject.MedicalCode
  644. order.HosplistName = subItem.HisProject.ProjectName
  645. order.Cnt = subItem.Count
  646. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  647. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  648. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  649. order.OwnpayAmt = ""
  650. order.SelfpayAmt = ""
  651. order.Spec = ""
  652. order.SpecUnt = ""
  653. order.DrordBegnDate = s_tm
  654. order.DrordStopDate = ""
  655. order.DrordDrCodg = "1"
  656. order.DrordDeptName = department.Name
  657. order.DrordDrCodg = "1"
  658. order.DrordDrName = doctor_info.UserName
  659. order.DrordDrProfttl = ""
  660. order.CurrDrordFlag = "1"
  661. orders = append(orders, &order)
  662. }
  663. if subItem.Type == 3 {
  664. var order models.FsiOrderDtos
  665. order.RxID = strconv.FormatInt(item.ID, 10)
  666. order.Rxno = strconv.FormatInt(item.ID, 10)
  667. order.LongDrordFlag = "0"
  668. order.HilistType = "1"
  669. order.ChrgType = "1"
  670. order.DrordBhvr = "-"
  671. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  672. order.HosplistName = subItem.GoodInfo.GoodName
  673. order.HilistLv = "1"
  674. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  675. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  676. order.HosplistName = subItem.GoodInfo.GoodName
  677. order.Cnt = subItem.Count
  678. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  679. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  680. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  681. order.OwnpayAmt = ""
  682. order.SelfpayAmt = ""
  683. order.Spec = ""
  684. order.SpecUnt = ""
  685. order.DrordBegnDate = s_tm
  686. order.DrordStopDate = ""
  687. order.DrordDrCodg = "1"
  688. order.DrordDeptName = department.Name
  689. order.DrordDrCodg = "1"
  690. order.DrordDrName = doctor_info.UserName
  691. order.DrordDrProfttl = ""
  692. order.CurrDrordFlag = "1"
  693. orders = append(orders, &order)
  694. }
  695. }
  696. }
  697. //处方医嘱信息
  698. fed.MatnStas = "0"
  699. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  700. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  701. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  702. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  703. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  704. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  705. fed.SetlTotlnum = "1"
  706. fed.Insutype = his.Insutype
  707. fed.ReimFlag = "0"
  708. fed.OutSetlFlag = "0"
  709. var fopd []*models.FsiOperationDtosData
  710. data := make(map[string]interface{})
  711. data["fed"] = fed
  712. data["fdd"] = fdds
  713. data["fod"] = orders
  714. data["pd"] = pd
  715. data["pp"] = pp
  716. data["fopd"] = fopd
  717. data["trig_scen"] = trig_scen
  718. client := &http.Client{}
  719. bytesData, _ := json.Marshal(data)
  720. var req *http.Request
  721. if miConfig.MdtrtareaAdmvs == "320921" {
  722. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  723. } else {
  724. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  725. }
  726. resp, _ := client.Do(req)
  727. defer resp.Body.Close()
  728. body, ioErr := ioutil.ReadAll(resp.Body)
  729. if ioErr != nil {
  730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  732. return res
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return res
  739. }
  740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  741. result, _ := json.Marshal(respJSON)
  742. if err := json.Unmarshal([]byte(result), &res); err != nil {
  743. utils.ErrorLog("解析失败:%v", err)
  744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  745. return res
  746. }
  747. return res
  748. //手术操作集合
  749. //手术操作集合
  750. }
  751. func (c *HisApiController) Check() {
  752. psn_no := c.GetString("psn_no")
  753. in := c.GetString("in")
  754. mt := c.GetString("mt")
  755. baseParams := models.BaseParams{
  756. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  757. FixmedinsCode: "H15049901371",
  758. InsuplcAdmdvs: "150499",
  759. MdtrtareaAdmvs: "150499",
  760. OrgName: "赤峰费森血液透析中心",
  761. Doctor: "1111",
  762. }
  763. service.Gdyb2001(baseParams, psn_no, in, mt)
  764. }
  765. func (c *HisApiController) GetPsnNcdsInfo() {
  766. admin_user_id, _ := c.GetInt64("admin_user_id")
  767. patient_id, _ := c.GetInt64("patient_id")
  768. id, _ := c.GetInt64("id")
  769. adminUser := c.GetAdminUserInfo()
  770. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  771. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  772. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  773. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  774. psn_record, _ := service.GetPsnNCDSRecordById(id)
  775. //
  776. //if psn_record.ID == 0 {
  777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  778. // return
  779. //}
  780. var res Result5301
  781. var res10265 Result5301For10265
  782. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  783. psn_info, _ := service.GetPsnByPatientId(patient_id)
  784. var api string
  785. if miConfig.MdtrtareaAdmvs == "320921" {
  786. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  787. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  788. } else {
  789. 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 +
  790. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  791. }
  792. resp, requestErr := http.Get(api)
  793. if requestErr != nil {
  794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  795. return
  796. }
  797. body, ioErr := ioutil.ReadAll(resp.Body)
  798. if ioErr != nil {
  799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  801. return
  802. }
  803. var respJSON map[string]interface{}
  804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  810. result, _ := json.Marshal(respJSON)
  811. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  812. utils.ErrorLog("解析失败:%v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. res.ErrMsg = res10265.ErrMsg
  817. res.Output = res10265.Output
  818. res.InfRefmsgid = res10265.InfRefmsgid
  819. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  820. res.Infcode = infocode
  821. } else {
  822. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  823. var dat map[string]interface{}
  824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  825. fmt.Println(dat)
  826. } else {
  827. fmt.Println(err)
  828. }
  829. userJSONBytes, _ := json.Marshal(dat)
  830. if miConfig.Code == "H15049901371" {
  831. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  832. utils.ErrorLog("解析失败:%v", err)
  833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  834. return
  835. }
  836. res.InfRefmsgid = res10265.InfRefmsgid
  837. res.Output = res10265.Output
  838. res.ErrMsg = res10265.ErrMsg
  839. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  840. res.Infcode = infocode
  841. } else {
  842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  843. utils.ErrorLog("解析失败:%v", err)
  844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  845. return
  846. }
  847. }
  848. }
  849. if res.Infcode == 0 {
  850. c.ServeSuccessJSON(map[string]interface{}{
  851. "result": res.Output.Result,
  852. })
  853. }
  854. }
  855. func (c *HisApiController) CheckInsutype() {
  856. his_patient_id, _ := c.GetInt64("his_patient_id")
  857. admin_user_id, _ := c.GetInt64("admin_user_id")
  858. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  859. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  860. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  861. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  862. var dat map[string]interface{}
  863. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  864. fmt.Println(dat)
  865. } else {
  866. fmt.Println(err)
  867. }
  868. userJSONBytes, _ := json.Marshal(dat)
  869. var res Result90100
  870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  871. utils.ErrorLog("解析失败:%v", err)
  872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  873. return
  874. }
  875. if res.Infcode != 0 {
  876. c.ServeSuccessJSON(map[string]interface{}{
  877. "failed_code": -10,
  878. "msg": res.ErrMsg,
  879. })
  880. return
  881. } else {
  882. fmt.Println(res)
  883. }
  884. }
  885. func (c *HisApiController) CheckCardPWD() {
  886. card_pwd := c.GetString("card_pwd")
  887. his_patient_id, _ := c.GetInt64("his_patient_id")
  888. admin_user_id, _ := c.GetInt64("admin_user_id")
  889. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  891. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  892. psn, _ := service.GetPsnByPatientId(his.PatientId)
  893. bas := strings.Split(psn.CardInfo, "|")
  894. basNumber := bas[2]
  895. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  896. var dat map[string]interface{}
  897. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  898. fmt.Println(dat)
  899. } else {
  900. fmt.Println(err)
  901. }
  902. userJSONBytes, _ := json.Marshal(dat)
  903. var res Result90991
  904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  905. utils.ErrorLog("解析失败:%v", err)
  906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  907. return
  908. }
  909. if res.Infcode != 0 {
  910. c.ServeSuccessJSON(map[string]interface{}{
  911. "failed_code": -10,
  912. "msg": res.ErrMsg,
  913. })
  914. return
  915. } else {
  916. if res.Output.Result.SscnoCheckStat == "0" {
  917. var msg string
  918. switch res.Output.Result.CardStat {
  919. case "00":
  920. msg = "未激活"
  921. break
  922. case "10":
  923. msg = "激活"
  924. break
  925. case "20":
  926. msg = "窗口挂失"
  927. break
  928. case "21":
  929. msg = "电话挂失"
  930. break
  931. case "22":
  932. msg = "单位网上申报挂失"
  933. break
  934. case "23":
  935. msg = "保健办挂失"
  936. break
  937. case "24":
  938. msg = "个人网上挂失"
  939. break
  940. case "25":
  941. msg = "网上服务大厅挂失"
  942. break
  943. case "30":
  944. msg = "注销"
  945. break
  946. case "40":
  947. msg = "回收"
  948. break
  949. case "99":
  950. msg = "制卡中(无效卡)"
  951. break
  952. }
  953. c.ServeSuccessJSON(map[string]interface{}{
  954. "failed_code": -10,
  955. "msg": msg,
  956. })
  957. return
  958. } else {
  959. c.ServeSuccessJSON(map[string]interface{}{
  960. "msg": "校验成功",
  961. })
  962. return
  963. }
  964. }
  965. }
  966. func (c *HisApiController) CheckCardPWDTwo() {
  967. //card_pwd := c.GetString("card_pwd")
  968. //his_patient_id, _ := c.GetInt64("his_patient_id")
  969. admin_user_id, _ := c.GetInt64("admin_user_id")
  970. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  971. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  972. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  973. var dat map[string]interface{}
  974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  975. fmt.Println(dat)
  976. } else {
  977. fmt.Println(err)
  978. }
  979. userJSONBytes, _ := json.Marshal(dat)
  980. var res Result90991
  981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  982. utils.ErrorLog("解析失败:%v", err)
  983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. if res.Infcode != 0 {
  987. c.ServeSuccessJSON(map[string]interface{}{
  988. "failed_code": -10,
  989. "msg": res.ErrMsg,
  990. })
  991. return
  992. } else {
  993. if res.Output.Result.SscnoCheckStat == "0" {
  994. var msg string
  995. switch res.Output.Result.CardStat {
  996. case "00":
  997. msg = "未激活"
  998. break
  999. case "10":
  1000. msg = "激活"
  1001. break
  1002. case "20":
  1003. msg = "窗口挂失"
  1004. break
  1005. case "21":
  1006. msg = "电话挂失"
  1007. break
  1008. case "22":
  1009. msg = "单位网上申报挂失"
  1010. break
  1011. case "23":
  1012. msg = "保健办挂失"
  1013. break
  1014. case "24":
  1015. msg = "个人网上挂失"
  1016. break
  1017. case "25":
  1018. msg = "网上服务大厅挂失"
  1019. break
  1020. case "30":
  1021. msg = "注销"
  1022. break
  1023. case "40":
  1024. msg = "回收"
  1025. break
  1026. case "99":
  1027. msg = "制卡中(无效卡)"
  1028. break
  1029. }
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "failed_code": -10,
  1032. "msg": msg,
  1033. })
  1034. return
  1035. } else {
  1036. c.ServeSuccessJSON(map[string]interface{}{
  1037. "msg": "校验成功",
  1038. })
  1039. return
  1040. }
  1041. }
  1042. }
  1043. type ELeCertData struct {
  1044. Data struct {
  1045. Extra string `json:"extra"`
  1046. IDNo string `json:"idNo"`
  1047. IDType string `json:"idType"`
  1048. EcToken string `json:"ecToken"`
  1049. InsuOrg string `json:"insuOrg"`
  1050. UserName string `json:"userName"`
  1051. EcIndexNo string `json:"ecIndexNo"`
  1052. Gender string `json:"gender"`
  1053. Birthday string `json:"birthday"`
  1054. Nationality string `json:"nationality"`
  1055. Email string `json:"email"`
  1056. } `json:"OutData"`
  1057. }
  1058. func (c *HisApiController) ReadCard() {
  1059. id_card_type, _ := c.GetInt64("id_card_type")
  1060. admin_user_id, _ := c.GetInt64("admin_user_id")
  1061. certificates, _ := c.GetInt64("certificates")
  1062. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1063. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1064. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1065. switch id_card_type {
  1066. case 1:
  1067. if miConfig.MdtrtareaAdmvs == "421300" {
  1068. var res ResultTwo
  1069. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1070. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1071. "&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)
  1072. resp, requestErr := http.Get(api)
  1073. if requestErr != nil {
  1074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1075. return
  1076. }
  1077. body, ioErr := ioutil.ReadAll(resp.Body)
  1078. if ioErr != nil {
  1079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1081. return
  1082. }
  1083. var respJSON map[string]interface{}
  1084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1087. return
  1088. }
  1089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1090. result, _ := json.Marshal(respJSON)
  1091. fmt.Println("log")
  1092. fmt.Println(string(result))
  1093. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1094. utils.ErrorLog("解析失败:%v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. return
  1097. }
  1098. if res.Infcode == 0 {
  1099. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1100. if err == gorm.ErrRecordNotFound {
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1102. return
  1103. } else if err != nil {
  1104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1105. return
  1106. } else {
  1107. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1108. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1109. infoStr := string(Iinfos)
  1110. idetinfoStr := string(Idetinfos)
  1111. psn := &models.HisPsn{
  1112. PsnNo: res.Output.Baseinfo.PsnNo,
  1113. Age: res.Output.Baseinfo.Age,
  1114. PatientId: patient.ID,
  1115. Certno: res.Output.Baseinfo.Certno,
  1116. Brdy: res.Output.Baseinfo.Brdy,
  1117. Gend: res.Output.Baseinfo.Gend,
  1118. Naty: res.Output.Baseinfo.Naty,
  1119. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1120. PsnName: res.Output.Baseinfo.PsnName,
  1121. Idetinfo: idetinfoStr,
  1122. Insuinfo: infoStr,
  1123. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1124. }
  1125. service.CreateHisPsn(psn)
  1126. c.ServeSuccessJSON(map[string]interface{}{
  1127. "patient": patient,
  1128. "number": res.Output.Baseinfo.Certno,
  1129. })
  1130. }
  1131. } else {
  1132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1133. return
  1134. }
  1135. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1136. var api string
  1137. if miConfig.MdtrtareaAdmvs == "320921" {
  1138. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1139. "&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
  1140. fmt.Println(api)
  1141. } else {
  1142. 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 +
  1143. "&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)
  1144. }
  1145. resp, requestErr := http.Get(api)
  1146. if requestErr != nil {
  1147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1148. return
  1149. }
  1150. body, ioErr := ioutil.ReadAll(resp.Body)
  1151. if ioErr != nil {
  1152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1154. return
  1155. }
  1156. var respJSON map[string]interface{}
  1157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1160. return
  1161. }
  1162. var status string
  1163. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1164. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1165. //console.log()
  1166. fmt.Println("type===")
  1167. fmt.Println(card_type)
  1168. var token string
  1169. var res ResultTwo //1101结果
  1170. var res10265 ResultTwo10265 //1101结果
  1171. var card_info string //卡信息
  1172. var busi_card_info string
  1173. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1174. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1175. if status == "0" { //读卡成功
  1176. if card_type == "1" {
  1177. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1178. result, _ := json.Marshal(respJSON)
  1179. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. res.ErrMsg = res10265.ErrMsg
  1185. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1186. res.Infcode = infocode
  1187. res.Output = res10265.Output
  1188. res.InfRefmsgid = res10265.InfRefmsgid
  1189. } else {
  1190. //var card_info string //卡信息
  1191. //var busi_card_info string
  1192. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1193. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1194. //fmt.Println(card_info)
  1195. //fmt.Println(busi_card_info)
  1196. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1197. result, _ := json.Marshal(respJSON)
  1198. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1199. utils.ErrorLog("解析失败:%v", err)
  1200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1201. return
  1202. }
  1203. res.ErrMsg = res10265.ErrMsg
  1204. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1205. res.Infcode = infocode
  1206. res.Output = res10265.Output
  1207. res.InfRefmsgid = res10265.InfRefmsgid
  1208. }
  1209. if res.Infcode == 0 {
  1210. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1211. if err == gorm.ErrRecordNotFound {
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1213. return
  1214. } else if err != nil {
  1215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1216. return
  1217. } else {
  1218. if card_type == "1" {
  1219. bas := strings.Split(card_info, "|")
  1220. basNumber := bas[2]
  1221. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1222. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1223. infoStr := string(Iinfos)
  1224. idetinfoStr := string(Idetinfos)
  1225. psn := &models.HisPsn{
  1226. PsnNo: res.Output.Baseinfo.PsnNo,
  1227. Age: res.Output.Baseinfo.Age,
  1228. PatientId: patient.ID,
  1229. Certno: res.Output.Baseinfo.Certno,
  1230. Brdy: res.Output.Baseinfo.Brdy,
  1231. Gend: res.Output.Baseinfo.Gend,
  1232. Naty: res.Output.Baseinfo.Naty,
  1233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1234. PsnName: res.Output.Baseinfo.PsnName,
  1235. Idetinfo: idetinfoStr,
  1236. Insuinfo: infoStr,
  1237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1238. CardInfo: card_info,
  1239. VerifyNumber: busi_card_info,
  1240. }
  1241. service.CreateHisPsn(psn)
  1242. var rf []*ResultFive
  1243. json.Unmarshal([]byte(infoStr), &rf)
  1244. var insutypes []*ResultFive
  1245. var insutype string
  1246. var is390 int = 0
  1247. var is310 int = 0
  1248. for _, item := range rf {
  1249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1250. insutypes = append(insutypes, item)
  1251. }
  1252. }
  1253. if len(insutypes) == 1 {
  1254. insutype = insutypes[0].Insutype
  1255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1256. } else {
  1257. for _, i := range insutypes {
  1258. if i.Insutype == "390" {
  1259. is390 = 1
  1260. }
  1261. if i.Insutype == "310" {
  1262. is310 = 1
  1263. }
  1264. }
  1265. }
  1266. if is390 == 1 {
  1267. insutype = "390"
  1268. }
  1269. if is310 == 1 {
  1270. insutype = "310"
  1271. }
  1272. if len(insutypes) == 0 {
  1273. insutype = "310"
  1274. }
  1275. c.ServeSuccessJSON(map[string]interface{}{
  1276. "patient": patient,
  1277. "number": basNumber,
  1278. "insutype": insutype,
  1279. })
  1280. } else {
  1281. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1282. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1283. infoStr := string(Iinfos)
  1284. idetinfoStr := string(Idetinfos)
  1285. psn := &models.HisPsn{
  1286. PsnNo: res.Output.Baseinfo.PsnNo,
  1287. Age: res.Output.Baseinfo.Age,
  1288. PatientId: patient.ID,
  1289. Certno: res.Output.Baseinfo.Certno,
  1290. Brdy: res.Output.Baseinfo.Brdy,
  1291. Gend: res.Output.Baseinfo.Gend,
  1292. Naty: res.Output.Baseinfo.Naty,
  1293. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1294. PsnName: res.Output.Baseinfo.PsnName,
  1295. Idetinfo: idetinfoStr,
  1296. Insuinfo: infoStr,
  1297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1298. CardInfo: card_info,
  1299. VerifyNumber: token,
  1300. }
  1301. service.CreateHisPsn(psn)
  1302. c.ServeSuccessJSON(map[string]interface{}{
  1303. "patient": patient,
  1304. "number": token,
  1305. })
  1306. }
  1307. }
  1308. } else {
  1309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1310. return
  1311. }
  1312. } else { //读卡失败
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1314. return
  1315. }
  1316. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1317. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1318. cardnum = DeleteExtraSpaceTwo(cardnum)
  1319. cardCode = DeleteExtraSpaceTwo(cardCode)
  1320. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1321. name = DeleteExtraSpaceTwo(name)
  1322. errmsg = DeleteExtraSpaceTwo(errmsg)
  1323. cardnum = Remove0000(cardnum)
  1324. cardCode = Remove0000(cardCode)
  1325. id_card_no = Remove0000(id_card_no)
  1326. name = Remove0000(name)
  1327. errmsg = Remove0000(errmsg)
  1328. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1329. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1330. saveLog(result, requestLog, "1101", "获取人员信息")
  1331. fmt.Println(errMsgLog)
  1332. if len(errMsgLog) > 0 {
  1333. } else {
  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 ResultTwo
  1342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1343. utils.ErrorLog("解析失败:%v", err)
  1344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1345. return
  1346. }
  1347. res.ErrMsg = errMsgLog
  1348. if res.Infcode == 0 {
  1349. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1350. if err == gorm.ErrRecordNotFound {
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1352. return
  1353. } else if err != nil {
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1355. return
  1356. } else {
  1357. fmt.Println(res)
  1358. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1359. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1360. infoStr := string(Iinfos)
  1361. idetinfoStr := string(Idetinfos)
  1362. psn := &models.HisPsn{
  1363. PsnNo: res.Output.Baseinfo.PsnNo,
  1364. Age: res.Output.Baseinfo.Age,
  1365. PatientId: patient.ID,
  1366. Certno: res.Output.Baseinfo.Certno,
  1367. Brdy: res.Output.Baseinfo.Brdy,
  1368. Gend: res.Output.Baseinfo.Gend,
  1369. Naty: res.Output.Baseinfo.Naty,
  1370. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1371. PsnName: res.Output.Baseinfo.PsnName,
  1372. Idetinfo: idetinfoStr,
  1373. Insuinfo: infoStr,
  1374. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1375. CardInfo: basStr,
  1376. VerifyNumber: "",
  1377. }
  1378. service.CreateHisPsn(psn)
  1379. var rf []*ResultFive
  1380. json.Unmarshal([]byte(infoStr), &rf)
  1381. var insutypes []*ResultFive
  1382. var insutype string
  1383. var is390 int = 0
  1384. var is310 int = 0
  1385. for _, item := range rf {
  1386. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1387. insutypes = append(insutypes, item)
  1388. }
  1389. }
  1390. if len(insutypes) == 1 {
  1391. insutype = insutypes[0].Insutype
  1392. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1393. } else {
  1394. for _, i := range insutypes {
  1395. if i.Insutype == "390" {
  1396. is390 = 1
  1397. }
  1398. if i.Insutype == "310" {
  1399. is310 = 1
  1400. }
  1401. }
  1402. }
  1403. if is390 == 1 {
  1404. insutype = "390"
  1405. }
  1406. if is310 == 1 {
  1407. insutype = "310"
  1408. }
  1409. if len(insutypes) == 0 {
  1410. insutype = "310"
  1411. }
  1412. c.ServeSuccessJSON(map[string]interface{}{
  1413. "patient": patient,
  1414. "number": cardnum,
  1415. "insutype": insutype,
  1416. })
  1417. }
  1418. } else {
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1420. return
  1421. }
  1422. }
  1423. } else {
  1424. if initFlag == 0 {
  1425. c.TestGetBasBaseInit()
  1426. }
  1427. basStr := c.GetBasBaseInfo()
  1428. if len(basStr) == 0 {
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1430. return
  1431. }
  1432. fmt.Println(basStr)
  1433. bas := strings.Split(basStr, "|")
  1434. basNumber := bas[1]
  1435. fmt.Println(basNumber)
  1436. card_sn := bas[3]
  1437. fmt.Println(card_sn)
  1438. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1439. var dat map[string]interface{}
  1440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1441. fmt.Println(dat)
  1442. } else {
  1443. fmt.Println(err)
  1444. }
  1445. userJSONBytes, _ := json.Marshal(dat)
  1446. var res ResultTwo
  1447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1448. utils.ErrorLog("解析失败:%v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. if res.Infcode == 0 {
  1453. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1454. if err == gorm.ErrRecordNotFound {
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1456. return
  1457. } else if err != nil {
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1459. return
  1460. } else {
  1461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1463. infoStr := string(Iinfos)
  1464. idetinfoStr := string(Idetinfos)
  1465. psn := &models.HisPsn{
  1466. PsnNo: res.Output.Baseinfo.PsnNo,
  1467. Age: res.Output.Baseinfo.Age,
  1468. PatientId: patient.ID,
  1469. Certno: res.Output.Baseinfo.Certno,
  1470. Brdy: res.Output.Baseinfo.Brdy,
  1471. Gend: res.Output.Baseinfo.Gend,
  1472. Naty: res.Output.Baseinfo.Naty,
  1473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1474. PsnName: res.Output.Baseinfo.PsnName,
  1475. Idetinfo: idetinfoStr,
  1476. Insuinfo: infoStr,
  1477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1478. CardInfo: basStr,
  1479. VerifyNumber: "",
  1480. }
  1481. service.CreateHisPsn(psn)
  1482. c.ServeSuccessJSON(map[string]interface{}{
  1483. "patient": patient,
  1484. "number": basNumber,
  1485. })
  1486. }
  1487. } else {
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1489. return
  1490. }
  1491. break
  1492. }
  1493. case 2:
  1494. SFZStr := c.GetSFZBaseInfo()
  1495. id_card_str := strings.Split(SFZStr, "^")
  1496. id_card_number := id_card_str[0]
  1497. card_sn := ""
  1498. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1499. var dat map[string]interface{}
  1500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1501. fmt.Println(dat)
  1502. } else {
  1503. fmt.Println(err)
  1504. }
  1505. userJSONBytes, _ := json.Marshal(dat)
  1506. var res ResultTwo
  1507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1508. utils.ErrorLog("解析失败:%v", err)
  1509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1510. return
  1511. }
  1512. if res.Infcode == 0 {
  1513. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1514. if err == gorm.ErrRecordNotFound {
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1516. return
  1517. } else if err != nil {
  1518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1519. return
  1520. } else {
  1521. c.ServeSuccessJSON(map[string]interface{}{
  1522. "patient": patient,
  1523. "number": id_card_number,
  1524. })
  1525. }
  1526. } else {
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1528. return
  1529. }
  1530. break
  1531. case 3:
  1532. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1533. var api string
  1534. if miConfig.MdtrtareaAdmvs == "320921" {
  1535. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1536. "&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
  1537. fmt.Println(api)
  1538. } else {
  1539. 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 +
  1540. "&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)
  1541. }
  1542. resp, requestErr := http.Get(api)
  1543. if requestErr != nil {
  1544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1545. return
  1546. }
  1547. body, ioErr := ioutil.ReadAll(resp.Body)
  1548. if ioErr != nil {
  1549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1551. return
  1552. }
  1553. var respJSON map[string]interface{}
  1554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1557. return
  1558. }
  1559. var status string
  1560. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1561. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1562. var token string
  1563. var res ResultTwo //1101结果
  1564. var res10265 ResultTwo10265 //1101结果
  1565. var card_info string //卡信息
  1566. var busi_card_info string
  1567. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1568. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1569. if status == "0" { //读卡成功
  1570. if card_type == "1" {
  1571. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1572. result, _ := json.Marshal(respJSON)
  1573. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1574. utils.ErrorLog("解析失败:%v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. res.ErrMsg = res10265.ErrMsg
  1579. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1580. res.Infcode = infocode
  1581. res.Output = res10265.Output
  1582. res.InfRefmsgid = res10265.InfRefmsgid
  1583. } else {
  1584. //var card_info string //卡信息
  1585. //var busi_card_info string
  1586. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1587. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1588. //fmt.Println(card_info)
  1589. //fmt.Println(busi_card_info)
  1590. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1591. result, _ := json.Marshal(respJSON)
  1592. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1593. utils.ErrorLog("解析失败:%v", err)
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. return
  1596. }
  1597. res.ErrMsg = res10265.ErrMsg
  1598. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1599. res.Infcode = infocode
  1600. res.Output = res10265.Output
  1601. res.InfRefmsgid = res10265.InfRefmsgid
  1602. }
  1603. if res.Infcode == 0 {
  1604. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1605. if err == gorm.ErrRecordNotFound {
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1607. return
  1608. } else if err != nil {
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1610. return
  1611. } else {
  1612. if card_type == "1" {
  1613. bas := strings.Split(card_info, "|")
  1614. basNumber := bas[2]
  1615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1617. infoStr := string(Iinfos)
  1618. idetinfoStr := string(Idetinfos)
  1619. psn := &models.HisPsn{
  1620. PsnNo: res.Output.Baseinfo.PsnNo,
  1621. Age: res.Output.Baseinfo.Age,
  1622. PatientId: patient.ID,
  1623. Certno: res.Output.Baseinfo.Certno,
  1624. Brdy: res.Output.Baseinfo.Brdy,
  1625. Gend: res.Output.Baseinfo.Gend,
  1626. Naty: res.Output.Baseinfo.Naty,
  1627. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1628. PsnName: res.Output.Baseinfo.PsnName,
  1629. Idetinfo: idetinfoStr,
  1630. Insuinfo: infoStr,
  1631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1632. CardInfo: card_info,
  1633. VerifyNumber: busi_card_info,
  1634. }
  1635. service.CreateHisPsn(psn)
  1636. c.ServeSuccessJSON(map[string]interface{}{
  1637. "patient": patient,
  1638. "number": basNumber,
  1639. })
  1640. } else {
  1641. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1642. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1643. infoStr := string(Iinfos)
  1644. idetinfoStr := string(Idetinfos)
  1645. psn := &models.HisPsn{
  1646. PsnNo: res.Output.Baseinfo.PsnNo,
  1647. Age: res.Output.Baseinfo.Age,
  1648. PatientId: patient.ID,
  1649. Certno: res.Output.Baseinfo.Certno,
  1650. Brdy: res.Output.Baseinfo.Brdy,
  1651. Gend: res.Output.Baseinfo.Gend,
  1652. Naty: res.Output.Baseinfo.Naty,
  1653. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1654. PsnName: res.Output.Baseinfo.PsnName,
  1655. Idetinfo: idetinfoStr,
  1656. Insuinfo: infoStr,
  1657. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1658. CardInfo: card_info,
  1659. VerifyNumber: token,
  1660. }
  1661. service.CreateHisPsn(psn)
  1662. var rf []*ResultFive
  1663. json.Unmarshal([]byte(infoStr), &rf)
  1664. var insutypes []*ResultFive
  1665. var insutype string
  1666. var is390 int = 0
  1667. var is310 int = 0
  1668. for _, item := range rf {
  1669. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1670. insutypes = append(insutypes, item)
  1671. }
  1672. }
  1673. if len(insutypes) == 1 {
  1674. insutype = insutypes[0].Insutype
  1675. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1676. } else {
  1677. for _, i := range insutypes {
  1678. if i.Insutype == "390" {
  1679. is390 = 1
  1680. }
  1681. if i.Insutype == "310" {
  1682. is310 = 1
  1683. }
  1684. }
  1685. }
  1686. if is390 == 1 {
  1687. insutype = "390"
  1688. }
  1689. if is310 == 1 {
  1690. insutype = "310"
  1691. }
  1692. if len(insutypes) == 0 {
  1693. insutype = "310"
  1694. }
  1695. c.ServeSuccessJSON(map[string]interface{}{
  1696. "patient": patient,
  1697. "number": token,
  1698. "insutype": insutype,
  1699. })
  1700. }
  1701. }
  1702. } else {
  1703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1704. return
  1705. }
  1706. } else { //读卡失败
  1707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1708. return
  1709. }
  1710. }
  1711. break
  1712. case 4:
  1713. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1714. var api string
  1715. if miConfig.MdtrtareaAdmvs == "320921" {
  1716. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1717. "&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
  1718. fmt.Println(api)
  1719. } else {
  1720. 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 +
  1721. "&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)
  1722. }
  1723. resp, requestErr := http.Get(api)
  1724. if requestErr != nil {
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. return
  1727. }
  1728. body, ioErr := ioutil.ReadAll(resp.Body)
  1729. if ioErr != nil {
  1730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. return
  1733. }
  1734. var respJSON map[string]interface{}
  1735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1738. return
  1739. }
  1740. var status string
  1741. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1742. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1743. var token string
  1744. var res ResultTwo //1101结果
  1745. var res10265 ResultTwo10265 //1101结果
  1746. if status == "0" { //读卡成功
  1747. var card_info string //卡信息
  1748. var busi_card_info string
  1749. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1750. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1751. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1752. fmt.Println(card_info)
  1753. fmt.Println(busi_card_info)
  1754. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1755. result, _ := json.Marshal(respJSON)
  1756. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1757. utils.ErrorLog("解析失败:%v", err)
  1758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1759. return
  1760. }
  1761. res.ErrMsg = res10265.ErrMsg
  1762. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1763. res.Infcode = infocode
  1764. res.Output = res10265.Output
  1765. res.InfRefmsgid = res10265.InfRefmsgid
  1766. if res.Infcode == 0 {
  1767. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1768. if err == gorm.ErrRecordNotFound {
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1770. return
  1771. } else if err != nil {
  1772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1773. return
  1774. } else {
  1775. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1776. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1777. infoStr := string(Iinfos)
  1778. idetinfoStr := string(Idetinfos)
  1779. psn := &models.HisPsn{
  1780. PsnNo: res.Output.Baseinfo.PsnNo,
  1781. Age: res.Output.Baseinfo.Age,
  1782. PatientId: patient.ID,
  1783. Certno: res.Output.Baseinfo.Certno,
  1784. Brdy: res.Output.Baseinfo.Brdy,
  1785. Gend: res.Output.Baseinfo.Gend,
  1786. Naty: res.Output.Baseinfo.Naty,
  1787. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1788. PsnName: res.Output.Baseinfo.PsnName,
  1789. Idetinfo: idetinfoStr,
  1790. Insuinfo: infoStr,
  1791. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1792. CardInfo: card_info,
  1793. VerifyNumber: token,
  1794. }
  1795. service.CreateHisPsn(psn)
  1796. c.ServeSuccessJSON(map[string]interface{}{
  1797. "patient": patient,
  1798. "number": token,
  1799. })
  1800. }
  1801. } else {
  1802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1803. return
  1804. }
  1805. } else { //读卡失败
  1806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1807. return
  1808. }
  1809. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1810. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1811. saveLog(result, requestLog, "6101", "电子凭证")
  1812. var ele ELeCertData
  1813. err := json.Unmarshal([]byte(result), &ele)
  1814. if err != nil {
  1815. utils.ErrorLog("解析失败:%v", err)
  1816. }
  1817. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  1818. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1819. var res ResultTwo
  1820. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1821. utils.ErrorLog("解析失败:%v", err)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. return
  1824. }
  1825. if res.Infcode == 0 {
  1826. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  1827. if err == gorm.ErrRecordNotFound {
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1829. return
  1830. } else if err != nil {
  1831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1832. return
  1833. } else {
  1834. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1835. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1836. infoStr := string(Iinfos)
  1837. idetinfoStr := string(Idetinfos)
  1838. psn := &models.HisPsn{
  1839. PsnNo: res.Output.Baseinfo.PsnNo,
  1840. Age: res.Output.Baseinfo.Age,
  1841. PatientId: patient.ID,
  1842. Certno: res.Output.Baseinfo.Certno,
  1843. Brdy: res.Output.Baseinfo.Brdy,
  1844. Gend: res.Output.Baseinfo.Gend,
  1845. Naty: res.Output.Baseinfo.Naty,
  1846. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1847. PsnName: res.Output.Baseinfo.PsnName,
  1848. Idetinfo: idetinfoStr,
  1849. Insuinfo: infoStr,
  1850. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1851. CardInfo: "",
  1852. VerifyNumber: ele.Data.EcToken,
  1853. }
  1854. service.CreateHisPsn(psn)
  1855. c.ServeSuccessJSON(map[string]interface{}{
  1856. "patient": patient,
  1857. "number": ele.Data.EcToken,
  1858. })
  1859. }
  1860. } else {
  1861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1862. return
  1863. }
  1864. }
  1865. break
  1866. }
  1867. }
  1868. var initFlag int64 = 0
  1869. func (c *HisApiController) TestGetBasBaseInit() {
  1870. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1871. Iinit := DllDef.MustFindProc("Init")
  1872. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1873. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1874. if ret != 0 {
  1875. fmt.Println("SSCard的报错原因:", err)
  1876. fmt.Println("SSCard的运算结果为:", ret)
  1877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1878. return
  1879. }
  1880. result := int(ret)
  1881. fmt.Println("SSCard的运算结果为1:", result)
  1882. initFlag = 1
  1883. return
  1884. }
  1885. func (c *HisApiController) GetSFZBaseInfo() string {
  1886. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1887. readCard := DllDef.MustFindProc("ReadSFZ")
  1888. if readCard == nil {
  1889. fmt.Println("readcard is nil")
  1890. readCard = DllDef.MustFindProc("ReadSFZ")
  1891. }
  1892. str := make([]byte, 256)
  1893. str1 := make([]byte, 256)
  1894. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1895. fmt.Println(r)
  1896. return string(str)
  1897. }
  1898. func (c *HisApiController) GetBasBaseInfo() string {
  1899. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1900. readCard := DllDef.MustFindProc("ReadCardBas")
  1901. if readCard == nil {
  1902. fmt.Println("readcard is nil")
  1903. readCard = DllDef.MustFindProc("ReadCardBas")
  1904. }
  1905. str := make([]byte, 1024)
  1906. str1 := make([]byte, 1024)
  1907. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1908. fmt.Println(string(str1))
  1909. fmt.Println(string(str))
  1910. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1911. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1912. if ret2 != 0 {
  1913. return ""
  1914. }
  1915. return string(str)
  1916. }
  1917. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1918. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1919. readCard := DllDef.MustFindProc("read_cardinfo")
  1920. if readCard == nil {
  1921. fmt.Println("readcard is nil")
  1922. readCard = DllDef.MustFindProc("read_cardinfo")
  1923. }
  1924. str := make([]byte, 1024) //卡号
  1925. str1 := make([]byte, 1024) //卡识别码
  1926. str2 := make([]byte, 1024) //身份证号
  1927. str3 := make([]byte, 1024) //姓名
  1928. str4 := make([]byte, 1024) //错误信息
  1929. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  1930. fmt.Println(string(str1))
  1931. fmt.Println(string(str))
  1932. fmt.Println(string(str2))
  1933. fmt.Println(string(str3))
  1934. fmt.Println(string(str4))
  1935. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1936. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1937. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1938. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1939. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1940. if ret2 != 0 {
  1941. return "", "", "", "", ""
  1942. }
  1943. return string(str), string(str1), string(str2), string(str3), string(str4)
  1944. }
  1945. type CustomFundPay struct {
  1946. FundPayType string `json:"fund_pay_type"`
  1947. FundPayamt float64 `json:"fund_payamt"`
  1948. }
  1949. func (c *HisApiController) GetSettleList() {
  1950. order_id, _ := c.GetInt64("order_id")
  1951. admin_user_id, _ := c.GetInt64("admin_user_id")
  1952. order, _ := service.GetHisOrderByIDTwo(order_id)
  1953. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1954. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1955. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1956. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1957. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1958. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1959. if order.ID == 0 {
  1960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1961. return
  1962. }
  1963. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1964. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1965. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1966. fmt.Println(count)
  1967. var zero string
  1968. number := count + 1
  1969. if number >= 1000 {
  1970. zero = "0000" + strconv.FormatInt(number, 10)
  1971. } else if number >= 10000 {
  1972. zero = "000" + strconv.FormatInt(number, 10)
  1973. } else if number >= 100000 {
  1974. zero = "00" + strconv.FormatInt(number, 10)
  1975. } else if number >= 1000000 {
  1976. zero = "0" + strconv.FormatInt(number, 10)
  1977. } else {
  1978. zero = strconv.FormatInt(number, 10)
  1979. }
  1980. fmt.Println(zero)
  1981. struct4101 := service.Struct4101{
  1982. PsnNo: order.PsnNo,
  1983. MdtrtId: order.MdtrtId,
  1984. SetlId: order.SetlId,
  1985. PsnName: order.PsnName,
  1986. Gend: order.Gend,
  1987. Brdy: his.Brdy,
  1988. Age: his.Age,
  1989. Naty: order.Naty,
  1990. PatnCertType: "01",
  1991. Certno: order.Certno,
  1992. Prfs: "90",
  1993. ConerName: roles[0].UserName,
  1994. PatnRlts: "99",
  1995. ConerAddr: miConfig.OrgName,
  1996. ConerTel: admin.Mobile,
  1997. HiType: order.Insutype,
  1998. Insuplc: miConfig.InsuplcAdmdvs,
  1999. MaindiagFlag: "1",
  2000. BillCode: last_order.FaPiaoCode,
  2001. BillNo: zero,
  2002. BizSn: order.Number,
  2003. PsnSelfPay: order.PsnPartAmt,
  2004. PsnOwnPay: order.PsnPartAmt,
  2005. AcctPay: order.AcctPay,
  2006. PsnCashpay: order.PsnCashPay,
  2007. HiPaymtd: "1",
  2008. Hsorg: miConfig.InsuplcAdmdvs,
  2009. HsorgOpter: miConfig.InsuplcAdmdvs,
  2010. MedinsFillPsn: curRoles.UserName,
  2011. MedinsFillDept: depart.Name,
  2012. IptMedType: "2",
  2013. }
  2014. struct4101.SetlBegnDate = order.SetlTime
  2015. struct4101.SetlEndDate = order.SetlTime
  2016. time_arr := strings.Split(order.SetlTime, " ")
  2017. struct4101.AdmTime = time_arr[0]
  2018. struct4101.AdmEndTime = time_arr[0]
  2019. var rf []CustomFundPay
  2020. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2021. var tempFunPays []service.CustomStruct
  2022. for _, item := range rf {
  2023. var tempFunPay service.CustomStruct
  2024. tempFunPay.FundPayamt = item.FundPayamt
  2025. tempFunPay.FundPayType = item.FundPayType
  2026. tempFunPays = append(tempFunPays, tempFunPay)
  2027. }
  2028. struct4101.CustomStruct = tempFunPays
  2029. var tempDiaginfos []service.DiaginfoStructTwo
  2030. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2031. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2032. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2033. var config []*models.HisXtDiagnoseConfig
  2034. for _, item := range diagnosis_ids {
  2035. id, _ := strconv.ParseInt(item, 10, 64)
  2036. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2037. config = append(config, &diagnosisConfig)
  2038. }
  2039. for index, item := range config {
  2040. if index == 0 {
  2041. var tempDiaginfo service.DiaginfoStructTwo
  2042. tempDiaginfo.DiagCode = item.CountryCode
  2043. tempDiaginfo.DiagName = item.CountryContentName
  2044. tempDiaginfo.DiagType = "1"
  2045. tempDiaginfo.MaindiagFlag = "1"
  2046. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2047. } else {
  2048. var tempDiaginfo service.DiaginfoStructTwo
  2049. tempDiaginfo.DiagCode = item.CountryCode
  2050. tempDiaginfo.DiagName = item.CountryContentName
  2051. tempDiaginfo.DiagType = "2"
  2052. tempDiaginfo.MaindiagFlag = "0"
  2053. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2054. }
  2055. }
  2056. struct4101.Diseinfo = tempDiaginfos
  2057. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2058. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2059. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2060. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2061. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2062. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2063. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2064. var iteminfo service.IteminfoStruct
  2065. var bedCostTotal float64 = 0 //床位总费
  2066. var bedCostSelfTotal float64 = 0 //床位自费
  2067. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2068. var operationCostTotal float64 = 0 //手术费
  2069. var operationCostSelfTotal float64 = 0 //手术费
  2070. var operationCostPartSelfTotal float64 = 0 //手术费
  2071. var otherCostTotal float64 = 0 //其他费用
  2072. var otherCostSelfTotal float64 = 0 //其他费用
  2073. var otherCostPartSelfTotal float64 = 0 //其他费用
  2074. var materialCostTotal float64 = 0 //材料费
  2075. var materialCostSelfTotal float64 = 0 //材料费
  2076. var materialCostPartSelfTotal float64 = 0 //材料费
  2077. var westernMedicineCostTotal float64 = 0 //西药费
  2078. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2079. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2080. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2081. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2082. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2083. var checkCostTotal float64 = 0 //检查费
  2084. var checkCostSelfTotal float64 = 0 //检查费
  2085. var checkCostPartSelfTotal float64 = 0 //检查费
  2086. var laboratoryCostTotal float64 = 0 //化验费
  2087. var laboratoryCostSelfTotal float64 = 0 //化验费
  2088. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2089. var treatCostTotal float64 = 0 //治疗费用
  2090. var treatCostSelfTotal float64 = 0 //治疗费用
  2091. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2092. decimal.DivisionPrecision = 2
  2093. var bed_fulamt_ownpay_amt float64 = 0
  2094. var operation_fulamt_ownpay_amt float64 = 0
  2095. var other_fulamt_ownpay_amt float64 = 0
  2096. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2097. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2098. var check_fulamt_ownpay_amt float64 = 0
  2099. var material_fulamt_ownpay_amt float64 = 0
  2100. var laboratory_fulamt_ownpay_amt float64 = 0
  2101. var treat_fulamt_ownpay_amt float64 = 0
  2102. var bed_claa_sunmfee float64 = 0
  2103. var bed_clab_amt float64 = 0
  2104. var bed_other_amt float64 = 0
  2105. var operation_claa_sunmfee float64 = 0
  2106. var operation_clab_amt float64 = 0
  2107. var operation_other_amt float64 = 0
  2108. var other_claa_sunmfee float64 = 0
  2109. var other_clab_amt float64 = 0
  2110. var other_other_amt float64 = 0
  2111. var westernMedicine_claa_sunmfee float64 = 0
  2112. var westernMedicine_clab_amt float64 = 0
  2113. var westernMedicine_other_amt float64 = 0
  2114. var chineseTraditional_claa_sunmfee float64 = 0
  2115. var chineseTraditional_clab_amt float64 = 0
  2116. var chineseTraditional_other_amt float64 = 0
  2117. var check_claa_sunmfee float64 = 0
  2118. var check_clab_amt float64 = 0
  2119. var check_other_amt float64 = 0
  2120. var material_claa_sunmfee float64 = 0
  2121. var material_clab_amt float64 = 0
  2122. var material_other_amt float64 = 0
  2123. var laboratory_claa_sunmfee float64 = 0
  2124. var laboratory_clab_amt float64 = 0
  2125. var laboratory_other_amt float64 = 0
  2126. var treat_claa_sunmfee float64 = 0
  2127. var treat_clab_amt float64 = 0
  2128. var treat_other_amt float64 = 0
  2129. for _, item := range order.HisOrderInfo {
  2130. if item.MedChrgitmType == "01" { //床位费
  2131. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2132. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2133. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2134. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2135. if item.ChrgitmLv == "1" {
  2136. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2137. }
  2138. if item.ChrgitmLv == "2" {
  2139. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. }
  2141. if item.ChrgitmLv == "3" {
  2142. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2143. }
  2144. }
  2145. if item.MedChrgitmType == "03" { //检查费
  2146. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2147. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2148. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2149. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2150. if item.ChrgitmLv == "1" {
  2151. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2152. }
  2153. if item.ChrgitmLv == "2" {
  2154. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2155. }
  2156. if item.ChrgitmLv == "3" {
  2157. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2158. }
  2159. }
  2160. if item.MedChrgitmType == "04" { //化验费
  2161. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2162. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2163. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2164. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2165. if item.ChrgitmLv == "1" {
  2166. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2167. }
  2168. if item.ChrgitmLv == "2" {
  2169. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2170. }
  2171. if item.ChrgitmLv == "3" {
  2172. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2173. }
  2174. }
  2175. if item.MedChrgitmType == "05" { //治疗费
  2176. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2177. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2178. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2179. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2180. if item.ChrgitmLv == "1" {
  2181. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2182. }
  2183. if item.ChrgitmLv == "2" {
  2184. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2185. }
  2186. if item.ChrgitmLv == "3" {
  2187. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2188. }
  2189. }
  2190. if item.MedChrgitmType == "06" { //手术费
  2191. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2192. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2193. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2194. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2195. if item.ChrgitmLv == "1" {
  2196. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2197. }
  2198. if item.ChrgitmLv == "2" {
  2199. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2200. }
  2201. if item.ChrgitmLv == "3" {
  2202. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2203. }
  2204. }
  2205. if item.MedChrgitmType == "08" { //材料费
  2206. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2207. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2208. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2209. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2210. if item.ChrgitmLv == "1" {
  2211. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2212. }
  2213. if item.ChrgitmLv == "2" {
  2214. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2215. }
  2216. if item.ChrgitmLv == "3" {
  2217. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2218. }
  2219. }
  2220. if item.MedChrgitmType == "09" { //西药费
  2221. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2222. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2223. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2224. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2225. if item.ChrgitmLv == "1" {
  2226. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2227. }
  2228. if item.ChrgitmLv == "2" {
  2229. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2230. }
  2231. if item.ChrgitmLv == "3" {
  2232. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2233. }
  2234. }
  2235. if item.MedChrgitmType == "11" { //中成费
  2236. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2237. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2238. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2239. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2240. if item.ChrgitmLv == "1" {
  2241. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2242. }
  2243. if item.ChrgitmLv == "2" {
  2244. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2245. }
  2246. if item.ChrgitmLv == "3" {
  2247. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2248. }
  2249. }
  2250. if item.MedChrgitmType == "14" { //其他费
  2251. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2252. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2253. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2254. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2255. if item.ChrgitmLv == "1" {
  2256. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2257. }
  2258. if item.ChrgitmLv == "2" {
  2259. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2260. }
  2261. if item.ChrgitmLv == "3" {
  2262. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2263. }
  2264. }
  2265. }
  2266. var iteminfoStructs []service.IteminfoStruct
  2267. if bedCostTotal != 0 {
  2268. iteminfo.MedChrgitm = "01"
  2269. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2270. iteminfo.Amt = bedCostTotal
  2271. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2272. iteminfo.ClabAmt = bed_clab_amt
  2273. iteminfo.OthAmt = bed_other_amt
  2274. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2275. }
  2276. if checkCostTotal != 0 {
  2277. iteminfo.MedChrgitm = "03"
  2278. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2279. iteminfo.Amt = checkCostTotal
  2280. iteminfo.ClaaSumfee = check_claa_sunmfee
  2281. iteminfo.ClabAmt = check_clab_amt
  2282. iteminfo.OthAmt = check_other_amt
  2283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2284. }
  2285. if laboratoryCostTotal != 0 {
  2286. iteminfo.MedChrgitm = "04"
  2287. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2288. iteminfo.Amt = laboratoryCostTotal
  2289. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2290. iteminfo.ClabAmt = laboratory_clab_amt
  2291. iteminfo.OthAmt = laboratory_other_amt
  2292. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2293. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2294. }
  2295. if treatCostTotal != 0 {
  2296. iteminfo.MedChrgitm = "05"
  2297. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2298. iteminfo.Amt = treatCostTotal
  2299. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2300. iteminfo.ClabAmt = treat_clab_amt
  2301. iteminfo.OthAmt = treat_other_amt
  2302. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2303. //(struct4101.IteminfoStruct, iteminfo)
  2304. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2305. }
  2306. if operationCostTotal != 0 {
  2307. iteminfo.MedChrgitm = "06"
  2308. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2309. iteminfo.Amt = operationCostTotal
  2310. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2311. iteminfo.ClabAmt = operation_clab_amt
  2312. iteminfo.OthAmt = operation_other_amt
  2313. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2314. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2315. }
  2316. if materialCostTotal != 0 {
  2317. iteminfo.MedChrgitm = "08"
  2318. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2319. iteminfo.Amt = materialCostTotal
  2320. iteminfo.ClaaSumfee = material_claa_sunmfee
  2321. iteminfo.ClabAmt = material_clab_amt
  2322. iteminfo.OthAmt = material_other_amt
  2323. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2324. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2325. }
  2326. if westernMedicineCostTotal != 0 {
  2327. iteminfo.MedChrgitm = "09"
  2328. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2329. iteminfo.Amt = westernMedicineCostTotal
  2330. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2331. iteminfo.ClabAmt = westernMedicine_clab_amt
  2332. iteminfo.OthAmt = westernMedicine_other_amt
  2333. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2334. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2335. }
  2336. if chineseTraditionalMedicineCostTotal != 0 {
  2337. iteminfo.MedChrgitm = "11"
  2338. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2339. iteminfo.Amt = westernMedicineCostTotal
  2340. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2341. iteminfo.ClabAmt = westernMedicine_clab_amt
  2342. iteminfo.OthAmt = westernMedicine_other_amt
  2343. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2344. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2345. }
  2346. if otherCostTotal != 0 {
  2347. iteminfo.MedChrgitm = "14"
  2348. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2349. iteminfo.Amt = otherCostTotal
  2350. iteminfo.ClaaSumfee = other_claa_sunmfee
  2351. iteminfo.ClabAmt = other_clab_amt
  2352. iteminfo.OthAmt = other_other_amt
  2353. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2354. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2355. }
  2356. struct4101.IteminfoStruct = iteminfoStructs
  2357. struct4101.Ntly = "中国"
  2358. struct4101.AdmCaty = "A03.06"
  2359. var res ResultSeventeen
  2360. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2361. var resOther ResultSeventeenOther
  2362. var pp models.PublicParams
  2363. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2364. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2365. pp.FixmedinsName = miConfig.OrgName
  2366. pp.FixmedinsCode = miConfig.Code
  2367. pp.RequestUrl = miConfig.Url
  2368. pp.Cainfo = miConfig.Cainfo
  2369. pp.SecretKey = miConfig.SecretKey
  2370. pp.AccessKey = miConfig.AccessKey
  2371. pp.OpterName = curRoles.UserName
  2372. client := &http.Client{}
  2373. var req *http.Request
  2374. data := make(map[string]interface{})
  2375. data["struct4101"] = struct4101
  2376. data["pp"] = pp
  2377. bytesData, _ := json.Marshal(data)
  2378. if miConfig.MdtrtareaAdmvs == "320921" {
  2379. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2380. } else {
  2381. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2382. }
  2383. resp, _ := client.Do(req)
  2384. defer resp.Body.Close()
  2385. body, ioErr := ioutil.ReadAll(resp.Body)
  2386. if ioErr != nil {
  2387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2389. return
  2390. }
  2391. var respJSON map[string]interface{}
  2392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. return
  2396. }
  2397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2398. userJSONBytes, _ := json.Marshal(respJSON)
  2399. fmt.Println("log")
  2400. fmt.Println(string(userJSONBytes))
  2401. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2402. utils.ErrorLog("解析失败:%v", err)
  2403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2404. return
  2405. }
  2406. res.InfRefmsgid = resOther.InfRefmsgid
  2407. res.Output = resOther.Output
  2408. res.ErrMsg = resOther.ErrMsg
  2409. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2410. res.Infcode = infocode
  2411. } else {
  2412. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2413. var dat map[string]interface{}
  2414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2415. fmt.Println(dat)
  2416. } else {
  2417. fmt.Println(err)
  2418. }
  2419. userJSONBytes, _ := json.Marshal(dat)
  2420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2421. utils.ErrorLog("解析失败:%v", err)
  2422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. return
  2424. }
  2425. }
  2426. if res.Infcode != 0 {
  2427. c.ServeSuccessJSON(map[string]interface{}{
  2428. "failed_code": -10,
  2429. "msg": res.ErrMsg,
  2430. })
  2431. return
  2432. } else {
  2433. order.FaPiaoNumber = zero
  2434. order.FaPiaoCode = last_order.FaPiaoCode
  2435. service.UpdateOrder(order)
  2436. hisFundSettleListResult := &models.HisFundSettleListResult{
  2437. Number: res.Output.SetlListId,
  2438. Status: 1,
  2439. Ctime: time.Now().Unix(),
  2440. Mtime: time.Now().Unix(),
  2441. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2442. IsUpload: 1,
  2443. OrderId: order_id,
  2444. }
  2445. service.CreateUploadRecord(hisFundSettleListResult)
  2446. c.ServeSuccessJSON(map[string]interface{}{
  2447. "msg": "上传成功",
  2448. "result": hisFundSettleListResult,
  2449. })
  2450. return
  2451. }
  2452. }
  2453. func (c *HisApiController) GetSettleListHospital() {
  2454. order_id, _ := c.GetInt64("order_id")
  2455. admin_user_id, _ := c.GetInt64("admin_user_id")
  2456. order, _ := service.GetHisOrderByIDTwo(order_id)
  2457. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2458. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2459. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2460. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2461. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2462. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2463. if order.ID == 0 {
  2464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2465. return
  2466. }
  2467. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2468. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2469. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2470. fmt.Println(count)
  2471. var zero string
  2472. number := count + 1
  2473. if number >= 1000 {
  2474. zero = "0000" + strconv.FormatInt(number, 10)
  2475. } else if number >= 10000 {
  2476. zero = "000" + strconv.FormatInt(number, 10)
  2477. } else if number >= 100000 {
  2478. zero = "00" + strconv.FormatInt(number, 10)
  2479. } else if number >= 1000000 {
  2480. zero = "0" + strconv.FormatInt(number, 10)
  2481. } else {
  2482. zero = strconv.FormatInt(number, 10)
  2483. }
  2484. fmt.Println(zero)
  2485. struct4101 := service.Struct4101{
  2486. PsnNo: order.PsnNo,
  2487. MdtrtId: order.MdtrtId,
  2488. SetlId: order.SetlId,
  2489. PsnName: order.PsnName,
  2490. Gend: order.Gend,
  2491. Brdy: his.Brdy,
  2492. Age: int64(order.Age),
  2493. Naty: order.Naty,
  2494. PatnCertType: "01",
  2495. Certno: order.Certno,
  2496. Prfs: "90",
  2497. ConerName: roles[0].UserName,
  2498. PatnRlts: "99",
  2499. ConerAddr: miConfig.OrgName,
  2500. ConerTel: admin.Mobile,
  2501. HiType: order.Insutype,
  2502. Insuplc: miConfig.InsuplcAdmdvs,
  2503. MaindiagFlag: "1",
  2504. BillCode: last_order.FaPiaoCode,
  2505. BillNo: zero,
  2506. BizSn: order.Number,
  2507. PsnSelfPay: order.PsnPartAmt,
  2508. PsnOwnPay: order.PsnPartAmt,
  2509. AcctPay: order.AcctPay,
  2510. PsnCashpay: order.PsnCashPay,
  2511. HiPaymtd: "1",
  2512. Hsorg: miConfig.InsuplcAdmdvs,
  2513. HsorgOpter: miConfig.InsuplcAdmdvs,
  2514. MedinsFillPsn: curRoles.UserName,
  2515. MedinsFillDept: depart.Name,
  2516. IptMedType: "2",
  2517. AdmTime: his.InHosptialTime,
  2518. AdmEndTime: his.OutHosptialTime,
  2519. }
  2520. struct4101.SetlBegnDate = order.SetlTime
  2521. struct4101.SetlEndDate = order.SetlTime
  2522. var rf []CustomFundPay
  2523. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2524. var tempFunPays []service.CustomStruct
  2525. for _, item := range rf {
  2526. var tempFunPay service.CustomStruct
  2527. tempFunPay.FundPayamt = item.FundPayamt
  2528. tempFunPay.FundPayType = item.FundPayType
  2529. tempFunPays = append(tempFunPays, tempFunPay)
  2530. }
  2531. struct4101.CustomStruct = tempFunPays
  2532. var tempDiaginfos []service.DiaginfoStructTwo
  2533. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2534. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2535. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2536. var config []*models.HisXtDiagnoseConfig
  2537. for _, item := range diagnosis_ids {
  2538. id, _ := strconv.ParseInt(item, 10, 64)
  2539. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2540. config = append(config, &diagnosisConfig)
  2541. }
  2542. for index, item := range config {
  2543. if index == 0 {
  2544. var tempDiaginfo service.DiaginfoStructTwo
  2545. tempDiaginfo.DiagCode = item.CountryCode
  2546. tempDiaginfo.DiagName = item.CountryContentName
  2547. tempDiaginfo.DiagType = "1"
  2548. tempDiaginfo.MaindiagFlag = "1"
  2549. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2550. } else {
  2551. var tempDiaginfo service.DiaginfoStructTwo
  2552. tempDiaginfo.DiagCode = item.CountryCode
  2553. tempDiaginfo.DiagName = item.CountryContentName
  2554. tempDiaginfo.DiagType = "2"
  2555. tempDiaginfo.MaindiagFlag = "0"
  2556. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2557. }
  2558. }
  2559. struct4101.Diseinfo = tempDiaginfos
  2560. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2561. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2562. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2563. tempOpspdiseinfo2.OprnOprtCode = ""
  2564. tempOpspdiseinfo2.OprnOprtName = ""
  2565. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2566. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2567. var iteminfo service.IteminfoStruct
  2568. var bedCostTotal float64 = 0 //床位总费
  2569. var bedCostSelfTotal float64 = 0 //床位自费
  2570. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2571. var operationCostTotal float64 = 0 //手术费
  2572. var operationCostSelfTotal float64 = 0 //手术费
  2573. var operationCostPartSelfTotal float64 = 0 //手术费
  2574. var otherCostTotal float64 = 0 //其他费用
  2575. var otherCostSelfTotal float64 = 0 //其他费用
  2576. var otherCostPartSelfTotal float64 = 0 //其他费用
  2577. var materialCostTotal float64 = 0 //材料费
  2578. var materialCostSelfTotal float64 = 0 //材料费
  2579. var materialCostPartSelfTotal float64 = 0 //材料费
  2580. var westernMedicineCostTotal float64 = 0 //西药费
  2581. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2582. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2583. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2584. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2585. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2586. var checkCostTotal float64 = 0 //检查费
  2587. var checkCostSelfTotal float64 = 0 //检查费
  2588. var checkCostPartSelfTotal float64 = 0 //检查费
  2589. var laboratoryCostTotal float64 = 0 //化验费
  2590. var laboratoryCostSelfTotal float64 = 0 //化验费
  2591. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2592. var treatCostTotal float64 = 0 //治疗费用
  2593. var treatCostSelfTotal float64 = 0 //治疗费用
  2594. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2595. decimal.DivisionPrecision = 2
  2596. var bed_fulamt_ownpay_amt float64 = 0
  2597. var operation_fulamt_ownpay_amt float64 = 0
  2598. var other_fulamt_ownpay_amt float64 = 0
  2599. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2600. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2601. var check_fulamt_ownpay_amt float64 = 0
  2602. var material_fulamt_ownpay_amt float64 = 0
  2603. var laboratory_fulamt_ownpay_amt float64 = 0
  2604. var treat_fulamt_ownpay_amt float64 = 0
  2605. var bed_claa_sunmfee float64 = 0
  2606. var bed_clab_amt float64 = 0
  2607. var bed_other_amt float64 = 0
  2608. var operation_claa_sunmfee float64 = 0
  2609. var operation_clab_amt float64 = 0
  2610. var operation_other_amt float64 = 0
  2611. var other_claa_sunmfee float64 = 0
  2612. var other_clab_amt float64 = 0
  2613. var other_other_amt float64 = 0
  2614. var westernMedicine_claa_sunmfee float64 = 0
  2615. var westernMedicine_clab_amt float64 = 0
  2616. var westernMedicine_other_amt float64 = 0
  2617. var chineseTraditional_claa_sunmfee float64 = 0
  2618. var chineseTraditional_clab_amt float64 = 0
  2619. var chineseTraditional_other_amt float64 = 0
  2620. var check_claa_sunmfee float64 = 0
  2621. var check_clab_amt float64 = 0
  2622. var check_other_amt float64 = 0
  2623. var material_claa_sunmfee float64 = 0
  2624. var material_clab_amt float64 = 0
  2625. var material_other_amt float64 = 0
  2626. var laboratory_claa_sunmfee float64 = 0
  2627. var laboratory_clab_amt float64 = 0
  2628. var laboratory_other_amt float64 = 0
  2629. var treat_claa_sunmfee float64 = 0
  2630. var treat_clab_amt float64 = 0
  2631. var treat_other_amt float64 = 0
  2632. for _, item := range order.HisOrderInfo {
  2633. if item.MedChrgitmType == "01" { //床位费
  2634. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2635. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2636. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2637. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2638. if item.ChrgitmLv == "1" {
  2639. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2640. }
  2641. if item.ChrgitmLv == "2" {
  2642. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2643. }
  2644. if item.ChrgitmLv == "3" {
  2645. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2646. }
  2647. }
  2648. if item.MedChrgitmType == "03" { //检查费
  2649. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2650. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2651. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2652. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2653. if item.ChrgitmLv == "1" {
  2654. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2655. }
  2656. if item.ChrgitmLv == "2" {
  2657. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2658. }
  2659. if item.ChrgitmLv == "3" {
  2660. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2661. }
  2662. }
  2663. if item.MedChrgitmType == "04" { //化验费
  2664. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2665. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2666. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2667. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2668. if item.ChrgitmLv == "1" {
  2669. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2670. }
  2671. if item.ChrgitmLv == "2" {
  2672. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2673. }
  2674. if item.ChrgitmLv == "3" {
  2675. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2676. }
  2677. }
  2678. if item.MedChrgitmType == "05" { //治疗费
  2679. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2680. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2681. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2682. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2683. if item.ChrgitmLv == "1" {
  2684. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2685. }
  2686. if item.ChrgitmLv == "2" {
  2687. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2688. }
  2689. if item.ChrgitmLv == "3" {
  2690. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2691. }
  2692. }
  2693. if item.MedChrgitmType == "06" { //手术费
  2694. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2695. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2696. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2697. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2698. if item.ChrgitmLv == "1" {
  2699. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2700. }
  2701. if item.ChrgitmLv == "2" {
  2702. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2703. }
  2704. if item.ChrgitmLv == "3" {
  2705. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2706. }
  2707. }
  2708. if item.MedChrgitmType == "08" { //材料费
  2709. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2710. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2711. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2712. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2713. if item.ChrgitmLv == "1" {
  2714. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2715. }
  2716. if item.ChrgitmLv == "2" {
  2717. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2718. }
  2719. if item.ChrgitmLv == "3" {
  2720. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2721. }
  2722. }
  2723. if item.MedChrgitmType == "09" { //西药费
  2724. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2725. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2726. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2727. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2728. if item.ChrgitmLv == "1" {
  2729. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2730. }
  2731. if item.ChrgitmLv == "2" {
  2732. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2733. }
  2734. if item.ChrgitmLv == "3" {
  2735. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2736. }
  2737. }
  2738. if item.MedChrgitmType == "11" { //中成费
  2739. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2740. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2741. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2742. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2743. if item.ChrgitmLv == "1" {
  2744. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2745. }
  2746. if item.ChrgitmLv == "2" {
  2747. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2748. }
  2749. if item.ChrgitmLv == "3" {
  2750. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2751. }
  2752. }
  2753. if item.MedChrgitmType == "14" { //其他费
  2754. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2755. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2756. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2757. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2758. if item.ChrgitmLv == "1" {
  2759. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2760. }
  2761. if item.ChrgitmLv == "2" {
  2762. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2763. }
  2764. if item.ChrgitmLv == "3" {
  2765. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2766. }
  2767. }
  2768. }
  2769. var iteminfoStructs []service.IteminfoStruct
  2770. if bedCostTotal != 0 {
  2771. iteminfo.MedChrgitm = "01"
  2772. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2773. iteminfo.Amt = bedCostTotal
  2774. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2775. iteminfo.ClabAmt = bed_clab_amt
  2776. iteminfo.OthAmt = bed_other_amt
  2777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2778. }
  2779. if checkCostTotal != 0 {
  2780. iteminfo.MedChrgitm = "03"
  2781. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2782. iteminfo.Amt = checkCostTotal
  2783. iteminfo.ClaaSumfee = check_claa_sunmfee
  2784. iteminfo.ClabAmt = check_clab_amt
  2785. iteminfo.OthAmt = check_other_amt
  2786. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2787. }
  2788. if laboratoryCostTotal != 0 {
  2789. iteminfo.MedChrgitm = "04"
  2790. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2791. iteminfo.Amt = laboratoryCostTotal
  2792. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2793. iteminfo.ClabAmt = laboratory_clab_amt
  2794. iteminfo.OthAmt = laboratory_other_amt
  2795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2796. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2797. }
  2798. if treatCostTotal != 0 {
  2799. iteminfo.MedChrgitm = "05"
  2800. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2801. iteminfo.Amt = treatCostTotal
  2802. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2803. iteminfo.ClabAmt = treat_clab_amt
  2804. iteminfo.OthAmt = treat_other_amt
  2805. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2806. //(struct4101.IteminfoStruct, iteminfo)
  2807. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2808. }
  2809. if operationCostTotal != 0 {
  2810. iteminfo.MedChrgitm = "06"
  2811. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2812. iteminfo.Amt = operationCostTotal
  2813. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2814. iteminfo.ClabAmt = operation_clab_amt
  2815. iteminfo.OthAmt = operation_other_amt
  2816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2818. }
  2819. if materialCostTotal != 0 {
  2820. iteminfo.MedChrgitm = "08"
  2821. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2822. iteminfo.Amt = materialCostTotal
  2823. iteminfo.ClaaSumfee = material_claa_sunmfee
  2824. iteminfo.ClabAmt = material_clab_amt
  2825. iteminfo.OthAmt = material_other_amt
  2826. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2827. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2828. }
  2829. if westernMedicineCostTotal != 0 {
  2830. iteminfo.MedChrgitm = "09"
  2831. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2832. iteminfo.Amt = westernMedicineCostTotal
  2833. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2834. iteminfo.ClabAmt = westernMedicine_clab_amt
  2835. iteminfo.OthAmt = westernMedicine_other_amt
  2836. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2837. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2838. }
  2839. if chineseTraditionalMedicineCostTotal != 0 {
  2840. iteminfo.MedChrgitm = "11"
  2841. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2842. iteminfo.Amt = westernMedicineCostTotal
  2843. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2844. iteminfo.ClabAmt = westernMedicine_clab_amt
  2845. iteminfo.OthAmt = westernMedicine_other_amt
  2846. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2847. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2848. }
  2849. if otherCostTotal != 0 {
  2850. iteminfo.MedChrgitm = "14"
  2851. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2852. iteminfo.Amt = otherCostTotal
  2853. iteminfo.ClaaSumfee = other_claa_sunmfee
  2854. iteminfo.ClabAmt = other_clab_amt
  2855. iteminfo.OthAmt = other_other_amt
  2856. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2858. }
  2859. struct4101.IteminfoStruct = iteminfoStructs
  2860. struct4101.Ntly = "中国"
  2861. struct4101.AdmCaty = "A03.06"
  2862. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2863. fmt.Println(result)
  2864. var dat map[string]interface{}
  2865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2866. fmt.Println(dat)
  2867. } else {
  2868. fmt.Println(err)
  2869. }
  2870. userJSONBytes, _ := json.Marshal(dat)
  2871. var res ResultSeventeen
  2872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2873. utils.ErrorLog("解析失败:%v", err)
  2874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. return
  2876. }
  2877. if res.Infcode != 0 {
  2878. c.ServeSuccessJSON(map[string]interface{}{
  2879. "failed_code": -10,
  2880. "msg": res.ErrMsg,
  2881. })
  2882. return
  2883. } else {
  2884. order.FaPiaoNumber = zero
  2885. order.FaPiaoCode = last_order.FaPiaoCode
  2886. service.UpdateOrder(order)
  2887. hisFundSettleListResult := &models.HisFundSettleListResult{
  2888. Number: res.Output.SetlListId,
  2889. Status: 1,
  2890. Ctime: time.Now().Unix(),
  2891. Mtime: time.Now().Unix(),
  2892. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2893. IsUpload: 1,
  2894. OrderId: order_id,
  2895. }
  2896. service.CreateUploadRecord(hisFundSettleListResult)
  2897. c.ServeSuccessJSON(map[string]interface{}{
  2898. "msg": "上传成功",
  2899. "result": hisFundSettleListResult,
  2900. })
  2901. return
  2902. }
  2903. }
  2904. func (c *HisApiController) GetBatchSettleList() {
  2905. orders, _ := service.GetAllHisOrder(10088)
  2906. for _, item := range orders {
  2907. order_id := item.ID
  2908. order, _ := service.GetHisOrderByIDTwo(order_id)
  2909. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2910. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2911. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2912. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2273)
  2913. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2915. if order.ID == 0 {
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2917. return
  2918. }
  2919. if his.BalanceAccountsType == 2 {
  2920. continue
  2921. }
  2922. struct4101 := service.Struct4101{
  2923. PsnNo: order.PsnNo,
  2924. MdtrtId: order.MdtrtId,
  2925. SetlId: order.SetlId,
  2926. PsnName: order.PsnName,
  2927. Gend: order.Gend,
  2928. Brdy: his.Brdy,
  2929. Age: his.Age,
  2930. Naty: order.Naty,
  2931. PatnCertType: "01",
  2932. Certno: order.Certno,
  2933. Prfs: "90",
  2934. ConerName: roles[0].UserName,
  2935. PatnRlts: "99",
  2936. ConerAddr: miConfig.OrgName,
  2937. ConerTel: admin.Mobile,
  2938. HiType: order.Insutype,
  2939. Insuplc: his.InsuplcAdmdvs,
  2940. MaindiagFlag: "1",
  2941. BillCode: order.FaPiaoCode,
  2942. BillNo: order.FaPiaoNumber,
  2943. BizSn: order.Number,
  2944. PsnSelfPay: order.PsnPartAmt,
  2945. PsnOwnPay: order.PsnPartAmt,
  2946. AcctPay: order.AcctPay,
  2947. PsnCashpay: order.PsnCashPay,
  2948. HiPaymtd: "1",
  2949. Hsorg: his.InsuplcAdmdvs,
  2950. HsorgOpter: his.InsuplcAdmdvs,
  2951. MedinsFillPsn: curRoles.UserName,
  2952. MedinsFillDept: depart.Name,
  2953. IptMedType: "2",
  2954. }
  2955. struct4101.SetlBegnDate = order.SetlTime
  2956. struct4101.SetlEndDate = order.SetlTime
  2957. //if order.SettleType == 1 {
  2958. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2959. // dateStr := t.Format("2006-01-02")
  2960. // struct4101.SetlBegnDate = dateStr
  2961. // struct4101.SetlEndDate = dateStr
  2962. //} else {
  2963. // t := time.Unix(int64(order.SettleStartTime), 0)
  2964. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2965. // dateStartStr := t.Format("2006-01-02")
  2966. // dateEndStr := t2.Format("2006-01-02")
  2967. // struct4101.SetlBegnDate = dateStartStr
  2968. // struct4101.SetlEndDate = dateEndStr
  2969. //}
  2970. var rf []CustomFundPay
  2971. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2972. var tempFunPays []service.CustomStruct
  2973. var tempFunPay610100 service.CustomStruct
  2974. for _, item := range rf {
  2975. if item.FundPayType == "610100" {
  2976. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2977. tempFunPay610100.FundPayType = item.FundPayType
  2978. } else {
  2979. var tempFunPay service.CustomStruct
  2980. tempFunPay.FundPayamt = item.FundPayamt
  2981. tempFunPay.FundPayType = item.FundPayType
  2982. tempFunPays = append(tempFunPays, tempFunPay)
  2983. }
  2984. }
  2985. tempFunPays = append(tempFunPays, tempFunPay610100)
  2986. struct4101.CustomStruct = tempFunPays
  2987. var tempDiaginfos []service.DiaginfoStructTwo
  2988. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2989. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2990. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2991. var config []*models.HisXtDiagnoseConfig
  2992. for _, item := range diagnosis_ids {
  2993. id, _ := strconv.ParseInt(item, 10, 64)
  2994. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2995. config = append(config, &diagnosisConfig)
  2996. }
  2997. for index, item := range config {
  2998. if index == 0 {
  2999. var tempDiaginfo service.DiaginfoStructTwo
  3000. tempDiaginfo.DiagCode = item.CountryCode
  3001. tempDiaginfo.DiagName = item.CountryContentName
  3002. tempDiaginfo.DiagType = "1"
  3003. tempDiaginfo.MaindiagFlag = "1"
  3004. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3005. } else {
  3006. var tempDiaginfo service.DiaginfoStructTwo
  3007. tempDiaginfo.DiagCode = item.CountryCode
  3008. tempDiaginfo.DiagName = item.CountryContentName
  3009. tempDiaginfo.DiagType = "2"
  3010. tempDiaginfo.MaindiagFlag = "0"
  3011. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3012. }
  3013. }
  3014. struct4101.Diseinfo = tempDiaginfos
  3015. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3016. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3017. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3018. tempOpspdiseinfo2.OprnOprtCode = ""
  3019. tempOpspdiseinfo2.OprnOprtName = ""
  3020. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3021. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3022. var iteminfo service.IteminfoStruct
  3023. var bedCostTotal float64 = 0 //床位总费
  3024. var bedCostSelfTotal float64 = 0 //床位自费
  3025. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3026. var examineCostTotal float64 = 0 //诊查总费
  3027. var examineCostSelfTotal float64 = 0 //诊查自费
  3028. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3029. var nursingCostTotal float64 = 0 //护理总费
  3030. var nursingCostSelfTotal float64 = 0 //护理自费
  3031. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3032. var chineseMedicineCostTotal float64 = 0 //中成药
  3033. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3034. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3035. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3036. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3037. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3038. var registerCostTotal float64 = 0 //一般诊疗费
  3039. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3040. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3041. var operationCostTotal float64 = 0 //手术费
  3042. var operationCostSelfTotal float64 = 0 //手术费
  3043. var operationCostPartSelfTotal float64 = 0 //手术费
  3044. var otherCostTotal float64 = 0 //其他费用
  3045. var otherCostSelfTotal float64 = 0 //其他费用
  3046. var otherCostPartSelfTotal float64 = 0 //其他费用
  3047. var materialCostTotal float64 = 0 //材料费
  3048. var materialCostSelfTotal float64 = 0 //材料费
  3049. var materialCostPartSelfTotal float64 = 0 //材料费
  3050. var westernMedicineCostTotal float64 = 0 //西药费
  3051. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3052. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3053. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3054. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3055. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3056. var checkCostTotal float64 = 0 //检查费
  3057. var checkCostSelfTotal float64 = 0 //检查费
  3058. var checkCostPartSelfTotal float64 = 0 //检查费
  3059. var laboratoryCostTotal float64 = 0 //化验费
  3060. var laboratoryCostSelfTotal float64 = 0 //化验费
  3061. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3062. var treatCostTotal float64 = 0 //治疗费用
  3063. var treatCostSelfTotal float64 = 0 //治疗费用
  3064. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3065. decimal.DivisionPrecision = 2
  3066. var bed_fulamt_ownpay_amt float64 = 0
  3067. var examine_fulamt_ownpay_amt float64 = 0
  3068. var nursing_fulamt_ownpay_amt float64 = 0
  3069. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3070. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3071. var register_fulamt_ownpay_amt float64 = 0
  3072. var operation_fulamt_ownpay_amt float64 = 0
  3073. var other_fulamt_ownpay_amt float64 = 0
  3074. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3075. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3076. var check_fulamt_ownpay_amt float64 = 0
  3077. var material_fulamt_ownpay_amt float64 = 0
  3078. var laboratory_fulamt_ownpay_amt float64 = 0
  3079. var treat_fulamt_ownpay_amt float64 = 0
  3080. var bed_claa_sunmfee float64 = 0
  3081. var bed_clab_amt float64 = 0
  3082. var bed_other_amt float64 = 0
  3083. var examine_claa_sunmfee float64 = 0
  3084. var examine_clab_amt float64 = 0
  3085. var examine_other_amt float64 = 0
  3086. var nursing_claa_sunmfee float64 = 0
  3087. var nursing_clab_amt float64 = 0
  3088. var nursing_other_amt float64 = 0
  3089. var chinese_medicine_claa_sunmfee float64 = 0
  3090. var chinese_medicine_clab_amt float64 = 0
  3091. var chinese_medicine_other_amt float64 = 0
  3092. var commonly_treatment_claa_sunmfee float64 = 0
  3093. var commonly_treatment_clab_amt float64 = 0
  3094. var commonly_treatment_other_amt float64 = 0
  3095. var operation_claa_sunmfee float64 = 0
  3096. var operation_clab_amt float64 = 0
  3097. var operation_other_amt float64 = 0
  3098. var other_claa_sunmfee float64 = 0
  3099. var other_clab_amt float64 = 0
  3100. var other_other_amt float64 = 0
  3101. var westernMedicine_claa_sunmfee float64 = 0
  3102. var westernMedicine_clab_amt float64 = 0
  3103. var westernMedicine_other_amt float64 = 0
  3104. var chineseTraditional_claa_sunmfee float64 = 0
  3105. var chineseTraditional_clab_amt float64 = 0
  3106. var chineseTraditional_other_amt float64 = 0
  3107. var check_claa_sunmfee float64 = 0
  3108. var check_clab_amt float64 = 0
  3109. var check_other_amt float64 = 0
  3110. var material_claa_sunmfee float64 = 0
  3111. var material_clab_amt float64 = 0
  3112. var material_other_amt float64 = 0
  3113. var laboratory_claa_sunmfee float64 = 0
  3114. var laboratory_clab_amt float64 = 0
  3115. var laboratory_other_amt float64 = 0
  3116. var treat_claa_sunmfee float64 = 0
  3117. var treat_clab_amt float64 = 0
  3118. var treat_other_amt float64 = 0
  3119. var register_claa_sunmfee float64 = 0
  3120. var register_clab_amt float64 = 0
  3121. var register_other_amt float64 = 0
  3122. for _, item := range order.HisOrderInfo {
  3123. if item.MedChrgitmType == "01" { //床位费
  3124. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3125. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3126. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3127. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3128. if item.ChrgitmLv == "1" {
  3129. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3130. }
  3131. if item.ChrgitmLv == "2" {
  3132. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3133. }
  3134. if item.ChrgitmLv == "3" {
  3135. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3136. }
  3137. }
  3138. if item.MedChrgitmType == "02" { //诊查
  3139. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3140. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3141. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3142. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3143. if item.ChrgitmLv == "1" {
  3144. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3145. }
  3146. if item.ChrgitmLv == "2" {
  3147. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3148. }
  3149. if item.ChrgitmLv == "3" {
  3150. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3151. }
  3152. }
  3153. if item.MedChrgitmType == "03" { //检查费
  3154. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3155. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3156. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3157. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3158. if item.ChrgitmLv == "1" {
  3159. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3160. }
  3161. if item.ChrgitmLv == "2" {
  3162. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3163. }
  3164. if item.ChrgitmLv == "3" {
  3165. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3166. }
  3167. }
  3168. if item.MedChrgitmType == "04" { //化验费
  3169. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3170. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3171. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3172. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3173. if item.ChrgitmLv == "1" {
  3174. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3175. }
  3176. if item.ChrgitmLv == "2" {
  3177. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3178. }
  3179. if item.ChrgitmLv == "3" {
  3180. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3181. }
  3182. }
  3183. if item.MedChrgitmType == "05" { //治疗费
  3184. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3185. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3186. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3187. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3188. if item.ChrgitmLv == "1" {
  3189. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3190. }
  3191. if item.ChrgitmLv == "2" {
  3192. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3193. }
  3194. if item.ChrgitmLv == "3" {
  3195. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3196. }
  3197. }
  3198. if item.MedChrgitmType == "06" { //手术费
  3199. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3200. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3201. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3202. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3203. if item.ChrgitmLv == "1" {
  3204. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3205. }
  3206. if item.ChrgitmLv == "2" {
  3207. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3208. }
  3209. if item.ChrgitmLv == "3" {
  3210. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3211. }
  3212. }
  3213. if item.MedChrgitmType == "07" { //手术费
  3214. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3215. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3216. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3217. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3218. if item.ChrgitmLv == "1" {
  3219. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3220. }
  3221. if item.ChrgitmLv == "2" {
  3222. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3223. }
  3224. if item.ChrgitmLv == "3" {
  3225. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3226. }
  3227. }
  3228. if item.MedChrgitmType == "08" { //材料费
  3229. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3230. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3231. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3232. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3233. if item.ChrgitmLv == "1" {
  3234. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3235. }
  3236. if item.ChrgitmLv == "2" {
  3237. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3238. }
  3239. if item.ChrgitmLv == "3" {
  3240. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3241. }
  3242. }
  3243. if item.MedChrgitmType == "09" { //西药费
  3244. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3245. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3246. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3247. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3248. if item.ChrgitmLv == "1" {
  3249. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3250. }
  3251. if item.ChrgitmLv == "2" {
  3252. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3253. }
  3254. if item.ChrgitmLv == "3" {
  3255. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3256. }
  3257. }
  3258. if item.MedChrgitmType == "10" { //中药饮片
  3259. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3260. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3261. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3262. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3263. if item.ChrgitmLv == "1" {
  3264. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3265. }
  3266. if item.ChrgitmLv == "2" {
  3267. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3268. }
  3269. if item.ChrgitmLv == "3" {
  3270. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3271. }
  3272. }
  3273. if item.MedChrgitmType == "11" { //中成费
  3274. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3275. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3276. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3277. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3278. if item.ChrgitmLv == "1" {
  3279. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3280. }
  3281. if item.ChrgitmLv == "2" {
  3282. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3283. }
  3284. if item.ChrgitmLv == "3" {
  3285. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3286. }
  3287. }
  3288. if item.MedChrgitmType == "12" { //中成费
  3289. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3290. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3291. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3292. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3293. if item.ChrgitmLv == "1" {
  3294. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3295. }
  3296. if item.ChrgitmLv == "2" {
  3297. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3298. }
  3299. if item.ChrgitmLv == "3" {
  3300. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3301. }
  3302. }
  3303. if item.MedChrgitmType == "13" { //中成费
  3304. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3305. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3306. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3307. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3308. if item.ChrgitmLv == "1" {
  3309. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3310. }
  3311. if item.ChrgitmLv == "2" {
  3312. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3313. }
  3314. if item.ChrgitmLv == "3" {
  3315. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3316. }
  3317. }
  3318. if item.MedChrgitmType == "14" { //其他费
  3319. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3320. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3321. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3322. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3323. if item.ChrgitmLv == "1" {
  3324. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3325. }
  3326. if item.ChrgitmLv == "2" {
  3327. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3328. }
  3329. if item.ChrgitmLv == "3" {
  3330. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3331. }
  3332. }
  3333. }
  3334. var iteminfoStructs []service.IteminfoStruct
  3335. if bedCostTotal != 0 {
  3336. iteminfo.MedChrgitm = "01"
  3337. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3338. iteminfo.Amt = bedCostTotal
  3339. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3340. iteminfo.ClabAmt = bed_clab_amt
  3341. iteminfo.OthAmt = bed_other_amt
  3342. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3343. }
  3344. if examineCostTotal != 0 {
  3345. iteminfo.MedChrgitm = "02"
  3346. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3347. iteminfo.Amt = examineCostTotal
  3348. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3349. iteminfo.ClabAmt = examine_clab_amt
  3350. iteminfo.OthAmt = examine_other_amt
  3351. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3353. }
  3354. if checkCostTotal != 0 {
  3355. iteminfo.MedChrgitm = "03"
  3356. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3357. iteminfo.Amt = checkCostTotal
  3358. iteminfo.ClaaSumfee = check_claa_sunmfee
  3359. iteminfo.ClabAmt = check_clab_amt
  3360. iteminfo.OthAmt = check_other_amt
  3361. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3362. }
  3363. if laboratoryCostTotal != 0 {
  3364. iteminfo.MedChrgitm = "04"
  3365. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3366. iteminfo.Amt = laboratoryCostTotal
  3367. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3368. iteminfo.ClabAmt = laboratory_clab_amt
  3369. iteminfo.OthAmt = laboratory_other_amt
  3370. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3371. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3372. }
  3373. if treatCostTotal != 0 {
  3374. iteminfo.MedChrgitm = "05"
  3375. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3376. iteminfo.Amt = treatCostTotal
  3377. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3378. iteminfo.ClabAmt = treat_clab_amt
  3379. iteminfo.OthAmt = treat_other_amt
  3380. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3381. //(struct4101.IteminfoStruct, iteminfo)
  3382. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3383. }
  3384. if operationCostTotal != 0 {
  3385. iteminfo.MedChrgitm = "06"
  3386. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3387. iteminfo.Amt = operationCostTotal
  3388. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3389. iteminfo.ClabAmt = operation_clab_amt
  3390. iteminfo.OthAmt = operation_other_amt
  3391. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3392. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3393. }
  3394. if nursingCostTotal != 0 {
  3395. iteminfo.MedChrgitm = "07"
  3396. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3397. iteminfo.Amt = nursingCostTotal
  3398. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3399. iteminfo.ClabAmt = nursing_clab_amt
  3400. iteminfo.OthAmt = nursing_other_amt
  3401. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3402. }
  3403. if materialCostTotal != 0 {
  3404. iteminfo.MedChrgitm = "08"
  3405. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3406. iteminfo.Amt = materialCostTotal
  3407. iteminfo.ClaaSumfee = material_claa_sunmfee
  3408. iteminfo.ClabAmt = material_clab_amt
  3409. iteminfo.OthAmt = material_other_amt
  3410. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3411. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3412. }
  3413. if westernMedicineCostTotal != 0 {
  3414. iteminfo.MedChrgitm = "09"
  3415. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3416. iteminfo.Amt = westernMedicineCostTotal
  3417. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3418. iteminfo.ClabAmt = westernMedicine_clab_amt
  3419. iteminfo.OthAmt = westernMedicine_other_amt
  3420. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3421. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3422. }
  3423. if chineseMedicineCostTotal != 0 {
  3424. iteminfo.MedChrgitm = "10"
  3425. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3426. iteminfo.Amt = chineseMedicineCostTotal
  3427. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3428. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3429. iteminfo.OthAmt = chinese_medicine_other_amt
  3430. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3431. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3432. }
  3433. if chineseTraditionalMedicineCostTotal != 0 {
  3434. iteminfo.MedChrgitm = "11"
  3435. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3436. iteminfo.Amt = westernMedicineCostTotal
  3437. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3438. iteminfo.ClabAmt = westernMedicine_clab_amt
  3439. iteminfo.OthAmt = westernMedicine_other_amt
  3440. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3441. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3442. }
  3443. if commonlyTreatmentCostTotal != 0 {
  3444. iteminfo.MedChrgitm = "12"
  3445. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3446. iteminfo.Amt = commonlyTreatmentCostTotal
  3447. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3448. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3449. iteminfo.OthAmt = commonly_treatment_other_amt
  3450. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3451. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3452. }
  3453. if registerCostTotal != 0 {
  3454. iteminfo.MedChrgitm = "13"
  3455. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3456. iteminfo.Amt = registerCostTotal
  3457. iteminfo.ClaaSumfee = register_claa_sunmfee
  3458. iteminfo.ClabAmt = register_clab_amt
  3459. iteminfo.OthAmt = register_other_amt
  3460. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3461. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3462. }
  3463. if otherCostTotal != 0 {
  3464. iteminfo.MedChrgitm = "14"
  3465. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3466. iteminfo.Amt = otherCostTotal
  3467. iteminfo.ClaaSumfee = other_claa_sunmfee
  3468. iteminfo.ClabAmt = other_clab_amt
  3469. iteminfo.OthAmt = other_other_amt
  3470. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3471. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3472. }
  3473. struct4101.IteminfoStruct = iteminfoStructs
  3474. struct4101.Ntly = "中国"
  3475. struct4101.AdmCaty = "A03.06"
  3476. var res ResultSeventeen
  3477. if miConfig.MdtrtareaAdmvs == "421300" {
  3478. data := make(map[string]interface{})
  3479. data["struct4101"] = struct4101
  3480. data["secret_key"] = miConfig.SecretKey
  3481. data["org_name"] = miConfig.OrgName
  3482. data["opera"] = curRoles.UserName
  3483. data["code"] = miConfig.Code
  3484. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3485. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3486. client := &http.Client{}
  3487. bytesData, _ := json.Marshal(data)
  3488. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3489. resp, _ := client.Do(req)
  3490. defer resp.Body.Close()
  3491. body, ioErr := ioutil.ReadAll(resp.Body)
  3492. if ioErr != nil {
  3493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3495. return
  3496. }
  3497. var respJSON map[string]interface{}
  3498. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. return
  3502. }
  3503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3504. userJSONBytes, _ := json.Marshal(respJSON)
  3505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3506. utils.ErrorLog("解析失败:%v", err)
  3507. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3508. adminUser := c.GetAdminUserInfo()
  3509. errlog := &models.HisOrderError{
  3510. UserOrgId: adminUser.CurrentOrgId,
  3511. Ctime: time.Now().Unix(),
  3512. Mtime: time.Now().Unix(),
  3513. ErrMsg: res.ErrMsg + "解析失败",
  3514. Status: 1,
  3515. PatientId: order_id,
  3516. Stage: 10088,
  3517. }
  3518. service.CreateErrMsgLog(errlog)
  3519. continue
  3520. }
  3521. } else {
  3522. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3523. fmt.Println(result)
  3524. var dat map[string]interface{}
  3525. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3526. fmt.Println(dat)
  3527. } else {
  3528. fmt.Println(err)
  3529. }
  3530. userJSONBytes, _ := json.Marshal(dat)
  3531. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3532. utils.ErrorLog("解析失败:%v", err)
  3533. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3534. adminUser := c.GetAdminUserInfo()
  3535. errlog := &models.HisOrderError{
  3536. UserOrgId: adminUser.CurrentOrgId,
  3537. Ctime: time.Now().Unix(),
  3538. Mtime: time.Now().Unix(),
  3539. ErrMsg: res.ErrMsg + "解析失败",
  3540. Status: 1,
  3541. PatientId: order_id,
  3542. Stage: 10088,
  3543. }
  3544. service.CreateErrMsgLog(errlog)
  3545. continue
  3546. }
  3547. }
  3548. if res.Infcode != 0 {
  3549. adminUser := c.GetAdminUserInfo()
  3550. errlog := &models.HisOrderError{
  3551. UserOrgId: adminUser.CurrentOrgId,
  3552. Ctime: time.Now().Unix(),
  3553. Mtime: time.Now().Unix(),
  3554. ErrMsg: res.ErrMsg,
  3555. Status: 1,
  3556. PatientId: order_id,
  3557. Stage: 10088,
  3558. }
  3559. service.CreateErrMsgLog(errlog)
  3560. continue
  3561. } else {
  3562. hisFundSettleListResult := &models.HisFundSettleListResult{
  3563. Number: res.Output.SetlListId,
  3564. Status: 1,
  3565. Ctime: time.Now().Unix(),
  3566. Mtime: time.Now().Unix(),
  3567. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3568. IsUpload: 1,
  3569. OrderId: order_id,
  3570. }
  3571. service.CreateUploadRecord(hisFundSettleListResult)
  3572. continue
  3573. }
  3574. }
  3575. }
  3576. func (c *HisApiController) GetOrgInfo() {
  3577. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3578. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3579. }
  3580. func (c *HisApiController) GetHisPatientInfo() {
  3581. medical_insurance_card := c.GetString("medical_insurance_card")
  3582. id_card_type, _ := c.GetInt64("id_card_type")
  3583. id_card := c.GetString("id_card")
  3584. adminInfo := c.GetAdminUserInfo()
  3585. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3586. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3587. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3588. IdCardNo := ""
  3589. if id_card_type == 1 {
  3590. IdCardNo = medical_insurance_card
  3591. } else if id_card_type == 2 {
  3592. IdCardNo = id_card
  3593. }
  3594. if config.IsOpen == 1 {
  3595. 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
  3596. resp, requestErr := http.Get(api)
  3597. if requestErr != nil {
  3598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3599. return
  3600. }
  3601. defer resp.Body.Close()
  3602. body, ioErr := ioutil.ReadAll(resp.Body)
  3603. if ioErr != nil {
  3604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. var respJSON map[string]interface{}
  3609. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3612. return
  3613. }
  3614. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3615. userJSONBytes, _ := json.Marshal(userJSON)
  3616. var res ResultTwo
  3617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3618. utils.ErrorLog("解析失败:%v", err)
  3619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3620. return
  3621. }
  3622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3624. infoStr := string(Iinfos)
  3625. idetinfoStr := string(Idetinfos)
  3626. if res.Infcode == 0 {
  3627. his := models.VMHisPatient{
  3628. Status: 1,
  3629. Ctime: time.Now().Unix(),
  3630. Mtime: time.Now().Unix(),
  3631. PsnNo: res.Output.Baseinfo.PsnNo,
  3632. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3633. Certno: res.Output.Baseinfo.Certno,
  3634. PsnName: res.Output.Baseinfo.PsnName,
  3635. Gend: res.Output.Baseinfo.Gend,
  3636. Naty: res.Output.Baseinfo.Naty,
  3637. Brdy: res.Output.Baseinfo.Brdy,
  3638. Age: res.Output.Baseinfo.Age,
  3639. Iinfo: infoStr,
  3640. Idetinfo: idetinfoStr,
  3641. UserOrgId: adminInfo.CurrentOrgId,
  3642. IsReturn: 1,
  3643. IdCardType: id_card_type,
  3644. }
  3645. c.ServeSuccessJSON(map[string]interface{}{
  3646. "info": his,
  3647. })
  3648. } else {
  3649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3650. return
  3651. }
  3652. }
  3653. }
  3654. //func GetBasBaseInfo() (jsonStr string, err error) {
  3655. //
  3656. // handle := syscall.NewLazyDLL("SSCard.dll")
  3657. // add := handle.NewProc("ReadCardBas")
  3658. // str := make([]byte, 1024)
  3659. // str1 := make([]byte, 1024)
  3660. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3661. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3662. //
  3663. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3664. //
  3665. // fmt.Println("> Add(4,5)的结果为:", ret)
  3666. // handle.Release()
  3667. //
  3668. // return "", nil
  3669. //
  3670. //}
  3671. //func GetQRBaseInfo() (jsonStr string, err error) {
  3672. // handle := syscall.LoadDLL("SSCard.dll")
  3673. // ReadCardBas := handle.FindProc("GetQRBase")
  3674. //
  3675. // str := make([]byte, 256)
  3676. // str1 := make([]byte, 256)
  3677. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3678. //
  3679. // fmt.Println(string(str))
  3680. // fmt.Println(r)
  3681. // return string(str), nil
  3682. //}
  3683. //func CardInit() int {
  3684. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3685. // add := DllTestDef.MustFindProc("Init")
  3686. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3687. // if err != nil {
  3688. // fmt.Println("SSCard的运算结果为:", ret)
  3689. // }
  3690. // result := int(ret)
  3691. // return result
  3692. //}
  3693. //func CardInit() int {
  3694. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3695. // if err != nil {
  3696. // fmt.Println("SSCard的运算结果为:", ret)
  3697. // }
  3698. // fmt.Println(err)
  3699. // result := int(ret)
  3700. // return result
  3701. //}
  3702. func IntPtr(n int) uintptr {
  3703. return uintptr(n)
  3704. }
  3705. func StrPtr(s string) uintptr {
  3706. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3707. }
  3708. type Result2001 struct {
  3709. Cainfo interface{} `json:"cainfo"`
  3710. ErrMsg string `json:"err_msg"`
  3711. InfRefmsgid string `json:"inf_refmsgid"`
  3712. Infcode int64 `json:"infcode"`
  3713. Output struct {
  3714. Trtinfo struct {
  3715. PsnNo string `json:"psn_no"`
  3716. TrtChkType string `json:"trt_chk_type"`
  3717. FundPayType string `json:"fund_pay_type"`
  3718. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3719. Begndate string `json:"begndate"`
  3720. Enddate string `json:"enddate"`
  3721. TrtChkRslt string `json:"trt_chk_rslt"`
  3722. } `json:"trtinfo"`
  3723. } `json:"output"`
  3724. RefmsgTime string `json:"refmsg_time"`
  3725. RespondTime string `json:"respond_time"`
  3726. Signtype interface{} `json:"signtype"`
  3727. WarnMsg interface{} `json:"warn_msg"`
  3728. }
  3729. type Result2001Org10265 struct {
  3730. Cainfo interface{} `json:"cainfo"`
  3731. ErrMsg string `json:"err_msg"`
  3732. InfRefmsgid string `json:"inf_refmsgid"`
  3733. Infcode string `json:"infcode"`
  3734. Output struct {
  3735. Trtinfo struct {
  3736. PsnNo string `json:"psn_no"`
  3737. TrtChkType string `json:"trt_chk_type"`
  3738. FundPayType string `json:"fund_pay_type"`
  3739. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3740. Begndate string `json:"begndate"`
  3741. Enddate string `json:"enddate"`
  3742. TrtChkRslt string `json:"trt_chk_rslt"`
  3743. } `json:"trtinfo"`
  3744. } `json:"output"`
  3745. RefmsgTime string `json:"refmsg_time"`
  3746. RespondTime string `json:"respond_time"`
  3747. Signtype interface{} `json:"signtype"`
  3748. WarnMsg interface{} `json:"warn_msg"`
  3749. }
  3750. type ResultTwo struct {
  3751. ErrMsg string `json:"err_msg"`
  3752. InfRefmsgid string `json:"inf_refmsgid"`
  3753. Infcode int64 `json:"infcode"`
  3754. Output struct {
  3755. Baseinfo struct {
  3756. Age float64 `json:"age"`
  3757. Brdy string `json:"brdy"`
  3758. Certno string `json:"certno"`
  3759. Gend string `json:"gend"`
  3760. Naty string `json:"naty"`
  3761. PsnCertType string `json:"psn_cert_type"`
  3762. PsnName string `json:"psn_name"`
  3763. PsnNo string `json:"psn_no"`
  3764. } `json:"baseinfo"`
  3765. Idetinfo []interface{} `json:"idetinfo"`
  3766. Iinfo []struct {
  3767. Balc float64 `json:"balc"`
  3768. CvlservFlag string `json:"cvlserv_flag"`
  3769. EmpName string `json:"emp_name"`
  3770. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3771. Insutype string `json:"insutype"`
  3772. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3773. PausInsuDate string `json:"paus_insu_date"`
  3774. PsnInsuDate string `json:"psn_insu_date"`
  3775. PsnInsuStas string `json:"psn_insu_stas"`
  3776. PsnType string `json:"psn_type"`
  3777. } `json:"insuinfo"`
  3778. } `json:"output"`
  3779. RefmsgTime string `json:"refmsg_time"`
  3780. RespondTime string `json:"respond_time"`
  3781. Signtype interface{} `json:"signtype"`
  3782. WarnInfo interface{} `json:"warn_info"`
  3783. }
  3784. type ResultTwo10265 struct {
  3785. ErrMsg string `json:"err_msg"`
  3786. InfRefmsgid string `json:"inf_refmsgid"`
  3787. Infcode string `json:"infcode"`
  3788. Output struct {
  3789. Baseinfo struct {
  3790. Age float64 `json:"age"`
  3791. Brdy string `json:"brdy"`
  3792. Certno string `json:"certno"`
  3793. Gend string `json:"gend"`
  3794. Naty string `json:"naty"`
  3795. PsnCertType string `json:"psn_cert_type"`
  3796. PsnName string `json:"psn_name"`
  3797. PsnNo string `json:"psn_no"`
  3798. } `json:"baseinfo"`
  3799. Idetinfo []interface{} `json:"idetinfo"`
  3800. Iinfo []struct {
  3801. Balc float64 `json:"balc"`
  3802. CvlservFlag string `json:"cvlserv_flag"`
  3803. EmpName string `json:"emp_name"`
  3804. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3805. Insutype string `json:"insutype"`
  3806. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3807. PausInsuDate string `json:"paus_insu_date"`
  3808. PsnInsuDate string `json:"psn_insu_date"`
  3809. PsnInsuStas string `json:"psn_insu_stas"`
  3810. PsnType string `json:"psn_type"`
  3811. } `json:"insuinfo"`
  3812. } `json:"output"`
  3813. RefmsgTime string `json:"refmsg_time"`
  3814. RespondTime string `json:"respond_time"`
  3815. Signtype interface{} `json:"signtype"`
  3816. WarnInfo interface{} `json:"warn_info"`
  3817. }
  3818. type ResultThree struct {
  3819. Cainfo interface{} `json:"cainfo"`
  3820. ErrMsg string `json:"err_msg"`
  3821. InfRefmsgid string `json:"inf_refmsgid"`
  3822. Infcode int64 `json:"infcode"`
  3823. Output struct {
  3824. Data struct {
  3825. IptOtpNo string `json:"ipt_otp_no"`
  3826. MdtrtID string `json:"mdtrt_id"`
  3827. PsnNo string `json:"psn_no"`
  3828. } `json:"data"`
  3829. } `json:"output"`
  3830. RefmsgTime string `json:"refmsg_time"`
  3831. RespondTime string `json:"respond_time"`
  3832. Signtype interface{} `json:"signtype"`
  3833. WarnMsg interface{} `json:"warn_msg"`
  3834. }
  3835. type ResultThree10265 struct {
  3836. Cainfo interface{} `json:"cainfo"`
  3837. ErrMsg string `json:"err_msg"`
  3838. InfRefmsgid string `json:"inf_refmsgid"`
  3839. Infcode string `json:"infcode"`
  3840. Output struct {
  3841. Data struct {
  3842. IptOtpNo string `json:"ipt_otp_no"`
  3843. MdtrtID string `json:"mdtrt_id"`
  3844. PsnNo string `json:"psn_no"`
  3845. } `json:"data"`
  3846. } `json:"output"`
  3847. RefmsgTime string `json:"refmsg_time"`
  3848. RespondTime string `json:"respond_time"`
  3849. Signtype interface{} `json:"signtype"`
  3850. WarnMsg interface{} `json:"warn_msg"`
  3851. }
  3852. type ResultFour struct {
  3853. Cainfo string `json:"cainfo"`
  3854. ErrMsg string `json:"err_msg"`
  3855. InfRefmsgid string `json:"inf_refmsgid"`
  3856. Infcode int64 `json:"infcode"`
  3857. Output struct {
  3858. Result []struct {
  3859. BasMednFlag string `json:"bas_medn_flag"`
  3860. ChldMedcFlag string `json:"chld_medc_flag"`
  3861. ChrgitmLv string `json:"chrgitm_lv"`
  3862. Cnt float64 `json:"cnt"`
  3863. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3864. DrtReimFlag string `json:"drt_reim_flag"`
  3865. FeedetlSn string `json:"feedetl_sn"`
  3866. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3867. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3868. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3869. ListSpItemFlag string `json:"list_sp_item_flag"`
  3870. LmtUsedFlag string `json:"lmt_used_flag"`
  3871. MedChrgitmType string `json:"med_chrgitm_type"`
  3872. Memo string `json:"memo"`
  3873. OverlmtAmt float64 `json:"overlmt_amt"`
  3874. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3875. Pric float64 `json:"pric"`
  3876. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3877. SelfpayProp float64 `json:"selfpay_prop"`
  3878. } `json:"result"`
  3879. } `json:"output"`
  3880. RefmsgTime string `json:"refmsg_time"`
  3881. RespondTime string `json:"respond_time"`
  3882. Signtype string `json:"signtype"`
  3883. WarnMsg string `json:"warn_msg"`
  3884. }
  3885. type ResultFour10265 struct {
  3886. Cainfo string `json:"cainfo"`
  3887. ErrMsg string `json:"err_msg"`
  3888. InfRefmsgid string `json:"inf_refmsgid"`
  3889. Infcode string `json:"infcode"`
  3890. Output struct {
  3891. Result []struct {
  3892. BasMednFlag string `json:"bas_medn_flag"`
  3893. ChldMedcFlag string `json:"chld_medc_flag"`
  3894. ChrgitmLv string `json:"chrgitm_lv"`
  3895. Cnt float64 `json:"cnt"`
  3896. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3897. DrtReimFlag string `json:"drt_reim_flag"`
  3898. FeedetlSn string `json:"feedetl_sn"`
  3899. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3900. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3901. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3902. ListSpItemFlag string `json:"list_sp_item_flag"`
  3903. LmtUsedFlag string `json:"lmt_used_flag"`
  3904. MedChrgitmType string `json:"med_chrgitm_type"`
  3905. Memo string `json:"memo"`
  3906. OverlmtAmt float64 `json:"overlmt_amt"`
  3907. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3908. Pric float64 `json:"pric"`
  3909. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3910. SelfpayProp float64 `json:"selfpay_prop"`
  3911. } `json:"result"`
  3912. } `json:"output"`
  3913. RefmsgTime string `json:"refmsg_time"`
  3914. RespondTime string `json:"respond_time"`
  3915. Signtype string `json:"signtype"`
  3916. WarnMsg string `json:"warn_msg"`
  3917. }
  3918. type ResultFive struct {
  3919. Balc float64 `json:"balc"`
  3920. CvlservFlag string `json:"cvlserv_flag"`
  3921. EmpName string `json:"emp_name"`
  3922. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3923. Insutype string `json:"insutype"`
  3924. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3925. PausInsuDate string `json:"paus_insu_date"`
  3926. PsnInsuDate string `json:"psn_insu_date"`
  3927. PsnInsuStas string `json:"psn_insu_stas"`
  3928. PsnType string `json:"psn_type"`
  3929. }
  3930. type ResultSix struct {
  3931. Cainfo interface{} `json:"cainfo"`
  3932. ErrMsg string `json:"err_msg"`
  3933. InfRefmsgid string `json:"inf_refmsgid"`
  3934. Infcode int64 `json:"infcode"`
  3935. Output struct {
  3936. } `json:"output"`
  3937. RefmsgTime string `json:"refmsg_time"`
  3938. RespondTime string `json:"respond_time"`
  3939. Signtype interface{} `json:"signtype"`
  3940. WarnMsg interface{} `json:"warn_msg"`
  3941. }
  3942. type ResultSix10265 struct {
  3943. Cainfo interface{} `json:"cainfo"`
  3944. ErrMsg string `json:"err_msg"`
  3945. InfRefmsgid string `json:"inf_refmsgid"`
  3946. Infcode string `json:"infcode"`
  3947. Output struct {
  3948. } `json:"output"`
  3949. RefmsgTime string `json:"refmsg_time"`
  3950. RespondTime string `json:"respond_time"`
  3951. Signtype interface{} `json:"signtype"`
  3952. WarnMsg interface{} `json:"warn_msg"`
  3953. }
  3954. type ResultSeven struct {
  3955. Cainfo string `json:"cainfo"`
  3956. ErrMsg string `json:"err_msg"`
  3957. InfRefmsgid string `json:"inf_refmsgid"`
  3958. Infcode int64 `json:"infcode"`
  3959. Output struct {
  3960. Setldetail []interface{} `json:"setldetail"`
  3961. Setlinfo struct {
  3962. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3963. AcctPay float64 `json:"acct_pay"`
  3964. ActPayDedc float64 `json:"act_pay_dedc"`
  3965. Age float64 `json:"age"`
  3966. Balc float64 `json:"balc"`
  3967. Brdy string `json:"brdy"`
  3968. Certno string `json:"certno"`
  3969. ClrOptins string `json:"clr_optins"`
  3970. ClrType string `json:"clr_type"`
  3971. ClrWay string `json:"clr_way"`
  3972. CvlservFlag string `json:"cvlserv_flag"`
  3973. CvlservPay float64 `json:"cvlserv_pay"`
  3974. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3975. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3976. Gend string `json:"gend"`
  3977. HifesPay float64 `json:"hifes_pay"`
  3978. HifmiPay float64 `json:"hifmi_pay"`
  3979. HifpPay float64 `json:"hifp_pay"`
  3980. HospPartAmt float64 `json:"hosp_part_amt"`
  3981. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3982. Insutype string `json:"insutype"`
  3983. MafPay float64 `json:"maf_pay"`
  3984. MdtrtCertType string `json:"mdtrt_cert_type"`
  3985. HifobPay float64 `json:"hifob_pay"`
  3986. MdtrtID string `json:"mdtrt_id"`
  3987. MedType string `json:"med_type"`
  3988. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3989. MedinsSetlID string `json:"medins_setl_id"`
  3990. Naty string `json:"naty"`
  3991. OthPay float64 `json:"oth_pay"`
  3992. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3993. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3994. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3995. PsnCashPay float64 `json:"psn_cash_pay"`
  3996. PsnCertType string `json:"psn_cert_type"`
  3997. PsnName string `json:"psn_name"`
  3998. PsnNo string `json:"psn_no"`
  3999. PsnPartAmt float64 `json:"psn_part_amt"`
  4000. PsnType string `json:"psn_type"`
  4001. SetlID string `json:"setl_id"`
  4002. SetlTime string `json:"setl_time"`
  4003. } `json:"setlinfo"`
  4004. } `json:"output"`
  4005. RefmsgTime string `json:"refmsg_time"`
  4006. RespondTime string `json:"respond_time"`
  4007. Signtype interface{} `json:"signtype"`
  4008. WarnMsg interface{} `json:"warn_msg"`
  4009. }
  4010. type ResultSeven10265 struct {
  4011. Cainfo string `json:"cainfo"`
  4012. ErrMsg string `json:"err_msg"`
  4013. InfRefmsgid string `json:"inf_refmsgid"`
  4014. Infcode string `json:"infcode"`
  4015. Output struct {
  4016. Setldetail []interface{} `json:"setldetail"`
  4017. Setlinfo struct {
  4018. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4019. AcctPay float64 `json:"acct_pay"`
  4020. ActPayDedc float64 `json:"act_pay_dedc"`
  4021. Age float64 `json:"age"`
  4022. Balc float64 `json:"balc"`
  4023. Brdy string `json:"brdy"`
  4024. Certno string `json:"certno"`
  4025. ClrOptins string `json:"clr_optins"`
  4026. ClrType string `json:"clr_type"`
  4027. ClrWay string `json:"clr_way"`
  4028. CvlservFlag string `json:"cvlserv_flag"`
  4029. CvlservPay float64 `json:"cvlserv_pay"`
  4030. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4031. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4032. Gend string `json:"gend"`
  4033. HifesPay float64 `json:"hifes_pay"`
  4034. HifmiPay float64 `json:"hifmi_pay"`
  4035. HifpPay float64 `json:"hifp_pay"`
  4036. HospPartAmt float64 `json:"hosp_part_amt"`
  4037. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4038. Insutype string `json:"insutype"`
  4039. MafPay float64 `json:"maf_pay"`
  4040. MdtrtCertType string `json:"mdtrt_cert_type"`
  4041. HifobPay float64 `json:"hifob_pay"`
  4042. MdtrtID string `json:"mdtrt_id"`
  4043. MedType string `json:"med_type"`
  4044. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4045. MedinsSetlID string `json:"medins_setl_id"`
  4046. Naty string `json:"naty"`
  4047. OthPay float64 `json:"oth_pay"`
  4048. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4049. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4050. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4051. PsnCashPay float64 `json:"psn_cash_pay"`
  4052. PsnCertType string `json:"psn_cert_type"`
  4053. PsnName string `json:"psn_name"`
  4054. PsnNo string `json:"psn_no"`
  4055. PsnPartAmt float64 `json:"psn_part_amt"`
  4056. PsnType string `json:"psn_type"`
  4057. SetlID string `json:"setl_id"`
  4058. SetlTime string `json:"setl_time"`
  4059. } `json:"setlinfo"`
  4060. } `json:"output"`
  4061. RefmsgTime string `json:"refmsg_time"`
  4062. RespondTime string `json:"respond_time"`
  4063. Signtype interface{} `json:"signtype"`
  4064. WarnMsg interface{} `json:"warn_msg"`
  4065. }
  4066. type ResultEight struct {
  4067. Cainfo string `json:"cainfo"`
  4068. ErrMsg string `json:"err_msg"`
  4069. InfRefmsgid string `json:"inf_refmsgid"`
  4070. Infcode int64 `json:"infcode"`
  4071. Output struct {
  4072. Stmtinfo struct {
  4073. SetlOptins string `json:"setl_optins"`
  4074. StmtRslt string `json:"stmt_rslt"`
  4075. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4076. } `json:"stmtinfo"`
  4077. } `json:"output"`
  4078. RefmsgTime string `json:"refmsg_time"`
  4079. RespondTime string `json:"respond_time"`
  4080. Signtype interface{} `json:"signtype"`
  4081. WarnMsg interface{} `json:"warn_msg"`
  4082. }
  4083. type ResultEightFor10188 struct {
  4084. Cainfo string `json:"cainfo"`
  4085. ErrMsg string `json:"err_msg"`
  4086. InfRefmsgid string `json:"inf_refmsgid"`
  4087. Infcode string `json:"infcode"`
  4088. Output struct {
  4089. Stmtinfo struct {
  4090. SetlOptins string `json:"setl_optins"`
  4091. StmtRslt string `json:"stmt_rslt"`
  4092. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4093. } `json:"stmtinfo"`
  4094. } `json:"output"`
  4095. RefmsgTime string `json:"refmsg_time"`
  4096. RespondTime string `json:"respond_time"`
  4097. Signtype interface{} `json:"signtype"`
  4098. WarnMsg interface{} `json:"warn_msg"`
  4099. }
  4100. type ResultNine struct {
  4101. Cainfo string `json:"cainfo"`
  4102. ErrMsg string `json:"err_msg"`
  4103. InfRefmsgid string `json:"inf_refmsgid"`
  4104. Infcode int64 `json:"infcode"`
  4105. Output struct {
  4106. FileQuryNo string `json:"file_qury_no"`
  4107. } `json:"output"`
  4108. RefmsgTime string `json:"refmsg_time"`
  4109. RespondTime string `json:"respond_time"`
  4110. Signtype interface{} `json:"signtype"`
  4111. WarnMsg interface{} `json:"warn_msg"`
  4112. }
  4113. type ResultTen struct {
  4114. Cainfo string `json:"cainfo"`
  4115. ErrMsg string `json:"err_msg"`
  4116. InfRefmsgid string `json:"inf_refmsgid"`
  4117. Infcode int64 `json:"infcode"`
  4118. Output struct {
  4119. DldEndtime string `json:"dld_endtime"`
  4120. FileQuryNo string `json:"file_qury_no"`
  4121. Filename string `json:"filename"`
  4122. } `json:"output"`
  4123. RefmsgTime string `json:"refmsg_time"`
  4124. RespondTime string `json:"respond_time"`
  4125. Signtype interface{} `json:"signtype"`
  4126. WarnMsg interface{} `json:"warn_msg"`
  4127. }
  4128. //type Autogenerated struct {
  4129. // Output struct {
  4130. // Setlinfo struct {
  4131. // SetlTime string `json:"setl_time"`
  4132. // CvlservPay float64 `json:"cvlserv_pay"`
  4133. // Year string `json:"year"`
  4134. // MedType string `json:"med_type"`
  4135. // PsnPay float64 `json:"psn_pay"`
  4136. // OpterID string `json:"opter_id"`
  4137. // Begndate string `json:"begndate"`
  4138. // FlxempeFlag string `json:"flxempe_flag"`
  4139. // HifmiPay float64 `json:"hifmi_pay"`
  4140. // PsnNo string `json:"psn_no"`
  4141. // ActPayDedc float64 `json:"act_pay_dedc"`
  4142. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4143. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4144. // ClrWay string `json:"clr_way"`
  4145. // OthPay float64 `json:"oth_pay"`
  4146. // Gend string `json:"gend"`
  4147. // MdtrtID string `json:"mdtrt_id"`
  4148. // AcctPay float64 `json:"acct_pay"`
  4149. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4150. // Insutype string `json:"insutype"`
  4151. // Invono interface{} `json:"invono"`
  4152. // Enddate string `json:"enddate"`
  4153. // CashPayamt float64 `json:"cash_payamt"`
  4154. // PsnType string `json:"psn_type"`
  4155. // FixmedinsName string `json:"fixmedins_name"`
  4156. // HifpPay float64 `json:"hifp_pay"`
  4157. // NewFlag interface{} `json:"new_flag"`
  4158. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4159. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4160. // PayLoc string `json:"pay_loc"`
  4161. // ClrType string `json:"clr_type"`
  4162. // RefdSetlFlag string `json:"refd_setl_flag"`
  4163. // CvlservFlag string `json:"cvlserv_flag"`
  4164. // EmpName string `json:"emp_name"`
  4165. // Brdy string `json:"brdy"`
  4166. // Naty string `json:"naty"`
  4167. // Certno string `json:"certno"`
  4168. // DiseCode string `json:"dise_code"`
  4169. // FixmedinsCode string `json:"fixmedins_code"`
  4170. // DedcHospLv string `json:"dedc_hosp_lv"`
  4171. // OpterName string `json:"opter_name"`
  4172. // Balc float64 `json:"balc"`
  4173. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4174. // PsnCertType string `json:"psn_cert_type"`
  4175. // HifobPay float64 `json:"hifob_pay"`
  4176. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4177. // HifesPay float64 `json:"hifes_pay"`
  4178. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4179. // OptTime string `json:"opt_time"`
  4180. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4181. // SetlID string `json:"setl_id"`
  4182. // MafPay float64 `json:"maf_pay"`
  4183. // PsnName string `json:"psn_name"`
  4184. // InsuOptins interface{} `json:"insu_optins"`
  4185. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4186. // ClrOptins string `json:"clr_optins"`
  4187. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4188. // DiseName string `json:"dise_name"`
  4189. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4190. // Age float64 `json:"age"`
  4191. // DtrtCertType string `json:"dtrt_cert_type"`
  4192. // HospLv string `json:"hosp_lv"`
  4193. // } `json:"setlinfo"`
  4194. // Setldetail []struct {
  4195. // FundPayType string `json:"fund_pay_type"`
  4196. // FundPayamt float64 `json:"fund_payamt"`
  4197. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4198. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4199. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4200. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4201. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4202. // } `json:"setldetail"`
  4203. // } `json:"output"`
  4204. // Infcode int `json:"infcode"`
  4205. // WarnMsg interface{} `json:"warn_msg"`
  4206. // Cainfo interface{} `json:"cainfo"`
  4207. // ErrMsg interface{} `json:"err_msg"`
  4208. // RefmsgTime string `json:"refmsg_time"`
  4209. // Signtype interface{} `json:"signtype"`
  4210. // RespondTime string `json:"respond_time"`
  4211. // InfRefmsgid string `json:"inf_refmsgid"`
  4212. //}
  4213. type ResultEleven struct {
  4214. Cainfo string `json:"cainfo"`
  4215. ErrMsg string `json:"err_msg"`
  4216. InfRefmsgid string `json:"inf_refmsgid"`
  4217. Infcode int64 `json:"infcode"`
  4218. Output struct {
  4219. Setlinfo struct {
  4220. SetlTime string `json:"setl_time"`
  4221. CvlservPay float64 `json:"cvlserv_pay"`
  4222. Year string `json:"year"`
  4223. MedType string `json:"med_type"`
  4224. PsnPay float64 `json:"psn_pay"`
  4225. OpterID string `json:"opter_id"`
  4226. Begndate string `json:"begndate"`
  4227. FlxempeFlag string `json:"flxempe_flag"`
  4228. HifmiPay float64 `json:"hifmi_pay"`
  4229. PsnNo string `json:"psn_no"`
  4230. ActPayDedc float64 `json:"act_pay_dedc"`
  4231. MedinsSetlID interface{} `json:"medins_setl_id"`
  4232. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4233. ClrWay string `json:"clr_way"`
  4234. OthPay float64 `json:"oth_pay"`
  4235. Gend string `json:"gend"`
  4236. MdtrtID string `json:"mdtrt_id"`
  4237. AcctPay float64 `json:"acct_pay"`
  4238. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4239. Insutype string `json:"insutype"`
  4240. Invono interface{} `json:"invono"`
  4241. Enddate string `json:"enddate"`
  4242. CashPayamt float64 `json:"cash_payamt"`
  4243. PsnType string `json:"psn_type"`
  4244. FixmedinsName string `json:"fixmedins_name"`
  4245. HifpPay float64 `json:"hifp_pay"`
  4246. NewFlag interface{} `json:"new_flag"`
  4247. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4248. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4249. PayLoc string `json:"pay_loc"`
  4250. ClrType string `json:"clr_type"`
  4251. RefdSetlFlag string `json:"refd_setl_flag"`
  4252. CvlservFlag string `json:"cvlserv_flag"`
  4253. EmpName string `json:"emp_name"`
  4254. Brdy string `json:"brdy"`
  4255. Naty string `json:"naty"`
  4256. Certno string `json:"certno"`
  4257. DiseCode string `json:"dise_code"`
  4258. FixmedinsCode string `json:"fixmedins_code"`
  4259. DedcHospLv string `json:"dedc_hosp_lv"`
  4260. OpterName string `json:"opter_name"`
  4261. Balc float64 `json:"balc"`
  4262. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4263. PsnCertType string `json:"psn_cert_type"`
  4264. HifobPay float64 `json:"hifob_pay"`
  4265. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4266. HifesPay float64 `json:"hifes_pay"`
  4267. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4268. OptTime string `json:"opt_time"`
  4269. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4270. SetlID string `json:"setl_id"`
  4271. MafPay float64 `json:"maf_pay"`
  4272. PsnName string `json:"psn_name"`
  4273. InsuOptins interface{} `json:"insu_optins"`
  4274. PrefFundPay interface{} `json:"pref_fund_pay"`
  4275. ClrOptins string `json:"clr_optins"`
  4276. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4277. DiseName string `json:"dise_name"`
  4278. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4279. Age float64 `json:"age"`
  4280. DtrtCertType string `json:"dtrt_cert_type"`
  4281. HospLv string `json:"hosp_lv"`
  4282. } `json:"setlinfo"`
  4283. } `json:"output"`
  4284. RefmsgTime string `json:"refmsg_time"`
  4285. RespondTime string `json:"respond_time"`
  4286. Signtype interface{} `json:"signtype"`
  4287. WarnMsg interface{} `json:"warn_msg"`
  4288. }
  4289. type ResultEleven10265 struct {
  4290. Cainfo string `json:"cainfo"`
  4291. ErrMsg string `json:"err_msg"`
  4292. InfRefmsgid string `json:"inf_refmsgid"`
  4293. Infcode string `json:"infcode"`
  4294. Output struct {
  4295. Setlinfo struct {
  4296. SetlTime string `json:"setl_time"`
  4297. CvlservPay float64 `json:"cvlserv_pay"`
  4298. Year string `json:"year"`
  4299. MedType string `json:"med_type"`
  4300. PsnPay float64 `json:"psn_pay"`
  4301. OpterID string `json:"opter_id"`
  4302. Begndate string `json:"begndate"`
  4303. FlxempeFlag string `json:"flxempe_flag"`
  4304. HifmiPay float64 `json:"hifmi_pay"`
  4305. PsnNo string `json:"psn_no"`
  4306. ActPayDedc float64 `json:"act_pay_dedc"`
  4307. MedinsSetlID interface{} `json:"medins_setl_id"`
  4308. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4309. ClrWay string `json:"clr_way"`
  4310. OthPay float64 `json:"oth_pay"`
  4311. Gend string `json:"gend"`
  4312. MdtrtID string `json:"mdtrt_id"`
  4313. AcctPay float64 `json:"acct_pay"`
  4314. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4315. Insutype string `json:"insutype"`
  4316. Invono interface{} `json:"invono"`
  4317. Enddate string `json:"enddate"`
  4318. CashPayamt float64 `json:"cash_payamt"`
  4319. PsnType string `json:"psn_type"`
  4320. FixmedinsName string `json:"fixmedins_name"`
  4321. HifpPay float64 `json:"hifp_pay"`
  4322. NewFlag interface{} `json:"new_flag"`
  4323. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4324. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4325. PayLoc string `json:"pay_loc"`
  4326. ClrType string `json:"clr_type"`
  4327. RefdSetlFlag string `json:"refd_setl_flag"`
  4328. CvlservFlag string `json:"cvlserv_flag"`
  4329. EmpName string `json:"emp_name"`
  4330. Brdy string `json:"brdy"`
  4331. Naty string `json:"naty"`
  4332. Certno string `json:"certno"`
  4333. DiseCode string `json:"dise_code"`
  4334. FixmedinsCode string `json:"fixmedins_code"`
  4335. DedcHospLv string `json:"dedc_hosp_lv"`
  4336. OpterName string `json:"opter_name"`
  4337. Balc float64 `json:"balc"`
  4338. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4339. PsnCertType string `json:"psn_cert_type"`
  4340. HifobPay float64 `json:"hifob_pay"`
  4341. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4342. HifesPay float64 `json:"hifes_pay"`
  4343. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4344. OptTime string `json:"opt_time"`
  4345. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4346. SetlID string `json:"setl_id"`
  4347. MafPay float64 `json:"maf_pay"`
  4348. PsnName string `json:"psn_name"`
  4349. InsuOptins interface{} `json:"insu_optins"`
  4350. PrefFundPay interface{} `json:"pref_fund_pay"`
  4351. ClrOptins string `json:"clr_optins"`
  4352. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4353. DiseName string `json:"dise_name"`
  4354. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4355. Age float64 `json:"age"`
  4356. DtrtCertType string `json:"dtrt_cert_type"`
  4357. HospLv string `json:"hosp_lv"`
  4358. } `json:"setlinfo"`
  4359. } `json:"output"`
  4360. RefmsgTime string `json:"refmsg_time"`
  4361. RespondTime string `json:"respond_time"`
  4362. Signtype interface{} `json:"signtype"`
  4363. WarnMsg interface{} `json:"warn_msg"`
  4364. }
  4365. type ResultTwelve struct {
  4366. Cainfo string `json:"cainfo"`
  4367. ErrMsg string `json:"err_msg"`
  4368. InfRefmsgid string `json:"inf_refmsgid"`
  4369. Infcode int64 `json:"infcode"`
  4370. Output struct {
  4371. MdtrtId string `json:"mdtrt_id"`
  4372. ChrgBchno string `json:"chrg_bchno"`
  4373. PsnNo string `json:"psn_no"`
  4374. } `json:"output"`
  4375. RefmsgTime string `json:"refmsg_time"`
  4376. RespondTime string `json:"respond_time"`
  4377. Signtype interface{} `json:"signtype"`
  4378. WarnMsg interface{} `json:"warn_msg"`
  4379. }
  4380. type ResultThirteen struct {
  4381. ErrMsg string `json:"err_msg"`
  4382. InfRefmsgid string `json:"inf_refmsgid"`
  4383. Infcode int64 `json:"infcode"`
  4384. Output struct {
  4385. Result struct {
  4386. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4387. } `json:"result"`
  4388. } `json:"output"`
  4389. RefmsgTime string `json:"refmsg_time"`
  4390. RespondTime string `json:"respond_time"`
  4391. Signtype interface{} `json:"signtype"`
  4392. WarnInfo interface{} `json:"warn_info"`
  4393. }
  4394. type ResultThirteen10265 struct {
  4395. ErrMsg string `json:"err_msg"`
  4396. InfRefmsgid string `json:"inf_refmsgid"`
  4397. Infcode string `json:"infcode"`
  4398. Output struct {
  4399. Result struct {
  4400. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4401. } `json:"result"`
  4402. } `json:"output"`
  4403. RefmsgTime string `json:"refmsg_time"`
  4404. RespondTime string `json:"respond_time"`
  4405. Signtype interface{} `json:"signtype"`
  4406. WarnInfo interface{} `json:"warn_info"`
  4407. }
  4408. type ResultFourteen struct {
  4409. ErrMsg string `json:"err_msg"`
  4410. InfRefmsgid string `json:"inf_refmsgid"`
  4411. Infcode int64 `json:"infcode"`
  4412. Output struct {
  4413. } `json:"output"`
  4414. RefmsgTime string `json:"refmsg_time"`
  4415. RespondTime string `json:"respond_time"`
  4416. Signtype interface{} `json:"signtype"`
  4417. WarnInfo interface{} `json:"warn_info"`
  4418. }
  4419. type ResultFourteen10265 struct {
  4420. ErrMsg string `json:"err_msg"`
  4421. InfRefmsgid string `json:"inf_refmsgid"`
  4422. Infcode string `json:"infcode"`
  4423. Output struct {
  4424. } `json:"output"`
  4425. RefmsgTime string `json:"refmsg_time"`
  4426. RespondTime string `json:"respond_time"`
  4427. Signtype interface{} `json:"signtype"`
  4428. WarnInfo interface{} `json:"warn_info"`
  4429. }
  4430. type ResultSixteen struct {
  4431. Cainfo string `json:"cainfo"`
  4432. ErrMsg string `json:"err_msg"`
  4433. InfRefmsgid string `json:"inf_refmsgid"`
  4434. Infcode int64 `json:"infcode"`
  4435. Output struct {
  4436. Setldetail []interface{} `json:"setldetail"`
  4437. Setlinfo struct {
  4438. MdtrtID string `json:"mdtrt_id"`
  4439. SetlID string `json:"setl_id"`
  4440. ClrOptins string `json:"clr_optins"`
  4441. SetlTime string `json:"setl_time"`
  4442. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4443. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4444. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4445. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4446. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4447. ActPayDedc float64 `json:"act_pay_dedc"`
  4448. HifpPay float64 `json:"hifp_pay"`
  4449. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4450. Lfpay float64 `json:"selfpay"`
  4451. CvlservPay float64 `json:"cvlserv_pay"`
  4452. HifesPay float64 `json:"hifes_pay"`
  4453. HifmiPay float64 `json:"hifmi_pay"`
  4454. HifobPay float64 `json:"hifob_pay"`
  4455. MafPay float64 `json:"maf_pay"`
  4456. OthPay float64 `json:"oth_pay"`
  4457. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4458. PsnPartAmt float64 `json:"psn_part_amt"`
  4459. AcctPay float64 `json:"acct_pay"`
  4460. Balc float64 `json:"balc"`
  4461. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4462. HospPartAmt float64 `json:"hosp_part_amt"`
  4463. MedinsSetlID string `json:"medins_setl_id"`
  4464. PdnCashPay string `json:"pdn_cash_pay"`
  4465. } `json:"setlinfo"`
  4466. } `json:"output"`
  4467. RefmsgTime string `json:"refmsg_time"`
  4468. RespondTime string `json:"respond_time"`
  4469. Signtype interface{} `json:"signtype"`
  4470. WarnMsg interface{} `json:"warn_msg"`
  4471. }
  4472. type ResultSixteen10265 struct {
  4473. Cainfo string `json:"cainfo"`
  4474. ErrMsg string `json:"err_msg"`
  4475. InfRefmsgid string `json:"inf_refmsgid"`
  4476. Infcode string `json:"infcode"`
  4477. Output struct {
  4478. Setldetail []interface{} `json:"setldetail"`
  4479. Setlinfo struct {
  4480. MdtrtID string `json:"mdtrt_id"`
  4481. SetlID string `json:"setl_id"`
  4482. ClrOptins string `json:"clr_optins"`
  4483. SetlTime string `json:"setl_time"`
  4484. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4485. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4486. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4487. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4488. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4489. ActPayDedc float64 `json:"act_pay_dedc"`
  4490. HifpPay float64 `json:"hifp_pay"`
  4491. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4492. Lfpay float64 `json:"selfpay"`
  4493. CvlservPay float64 `json:"cvlserv_pay"`
  4494. HifesPay float64 `json:"hifes_pay"`
  4495. HifmiPay float64 `json:"hifmi_pay"`
  4496. HifobPay float64 `json:"hifob_pay"`
  4497. MafPay float64 `json:"maf_pay"`
  4498. OthPay float64 `json:"oth_pay"`
  4499. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4500. PsnPartAmt float64 `json:"psn_part_amt"`
  4501. AcctPay float64 `json:"acct_pay"`
  4502. Balc float64 `json:"balc"`
  4503. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4504. HospPartAmt float64 `json:"hosp_part_amt"`
  4505. MedinsSetlID string `json:"medins_setl_id"`
  4506. PdnCashPay string `json:"pdn_cash_pay"`
  4507. } `json:"setlinfo"`
  4508. } `json:"output"`
  4509. RefmsgTime string `json:"refmsg_time"`
  4510. RespondTime string `json:"respond_time"`
  4511. Signtype interface{} `json:"signtype"`
  4512. WarnMsg interface{} `json:"warn_msg"`
  4513. }
  4514. type ResultSeventeen struct {
  4515. ErrMsg string `json:"err_msg"`
  4516. InfRefmsgid string `json:"inf_refmsgid"`
  4517. Infcode int64 `json:"infcode"`
  4518. Output struct {
  4519. SetlListId string `json:"setl_list_id"`
  4520. } `json:"output"`
  4521. RefmsgTime string `json:"refmsg_time"`
  4522. RespondTime string `json:"respond_time"`
  4523. Signtype string `json:"signtype"`
  4524. WarnInfo string `json:"warn_info"`
  4525. }
  4526. type ResultSeventeenOther struct {
  4527. ErrMsg string `json:"err_msg"`
  4528. InfRefmsgid string `json:"inf_refmsgid"`
  4529. Infcode string `json:"infcode"`
  4530. Output struct {
  4531. SetlListId string `json:"setl_list_id"`
  4532. } `json:"output"`
  4533. RefmsgTime string `json:"refmsg_time"`
  4534. RespondTime string `json:"respond_time"`
  4535. Signtype string `json:"signtype"`
  4536. WarnInfo string `json:"warn_info"`
  4537. }
  4538. type Result90991 struct {
  4539. ErrMsg string `json:"err_msg"`
  4540. InfRefmsgid string `json:"inf_refmsgid"`
  4541. Infcode int64 `json:"infcode"`
  4542. Output struct {
  4543. Result struct {
  4544. PsnNo string `json:"psn_no"`
  4545. CardStat string `json:"card_stat"`
  4546. Certno string `json:"certno"`
  4547. PsnName string `json:"psn_name"`
  4548. CheckStat string `json:"check_stat"`
  4549. SscnoCheckStat string `json:"sscno_check_stat"`
  4550. } `json:"result"`
  4551. } `json:"output"`
  4552. RefmsgTime string `json:"refmsg_time"`
  4553. RespondTime string `json:"respond_time"`
  4554. Signtype interface{} `json:"signtype"`
  4555. WarnInfo interface{} `json:"warn_info"`
  4556. }
  4557. type Result90100 struct {
  4558. ErrMsg string `json:"err_msg"`
  4559. InfRefmsgid string `json:"inf_refmsgid"`
  4560. Infcode int64 `json:"infcode"`
  4561. Output struct {
  4562. PoolareaNo string `json:"poolarea_no"`
  4563. PoolareaNoName string `json:"poolarea_no_name"`
  4564. Insutype string `json:"insutype"`
  4565. InsutypeName string `json:"insutype_name"`
  4566. ClctType string `json:"clct_type"`
  4567. ClctTypeName string `json:"clct_type_name"`
  4568. ClctFlag string `json:"clct_flag"`
  4569. ClctFlagName string `json:"clct_flag_name"`
  4570. AccrymBegn string `json:"accrym_begn"`
  4571. AccrymEnd string `json:"accrym_end"`
  4572. ClctTime string `json:"clct_time"`
  4573. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4574. } `json:"output"`
  4575. RefmsgTime string `json:"refmsg_time"`
  4576. RespondTime string `json:"respond_time"`
  4577. Signtype interface{} `json:"signtype"`
  4578. WarnInfo interface{} `json:"warn_info"`
  4579. }
  4580. type Custom struct {
  4581. DetItemFeeSumamt string
  4582. Cut string
  4583. FeedetlSn string
  4584. Price string
  4585. MedListCodg string
  4586. Type int64
  4587. AdviceId int64
  4588. ProjectId int64
  4589. ItemId int64
  4590. }
  4591. type Result5301 struct {
  4592. ErrMsg string `json:"err_msg"`
  4593. InfRefmsgid string `json:"inf_refmsgid"`
  4594. Infcode int64 `json:"infcode"`
  4595. Output struct {
  4596. Result []struct {
  4597. OpspDiseCode string `json:"opsp_dise_code"`
  4598. OpspDiseName string `json:"opsp_dise_name"`
  4599. Begndate string `json:"begndate"`
  4600. Enddate string `json:"enddate"`
  4601. } `json:"feedetail"`
  4602. } `json:"output"`
  4603. RefmsgTime string `json:"refmsg_time"`
  4604. RespondTime string `json:"respond_time"`
  4605. Signtype interface{} `json:"signtype"`
  4606. WarnInfo interface{} `json:"warn_info"`
  4607. }
  4608. type Result5301For10265 struct {
  4609. ErrMsg string `json:"err_msg"`
  4610. InfRefmsgid string `json:"inf_refmsgid"`
  4611. Infcode string `json:"infcode"`
  4612. Output struct {
  4613. Result []struct {
  4614. OpspDiseCode string `json:"opsp_dise_code"`
  4615. OpspDiseName string `json:"opsp_dise_name"`
  4616. Begndate string `json:"begndate"`
  4617. Enddate string `json:"enddate"`
  4618. } `json:"feedetail"`
  4619. } `json:"output"`
  4620. RefmsgTime string `json:"refmsg_time"`
  4621. RespondTime string `json:"respond_time"`
  4622. Signtype interface{} `json:"signtype"`
  4623. WarnInfo interface{} `json:"warn_info"`
  4624. }
  4625. //获取个人信息----挂号-----上传就诊信息
  4626. func (c *HisApiController) GetRegisterInfo() {
  4627. id, _ := c.GetInt64("id")
  4628. record_time := c.GetString("record_time")
  4629. settlementValue, _ := c.GetInt64("settlement_value")
  4630. medical_insurance_card := c.GetString("medical_insurance_card")
  4631. name := c.GetString("name")
  4632. id_card_type, _ := c.GetInt64("id_card_type")
  4633. certificates, _ := c.GetInt64("certificates")
  4634. medical_care, _ := c.GetInt64("medical_care")
  4635. birthday := c.GetString("birthday")
  4636. id_card := c.GetString("id_card")
  4637. register_type, _ := c.GetInt64("register")
  4638. doctor, _ := c.GetInt64("doctor")
  4639. department, _ := c.GetInt64("department")
  4640. gender, _ := c.GetInt64("sex")
  4641. registration_fee, _ := c.GetFloat("registration_fee")
  4642. medical_expenses, _ := c.GetFloat("medical_expenses")
  4643. social_type, _ := c.GetInt64("social_type")
  4644. med_type := c.GetString("social_type")
  4645. admin_user_id, _ := c.GetInt64("admin_user_id")
  4646. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4647. timeLayout := "2006-01-02"
  4648. loc, _ := time.LoadLocation("Local")
  4649. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4650. birthUnix := birthdays.Unix()
  4651. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4652. if err != nil {
  4653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4654. return
  4655. }
  4656. recordDateTime := theTime.Unix()
  4657. adminInfo := c.GetAdminUserInfo()
  4658. var patient service.Patients
  4659. if id == 0 {
  4660. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4661. } else {
  4662. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4663. }
  4664. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4665. if patientPrescription.ID == 0 {
  4666. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4667. }
  4668. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4669. if patient.ID == 0 {
  4670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4671. return
  4672. }
  4673. if len(patient.IdCardNo) == 0 {
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4675. return
  4676. }
  4677. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4678. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4679. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4680. //就诊结算未完成,不能进行二次挂号
  4681. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4682. if len(his) >= 1 {
  4683. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4684. if len(his) >= 1 && order.ID == 0 {
  4685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4686. return
  4687. }
  4688. }
  4689. //var register_log string
  4690. if config.IsOpen == 1 {
  4691. var res ResultTwo
  4692. var res10265 ResultTwo10265
  4693. var PsnNo string
  4694. var PsnCertType string
  4695. var Certno string
  4696. var PsnName string
  4697. var Gend string
  4698. var Naty string
  4699. var Brdy string
  4700. var Age float64
  4701. var infoStr string
  4702. var idetinfoStr string
  4703. var infocode int64
  4704. var verify_number string
  4705. fmt.Println(verify_number)
  4706. if miConfig.MdtrtareaAdmvs == "421300" {
  4707. psn_info, _ := service.GetPsnByPatientId(id)
  4708. PsnNo = psn_info.PsnNo
  4709. PsnCertType = psn_info.PsnCertType
  4710. Certno = psn_info.Certno
  4711. PsnName = psn_info.PsnName
  4712. Gend = psn_info.Gend
  4713. Naty = psn_info.Naty
  4714. Brdy = psn_info.Brdy
  4715. Age = psn_info.Age
  4716. infoStr = psn_info.Insuinfo
  4717. idetinfoStr = psn_info.Idetinfo
  4718. infocode = 0
  4719. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4720. psn_info, _ := service.GetPsnByPatientId(id)
  4721. PsnNo = psn_info.PsnNo
  4722. PsnCertType = psn_info.PsnCertType
  4723. Certno = psn_info.Certno
  4724. PsnName = psn_info.PsnName
  4725. Gend = psn_info.Gend
  4726. Naty = psn_info.Naty
  4727. Brdy = psn_info.Brdy
  4728. Age = psn_info.Age
  4729. infoStr = psn_info.Insuinfo
  4730. idetinfoStr = psn_info.Idetinfo
  4731. infocode = 0
  4732. verify_number = psn_info.VerifyNumber
  4733. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4734. if id_card_type == 1 {
  4735. psn_info, _ := service.GetPsnByPatientId(id)
  4736. PsnNo = psn_info.PsnNo
  4737. PsnCertType = psn_info.PsnCertType
  4738. Certno = psn_info.Certno
  4739. PsnName = psn_info.PsnName
  4740. Gend = psn_info.Gend
  4741. Naty = psn_info.Naty
  4742. Brdy = psn_info.Brdy
  4743. Age = psn_info.Age
  4744. infoStr = psn_info.Insuinfo
  4745. idetinfoStr = psn_info.Idetinfo
  4746. infocode = 0
  4747. verify_number = psn_info.VerifyNumber
  4748. } else if id_card_type == 2 {
  4749. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  4750. fmt.Println(errMsgLog)
  4751. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4752. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4753. utils.ErrorLog("解析失败:%v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. PsnNo = res.Output.Baseinfo.PsnNo
  4758. PsnCertType = res.Output.Baseinfo.PsnCertType
  4759. Certno = res.Output.Baseinfo.Certno
  4760. PsnName = res.Output.Baseinfo.PsnName
  4761. Gend = res.Output.Baseinfo.Gend
  4762. Naty = res.Output.Baseinfo.Naty
  4763. Brdy = res.Output.Baseinfo.Brdy
  4764. Age = res.Output.Baseinfo.Age
  4765. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4766. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4767. infoStr = string(Iinfos)
  4768. idetinfoStr = string(Idetinfos)
  4769. infocode = res.Infcode
  4770. }
  4771. } else {
  4772. var result string
  4773. var requestLog string
  4774. if miConfig.UserOrgId == 10138 {
  4775. if id_card_type == 4 {
  4776. psn_info, _ := service.GetPsnByPatientId(id)
  4777. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  4778. } else {
  4779. 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, record_time)
  4780. }
  4781. } else {
  4782. 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)
  4783. }
  4784. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4785. if miConfig.Code == "H15049901371" {
  4786. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4787. utils.ErrorLog("解析失败:%v", err)
  4788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4789. return
  4790. }
  4791. res.ErrMsg = res10265.ErrMsg
  4792. res.Output = res10265.Output
  4793. res.InfRefmsgid = res10265.InfRefmsgid
  4794. } else {
  4795. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4796. utils.ErrorLog("解析失败:%v", err)
  4797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4798. return
  4799. }
  4800. }
  4801. PsnNo = res.Output.Baseinfo.PsnNo
  4802. PsnCertType = res.Output.Baseinfo.PsnCertType
  4803. Certno = res.Output.Baseinfo.Certno
  4804. PsnName = res.Output.Baseinfo.PsnName
  4805. Gend = res.Output.Baseinfo.Gend
  4806. Naty = res.Output.Baseinfo.Naty
  4807. Brdy = res.Output.Baseinfo.Brdy
  4808. Age = res.Output.Baseinfo.Age
  4809. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4810. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4811. infoStr = string(Iinfos)
  4812. idetinfoStr = string(Idetinfos)
  4813. if miConfig.Code == "H15049901371" {
  4814. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4815. } else {
  4816. infocode = res.Infcode
  4817. }
  4818. }
  4819. if infocode == 0 {
  4820. his := models.VMHisPatient{
  4821. Name: name,
  4822. Gender: gender,
  4823. Birthday: birthUnix,
  4824. MedicalTreatmentType: medical_care,
  4825. IdType: certificates,
  4826. IdCardNo: id_card,
  4827. BalanceAccountsType: settlementValue,
  4828. SocialType: social_type,
  4829. MedicalInsuranceNumber: medical_insurance_card,
  4830. RegisterType: register_type,
  4831. RegisterCost: registration_fee,
  4832. TreatmentCost: medical_expenses,
  4833. Status: 1,
  4834. Ctime: time.Now().Unix(),
  4835. Mtime: time.Now().Unix(),
  4836. PsnNo: PsnNo,
  4837. PsnCertType: PsnCertType,
  4838. Certno: Certno,
  4839. PsnName: PsnName,
  4840. Gend: Gend,
  4841. Naty: Naty,
  4842. Brdy: Brdy,
  4843. Age: Age,
  4844. Iinfo: infoStr,
  4845. Idetinfo: idetinfoStr,
  4846. PatientId: patient.ID,
  4847. RecordDate: theTime.Unix(),
  4848. UserOrgId: adminInfo.CurrentOrgId,
  4849. AdminUserId: admin_user_id,
  4850. IsReturn: 1,
  4851. IdCardType: id_card_type,
  4852. Doctor: doctor,
  4853. Departments: department,
  4854. }
  4855. timestamp := time.Now().Unix()
  4856. tempTime := time.Unix(timestamp, 0)
  4857. timeFormat := tempTime.Format("20060102150405")
  4858. chrgBchno := rand.Intn(100000) + 10000
  4859. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4860. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4861. department, _ := service.GetDepartMentDetail(department)
  4862. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  4863. IdCardNo := ""
  4864. if id_card_type == 1 {
  4865. // IdCardNo = medical_insurance_card
  4866. IdCardNo = patient.IdCardNo
  4867. } else {
  4868. IdCardNo = patient.IdCardNo
  4869. }
  4870. var rf []*ResultFive
  4871. json.Unmarshal([]byte(his.Iinfo), &rf)
  4872. var insutypes []*ResultFive
  4873. var insutype string
  4874. var insuplc_admdvs_temp string
  4875. var is390 int = 0
  4876. var is310 int = 0
  4877. for _, item := range rf {
  4878. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4879. insutypes = append(insutypes, item)
  4880. }
  4881. }
  4882. if len(insutypes) == 1 {
  4883. insutype = insutypes[0].Insutype
  4884. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4885. } else {
  4886. for _, i := range insutypes {
  4887. if i.Insutype == "390" {
  4888. is390 = 1
  4889. }
  4890. if i.Insutype == "310" {
  4891. is310 = 1
  4892. }
  4893. }
  4894. }
  4895. if is390 == 1 {
  4896. insutype = "390"
  4897. }
  4898. if is310 == 1 {
  4899. insutype = "310"
  4900. }
  4901. if len(insutypes) == 0 {
  4902. insutype = "310"
  4903. }
  4904. if len(insutypes) == 2 {
  4905. insutype = med_type
  4906. }
  4907. if len(med_type) > 0 {
  4908. insutype = med_type
  4909. }
  4910. //for _, item := range rf {
  4911. // if item.Insutype == insutype {
  4912. // insuplc_admdvs = item.InsuplcAdmdvs
  4913. // }
  4914. //}
  4915. var infocode int64
  4916. var resThree ResultThree
  4917. var resThree10265 ResultThree10265
  4918. if len(insuplc_admdvs) == 0 {
  4919. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4920. } else {
  4921. insuplc_admdvs_temp = insuplc_admdvs
  4922. }
  4923. if miConfig.MdtrtareaAdmvs == "421300" {
  4924. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4925. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4926. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4927. "&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=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  4928. resp, requestErr := http.Get(api)
  4929. if requestErr != nil {
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4931. return
  4932. }
  4933. body, ioErr := ioutil.ReadAll(resp.Body)
  4934. if ioErr != nil {
  4935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. return
  4938. }
  4939. var respJSON map[string]interface{}
  4940. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4943. return
  4944. }
  4945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4946. result, _ := json.Marshal(respJSON)
  4947. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4948. utils.ErrorLog("解析失败:%v", err)
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4950. return
  4951. }
  4952. infocode = resThree.Infcode
  4953. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4954. psn_info, _ := service.GetPsnByPatientId(id)
  4955. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4956. var cert_no string
  4957. if id_card_type == 3 {
  4958. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4959. cert_no = IdCardNo
  4960. } else if id_card_type == 4 {
  4961. cert_no = IdCardNo
  4962. psn_info.VerifyNumber = psn_info.VerifyNumber
  4963. } else {
  4964. bas := strings.Split(psn_info.CardInfo, "|")
  4965. cert_no = bas[2]
  4966. }
  4967. var api string
  4968. if miConfig.MdtrtareaAdmvs == "320921" {
  4969. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4970. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4971. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4972. } else {
  4973. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4974. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4975. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4976. }
  4977. resp, requestErr := http.Get(api)
  4978. if requestErr != nil {
  4979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4980. return
  4981. }
  4982. body, ioErr := ioutil.ReadAll(resp.Body)
  4983. if ioErr != nil {
  4984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4986. return
  4987. }
  4988. var respJSON map[string]interface{}
  4989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4992. return
  4993. }
  4994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4995. result, _ := json.Marshal(respJSON)
  4996. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4997. utils.ErrorLog("解析失败:%v", err)
  4998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4999. return
  5000. }
  5001. resThree.ErrMsg = resThree10265.ErrMsg
  5002. resThree.Output = resThree10265.Output
  5003. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5004. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5005. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5006. psn_info, _ := service.GetPsnByPatientId(id)
  5007. var cert_no string
  5008. if id_card_type == 1 {
  5009. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5010. } else {
  5011. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5012. }
  5013. fmt.Println(cert_no)
  5014. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  5015. saveLog(result, requestLog, "2201", "挂号")
  5016. if miConfig.Code == "H15049901371" {
  5017. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5018. utils.ErrorLog("解析失败:%v", err)
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. return
  5021. }
  5022. resThree.ErrMsg = resThree10265.ErrMsg
  5023. resThree.Output = resThree10265.Output
  5024. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5025. } else {
  5026. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5027. utils.ErrorLog("解析失败:%v", err)
  5028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5029. return
  5030. }
  5031. }
  5032. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5033. } else {
  5034. psn_info, _ := service.GetPsnByPatientId(id)
  5035. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  5036. saveLog(result, requestLog, "2201A", "挂号")
  5037. if miConfig.Code == "H15049901371" {
  5038. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5039. utils.ErrorLog("解析失败:%v", err)
  5040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5041. return
  5042. }
  5043. resThree.ErrMsg = resThree10265.ErrMsg
  5044. resThree.Output = resThree10265.Output
  5045. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5046. } else {
  5047. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5048. utils.ErrorLog("解析失败:%v", err)
  5049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5050. return
  5051. }
  5052. }
  5053. if miConfig.Code == "H15049901371" {
  5054. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5055. } else {
  5056. infocode = resThree.Infcode
  5057. }
  5058. }
  5059. if infocode != 0 {
  5060. adminUser := c.GetAdminUserInfo()
  5061. errlog := &models.HisOrderError{
  5062. UserOrgId: adminUser.CurrentOrgId,
  5063. Ctime: time.Now().Unix(),
  5064. Mtime: time.Now().Unix(),
  5065. ErrMsg: resThree.ErrMsg,
  5066. Status: 1,
  5067. PatientId: id,
  5068. RecordTime: recordDateTime,
  5069. Stage: 2,
  5070. }
  5071. service.CreateErrMsgLog(errlog)
  5072. c.ServeSuccessJSON(map[string]interface{}{
  5073. "failed_code": -10,
  5074. "msg": resThree.ErrMsg,
  5075. })
  5076. return
  5077. }
  5078. his.Number = resThree.Output.Data.MdtrtID
  5079. his.PsnNo = resThree.Output.Data.PsnNo
  5080. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5081. his.IdCardNo = patient.IdCardNo
  5082. his.PhoneNumber = patient.Phone
  5083. his.UserOrgId = adminInfo.CurrentOrgId
  5084. his.Insutype = insutype
  5085. his.Ctime = time.Now().Unix()
  5086. his.Mtime = time.Now().Unix()
  5087. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5088. his.Status = 1
  5089. service.UpdateHisPatientStatus(&his)
  5090. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5091. c.ServeSuccessJSON(map[string]interface{}{
  5092. "his_info": his,
  5093. })
  5094. } else {
  5095. adminUser := c.GetAdminUserInfo()
  5096. errlog := &models.HisOrderError{
  5097. UserOrgId: adminUser.CurrentOrgId,
  5098. Ctime: time.Now().Unix(),
  5099. Mtime: time.Now().Unix(),
  5100. ErrMsg: res.ErrMsg,
  5101. Status: 1,
  5102. PatientId: id,
  5103. RecordTime: recordDateTime,
  5104. Stage: 1,
  5105. }
  5106. service.CreateErrMsgLog(errlog)
  5107. c.ServeSuccessJSON(map[string]interface{}{
  5108. "failed_code": -10,
  5109. "msg": res.ErrMsg,
  5110. })
  5111. return
  5112. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5113. }
  5114. }
  5115. }
  5116. //上传明细----预结算----确认订单
  5117. func (c *HisApiController) GetUploadInfo() {
  5118. id, _ := c.GetInt64("id")
  5119. record_time := c.GetString("record_time")
  5120. his_patient_id, _ := c.GetInt64("his_patient_id")
  5121. order_id, _ := c.GetInt64("order_id")
  5122. pay_way, _ := c.GetInt64("pay_way")
  5123. pay_price, _ := c.GetFloat("pay_price")
  5124. pay_card_no := c.GetString("pay_card_no")
  5125. token := c.GetString("token")
  5126. discount_price, _ := c.GetFloat("discount_price")
  5127. preferential_price, _ := c.GetFloat("preferential_price")
  5128. reality_price, _ := c.GetFloat("reality_price")
  5129. found_price, _ := c.GetFloat("found_price")
  5130. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5131. private_price, _ := c.GetFloat("private_price")
  5132. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5133. admin_user_id, _ := c.GetInt64("admin_user_id")
  5134. fapiao_code := c.GetString("fapiao_code")
  5135. fapiao_number := c.GetString("fapiao_number")
  5136. diagnosis_id := c.GetString("diagnosis")
  5137. sick_type, _ := c.GetInt64("sick_type")
  5138. reg_type, _ := c.GetInt64("p_type")
  5139. begin_time := c.GetString("begin_time")
  5140. id_str := c.GetString("ids")
  5141. ids_arr := strings.Split(id_str, ",")
  5142. timeLayout := "2006-01-02"
  5143. loc, _ := time.LoadLocation("Local")
  5144. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5145. if err != nil {
  5146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5147. return
  5148. }
  5149. recordDateTime := theTime.Unix()
  5150. adminUser := c.GetAdminUserInfo()
  5151. var tempOrder models.HisOrder
  5152. tempOrder, _ = service.GetHisOrderByID(order_id)
  5153. var prescriptions []*models.HisPrescription
  5154. var start_time int64
  5155. var end_time int64
  5156. //押金模块
  5157. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5158. tmp_decimal := c.GetString("tmp_decimal")
  5159. var decimal float64 //本次使用的押金
  5160. var errmsg error
  5161. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5162. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5163. return
  5164. }
  5165. if len(tmp_decimal) > 0 {
  5166. if tmp_decimal[0] == 45 {
  5167. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5168. return
  5169. }
  5170. }
  5171. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5172. fmt.Println(errs)
  5173. decimal = tt
  5174. //if adminUser.CurrentOrgId == 10106{
  5175. // if len(fapiao_code) == 0{
  5176. // fapiao_code = "144072080589"
  5177. // }
  5178. // if len(fapiao_number) == 0{
  5179. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5180. // if order.ID == 0{
  5181. // fapiao_number = "00001520"
  5182. // }else{
  5183. // //fapiao_code = "00001520"
  5184. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5185. // var zero string
  5186. // if fpNumber >= 1000{
  5187. // zero = "0000" + strconv.Itoa(fpNumber)
  5188. // }else if fpNumber >= 10000{
  5189. // zero = "000" + strconv.Itoa(fpNumber)
  5190. // } else if fpNumber >= 100000{
  5191. // zero = "00" + strconv.Itoa(fpNumber)
  5192. // } else if fpNumber >= 1000000{
  5193. // zero = "0" + strconv.Itoa(fpNumber)
  5194. // }else {
  5195. // zero = strconv.Itoa(fpNumber)
  5196. // }
  5197. // fapiao_number = zero
  5198. // }
  5199. // }
  5200. //}
  5201. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5202. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5203. var patientPrescription models.HisPrescriptionInfo
  5204. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5205. if patientPrescription.ID == 0 {
  5206. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5207. }
  5208. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5209. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5210. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5211. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5212. var config []*models.HisXtDiagnoseConfig
  5213. for _, item := range diagnosis_ids {
  5214. id, _ := strconv.ParseInt(item, 10, 64)
  5215. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5216. config = append(config, &diagnosisConfig)
  5217. }
  5218. sickConfig, _ := service.FindSickById(sick_type)
  5219. //if tempOrder.ID == 0 {
  5220. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5221. //}
  5222. if tempOrder.ID == 0 {
  5223. var result string
  5224. var requestLog string
  5225. var res2 ResultSix
  5226. var ressix10265 ResultSix10265
  5227. if miConfig.MdtrtareaAdmvs == "421300" {
  5228. data := make(map[string]interface{})
  5229. client := &http.Client{}
  5230. data["psn_no"] = his.PsnNo
  5231. data["mdtrt_id"] = his.Number
  5232. data["opter"] = roles.UserName
  5233. data["org_name"] = miConfig.OrgName
  5234. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5235. data["doctor_id"] = doctor_info.DoctorNumber
  5236. data["doctor_name"] = doctor_info.UserName
  5237. data["department"] = department.Name
  5238. data["fixmedins_code"] = miConfig.Code
  5239. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5240. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5241. data["secret_key"] = miConfig.SecretKey
  5242. data["sick_code"] = sickConfig.CountryCode
  5243. data["sick_name"] = sickConfig.ClassName
  5244. data["dept"] = strconv.FormatInt(department.ID, 10)
  5245. data["config"] = config
  5246. data["begin_time"] = begin_time
  5247. bytesData, _ := json.Marshal(data)
  5248. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5249. resp, _ := client.Do(req)
  5250. defer resp.Body.Close()
  5251. body, ioErr := ioutil.ReadAll(resp.Body)
  5252. if ioErr != nil {
  5253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5255. return
  5256. }
  5257. var respJSON map[string]interface{}
  5258. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5264. userJSONBytes, _ := json.Marshal(respJSON)
  5265. fmt.Println("log")
  5266. fmt.Println(string(userJSONBytes))
  5267. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5268. utils.ErrorLog("解析失败:%v", err)
  5269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. return
  5271. }
  5272. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5273. //江苏地区国家医保医疗类别
  5274. //职工透析:医疗类别选特殊情况门诊9933
  5275. //居民血透门慢: 医疗类别选门诊慢病1402
  5276. //var med_type string
  5277. //if his.Insutype == "310" {
  5278. // if reg_type == 14 {
  5279. // med_type = "9933"
  5280. // } else if reg_type == 11 {
  5281. // med_type = "11"
  5282. //
  5283. // }
  5284. //} else if his.Insutype == "390" {
  5285. // if reg_type == 14 {
  5286. // med_type = "1402"
  5287. // } else if reg_type == 11 {
  5288. // med_type = "11"
  5289. // }
  5290. //}
  5291. data := make(map[string]interface{})
  5292. client := &http.Client{}
  5293. data["psn_no"] = his.PsnNo
  5294. data["mdtrt_id"] = his.Number
  5295. data["doctor"] = roles.UserName
  5296. data["department"] = department.Name
  5297. data["org_name"] = miConfig.OrgName
  5298. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5299. data["doctor_id"] = doctor_info.DoctorNumber
  5300. data["new_doctor_name"] = doctor_info.UserName
  5301. data["fixmedins_code"] = miConfig.Code
  5302. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5303. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5304. data["secret_key"] = miConfig.SecretKey
  5305. data["sick_code"] = sickConfig.CountryCode
  5306. data["sick_name"] = sickConfig.ClassName
  5307. data["url"] = miConfig.Url
  5308. data["ak"] = miConfig.AccessKey
  5309. data["begin_time"] = begin_time
  5310. data["cainfo"] = miConfig.Cainfo
  5311. data["dept"] = strconv.FormatInt(department.ID, 10)
  5312. data["config"] = config
  5313. bytesData, _ := json.Marshal(data)
  5314. var req *http.Request
  5315. if miConfig.MdtrtareaAdmvs == "320921" {
  5316. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5317. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5318. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5319. } else {
  5320. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5321. }
  5322. resp, _ := client.Do(req)
  5323. defer resp.Body.Close()
  5324. body, ioErr := ioutil.ReadAll(resp.Body)
  5325. if ioErr != nil {
  5326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5328. return
  5329. }
  5330. var respJSON map[string]interface{}
  5331. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. return
  5335. }
  5336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5337. userJSONBytes, _ := json.Marshal(respJSON)
  5338. fmt.Println("log")
  5339. fmt.Println(string(userJSONBytes))
  5340. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5341. utils.ErrorLog("解析失败:%v", err)
  5342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5343. return
  5344. }
  5345. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5346. res2.Output = ressix10265.Output
  5347. res2.ErrMsg = ressix10265.ErrMsg
  5348. res2.Cainfo = ressix10265.Cainfo
  5349. res2.WarnMsg = ressix10265.WarnMsg
  5350. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5351. res2.Infcode = infocode
  5352. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5353. result, requestLog, _ = service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5354. saveLog(result, requestLog, "2203", "上传就诊信息")
  5355. var respJSON2 map[string]interface{}
  5356. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5359. return
  5360. }
  5361. userJSONBytes2, _ := json.Marshal(respJSON2)
  5362. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5363. utils.ErrorLog("解析失败:%v", err)
  5364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5365. return
  5366. }
  5367. } else {
  5368. if miConfig.MdtrtareaAdmvs == "440781" { //
  5369. 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)
  5370. } else {
  5371. if miConfig.Code == "H15049901371" {
  5372. //赤峰地区国家医保医疗类别
  5373. //职工透析:医疗类别选特殊情况门诊990502
  5374. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5375. var med_type string
  5376. if his.Insutype == "390" {
  5377. if reg_type == 14 {
  5378. med_type = "9933"
  5379. } else if reg_type == 11 {
  5380. med_type = "11"
  5381. }
  5382. } else if his.Insutype == "310" {
  5383. if reg_type == 14 {
  5384. med_type = "990502"
  5385. } else if reg_type == 11 {
  5386. med_type = "11"
  5387. }
  5388. }
  5389. 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)
  5390. } else {
  5391. 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)
  5392. }
  5393. }
  5394. saveLog(result, requestLog, "2203", "上传就诊信息")
  5395. var respJSON2 map[string]interface{}
  5396. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5399. return
  5400. }
  5401. userJSONBytes2, _ := json.Marshal(respJSON2)
  5402. if miConfig.Code == "H15049901371" {
  5403. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5404. utils.ErrorLog("解析失败:%v", err)
  5405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5406. return
  5407. }
  5408. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5409. res2.Output = ressix10265.Output
  5410. res2.ErrMsg = ressix10265.ErrMsg
  5411. res2.Cainfo = ressix10265.Cainfo
  5412. res2.WarnMsg = ressix10265.WarnMsg
  5413. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5414. res2.Infcode = infocode
  5415. } else {
  5416. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5417. utils.ErrorLog("解析失败:%v", err)
  5418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5419. return
  5420. }
  5421. }
  5422. }
  5423. if res2.Infcode != 0 {
  5424. adminUser := c.GetAdminUserInfo()
  5425. errlog := &models.HisOrderError{
  5426. UserOrgId: adminUser.CurrentOrgId,
  5427. Ctime: time.Now().Unix(),
  5428. Mtime: time.Now().Unix(),
  5429. ErrMsg: res2.ErrMsg,
  5430. Status: 1,
  5431. PatientId: id,
  5432. RecordTime: recordDateTime,
  5433. Stage: 3,
  5434. }
  5435. service.CreateErrMsgLog(errlog)
  5436. c.ServeSuccessJSON(map[string]interface{}{
  5437. "failed_code": -10,
  5438. "msg": res2.ErrMsg,
  5439. })
  5440. return
  5441. } else {
  5442. his.Diagnosis = diagnosis_id
  5443. his.SickType = sickConfig.ID
  5444. //var p_type int64
  5445. //if reg_type == 1111 || reg_type == 1112 {
  5446. // p_type = 11
  5447. //
  5448. //}
  5449. his.PType = fmt.Sprintf("%d", reg_type)
  5450. service.UpdateHisPatientThree(&his)
  5451. data := make(map[string]interface{})
  5452. if settle_accounts_type == 1 { //日结
  5453. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5454. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5455. } else {
  5456. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5457. }
  5458. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5459. data["pre"] = prescriptions
  5460. } else { //月结
  5461. start_time_str := c.GetString("start_time")
  5462. end_time_str := c.GetString("end_time")
  5463. timeLayout := "2006-01-02"
  5464. loc, _ := time.LoadLocation("Local")
  5465. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5466. if err != nil {
  5467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5468. return
  5469. }
  5470. recordStartTime := theStartTime.Unix()
  5471. start_time = recordStartTime
  5472. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5473. if err != nil {
  5474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5475. return
  5476. }
  5477. recordEndTime := theEndTime.Unix()
  5478. end_time = recordEndTime
  5479. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5480. data["pre"] = prescriptions
  5481. }
  5482. timestamp := time.Now().Unix()
  5483. tempTime := time.Unix(timestamp, 0)
  5484. timeFormat := tempTime.Format("20060102150405")
  5485. chrgBchno := rand.Intn(100000) + 10000
  5486. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5487. strconv.FormatInt(his.PatientId, 10)
  5488. client := &http.Client{}
  5489. data["psn_no"] = his.PsnNo
  5490. data["mdtrt_id"] = his.Number
  5491. data["chrg_bchno"] = chrg_bchno
  5492. data["org_name"] = miConfig.OrgName
  5493. data["doctor"] = doctor_info.UserName
  5494. data["doctor_id"] = doctor_info.DoctorNumber
  5495. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5496. data["fixmedins_code"] = miConfig.Code
  5497. data["opter"] = roles.UserName
  5498. data["dept_code"] = department.Number
  5499. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5500. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5501. data["secret_key"] = miConfig.SecretKey
  5502. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5503. data["url"] = miConfig.Url
  5504. data["ak"] = miConfig.AccessKey
  5505. data["new_doctor_name"] = patientPrescription.Doctor
  5506. data["diag_code"] = sickConfig.CountryCode
  5507. data["cainfo"] = miConfig.Cainfo
  5508. var ids []int64
  5509. for _, item := range prescriptions {
  5510. ids = append(ids, item.ID)
  5511. }
  5512. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5513. if config.IsOpen == 1 { //对接了医保,走医保流程
  5514. var res ResultFour
  5515. var resFour10265 ResultFour10265
  5516. if miConfig.MdtrtareaAdmvs == "421300" {
  5517. bytesData, _ := json.Marshal(data)
  5518. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5519. resp, _ := client.Do(req)
  5520. defer resp.Body.Close()
  5521. body, ioErr := ioutil.ReadAll(resp.Body)
  5522. if ioErr != nil {
  5523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5525. return
  5526. }
  5527. var respJSON map[string]interface{}
  5528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5534. userJSONBytes, _ := json.Marshal(respJSON)
  5535. fmt.Println("log")
  5536. fmt.Println(string(userJSONBytes))
  5537. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5538. utils.ErrorLog("解析失败:%v", err)
  5539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5540. return
  5541. }
  5542. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5543. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5544. if result3101.Infcode == "0" {
  5545. if len(result3101.Output.Result) > 0 {
  5546. var errMsgs []string
  5547. for _, item := range result3101.Output.Result {
  5548. errMsgs = append(errMsgs, item.VolaCont)
  5549. }
  5550. c.ServeSuccessJSON(map[string]interface{}{
  5551. "failed_code": -10,
  5552. "msg": errMsgs,
  5553. })
  5554. return
  5555. }
  5556. }
  5557. bytesData, _ := json.Marshal(data)
  5558. var req *http.Request
  5559. if miConfig.MdtrtareaAdmvs == "320921" {
  5560. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5561. } else {
  5562. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5563. }
  5564. resp, _ := client.Do(req)
  5565. defer resp.Body.Close()
  5566. body, ioErr := ioutil.ReadAll(resp.Body)
  5567. if ioErr != nil {
  5568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5570. return
  5571. }
  5572. var respJSON map[string]interface{}
  5573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5576. return
  5577. }
  5578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5579. userJSONBytes, _ := json.Marshal(respJSON)
  5580. fmt.Println("log")
  5581. fmt.Println(string(userJSONBytes))
  5582. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5583. utils.ErrorLog("解析失败:%v", err)
  5584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5585. return
  5586. }
  5587. res.InfRefmsgid = resFour10265.InfRefmsgid
  5588. res.Output = resFour10265.Output
  5589. res.ErrMsg = resFour10265.ErrMsg
  5590. res.Cainfo = resFour10265.Cainfo
  5591. res.WarnMsg = resFour10265.WarnMsg
  5592. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5593. res.Infcode = infocode
  5594. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5595. result, request_log, _ := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  5596. var dat map[string]interface{}
  5597. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5598. fmt.Println(dat)
  5599. } else {
  5600. fmt.Println(err)
  5601. }
  5602. saveLog(result, request_log, "2204", "上传费用明细")
  5603. userJSONBytes, _ := json.Marshal(dat)
  5604. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5605. utils.ErrorLog("解析失败:%v", err)
  5606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5607. return
  5608. }
  5609. res.InfRefmsgid = resFour10265.InfRefmsgid
  5610. res.Output = resFour10265.Output
  5611. res.ErrMsg = resFour10265.ErrMsg
  5612. res.Cainfo = resFour10265.Cainfo
  5613. res.WarnMsg = resFour10265.WarnMsg
  5614. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5615. res.Infcode = infocode
  5616. } else {
  5617. if miConfig.Code == "H15049901371" {
  5618. 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)
  5619. var dat map[string]interface{}
  5620. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5621. fmt.Println(dat)
  5622. } else {
  5623. fmt.Println(err)
  5624. }
  5625. saveLog(result, request_log, "2204", "上传费用明细")
  5626. userJSONBytes, _ := json.Marshal(dat)
  5627. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5628. utils.ErrorLog("解析失败:%v", err)
  5629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5630. return
  5631. }
  5632. res.InfRefmsgid = resFour10265.InfRefmsgid
  5633. res.Output = resFour10265.Output
  5634. res.ErrMsg = resFour10265.ErrMsg
  5635. res.Cainfo = resFour10265.Cainfo
  5636. res.WarnMsg = resFour10265.WarnMsg
  5637. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5638. res.Infcode = infocode
  5639. } else {
  5640. 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)
  5641. var dat map[string]interface{}
  5642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5643. fmt.Println(dat)
  5644. } else {
  5645. fmt.Println(err)
  5646. }
  5647. saveLog(result, request_log, "2204", "上传费用明细")
  5648. userJSONBytes, _ := json.Marshal(dat)
  5649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5650. utils.ErrorLog("解析失败:%v", err)
  5651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5652. return
  5653. }
  5654. }
  5655. }
  5656. if res.Infcode == 0 {
  5657. order := &models.HisOrder{
  5658. UserOrgId: adminUser.CurrentOrgId,
  5659. HisPatientId: his.ID,
  5660. PatientId: his.PatientId,
  5661. SettleAccountsDate: recordDateTime,
  5662. MdtrtId: his.Number,
  5663. PsnNo: his.PsnNo,
  5664. MedType: strconv.FormatInt(reg_type, 10),
  5665. Ctime: time.Now().Unix(),
  5666. Mtime: time.Now().Unix(),
  5667. Status: 1,
  5668. Number: chrg_bchno,
  5669. Infcode: res.Infcode,
  5670. WarnMsg: res.WarnMsg,
  5671. Cainfo: res.Cainfo,
  5672. ErrMsg: res.ErrMsg,
  5673. RespondTime: res.RefmsgTime,
  5674. InfRefmsgid: res.InfRefmsgid,
  5675. OrderStatus: 1,
  5676. PayWay: pay_way,
  5677. PayPrice: pay_price,
  5678. PayCardNo: pay_card_no,
  5679. DiscountPrice: discount_price,
  5680. PreferentialPrice: preferential_price,
  5681. RealityPrice: reality_price,
  5682. FoundPrice: found_price,
  5683. MedicalInsurancePrice: medical_insurance_price,
  5684. PrivatePrice: private_price,
  5685. IsMedicineInsurance: 1,
  5686. SettleType: settle_accounts_type,
  5687. SettleStartTime: start_time,
  5688. SettleEndTime: end_time,
  5689. Creator: roles.AdminUserId,
  5690. Modify: roles.AdminUserId,
  5691. FaPiaoNumber: fapiao_number,
  5692. FaPiaoCode: fapiao_code,
  5693. PType: 2,
  5694. Diagnosis: diagnosis_id,
  5695. }
  5696. err = service.CreateOrder(order)
  5697. if err != nil {
  5698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5699. return
  5700. }
  5701. for _, item := range res.Output.Result {
  5702. temp := strings.Split(item.FeedetlSn, "-")
  5703. var advice_id int64 = 0
  5704. var project_id int64 = 0
  5705. var types int64 = 0
  5706. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5707. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5708. if temp[1] == "1" {
  5709. advice_id = id
  5710. project_id = 0
  5711. } else if temp[1] == "2" {
  5712. advice_id = 0
  5713. project_id = id
  5714. }
  5715. info := &models.HisOrderInfo{
  5716. OrderNumber: order.Number,
  5717. FeedetlSn: item.FeedetlSn,
  5718. UploadDate: time.Now().Unix(),
  5719. AdviceId: advice_id,
  5720. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5721. Cnt: item.Cnt,
  5722. Pric: float64(item.Pric),
  5723. PatientId: his.PatientId,
  5724. PricUplmtAmt: item.PricUplmtAmt,
  5725. SelfpayProp: item.SelfpayProp,
  5726. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5727. OverlmtAmt: item.OverlmtAmt,
  5728. PreselfpayAmt: item.PreselfpayAmt,
  5729. BasMednFlag: item.BasMednFlag,
  5730. MedChrgitmType: item.MedChrgitmType,
  5731. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5732. Status: 1,
  5733. Memo: item.Memo,
  5734. Mtime: time.Now().Unix(),
  5735. InscpScpAmt: item.InscpScpAmt,
  5736. DrtReimFlag: item.DrtReimFlag,
  5737. Ctime: time.Now().Unix(),
  5738. ListSpItemFlag: item.ListSpItemFlag,
  5739. ChldMedcFlag: item.ChldMedcFlag,
  5740. LmtUsedFlag: item.LmtUsedFlag,
  5741. ChrgitmLv: item.ChrgitmLv,
  5742. UserOrgId: adminUser.CurrentOrgId,
  5743. HisPatientId: his.ID,
  5744. OrderId: order.ID,
  5745. ProjectId: project_id,
  5746. Type: types,
  5747. }
  5748. service.CreateOrderInfo(info)
  5749. }
  5750. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5751. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5752. var total float64
  5753. for _, item := range prescriptions {
  5754. if item.Type == 1 { //药品
  5755. for _, subItem := range item.HisDoctorAdviceInfo {
  5756. total = total + (subItem.Price * subItem.PrescribingNumber)
  5757. }
  5758. }
  5759. if item.Type == 2 { //项目
  5760. for _, subItem := range item.HisPrescriptionProject {
  5761. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5762. total = total + (subItem.Price * cnt)
  5763. }
  5764. }
  5765. }
  5766. for _, item := range prescriptions {
  5767. for _, subItem := range item.HisAdditionalCharge {
  5768. total = total + (subItem.Price * float64(subItem.Count))
  5769. }
  5770. }
  5771. var allTotal string
  5772. if adminUser.CurrentOrgId == 9919 {
  5773. allTotal = fmt.Sprintf("%.4f", total)
  5774. } else {
  5775. allTotal = fmt.Sprintf("%.4f", total)
  5776. }
  5777. if res.Infcode == 0 {
  5778. var rf []*ResultFive
  5779. json.Unmarshal([]byte(his.Iinfo), &rf)
  5780. chrg_bchno := chrg_bchno
  5781. cert_no := his.Certno
  5782. var insutypes []string
  5783. var insutype string
  5784. var is390 int = 0
  5785. var is310 int = 0
  5786. for _, item := range rf {
  5787. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5788. insutypes = append(insutypes, item.Insutype)
  5789. }
  5790. }
  5791. if len(insutypes) == 1 {
  5792. insutype = insutypes[0]
  5793. } else {
  5794. for _, i := range insutypes {
  5795. if i == "390" {
  5796. is390 = 1
  5797. }
  5798. if i == "310" {
  5799. is310 = 1
  5800. }
  5801. }
  5802. }
  5803. if is390 == 1 {
  5804. insutype = "390"
  5805. }
  5806. if is310 == 1 {
  5807. insutype = "310"
  5808. }
  5809. if len(insutypes) == 0 {
  5810. insutype = "310"
  5811. }
  5812. if len(insutypes) == 2 {
  5813. insutype = strconv.FormatInt(his.SocialType, 10)
  5814. }
  5815. insutype = strconv.FormatInt(his.SocialType, 10)
  5816. //insutype = "390"
  5817. if his.IdCardType == 1 {
  5818. // cert_no = his.MedicalInsuranceNumber
  5819. cert_no = his.Certno
  5820. } else {
  5821. cert_no = his.Certno
  5822. }
  5823. var res ResultSeven
  5824. var resSeven10265 ResultSeven10265
  5825. var src_resquest string
  5826. var result2 string
  5827. var acct_used_flag string
  5828. fmt.Println("pay_way")
  5829. fmt.Println(pay_way)
  5830. fmt.Println("pay_way")
  5831. if pay_way == 4 {
  5832. acct_used_flag = "1"
  5833. } else {
  5834. acct_used_flag = "0"
  5835. }
  5836. if miConfig.MdtrtareaAdmvs == "421300" {
  5837. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5838. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5839. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5841. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5842. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5843. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5844. resp, requestErr := http.Get(api)
  5845. if requestErr != nil {
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5847. return
  5848. }
  5849. body, ioErr := ioutil.ReadAll(resp.Body)
  5850. if ioErr != nil {
  5851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5853. return
  5854. }
  5855. var respJSON map[string]interface{}
  5856. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5859. return
  5860. }
  5861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5862. result, _ := json.Marshal(respJSON)
  5863. if miConfig.Code == "H15049901371" {
  5864. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5865. utils.ErrorLog("解析失败:%v", err)
  5866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5867. return
  5868. }
  5869. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5870. res.Output = resSeven10265.Output
  5871. res.ErrMsg = resSeven10265.ErrMsg
  5872. res.Cainfo = resSeven10265.Cainfo
  5873. res.WarnMsg = resSeven10265.WarnMsg
  5874. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5875. res.Infcode = infocode
  5876. } else {
  5877. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5878. utils.ErrorLog("解析失败:%v", err)
  5879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5880. return
  5881. }
  5882. }
  5883. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5884. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5885. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5886. bas := strings.Split(psn_info.CardInfo, "|")
  5887. if his.IdCardType == 1 {
  5888. cert_no = bas[2]
  5889. } else if his.IdCardType == 3 {
  5890. cert_no = his.Certno
  5891. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5892. } else if his.IdCardType == 4 {
  5893. cert_no = his.Certno
  5894. psn_info.VerifyNumber = token
  5895. }
  5896. var api string
  5897. if miConfig.MdtrtareaAdmvs == "320921" {
  5898. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5899. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5900. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5901. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5902. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5903. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5904. "&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
  5905. } else {
  5906. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5907. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5908. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5909. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5910. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5911. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5912. "&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
  5913. }
  5914. resp, requestErr := http.Get(api)
  5915. if requestErr != nil {
  5916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5917. return
  5918. }
  5919. body, ioErr := ioutil.ReadAll(resp.Body)
  5920. if ioErr != nil {
  5921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5923. return
  5924. }
  5925. var respJSON map[string]interface{}
  5926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5929. return
  5930. }
  5931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5932. result, _ := json.Marshal(respJSON)
  5933. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5934. utils.ErrorLog("解析失败:%v", err)
  5935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. return
  5937. }
  5938. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5939. res.Output = resSeven10265.Output
  5940. res.ErrMsg = resSeven10265.ErrMsg
  5941. res.Cainfo = resSeven10265.Cainfo
  5942. res.WarnMsg = resSeven10265.WarnMsg
  5943. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5944. res.Infcode = infocode
  5945. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5946. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5947. var cert_no string
  5948. if his.IdCardType == 1 {
  5949. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5950. }
  5951. fmt.Println(cert_no)
  5952. result2, src_resquest, _ = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5953. //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)
  5954. var dat map[string]interface{}
  5955. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5956. fmt.Println(dat)
  5957. } else {
  5958. fmt.Println(err)
  5959. }
  5960. saveLog(result2, src_resquest, "2207", "结算")
  5961. userJSONBytes, _ := json.Marshal(dat)
  5962. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5963. utils.ErrorLog("解析失败:%v", err)
  5964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5965. return
  5966. }
  5967. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5968. res.Output = resSeven10265.Output
  5969. res.ErrMsg = resSeven10265.ErrMsg
  5970. res.Cainfo = resSeven10265.Cainfo
  5971. res.WarnMsg = resSeven10265.WarnMsg
  5972. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5973. res.Infcode = infocode
  5974. } else {
  5975. if miConfig.Code == "H15049901371" {
  5976. //赤峰地区国家医保医疗类别
  5977. //职工透析:医疗类别选特殊情况门诊990502
  5978. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5979. var med_type string
  5980. if his.Insutype == "390" {
  5981. if reg_type == 14 {
  5982. med_type = "9933"
  5983. } else if reg_type == 11 {
  5984. med_type = "11"
  5985. }
  5986. } else if his.Insutype == "310" {
  5987. if reg_type == 14 {
  5988. med_type = "990502"
  5989. } else if reg_type == 11 {
  5990. med_type = "11"
  5991. }
  5992. }
  5993. 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)
  5994. } else {
  5995. 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)
  5996. }
  5997. //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)
  5998. var dat map[string]interface{}
  5999. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6000. fmt.Println(dat)
  6001. } else {
  6002. fmt.Println(err)
  6003. }
  6004. saveLog(result2, src_resquest, "2207", "结算")
  6005. userJSONBytes, _ := json.Marshal(dat)
  6006. if miConfig.Code == "H15049901371" {
  6007. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6008. utils.ErrorLog("解析失败:%v", err)
  6009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6010. return
  6011. }
  6012. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6013. res.Output = resSeven10265.Output
  6014. res.ErrMsg = resSeven10265.ErrMsg
  6015. res.Cainfo = resSeven10265.Cainfo
  6016. res.WarnMsg = resSeven10265.WarnMsg
  6017. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6018. res.Infcode = infocode
  6019. } else {
  6020. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6021. utils.ErrorLog("解析失败:%v", err)
  6022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6023. return
  6024. }
  6025. }
  6026. }
  6027. if res.Infcode != 0 {
  6028. errlog := &models.HisOrderError{
  6029. UserOrgId: adminUser.CurrentOrgId,
  6030. Ctime: time.Now().Unix(),
  6031. Mtime: time.Now().Unix(),
  6032. Number: chrg_bchno,
  6033. ErrMsg: res.ErrMsg,
  6034. Status: 1,
  6035. PatientId: id,
  6036. RecordTime: recordDateTime,
  6037. Stage: 6,
  6038. }
  6039. service.CreateErrMsgLog(errlog)
  6040. c.ServeSuccessJSON(map[string]interface{}{
  6041. "failed_code": -10,
  6042. "msg": res.ErrMsg,
  6043. })
  6044. return
  6045. } else {
  6046. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6047. order.OrderStatus = 2
  6048. order.Status = 1
  6049. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6050. order.SetlId = res.Output.Setlinfo.SetlID
  6051. order.PsnNo = res.Output.Setlinfo.PsnNo
  6052. order.PsnName = res.Output.Setlinfo.PsnName
  6053. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6054. order.Certno = res.Output.Setlinfo.Certno
  6055. order.Gend = res.Output.Setlinfo.Gend
  6056. order.Naty = res.Output.Setlinfo.Naty
  6057. order.Age = res.Output.Setlinfo.Age
  6058. order.Insutype = res.Output.Setlinfo.Insutype
  6059. order.PsnType = res.Output.Setlinfo.PsnType
  6060. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6061. order.SetlTime = res.Output.Setlinfo.SetlTime
  6062. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6063. if res.Output.Setlinfo.MedType == "140101" {
  6064. order.MedType = "14"
  6065. } else {
  6066. order.MedType = res.Output.Setlinfo.MedType
  6067. }
  6068. if reg_type == 1112 {
  6069. order.MedType = "1112"
  6070. }
  6071. if reg_type == 1111 {
  6072. order.MedType = "1111"
  6073. }
  6074. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6075. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6076. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6077. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6078. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6079. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6080. order.HifpPay = res.Output.Setlinfo.HifpPay
  6081. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6082. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6083. order.HifesPay = res.Output.Setlinfo.HifesPay
  6084. order.HifobPay = res.Output.Setlinfo.HifobPay
  6085. order.MafPay = res.Output.Setlinfo.MafPay
  6086. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6087. order.OthPay = res.Output.Setlinfo.OthPay
  6088. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6089. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6090. order.AcctPay = res.Output.Setlinfo.AcctPay
  6091. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6092. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6093. order.Balc = res.Output.Setlinfo.Balc
  6094. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6095. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6096. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6097. order.ClrType = res.Output.Setlinfo.ClrType
  6098. order.ClrWay = res.Output.Setlinfo.ClrWay
  6099. order.Creator = order.Creator
  6100. order.Modify = roles.AdminUserId
  6101. order.RequestLog = src_resquest
  6102. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6103. detailStr := string(setlDetail)
  6104. order.SetlDetail = detailStr
  6105. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6106. err = service.UpDateOrder(order)
  6107. if err == nil {
  6108. //判断是否使用了押金
  6109. if dec_way == "true" {
  6110. tmpstring := strconv.FormatInt(order.ID, 10)
  6111. order.Decimal = decimal
  6112. service.UpDateOrder(order)
  6113. //扣押金
  6114. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6115. if errmsg != nil {
  6116. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6117. return
  6118. }
  6119. }
  6120. c.ServeSuccessJSON(map[string]interface{}{
  6121. "msg": "结算成功",
  6122. })
  6123. } else {
  6124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6125. return
  6126. }
  6127. }
  6128. } else {
  6129. adminUser := c.GetAdminUserInfo()
  6130. errlog := &models.HisOrderError{
  6131. UserOrgId: adminUser.CurrentOrgId,
  6132. Ctime: time.Now().Unix(),
  6133. Mtime: time.Now().Unix(),
  6134. ErrMsg: res.ErrMsg,
  6135. Status: 1,
  6136. PatientId: id,
  6137. RecordTime: recordDateTime,
  6138. Stage: 4,
  6139. }
  6140. service.CreateErrMsgLog(errlog)
  6141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6142. return
  6143. }
  6144. } else {
  6145. adminUser := c.GetAdminUserInfo()
  6146. errlog := &models.HisOrderError{
  6147. UserOrgId: adminUser.CurrentOrgId,
  6148. Ctime: time.Now().Unix(),
  6149. Mtime: time.Now().Unix(),
  6150. ErrMsg: res.ErrMsg,
  6151. Status: 1,
  6152. PatientId: id,
  6153. RecordTime: recordDateTime,
  6154. Stage: 4,
  6155. }
  6156. service.CreateErrMsgLog(errlog)
  6157. c.ServeSuccessJSON(map[string]interface{}{
  6158. "failed_code": -10,
  6159. "msg": res.ErrMsg,
  6160. })
  6161. return
  6162. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6163. //return
  6164. }
  6165. }
  6166. }
  6167. } else if tempOrder.ID > 0 {
  6168. if tempOrder.IsPre == 1 {
  6169. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6170. var rf []*ResultFive
  6171. json.Unmarshal([]byte(his.Iinfo), &rf)
  6172. chrg_bchno := tempOrder.Number
  6173. cert_no := his.Certno
  6174. var insutypes []string
  6175. var insutype string
  6176. var is390 int = 0
  6177. var is310 int = 0
  6178. for _, item := range rf {
  6179. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6180. insutypes = append(insutypes, item.Insutype)
  6181. }
  6182. }
  6183. if len(insutypes) == 1 {
  6184. insutype = insutypes[0]
  6185. } else {
  6186. for _, i := range insutypes {
  6187. if i == "390" {
  6188. is390 = 1
  6189. }
  6190. if i == "310" {
  6191. is310 = 1
  6192. }
  6193. }
  6194. }
  6195. if is390 == 1 {
  6196. insutype = "390"
  6197. }
  6198. if is310 == 1 {
  6199. insutype = "310"
  6200. }
  6201. if len(insutypes) == 0 {
  6202. insutype = "310"
  6203. }
  6204. if len(insutypes) == 2 {
  6205. insutype = strconv.FormatInt(his.SocialType, 64)
  6206. }
  6207. //insutype = "390"
  6208. if his.IdCardType == 1 {
  6209. // cert_no = his.MedicalInsuranceNumber
  6210. cert_no = his.Certno
  6211. } else {
  6212. cert_no = his.Certno
  6213. }
  6214. var res ResultSeven
  6215. var resSeven10265 ResultSeven10265
  6216. var src_resquest string
  6217. var result2 string
  6218. var acct_used_flag string
  6219. fmt.Println("pay_way")
  6220. fmt.Println(pay_way)
  6221. fmt.Println("pay_way")
  6222. if pay_way == 4 {
  6223. acct_used_flag = "1"
  6224. } else {
  6225. acct_used_flag = "0"
  6226. }
  6227. if miConfig.MdtrtareaAdmvs == "421300" {
  6228. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6229. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6230. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6231. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6232. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6233. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6234. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6235. resp, requestErr := http.Get(api)
  6236. if requestErr != nil {
  6237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6238. return
  6239. }
  6240. body, ioErr := ioutil.ReadAll(resp.Body)
  6241. if ioErr != nil {
  6242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6244. return
  6245. }
  6246. var respJSON map[string]interface{}
  6247. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6250. return
  6251. }
  6252. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6253. result, _ := json.Marshal(respJSON)
  6254. fmt.Println("log")
  6255. fmt.Println(string(result))
  6256. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6257. utils.ErrorLog("解析失败:%v", err)
  6258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6259. return
  6260. }
  6261. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6262. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6263. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6264. //psn_info, _ := service.GetPsnByPatientId(id)
  6265. bas := strings.Split(psn_info.CardInfo, "|")
  6266. if his.IdCardType == 1 {
  6267. cert_no = bas[2]
  6268. } else {
  6269. cert_no = bas[1]
  6270. }
  6271. //江苏地区国家医保医疗类别
  6272. //职工透析:医疗类别选特殊情况门诊9933
  6273. //居民血透门慢: 医疗类别选门诊慢病1402
  6274. //var med_type string
  6275. //if his.Insutype == "310" {
  6276. // if reg_type == 14 {
  6277. // med_type = "9933"
  6278. // } else if reg_type == 11 {
  6279. // med_type = "11"
  6280. //
  6281. // }
  6282. //} else if his.Insutype == "390" {
  6283. // if reg_type == 14 {
  6284. // med_type = "1402"
  6285. // } else if reg_type == 11 {
  6286. // med_type = "11"
  6287. // }
  6288. //}
  6289. var api string
  6290. if miConfig.MdtrtareaAdmvs == "320921" {
  6291. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6292. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6293. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6294. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6295. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6296. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6297. "&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
  6298. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6299. } else {
  6300. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6301. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6302. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6303. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6304. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6305. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6306. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6307. "&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
  6308. }
  6309. resp, requestErr := http.Get(api)
  6310. if requestErr != nil {
  6311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6312. return
  6313. }
  6314. body, ioErr := ioutil.ReadAll(resp.Body)
  6315. if ioErr != nil {
  6316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6318. return
  6319. }
  6320. var respJSON map[string]interface{}
  6321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6324. return
  6325. }
  6326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6327. result, _ := json.Marshal(respJSON)
  6328. fmt.Println("log")
  6329. fmt.Println(string(result))
  6330. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6331. utils.ErrorLog("解析失败:%v", err)
  6332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6333. return
  6334. }
  6335. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6336. res.Output = resSeven10265.Output
  6337. res.ErrMsg = resSeven10265.ErrMsg
  6338. res.Cainfo = resSeven10265.Cainfo
  6339. res.WarnMsg = resSeven10265.WarnMsg
  6340. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6341. res.Infcode = infocode
  6342. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6343. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6344. var cert_no string
  6345. if his.IdCardType == 1 {
  6346. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6347. }
  6348. fmt.Println(cert_no)
  6349. result2, src_resquest, _ = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6350. var dat map[string]interface{}
  6351. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6352. fmt.Println(dat)
  6353. } else {
  6354. fmt.Println(err)
  6355. }
  6356. saveLog(result2, src_resquest, "2207", "结算")
  6357. userJSONBytes, _ := json.Marshal(dat)
  6358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6359. utils.ErrorLog("解析失败:%v", err)
  6360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6361. return
  6362. }
  6363. } else {
  6364. var src_resquest string
  6365. if miConfig.Code == "H15049901371" {
  6366. //赤峰地区国家医保医疗类别
  6367. //职工透析:医疗类别选特殊情况门诊990502
  6368. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6369. var med_type string
  6370. if his.Insutype == "390" {
  6371. if reg_type == 14 {
  6372. med_type = "9933"
  6373. } else if reg_type == 11 {
  6374. med_type = "11"
  6375. }
  6376. } else if his.Insutype == "310" {
  6377. if reg_type == 14 {
  6378. med_type = "990502"
  6379. } else if reg_type == 11 {
  6380. med_type = "11"
  6381. }
  6382. }
  6383. 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)
  6384. } else {
  6385. 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)
  6386. }
  6387. var dat map[string]interface{}
  6388. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6389. fmt.Println(dat)
  6390. } else {
  6391. fmt.Println(err)
  6392. }
  6393. saveLog(result2, src_resquest, "2207", "结算")
  6394. userJSONBytes, _ := json.Marshal(dat)
  6395. if miConfig.Code == "H15049901371" {
  6396. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6397. utils.ErrorLog("解析失败:%v", err)
  6398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6399. return
  6400. }
  6401. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6402. res.Output = resSeven10265.Output
  6403. res.ErrMsg = resSeven10265.ErrMsg
  6404. res.Cainfo = resSeven10265.Cainfo
  6405. res.WarnMsg = resSeven10265.WarnMsg
  6406. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6407. res.Infcode = infocode
  6408. } else {
  6409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6410. utils.ErrorLog("解析失败:%v", err)
  6411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6412. return
  6413. }
  6414. }
  6415. }
  6416. if res.Infcode != 0 {
  6417. errlog := &models.HisOrderError{
  6418. UserOrgId: adminUser.CurrentOrgId,
  6419. Ctime: time.Now().Unix(),
  6420. Mtime: time.Now().Unix(),
  6421. Number: chrg_bchno,
  6422. ErrMsg: res.ErrMsg,
  6423. Status: 1,
  6424. PatientId: id,
  6425. RecordTime: recordDateTime,
  6426. Stage: 6,
  6427. }
  6428. service.CreateErrMsgLog(errlog)
  6429. c.ServeSuccessJSON(map[string]interface{}{
  6430. "failed_code": -10,
  6431. "msg": res.ErrMsg,
  6432. })
  6433. return
  6434. } else {
  6435. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6436. order.OrderStatus = 2
  6437. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6438. order.SetlId = res.Output.Setlinfo.SetlID
  6439. order.PsnNo = res.Output.Setlinfo.PsnNo
  6440. order.PsnName = res.Output.Setlinfo.PsnName
  6441. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6442. order.Certno = res.Output.Setlinfo.Certno
  6443. order.Gend = res.Output.Setlinfo.Gend
  6444. order.Naty = res.Output.Setlinfo.Naty
  6445. order.Age = res.Output.Setlinfo.Age
  6446. order.Insutype = res.Output.Setlinfo.Insutype
  6447. order.PsnType = res.Output.Setlinfo.PsnType
  6448. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6449. order.SetlTime = res.Output.Setlinfo.SetlTime
  6450. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6451. //order.MedType = res.Output.Setlinfo.MedType
  6452. if reg_type == 1112 {
  6453. order.MedType = "1112"
  6454. }
  6455. if reg_type == 1111 {
  6456. order.MedType = "1111"
  6457. }
  6458. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6459. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6460. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6461. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6462. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6463. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6464. order.HifpPay = res.Output.Setlinfo.HifpPay
  6465. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6466. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6467. order.HifesPay = res.Output.Setlinfo.HifesPay
  6468. order.HifobPay = res.Output.Setlinfo.HifobPay
  6469. order.MafPay = res.Output.Setlinfo.MafPay
  6470. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6471. order.OthPay = res.Output.Setlinfo.OthPay
  6472. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6473. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6474. order.AcctPay = res.Output.Setlinfo.AcctPay
  6475. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6476. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6477. order.Balc = res.Output.Setlinfo.Balc
  6478. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6479. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6480. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6481. order.ClrWay = res.Output.Setlinfo.ClrWay
  6482. order.Creator = order.Creator
  6483. order.Modify = roles.AdminUserId
  6484. order.RequestLog = src_resquest
  6485. order.Diagnosis = diagnosis_id
  6486. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6487. detailStr := string(setlDetail)
  6488. order.SetlDetail = detailStr
  6489. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6490. err = service.UpDateOrder(order)
  6491. if err == nil {
  6492. //判断是否使用了押金
  6493. if dec_way == "true" {
  6494. tmpstring := strconv.FormatInt(order.ID, 10)
  6495. //扣押金
  6496. order.Decimal = decimal
  6497. service.UpDateOrder(order)
  6498. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6499. if errmsg != nil {
  6500. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6501. return
  6502. }
  6503. }
  6504. c.ServeSuccessJSON(map[string]interface{}{
  6505. "msg": "结算成功",
  6506. })
  6507. } else {
  6508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6509. return
  6510. }
  6511. }
  6512. }
  6513. }
  6514. }
  6515. //func (c *HisApiController) GetPreUploadInfo() {
  6516. // id, _ := c.GetInt64("id")
  6517. // record_time := c.GetString("record_time")
  6518. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6519. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6520. //
  6521. // timeLayout := "2006-01-02"
  6522. // loc, _ := time.LoadLocation("Local")
  6523. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6524. // if err != nil {
  6525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6526. // return
  6527. // }
  6528. // recordDateTime := theTime.Unix()
  6529. // adminUser := c.GetAdminUserInfo()
  6530. //
  6531. // var prescriptions []*models.HisPrescription
  6532. //
  6533. // var start_time int64
  6534. // var end_time int64
  6535. //
  6536. // data := make(map[string]interface{})
  6537. // if settle_accounts_type == 1 { //日结
  6538. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6539. // data["pre"] = prescriptions
  6540. //
  6541. // } else { //月结
  6542. // start_time_str := c.GetString("start_time")
  6543. // end_time_str := c.GetString("end_time")
  6544. // timeLayout := "2006-01-02"
  6545. // loc, _ := time.LoadLocation("Local")
  6546. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6547. // if err != nil {
  6548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6549. // return
  6550. // }
  6551. // recordStartTime := theStartTime.Unix()
  6552. // start_time = recordStartTime
  6553. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6554. // if err != nil {
  6555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6556. // return
  6557. // }
  6558. // recordEndTime := theEndTime.Unix()
  6559. // end_time = recordEndTime
  6560. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6561. // data["pre"] = prescriptions
  6562. //
  6563. // }
  6564. //
  6565. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6566. //
  6567. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6568. // timestamp := time.Now().Unix()
  6569. // tempTime := time.Unix(timestamp, 0)
  6570. // timeFormat := tempTime.Format("20060102150405")
  6571. // chrgBchno := rand.Intn(100000) + 10000
  6572. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6573. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6574. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6575. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6576. // strconv.FormatInt(his.PatientId, 10)
  6577. // client := &http.Client{}
  6578. // data["psn_no"] = his.PsnNo
  6579. // data["mdtrt_id"] = his.Number
  6580. // data["chrg_bchno"] = chrg_bchno
  6581. // data["org_name"] = miConfig.OrgName
  6582. // data["doctor"] = roles.UserName
  6583. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6584. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6585. // data["fixmedins_code"] = miConfig.Code
  6586. // data["dept_code"] = department.Number
  6587. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6588. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6589. // data["secret_key"] = miConfig.SecretKey
  6590. // var ids []int64
  6591. //
  6592. // for _, item := range prescriptions {
  6593. // ids = append(ids, item.ID)
  6594. // }
  6595. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6596. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6597. // bytesData, _ := json.Marshal(data)
  6598. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6599. // resp, _ := client.Do(req)
  6600. // defer resp.Body.Close()
  6601. // body, ioErr := ioutil.ReadAll(resp.Body)
  6602. // if ioErr != nil {
  6603. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6605. // return
  6606. // }
  6607. // var respJSON map[string]interface{}
  6608. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6609. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6611. // return
  6612. // }
  6613. //
  6614. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6615. // userJSONBytes, _ := json.Marshal(respJSON)
  6616. // var res ResultFour
  6617. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6618. // utils.ErrorLog("解析失败:%v", err)
  6619. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6620. // return
  6621. // }
  6622. //
  6623. // if res.Infcode == 0 {
  6624. // order := &models.HisOrder{
  6625. // UserOrgId: adminUser.CurrentOrgId,
  6626. // HisPatientId: his.ID,
  6627. // PatientId: his.PatientId,
  6628. // SettleAccountsDate: recordDateTime,
  6629. // Ctime: time.Now().Unix(),
  6630. // Mtime: time.Now().Unix(),
  6631. // Status: 1,
  6632. // Number: chrg_bchno,
  6633. // Infcode: res.Infcode,
  6634. // WarnMsg: res.WarnMsg,
  6635. // Cainfo: res.Cainfo,
  6636. // ErrMsg: res.ErrMsg,
  6637. // RespondTime: res.RefmsgTime,
  6638. // InfRefmsgid: res.InfRefmsgid,
  6639. // OrderStatus: 1,
  6640. // IsMedicineInsurance: 1,
  6641. // SettleType: settle_accounts_type,
  6642. // SettleStartTime: start_time,
  6643. // SettleEndTime: end_time,
  6644. // Creator: roles.ID,
  6645. // Modify: roles.ID,
  6646. // PType: 2,
  6647. // }
  6648. // err = service.CreateOrder(order)
  6649. // if err != nil {
  6650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6651. // return
  6652. // }
  6653. //
  6654. // for _, item := range res.Output.Result {
  6655. // temp := strings.Split(item.FeedetlSn, "-")
  6656. // var advice_id int64 = 0
  6657. // var project_id int64 = 0
  6658. // var types int64 = 0
  6659. //
  6660. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6661. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6662. //
  6663. // if temp[1] == "1" {
  6664. // advice_id = id
  6665. // project_id = 0
  6666. // } else if temp[1] == "2" {
  6667. // advice_id = 0
  6668. // project_id = id
  6669. // }
  6670. //
  6671. // info := &models.HisOrderInfo{
  6672. // OrderNumber: order.Number,
  6673. // FeedetlSn: item.FeedetlSn,
  6674. // UploadDate: time.Now().Unix(),
  6675. // AdviceId: advice_id,
  6676. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6677. // Cnt: item.Cnt,
  6678. // Pric: float64(item.Pric),
  6679. // PatientId: his.PatientId,
  6680. // PricUplmtAmt: item.PricUplmtAmt,
  6681. // SelfpayProp: item.SelfpayProp,
  6682. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6683. // OverlmtAmt: item.OverlmtAmt,
  6684. // PreselfpayAmt: item.PreselfpayAmt,
  6685. // BasMednFlag: item.BasMednFlag,
  6686. // MedChrgitmType: item.MedChrgitmType,
  6687. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6688. // Status: 1,
  6689. // Memo: item.Memo,
  6690. // Mtime: time.Now().Unix(),
  6691. // InscpScpAmt: item.InscpScpAmt,
  6692. // DrtReimFlag: item.DrtReimFlag,
  6693. // Ctime: time.Now().Unix(),
  6694. // ListSpItemFlag: item.ListSpItemFlag,
  6695. // ChldMedcFlag: item.ChldMedcFlag,
  6696. // LmtUsedFlag: item.LmtUsedFlag,
  6697. // ChrgitmLv: item.ChrgitmLv,
  6698. // UserOrgId: adminUser.CurrentOrgId,
  6699. // HisPatientId: his.ID,
  6700. // OrderId: order.ID,
  6701. // ProjectId: project_id,
  6702. // Type: types,
  6703. // }
  6704. // service.CreateOrderInfo(info)
  6705. //
  6706. // }
  6707. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6708. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6709. //
  6710. // var total float64
  6711. // for _, item := range prescriptions {
  6712. // if item.Type == 1 { //药品
  6713. // for _, subItem := range item.HisDoctorAdviceInfo {
  6714. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6715. // }
  6716. // }
  6717. // if item.Type == 2 { //项目
  6718. // for _, subItem := range item.HisPrescriptionProject {
  6719. // total = total + (subItem.Price * float64(subItem.Count))
  6720. // }
  6721. // }
  6722. // }
  6723. //
  6724. // for _, item := range prescriptions {
  6725. // for _, subItem := range item.HisAdditionalCharge {
  6726. // total = total + (subItem.Price * float64(subItem.Count))
  6727. // }
  6728. // }
  6729. //
  6730. // allTotal := fmt.Sprintf("%.2f", total)
  6731. // if res.Infcode == 0 {
  6732. // var rf []*ResultFive
  6733. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6734. // psn_no := his.PsnNo
  6735. // mdtrt_id := his.Number
  6736. // chrg_bchno := chrg_bchno
  6737. // cert_no := his.Certno
  6738. // insutype := rf[0].Insutype
  6739. //
  6740. // if his.IdCardType == 1 {
  6741. // cert_no = his.MedicalInsuranceNumber
  6742. //
  6743. // } else {
  6744. //
  6745. // cert_no = his.Certno
  6746. //
  6747. // }
  6748. //
  6749. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6750. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6751. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6752. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6753. // resp, requestErr := http.Get(api)
  6754. // if requestErr != nil {
  6755. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. // return
  6757. // }
  6758. // defer resp.Body.Close()
  6759. // body, ioErr := ioutil.ReadAll(resp.Body)
  6760. // if ioErr != nil {
  6761. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6763. // return
  6764. // }
  6765. // var respJSON map[string]interface{}
  6766. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6767. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6769. // return
  6770. // }
  6771. // fmt.Println(respJSON)
  6772. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6773. // userJSONBytes, _ := json.Marshal(respJSON)
  6774. // var res ResultSeven
  6775. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6776. // utils.ErrorLog("解析失败:%v", err)
  6777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6778. // return
  6779. // }
  6780. // if res.Infcode != 0 {
  6781. // errlog := &models.HisOrderError{
  6782. // UserOrgId: adminUser.CurrentOrgId,
  6783. // Ctime: time.Now().Unix(),
  6784. // Mtime: time.Now().Unix(),
  6785. // Number: chrg_bchno,
  6786. // ErrMsg: res.ErrMsg,
  6787. // Status: 1,
  6788. // PatientId: id,
  6789. // RecordTime: recordDateTime,
  6790. // Stage: 7,
  6791. // }
  6792. // service.CreateErrMsgLog(errlog)
  6793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6794. // return
  6795. // } else {
  6796. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6797. // order.OrderStatus = 1
  6798. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6799. // order.SetlId = res.Output.Setlinfo.SetlID
  6800. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6801. // order.PsnName = res.Output.Setlinfo.PsnName
  6802. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6803. // order.Certno = res.Output.Setlinfo.Certno
  6804. // order.Gend = res.Output.Setlinfo.Gend
  6805. // order.Naty = res.Output.Setlinfo.Naty
  6806. // order.Age = res.Output.Setlinfo.Age
  6807. // order.Insutype = res.Output.Setlinfo.Insutype
  6808. // order.PsnType = res.Output.Setlinfo.PsnType
  6809. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6810. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6811. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6812. // order.MedType = res.Output.Setlinfo.MedType
  6813. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6814. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6815. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6816. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6817. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6818. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6819. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6820. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6821. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6822. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6823. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6824. // order.MafPay = res.Output.Setlinfo.MafPay
  6825. // order.OthPay = res.Output.Setlinfo.OthPay
  6826. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6827. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6828. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6829. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6830. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6831. // order.Balc = res.Output.Setlinfo.Balc
  6832. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6833. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6834. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6835. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6836. // order.Creator = order.Creator
  6837. // order.Modify = roles.ID
  6838. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6839. // detailStr := string(setlDetail)
  6840. // order.SetlDetail = detailStr
  6841. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6842. // err = service.UpDateOrder(order)
  6843. // if err == nil {
  6844. // c.ServeSuccessJSON(map[string]interface{}{
  6845. // "msg": "预结算成功",
  6846. // })
  6847. // } else {
  6848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6849. // return
  6850. // }
  6851. // }
  6852. // } else {
  6853. // adminUser := c.GetAdminUserInfo()
  6854. // errlog := &models.HisOrderError{
  6855. // UserOrgId: adminUser.CurrentOrgId,
  6856. // Ctime: time.Now().Unix(),
  6857. // Mtime: time.Now().Unix(),
  6858. // ErrMsg: res.ErrMsg,
  6859. // Status: 1,
  6860. // PatientId: id,
  6861. // RecordTime: recordDateTime,
  6862. // Stage: 4,
  6863. // }
  6864. // service.CreateErrMsgLog(errlog)
  6865. //
  6866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6867. // return
  6868. // }
  6869. // } else {
  6870. // adminUser := c.GetAdminUserInfo()
  6871. // errlog := &models.HisOrderError{
  6872. // UserOrgId: adminUser.CurrentOrgId,
  6873. // Ctime: time.Now().Unix(),
  6874. // Mtime: time.Now().Unix(),
  6875. // ErrMsg: res.ErrMsg,
  6876. // Status: 1,
  6877. // PatientId: id,
  6878. // RecordTime: recordDateTime,
  6879. // Stage: 4,
  6880. // }
  6881. // service.CreateErrMsgLog(errlog)
  6882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6883. // return
  6884. // }
  6885. //
  6886. // } else {
  6887. // var total float64
  6888. // for _, item := range prescriptions {
  6889. // if item.Type == 1 { //药品
  6890. // for _, subItem := range item.HisDoctorAdviceInfo {
  6891. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6892. // }
  6893. // }
  6894. // if item.Type == 2 { //项目
  6895. // for _, subItem := range item.HisPrescriptionProject {
  6896. // total = total + (subItem.Price * float64(subItem.Count))
  6897. // }
  6898. // }
  6899. //
  6900. // for _, subItem := range item.HisAdditionalCharge {
  6901. // total = total + (subItem.Price * float64(subItem.Count))
  6902. // }
  6903. // }
  6904. //
  6905. // allTotal := fmt.Sprintf("%.2f", total)
  6906. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6907. // order := &models.HisOrder{
  6908. // UserOrgId: adminUser.CurrentOrgId,
  6909. // HisPatientId: his.ID,
  6910. // PatientId: id,
  6911. // SettleAccountsDate: recordDateTime,
  6912. // Ctime: time.Now().Unix(),
  6913. // Mtime: time.Now().Unix(),
  6914. // Status: 1,
  6915. // OrderStatus: 2,
  6916. // Number: chrg_bchno,
  6917. // MedfeeSumamt: totals,
  6918. // }
  6919. // err = service.CreateOrder(order)
  6920. // if err != nil {
  6921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6922. // return
  6923. // }
  6924. //
  6925. // var customs []*Custom
  6926. // for _, item := range prescriptions {
  6927. //
  6928. // if item.Type == 1 { //药品
  6929. // for _, subItem := range item.HisDoctorAdviceInfo {
  6930. // cus := &Custom{
  6931. // AdviceId: subItem.ID,
  6932. // ProjectId: 0,
  6933. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6934. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6935. // FeedetlSn: subItem.FeedetlSn,
  6936. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6937. // MedListCodg: subItem.MedListCodg,
  6938. // Type: 1,
  6939. // }
  6940. // customs = append(customs, cus)
  6941. // }
  6942. // }
  6943. //
  6944. // if item.Type == 2 { //项目
  6945. // for _, subItem := range item.HisPrescriptionProject {
  6946. //
  6947. // cus := &Custom{
  6948. // AdviceId: 0,
  6949. // ProjectId: subItem.ID,
  6950. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6951. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6952. // FeedetlSn: subItem.FeedetlSn,
  6953. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6954. // MedListCodg: subItem.MedListCodg,
  6955. // Type: 2,
  6956. // }
  6957. //
  6958. // customs = append(customs, cus)
  6959. // }
  6960. // }
  6961. //
  6962. // for _, item := range item.HisAdditionalCharge {
  6963. // cus := &Custom{
  6964. // ItemId: item.ID,
  6965. // AdviceId: 0,
  6966. // ProjectId: 0,
  6967. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6968. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6969. // FeedetlSn: item.FeedetlSn,
  6970. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6971. // MedListCodg: item.XtHisAddtionConfig.Code,
  6972. // Type: 3,
  6973. // }
  6974. //
  6975. // customs = append(customs, cus)
  6976. // }
  6977. //
  6978. // }
  6979. //
  6980. // for _, item := range customs {
  6981. // var advice_id int64 = 0
  6982. // var project_id int64 = 0
  6983. // var item_id int64 = 0
  6984. //
  6985. // var types int64 = 0
  6986. //
  6987. // if item.Type == 1 {
  6988. // advice_id = item.AdviceId
  6989. // project_id = 0
  6990. // item_id = 0
  6991. // } else if item.Type == 2 {
  6992. // advice_id = 0
  6993. // item_id = 0
  6994. //
  6995. // project_id = item.ProjectId
  6996. // } else if item.Type == 3 {
  6997. // advice_id = 0
  6998. // item_id = item.ItemId
  6999. // project_id = 0
  7000. // }
  7001. //
  7002. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7003. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7004. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7005. //
  7006. // info := &models.HisOrderInfo{
  7007. // OrderNumber: order.Number,
  7008. // UploadDate: time.Now().Unix(),
  7009. // AdviceId: advice_id,
  7010. // DetItemFeeSumamt: detItemFeeSumamt,
  7011. // Cnt: cut,
  7012. // Pric: pric,
  7013. // PatientId: id,
  7014. // Status: 1,
  7015. // Mtime: time.Now().Unix(),
  7016. // Ctime: time.Now().Unix(),
  7017. // UserOrgId: adminUser.CurrentOrgId,
  7018. // HisPatientId: his.ID,
  7019. // OrderId: order.ID,
  7020. // ProjectId: project_id,
  7021. // Type: types,
  7022. // ItemId: item_id,
  7023. // }
  7024. // service.CreateOrderInfo(info)
  7025. // }
  7026. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7027. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7028. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7029. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7030. // if err == nil {
  7031. // c.ServeSuccessJSON(map[string]interface{}{
  7032. // "msg": "结算成功",
  7033. // })
  7034. // } else {
  7035. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7036. // return
  7037. // }
  7038. // }
  7039. //}
  7040. //上传明细-预结算-
  7041. func (c *HisApiController) GetPreUploadInfo() {
  7042. id, _ := c.GetInt64("id")
  7043. record_time := c.GetString("record_time")
  7044. his_patient_id, _ := c.GetInt64("his_patient_id")
  7045. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7046. admin_user_id, _ := c.GetInt64("admin_user_id")
  7047. diagnosis_id := c.GetString("diagnosis")
  7048. sick_type, _ := c.GetInt64("sick_type")
  7049. reg_type, _ := c.GetInt64("p_type")
  7050. begin_time := c.GetString("begin_time")
  7051. id_str := c.GetString("ids")
  7052. ids_arr := strings.Split(id_str, ",")
  7053. timeLayout := "2006-01-02"
  7054. loc, _ := time.LoadLocation("Local")
  7055. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7056. if err != nil {
  7057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7058. return
  7059. }
  7060. recordDateTime := theTime.Unix()
  7061. adminUser := c.GetAdminUserInfo()
  7062. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7063. var config []*models.HisXtDiagnoseConfig
  7064. for _, item := range diagnosis_ids {
  7065. id, _ := strconv.ParseInt(item, 10, 64)
  7066. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7067. config = append(config, &diagnosisConfig)
  7068. }
  7069. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7070. sickConfig, _ := service.FindSickById(sick_type)
  7071. var prescriptions []*models.HisPrescription
  7072. var start_time int64
  7073. var end_time int64
  7074. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7075. fmt.Println(his_patient_id)
  7076. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7077. timestamp := time.Now().Unix()
  7078. tempTime := time.Unix(timestamp, 0)
  7079. timeFormat := tempTime.Format("20060102150405")
  7080. chrgBchno := rand.Intn(100000) + 10000
  7081. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7083. var patientPrescription models.HisPrescriptionInfo
  7084. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7085. if patientPrescription.ID == 0 {
  7086. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7087. }
  7088. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7089. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7090. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7091. strconv.FormatInt(his.PatientId, 10)
  7092. var res2 ResultSix
  7093. var resSix10265 ResultSix10265
  7094. var time_stamp string
  7095. if miConfig.MdtrtareaAdmvs == "421300" {
  7096. data := make(map[string]interface{})
  7097. client := &http.Client{}
  7098. data["psn_no"] = his.PsnNo
  7099. data["mdtrt_id"] = his.Number
  7100. data["department"] = department.Name
  7101. data["org_name"] = miConfig.OrgName
  7102. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7103. data["doctor_id"] = doctor_info.DoctorNumber
  7104. data["doctor_name"] = roles.UserName
  7105. data["fixmedins_code"] = miConfig.Code
  7106. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7107. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7108. data["secret_key"] = miConfig.SecretKey
  7109. data["sick_code"] = sickConfig.CountryCode
  7110. data["sick_name"] = sickConfig.ClassName
  7111. data["begin_time"] = begin_time
  7112. data["dept"] = strconv.FormatInt(department.ID, 10)
  7113. data["config"] = config
  7114. data["opter"] = roles.UserName
  7115. fmt.Println(data)
  7116. bytesData, _ := json.Marshal(data)
  7117. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7118. resp, _ := client.Do(req)
  7119. defer resp.Body.Close()
  7120. body, ioErr := ioutil.ReadAll(resp.Body)
  7121. if ioErr != nil {
  7122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7124. return
  7125. }
  7126. var respJSON map[string]interface{}
  7127. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. return
  7131. }
  7132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7133. userJSONBytes, _ := json.Marshal(respJSON)
  7134. fmt.Println("log")
  7135. fmt.Println(string(userJSONBytes))
  7136. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7137. utils.ErrorLog("解析失败:%v", err)
  7138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7139. return
  7140. }
  7141. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7142. data := make(map[string]interface{})
  7143. client := &http.Client{}
  7144. data["psn_no"] = his.PsnNo
  7145. data["mdtrt_id"] = his.Number
  7146. data["doctor"] = roles.UserName
  7147. data["department"] = department.Name
  7148. data["org_name"] = miConfig.OrgName
  7149. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7150. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7151. data["fixmedins_code"] = miConfig.Code
  7152. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7153. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7154. data["secret_key"] = miConfig.SecretKey
  7155. data["sick_code"] = sickConfig.CountryCode
  7156. data["sick_name"] = sickConfig.ClassName
  7157. data["begin_time"] = begin_time
  7158. data["dept"] = strconv.FormatInt(department.ID, 10)
  7159. data["config"] = config
  7160. data["url"] = miConfig.Url
  7161. data["ak"] = miConfig.AccessKey
  7162. data["cainfo"] = miConfig.Cainfo
  7163. bytesData, _ := json.Marshal(data)
  7164. var req *http.Request
  7165. if miConfig.MdtrtareaAdmvs == "320921" {
  7166. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7167. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  7168. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7169. } else {
  7170. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7171. }
  7172. resp, _ := client.Do(req)
  7173. defer resp.Body.Close()
  7174. body, ioErr := ioutil.ReadAll(resp.Body)
  7175. if ioErr != nil {
  7176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7178. return
  7179. }
  7180. var respJSON map[string]interface{}
  7181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7184. return
  7185. }
  7186. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7187. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7188. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7190. userJSONBytes, _ := json.Marshal(respJSON)
  7191. fmt.Println("log")
  7192. fmt.Println(string(userJSONBytes))
  7193. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7194. utils.ErrorLog("解析失败:%v", err)
  7195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7196. return
  7197. }
  7198. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7199. res2.Output = resSix10265.Output
  7200. res2.ErrMsg = resSix10265.ErrMsg
  7201. res2.Cainfo = resSix10265.Cainfo
  7202. res2.WarnMsg = resSix10265.WarnMsg
  7203. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7204. res2.Infcode = infocode
  7205. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7206. result, requestLog, _ := service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7207. saveLog(result, requestLog, "2203", "上传就诊信息")
  7208. var respJSON2 map[string]interface{}
  7209. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7212. return
  7213. }
  7214. userJSONBytes2, _ := json.Marshal(respJSON2)
  7215. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7216. utils.ErrorLog("解析失败:%v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. return
  7219. }
  7220. } else {
  7221. var result string
  7222. var requestLog string
  7223. if miConfig.MdtrtareaAdmvs == "440781" { //
  7224. 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)
  7225. } else {
  7226. if miConfig.Code == "H15049901371" {
  7227. //赤峰地区国家医保医疗类别
  7228. //职工透析:医疗类别选特殊情况门诊990502
  7229. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7230. var med_type string
  7231. if his.Insutype == "390" {
  7232. if reg_type == 14 {
  7233. med_type = "9933"
  7234. } else if reg_type == 11 {
  7235. med_type = "11"
  7236. }
  7237. } else if his.Insutype == "310" {
  7238. if reg_type == 14 {
  7239. med_type = "990502"
  7240. } else if reg_type == 11 {
  7241. med_type = "11"
  7242. }
  7243. }
  7244. 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)
  7245. } else {
  7246. 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)
  7247. }
  7248. saveLog(result, requestLog, "2203", "上传就诊信息")
  7249. var respJSON2 map[string]interface{}
  7250. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7253. return
  7254. }
  7255. userJSONBytes2, _ := json.Marshal(respJSON2)
  7256. if miConfig.Code == "H15049901371" {
  7257. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7258. utils.ErrorLog("解析失败:%v", err)
  7259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7260. return
  7261. }
  7262. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7263. res2.Output = resSix10265.Output
  7264. res2.ErrMsg = resSix10265.ErrMsg
  7265. res2.Cainfo = resSix10265.Cainfo
  7266. res2.WarnMsg = resSix10265.WarnMsg
  7267. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7268. res2.Infcode = infocode
  7269. } else {
  7270. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7271. utils.ErrorLog("解析失败:%v", err)
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7273. return
  7274. }
  7275. }
  7276. }
  7277. }
  7278. if res2.Infcode != 0 {
  7279. adminUser := c.GetAdminUserInfo()
  7280. errlog := &models.HisOrderError{
  7281. UserOrgId: adminUser.CurrentOrgId,
  7282. Ctime: time.Now().Unix(),
  7283. Mtime: time.Now().Unix(),
  7284. ErrMsg: res2.ErrMsg,
  7285. Status: 1,
  7286. PatientId: id,
  7287. RecordTime: recordDateTime,
  7288. Stage: 3,
  7289. }
  7290. service.CreateErrMsgLog(errlog)
  7291. c.ServeSuccessJSON(map[string]interface{}{
  7292. "failed_code": -10,
  7293. "msg": res2.ErrMsg,
  7294. })
  7295. return
  7296. } else {
  7297. his.Diagnosis = diagnosis_id
  7298. his.SickType = sickConfig.ID
  7299. his.PType = fmt.Sprintf("%d", reg_type)
  7300. service.UpdateHisPatientThree(&his)
  7301. data := make(map[string]interface{})
  7302. if settle_accounts_type == 1 { //日结
  7303. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7304. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7305. } else {
  7306. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7307. }
  7308. data["pre"] = prescriptions
  7309. } else { //月结
  7310. start_time_str := c.GetString("start_time")
  7311. end_time_str := c.GetString("end_time")
  7312. timeLayout := "2006-01-02"
  7313. loc, _ := time.LoadLocation("Local")
  7314. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7315. if err != nil {
  7316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7317. return
  7318. }
  7319. recordStartTime := theStartTime.Unix()
  7320. start_time = recordStartTime
  7321. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7322. if err != nil {
  7323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7324. return
  7325. }
  7326. recordEndTime := theEndTime.Unix()
  7327. end_time = recordEndTime
  7328. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7329. data["pre"] = prescriptions
  7330. }
  7331. client := &http.Client{}
  7332. data["psn_no"] = his.PsnNo
  7333. data["mdtrt_id"] = his.Number
  7334. data["chrg_bchno"] = chrg_bchno
  7335. data["org_name"] = miConfig.OrgName
  7336. data["doctor"] = roles.UserName
  7337. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7338. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7339. data["fixmedins_code"] = miConfig.Code
  7340. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7341. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7342. data["dept_code"] = "15"
  7343. } else {
  7344. data["dept_code"] = department.Number
  7345. }
  7346. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7347. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7348. data["secret_key"] = miConfig.SecretKey
  7349. data["url"] = miConfig.Url
  7350. data["ak"] = miConfig.AccessKey
  7351. data["new_doctor_name"] = patientPrescription.Doctor
  7352. data["diag_code"] = sickConfig.CountryCode
  7353. data["time_stamp"] = time_stamp
  7354. data["cainfo"] = miConfig.Cainfo
  7355. var ids []int64
  7356. for _, item := range prescriptions {
  7357. ids = append(ids, item.ID)
  7358. }
  7359. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7360. if config.IsOpen == 1 { //对接了医保,走医保流程
  7361. var res ResultFour
  7362. var resFour10265 ResultFour10265
  7363. if miConfig.MdtrtareaAdmvs == "421300" {
  7364. bytesData, _ := json.Marshal(data)
  7365. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7366. resp, _ := client.Do(req)
  7367. defer resp.Body.Close()
  7368. body, ioErr := ioutil.ReadAll(resp.Body)
  7369. if ioErr != nil {
  7370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7372. return
  7373. }
  7374. var respJSON map[string]interface{}
  7375. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7378. return
  7379. }
  7380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7381. userJSONBytes, _ := json.Marshal(respJSON)
  7382. fmt.Println("log")
  7383. fmt.Println(string(userJSONBytes))
  7384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7385. utils.ErrorLog("解析失败:%v", err)
  7386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7387. return
  7388. }
  7389. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7390. bytesData, _ := json.Marshal(data)
  7391. var req *http.Request
  7392. if miConfig.MdtrtareaAdmvs == "320921" {
  7393. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7394. } else {
  7395. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7396. }
  7397. resp, _ := client.Do(req)
  7398. defer resp.Body.Close()
  7399. body, ioErr := ioutil.ReadAll(resp.Body)
  7400. if ioErr != nil {
  7401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7403. return
  7404. }
  7405. var respJSON map[string]interface{}
  7406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. return
  7410. }
  7411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7412. userJSONBytes, _ := json.Marshal(respJSON)
  7413. fmt.Println("log")
  7414. fmt.Println(string(userJSONBytes))
  7415. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7416. utils.ErrorLog("解析失败:%v", err)
  7417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7418. return
  7419. }
  7420. res.InfRefmsgid = resFour10265.InfRefmsgid
  7421. res.Output = resFour10265.Output
  7422. res.ErrMsg = resFour10265.ErrMsg
  7423. res.Cainfo = resFour10265.Cainfo
  7424. res.WarnMsg = resFour10265.WarnMsg
  7425. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7426. res.Infcode = infocode
  7427. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7428. result, request_log, _ := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  7429. var dat map[string]interface{}
  7430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7431. fmt.Println(dat)
  7432. } else {
  7433. fmt.Println(err)
  7434. }
  7435. saveLog(result, request_log, "2204", "上传费用明细")
  7436. userJSONBytes, _ := json.Marshal(dat)
  7437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7438. utils.ErrorLog("解析失败:%v", err)
  7439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7440. return
  7441. }
  7442. } else {
  7443. if miConfig.Code == "H15049901371" {
  7444. 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)
  7445. var dat map[string]interface{}
  7446. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7447. fmt.Println(dat)
  7448. } else {
  7449. fmt.Println(err)
  7450. }
  7451. saveLog(result, request_log, "2204", "上传费用明细")
  7452. userJSONBytes, _ := json.Marshal(dat)
  7453. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7454. utils.ErrorLog("解析失败:%v", err)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. res.InfRefmsgid = resFour10265.InfRefmsgid
  7459. res.Output = resFour10265.Output
  7460. res.ErrMsg = resFour10265.ErrMsg
  7461. res.Cainfo = resFour10265.Cainfo
  7462. res.WarnMsg = resFour10265.WarnMsg
  7463. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7464. res.Infcode = infocode
  7465. } else {
  7466. 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)
  7467. var dat map[string]interface{}
  7468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7469. fmt.Println(dat)
  7470. } else {
  7471. fmt.Println(err)
  7472. }
  7473. saveLog(result, request_log, "2204", "上传费用明细")
  7474. userJSONBytes, _ := json.Marshal(dat)
  7475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7476. utils.ErrorLog("解析失败:%v", err)
  7477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7478. return
  7479. }
  7480. }
  7481. }
  7482. if res.Infcode == 0 {
  7483. order := &models.HisOrder{
  7484. UserOrgId: adminUser.CurrentOrgId,
  7485. HisPatientId: his.ID,
  7486. PatientId: his.PatientId,
  7487. SettleAccountsDate: recordDateTime,
  7488. Ctime: time.Now().Unix(),
  7489. Mtime: time.Now().Unix(),
  7490. MdtrtId: his.Number,
  7491. PsnNo: his.PsnNo,
  7492. MedType: strconv.FormatInt(reg_type, 10),
  7493. Status: 1,
  7494. Number: chrg_bchno,
  7495. Infcode: res.Infcode,
  7496. WarnMsg: res.WarnMsg,
  7497. Cainfo: res.Cainfo,
  7498. ErrMsg: res.ErrMsg,
  7499. RespondTime: res.RefmsgTime,
  7500. InfRefmsgid: res.InfRefmsgid,
  7501. OrderStatus: 1,
  7502. IsMedicineInsurance: 1,
  7503. SettleType: settle_accounts_type,
  7504. SettleStartTime: start_time,
  7505. SettleEndTime: end_time,
  7506. Creator: roles.AdminUserId,
  7507. Modify: roles.AdminUserId,
  7508. PType: 2,
  7509. Diagnosis: diagnosis_id,
  7510. }
  7511. err = service.CreateOrder(order)
  7512. if err != nil {
  7513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7514. return
  7515. }
  7516. for _, item := range res.Output.Result {
  7517. temp := strings.Split(item.FeedetlSn, "-")
  7518. var advice_id int64 = 0
  7519. var project_id int64 = 0
  7520. var types int64 = 0
  7521. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7522. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7523. if temp[1] == "1" {
  7524. advice_id = id
  7525. project_id = 0
  7526. } else if temp[1] == "2" {
  7527. advice_id = 0
  7528. project_id = id
  7529. }
  7530. info := &models.HisOrderInfo{
  7531. OrderNumber: order.Number,
  7532. FeedetlSn: item.FeedetlSn,
  7533. UploadDate: time.Now().Unix(),
  7534. AdviceId: advice_id,
  7535. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7536. Cnt: item.Cnt,
  7537. Pric: float64(item.Pric),
  7538. PatientId: his.PatientId,
  7539. PricUplmtAmt: item.PricUplmtAmt,
  7540. SelfpayProp: item.SelfpayProp,
  7541. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7542. OverlmtAmt: item.OverlmtAmt,
  7543. PreselfpayAmt: item.PreselfpayAmt,
  7544. BasMednFlag: item.BasMednFlag,
  7545. MedChrgitmType: item.MedChrgitmType,
  7546. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7547. Status: 1,
  7548. Memo: item.Memo,
  7549. Mtime: time.Now().Unix(),
  7550. InscpScpAmt: item.InscpScpAmt,
  7551. DrtReimFlag: item.DrtReimFlag,
  7552. Ctime: time.Now().Unix(),
  7553. ListSpItemFlag: item.ListSpItemFlag,
  7554. ChldMedcFlag: item.ChldMedcFlag,
  7555. LmtUsedFlag: item.LmtUsedFlag,
  7556. ChrgitmLv: item.ChrgitmLv,
  7557. UserOrgId: adminUser.CurrentOrgId,
  7558. HisPatientId: his.ID,
  7559. OrderId: order.ID,
  7560. ProjectId: project_id,
  7561. Type: types,
  7562. }
  7563. service.CreateOrderInfo(info)
  7564. }
  7565. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7566. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7567. var total float64
  7568. for _, item := range prescriptions {
  7569. if item.Type == 1 { //药品
  7570. for _, subItem := range item.HisDoctorAdviceInfo {
  7571. total = total + (subItem.Price * subItem.PrescribingNumber)
  7572. }
  7573. }
  7574. if item.Type == 2 { //项目
  7575. for _, subItem := range item.HisPrescriptionProject {
  7576. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7577. total = total + (subItem.Price * cnt)
  7578. }
  7579. }
  7580. }
  7581. for _, item := range prescriptions {
  7582. for _, subItem := range item.HisAdditionalCharge {
  7583. total = total + (subItem.Price * float64(subItem.Count))
  7584. }
  7585. }
  7586. allTotal := fmt.Sprintf("%.4f", total)
  7587. if res.Infcode == 0 {
  7588. var rf []*ResultFive
  7589. json.Unmarshal([]byte(his.Iinfo), &rf)
  7590. chrg_bchno := chrg_bchno
  7591. cert_no := his.Certno
  7592. var insutypes []string
  7593. var insutype string
  7594. var is390 int = 0
  7595. var is310 int = 0
  7596. for _, item := range rf {
  7597. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7598. insutypes = append(insutypes, item.Insutype)
  7599. }
  7600. }
  7601. if len(insutypes) == 1 {
  7602. insutype = insutypes[0]
  7603. } else {
  7604. for _, i := range insutypes {
  7605. if i == "390" {
  7606. is390 = 1
  7607. }
  7608. if i == "310" {
  7609. is310 = 1
  7610. }
  7611. }
  7612. }
  7613. if is390 == 1 {
  7614. insutype = "390"
  7615. }
  7616. if is310 == 1 {
  7617. insutype = "310"
  7618. }
  7619. if len(insutypes) == 0 {
  7620. insutype = "310"
  7621. }
  7622. if len(insutypes) == 2 {
  7623. insutype = strconv.FormatInt(his.SocialType, 64)
  7624. }
  7625. //insutype = "390"
  7626. if his.IdCardType == 1 {
  7627. cert_no = his.MedicalInsuranceNumber
  7628. } else {
  7629. cert_no = his.Certno
  7630. }
  7631. var res ResultSeven
  7632. var resSeven10265 ResultSeven10265
  7633. if miConfig.MdtrtareaAdmvs == "421300" {
  7634. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7635. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7636. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7638. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7639. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7640. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7641. resp, requestErr := http.Get(api)
  7642. if requestErr != nil {
  7643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7644. return
  7645. }
  7646. body, ioErr := ioutil.ReadAll(resp.Body)
  7647. if ioErr != nil {
  7648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7650. return
  7651. }
  7652. var respJSON map[string]interface{}
  7653. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7659. result, _ := json.Marshal(respJSON)
  7660. fmt.Println("log")
  7661. fmt.Println(string(result))
  7662. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7663. utils.ErrorLog("解析失败:%v", err)
  7664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7665. return
  7666. }
  7667. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7668. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7669. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7670. bas := strings.Split(psn_info.CardInfo, "|")
  7671. if his.IdCardType == 1 {
  7672. cert_no = bas[2]
  7673. } else {
  7674. cert_no = bas[1]
  7675. }
  7676. //江苏地区国家医保医疗类别
  7677. //职工透析:医疗类别选特殊情况门诊9933
  7678. //居民血透门慢: 医疗类别选门诊慢病1402
  7679. //var med_type string
  7680. //if his.Insutype == "310" {
  7681. // if reg_type == 14 {
  7682. // med_type = "9933"
  7683. // } else if reg_type == 11 {
  7684. // med_type = "11"
  7685. //
  7686. // }
  7687. //} else if his.Insutype == "390" {
  7688. // if reg_type == 14 {
  7689. // med_type = "1402"
  7690. // } else if reg_type == 11 {
  7691. // med_type = "11"
  7692. // }
  7693. //}
  7694. var api string
  7695. if miConfig.MdtrtareaAdmvs == "320921" {
  7696. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7697. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7698. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7699. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7700. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7701. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7702. "&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
  7703. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7704. } else {
  7705. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7706. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7707. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7708. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7710. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7711. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7712. "&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
  7713. }
  7714. resp, requestErr := http.Get(api)
  7715. if requestErr != nil {
  7716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7717. return
  7718. }
  7719. body, ioErr := ioutil.ReadAll(resp.Body)
  7720. if ioErr != nil {
  7721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7723. return
  7724. }
  7725. var respJSON map[string]interface{}
  7726. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7729. return
  7730. }
  7731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7732. result, _ := json.Marshal(respJSON)
  7733. fmt.Println("log")
  7734. fmt.Println(string(result))
  7735. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7736. utils.ErrorLog("解析失败:%v", err)
  7737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7738. return
  7739. }
  7740. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7741. res.Output = resSeven10265.Output
  7742. res.ErrMsg = resSeven10265.ErrMsg
  7743. res.Cainfo = resSeven10265.Cainfo
  7744. res.WarnMsg = resSeven10265.WarnMsg
  7745. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7746. res.Infcode = infocode
  7747. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7748. result, request_log, _ := service.FJyb2206(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7749. var dat map[string]interface{}
  7750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7751. fmt.Println(dat)
  7752. } else {
  7753. fmt.Println(err)
  7754. }
  7755. saveLog(result, request_log, "2206", "预结算")
  7756. userJSONBytes, _ := json.Marshal(dat)
  7757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7758. utils.ErrorLog("解析失败:%v", err)
  7759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7760. return
  7761. }
  7762. } else {
  7763. var result string
  7764. var request_log string
  7765. if miConfig.Code == "H15049901371" {
  7766. //赤峰地区国家医保医疗类别
  7767. //职工透析:医疗类别选特殊情况门诊990502
  7768. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7769. var med_type string
  7770. if his.Insutype == "390" {
  7771. if reg_type == 14 {
  7772. med_type = "9933"
  7773. } else if reg_type == 11 {
  7774. med_type = "11"
  7775. }
  7776. } else if his.Insutype == "310" {
  7777. if reg_type == 14 {
  7778. med_type = "990502"
  7779. } else if reg_type == 11 {
  7780. med_type = "11"
  7781. }
  7782. }
  7783. 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)
  7784. } else {
  7785. 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)
  7786. }
  7787. var dat map[string]interface{}
  7788. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7789. fmt.Println(dat)
  7790. } else {
  7791. fmt.Println(err)
  7792. }
  7793. saveLog(result, request_log, "2206", "预结算")
  7794. //userJSONBytes, _ := json.Marshal(dat)
  7795. //
  7796. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7797. // utils.ErrorLog("解析失败:%v", err)
  7798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. // return
  7800. //}
  7801. userJSONBytes, _ := json.Marshal(dat)
  7802. if miConfig.Code == "H15049901371" {
  7803. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7804. utils.ErrorLog("解析失败:%v", err)
  7805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. return
  7807. }
  7808. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7809. res.Output = resSeven10265.Output
  7810. res.ErrMsg = resSeven10265.ErrMsg
  7811. res.Cainfo = resSeven10265.Cainfo
  7812. res.WarnMsg = resSeven10265.WarnMsg
  7813. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7814. res.Infcode = infocode
  7815. } else {
  7816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7817. utils.ErrorLog("解析失败:%v", err)
  7818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7819. return
  7820. }
  7821. }
  7822. }
  7823. if res.Infcode != 0 {
  7824. errlog := &models.HisOrderError{
  7825. UserOrgId: adminUser.CurrentOrgId,
  7826. Ctime: time.Now().Unix(),
  7827. Mtime: time.Now().Unix(),
  7828. Number: chrg_bchno,
  7829. ErrMsg: res.ErrMsg,
  7830. Status: 1,
  7831. PatientId: id,
  7832. RecordTime: recordDateTime,
  7833. Stage: 20,
  7834. }
  7835. service.CreateErrMsgLog(errlog)
  7836. c.ServeSuccessJSON(map[string]interface{}{
  7837. "failed_code": -10,
  7838. "msg": res.ErrMsg,
  7839. })
  7840. return
  7841. } else {
  7842. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7843. order.OrderStatus = 1
  7844. order.IsPre = 1
  7845. order.Status = 1
  7846. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7847. order.SetlId = res.Output.Setlinfo.SetlID
  7848. order.PsnNo = res.Output.Setlinfo.PsnNo
  7849. order.PsnName = res.Output.Setlinfo.PsnName
  7850. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7851. order.Certno = res.Output.Setlinfo.Certno
  7852. order.Gend = res.Output.Setlinfo.Gend
  7853. order.Naty = res.Output.Setlinfo.Naty
  7854. order.Age = res.Output.Setlinfo.Age
  7855. order.Insutype = res.Output.Setlinfo.Insutype
  7856. order.PsnType = res.Output.Setlinfo.PsnType
  7857. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7858. order.SetlTime = res.Output.Setlinfo.SetlTime
  7859. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7860. if res.Output.Setlinfo.MedType == "140101" {
  7861. order.MedType = "14"
  7862. } else {
  7863. order.MedType = res.Output.Setlinfo.MedType
  7864. }
  7865. if reg_type == 1112 {
  7866. order.MedType = "1112"
  7867. }
  7868. if reg_type == 1111 {
  7869. order.MedType = "1111"
  7870. }
  7871. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7872. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7873. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7874. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7875. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7876. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7877. order.HifpPay = res.Output.Setlinfo.HifpPay
  7878. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7879. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7880. order.HifesPay = res.Output.Setlinfo.HifesPay
  7881. order.HifobPay = res.Output.Setlinfo.HifobPay
  7882. order.MafPay = res.Output.Setlinfo.MafPay
  7883. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7884. order.OthPay = res.Output.Setlinfo.OthPay
  7885. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7886. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7887. order.AcctPay = res.Output.Setlinfo.AcctPay
  7888. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7889. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7890. order.Balc = res.Output.Setlinfo.Balc
  7891. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7892. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7893. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7894. order.ClrWay = res.Output.Setlinfo.ClrWay
  7895. order.Creator = order.Creator
  7896. order.Modify = roles.AdminUserId
  7897. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7898. detailStr := string(setlDetail)
  7899. order.SetlDetail = detailStr
  7900. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7901. err = service.UpDateOrder(order)
  7902. if err == nil {
  7903. c.ServeSuccessJSON(map[string]interface{}{
  7904. "msg": "预结算成功",
  7905. })
  7906. } else {
  7907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7908. return
  7909. }
  7910. }
  7911. } else {
  7912. adminUser := c.GetAdminUserInfo()
  7913. errlog := &models.HisOrderError{
  7914. UserOrgId: adminUser.CurrentOrgId,
  7915. Ctime: time.Now().Unix(),
  7916. Mtime: time.Now().Unix(),
  7917. ErrMsg: res.ErrMsg,
  7918. Status: 1,
  7919. PatientId: id,
  7920. RecordTime: recordDateTime,
  7921. Stage: 4,
  7922. }
  7923. service.CreateErrMsgLog(errlog)
  7924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7925. return
  7926. }
  7927. } else {
  7928. adminUser := c.GetAdminUserInfo()
  7929. errlog := &models.HisOrderError{
  7930. UserOrgId: adminUser.CurrentOrgId,
  7931. Ctime: time.Now().Unix(),
  7932. Mtime: time.Now().Unix(),
  7933. ErrMsg: res.ErrMsg,
  7934. Status: 1,
  7935. PatientId: id,
  7936. RecordTime: recordDateTime,
  7937. Stage: 4,
  7938. }
  7939. service.CreateErrMsgLog(errlog)
  7940. c.ServeSuccessJSON(map[string]interface{}{
  7941. "failed_code": -10,
  7942. "msg": res.ErrMsg,
  7943. })
  7944. return
  7945. }
  7946. }
  7947. }
  7948. }
  7949. //退款
  7950. func (c *HisApiController) Refund() {
  7951. order_id, _ := c.GetInt64("order_id")
  7952. admin_user_id, _ := c.GetInt64("admin_user_id")
  7953. adminUser := c.GetAdminUserInfo()
  7954. var order models.HisOrder
  7955. order, _ = service.GetHisOrderByID(order_id)
  7956. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7957. if order.ID == 0 {
  7958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7959. return
  7960. }
  7961. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7962. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7963. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7964. if config.IsOpen == 1 { //对接了医保,走医保流程
  7965. var res ResultSixteen
  7966. var resSixteen10265 ResultSixteen10265
  7967. var src_resquest string
  7968. var result string
  7969. if miConfig.MdtrtareaAdmvs == "421300" {
  7970. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7971. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7972. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7973. resp3, requestErr3 := http.Get(api3)
  7974. if requestErr3 != nil {
  7975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7976. return
  7977. }
  7978. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7979. if ioErr3 != nil {
  7980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. var respJSON3 map[string]interface{}
  7985. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7991. userJSONBytes3, _ := json.Marshal(respJSON3)
  7992. fmt.Println("log")
  7993. fmt.Println(string(userJSONBytes3))
  7994. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7995. utils.ErrorLog("解析失败:%v", err)
  7996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7997. return
  7998. }
  7999. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8000. var api3 string
  8001. if miConfig.MdtrtareaAdmvs == "320921" {
  8002. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8003. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8004. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8005. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8006. } else {
  8007. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8008. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8009. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8010. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8011. }
  8012. resp3, requestErr3 := http.Get(api3)
  8013. if requestErr3 != nil {
  8014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8015. return
  8016. }
  8017. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8018. if ioErr3 != nil {
  8019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8021. return
  8022. }
  8023. var respJSON3 map[string]interface{}
  8024. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8027. return
  8028. }
  8029. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8030. userJSONBytes3, _ := json.Marshal(respJSON3)
  8031. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8032. utils.ErrorLog("解析失败:%v", err)
  8033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8034. return
  8035. }
  8036. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8037. res.Output = resSixteen10265.Output
  8038. res.ErrMsg = resSixteen10265.ErrMsg
  8039. res.Cainfo = resSixteen10265.Cainfo
  8040. res.WarnMsg = resSixteen10265.WarnMsg
  8041. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8042. res.Infcode = infocode
  8043. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8044. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8045. var dat map[string]interface{}
  8046. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8047. fmt.Println(dat)
  8048. } else {
  8049. fmt.Println(err)
  8050. }
  8051. saveLog(result, src_resquest, "2208", "退费")
  8052. userJSONBytes, _ := json.Marshal(dat)
  8053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8054. utils.ErrorLog("解析失败:%v", err)
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. } else {
  8059. if miConfig.Code == "H15049901371" {
  8060. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8061. var dat map[string]interface{}
  8062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8063. fmt.Println(dat)
  8064. } else {
  8065. fmt.Println(err)
  8066. }
  8067. saveLog(result, src_resquest, "2208", "退费")
  8068. userJSONBytes, _ := json.Marshal(dat)
  8069. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8070. utils.ErrorLog("解析失败:%v", err)
  8071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8072. return
  8073. }
  8074. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8075. res.Output = resSixteen10265.Output
  8076. res.ErrMsg = resSixteen10265.ErrMsg
  8077. res.Cainfo = resSixteen10265.Cainfo
  8078. res.WarnMsg = resSixteen10265.WarnMsg
  8079. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8080. res.Infcode = infocode
  8081. } else {
  8082. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8083. var dat map[string]interface{}
  8084. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8085. fmt.Println(dat)
  8086. } else {
  8087. fmt.Println(err)
  8088. }
  8089. saveLog(result, src_resquest, "2208", "退费")
  8090. userJSONBytes, _ := json.Marshal(dat)
  8091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8092. utils.ErrorLog("解析失败:%v", err)
  8093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8094. return
  8095. }
  8096. }
  8097. }
  8098. if res.Infcode == 0 {
  8099. var res2 ResultSix
  8100. var resSix10265 ResultSix10265
  8101. if miConfig.MdtrtareaAdmvs == "421300" {
  8102. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8103. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8104. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8105. resp3, requestErr3 := http.Get(api3)
  8106. if requestErr3 != nil {
  8107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8108. return
  8109. }
  8110. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8111. if ioErr3 != nil {
  8112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8114. return
  8115. }
  8116. var respJSON3 map[string]interface{}
  8117. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8120. return
  8121. }
  8122. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8123. userJSONBytes3, _ := json.Marshal(respJSON3)
  8124. fmt.Println("log")
  8125. fmt.Println(string(userJSONBytes3))
  8126. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8127. utils.ErrorLog("解析失败:%v", err)
  8128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8129. return
  8130. }
  8131. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8132. var api3 string
  8133. if miConfig.MdtrtareaAdmvs == "320921" {
  8134. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8135. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8136. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8137. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8138. } else {
  8139. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8140. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8141. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8142. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8143. }
  8144. resp3, requestErr3 := http.Get(api3)
  8145. if requestErr3 != nil {
  8146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8147. return
  8148. }
  8149. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8150. if ioErr3 != nil {
  8151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8153. return
  8154. }
  8155. var respJSON3 map[string]interface{}
  8156. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8159. return
  8160. }
  8161. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8162. userJSONBytes3, _ := json.Marshal(respJSON3)
  8163. fmt.Println("log")
  8164. fmt.Println(string(userJSONBytes3))
  8165. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8166. utils.ErrorLog("解析失败:%v", err)
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8171. res2.Output = resSix10265.Output
  8172. res2.ErrMsg = resSix10265.ErrMsg
  8173. res2.Cainfo = resSix10265.Cainfo
  8174. res2.WarnMsg = resSix10265.WarnMsg
  8175. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8176. res2.Infcode = infocode
  8177. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8178. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8179. var dat map[string]interface{}
  8180. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8181. fmt.Println(dat)
  8182. } else {
  8183. fmt.Println(err)
  8184. }
  8185. saveLog(result2, src_request, "2205", "撤销明细")
  8186. userJSONBytes, _ := json.Marshal(dat)
  8187. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8188. utils.ErrorLog("解析失败:%v", err)
  8189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8190. return
  8191. }
  8192. } else {
  8193. if miConfig.Code == "H15049901371" {
  8194. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8195. var dat map[string]interface{}
  8196. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8197. fmt.Println(dat)
  8198. } else {
  8199. fmt.Println(err)
  8200. }
  8201. saveLog(result2, src_request, "2205", "撤销明细")
  8202. userJSONBytes, _ := json.Marshal(dat)
  8203. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8204. utils.ErrorLog("解析失败:%v", err)
  8205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8206. return
  8207. }
  8208. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8209. res2.Output = resSix10265.Output
  8210. res2.ErrMsg = resSix10265.ErrMsg
  8211. res2.Cainfo = resSix10265.Cainfo
  8212. res2.WarnMsg = resSix10265.WarnMsg
  8213. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8214. res2.Infcode = infocode
  8215. } else {
  8216. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8217. var dat map[string]interface{}
  8218. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8219. fmt.Println(dat)
  8220. } else {
  8221. fmt.Println(err)
  8222. }
  8223. saveLog(result2, src_request, "2205", "撤销明细")
  8224. userJSONBytes, _ := json.Marshal(dat)
  8225. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8226. utils.ErrorLog("解析失败:%v", err)
  8227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8228. return
  8229. }
  8230. }
  8231. }
  8232. if res2.Infcode == 0 {
  8233. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8234. if err == nil {
  8235. //当押金不为零时产生退费记录
  8236. if order.Decimal != 0 {
  8237. tmp := strconv.FormatInt(order.ID, 10)
  8238. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8239. if err != nil {
  8240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8241. return
  8242. }
  8243. }
  8244. c.ServeSuccessJSON(map[string]interface{}{
  8245. "msg": "退费成功",
  8246. })
  8247. } else {
  8248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8249. return
  8250. }
  8251. } else {
  8252. c.ServeSuccessJSON(map[string]interface{}{
  8253. "code": -10,
  8254. "msg": res2.ErrMsg,
  8255. })
  8256. }
  8257. } else {
  8258. c.ServeSuccessJSON(map[string]interface{}{
  8259. "code": -10,
  8260. "msg": res.ErrMsg,
  8261. })
  8262. }
  8263. }
  8264. }
  8265. func (c *HisApiController) RefundNumber() {
  8266. record_time := c.GetString("record_time")
  8267. //patient_id, _ := c.GetInt64("patient_id")
  8268. admin_user_id, _ := c.GetInt64("admin_user_id")
  8269. his_patient_id, _ := c.GetInt64("id")
  8270. timeLayout := "2006-01-02"
  8271. loc, _ := time.LoadLocation("Local")
  8272. adminUser := c.GetAdminUserInfo()
  8273. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8274. fmt.Println(err)
  8275. if err != nil {
  8276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8277. return
  8278. }
  8279. recordDateTime := theTime.Unix()
  8280. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8281. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8282. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8283. //order, _ := service.GetHisOrderByID(order_id)
  8284. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8285. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8286. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8287. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8288. if count > 0 {
  8289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8290. return
  8291. }
  8292. if config.IsOpen == 1 { //对接了医保,走医保流程
  8293. var res2 ResultSix
  8294. var resSix10265 ResultSix10265
  8295. if miConfig.MdtrtareaAdmvs == "421300" {
  8296. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8297. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8298. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8299. resp3, requestErr3 := http.Get(api3)
  8300. if requestErr3 != nil {
  8301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8302. return
  8303. }
  8304. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8305. if ioErr3 != nil {
  8306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8308. return
  8309. }
  8310. var respJSON3 map[string]interface{}
  8311. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8314. return
  8315. }
  8316. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8317. userJSONBytes3, _ := json.Marshal(respJSON3)
  8318. fmt.Println("log")
  8319. fmt.Println(string(userJSONBytes3))
  8320. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8321. utils.ErrorLog("解析失败:%v", err)
  8322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8323. return
  8324. }
  8325. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8326. var api3 string
  8327. if miConfig.MdtrtareaAdmvs == "320921" {
  8328. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8329. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8330. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8331. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8332. } else {
  8333. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8334. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8335. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8336. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8337. }
  8338. resp3, requestErr3 := http.Get(api3)
  8339. if requestErr3 != nil {
  8340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8341. return
  8342. }
  8343. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8344. if ioErr3 != nil {
  8345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8347. return
  8348. }
  8349. var respJSON3 map[string]interface{}
  8350. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8353. return
  8354. }
  8355. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8356. userJSONBytes3, _ := json.Marshal(respJSON3)
  8357. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8358. utils.ErrorLog("解析失败:%v", err)
  8359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8360. return
  8361. }
  8362. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8363. res2.Output = resSix10265.Output
  8364. res2.ErrMsg = resSix10265.ErrMsg
  8365. res2.Cainfo = resSix10265.Cainfo
  8366. res2.WarnMsg = resSix10265.WarnMsg
  8367. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8368. res2.Infcode = infocode
  8369. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8370. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8371. var dat map[string]interface{}
  8372. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8373. fmt.Println(dat)
  8374. } else {
  8375. fmt.Println(err)
  8376. }
  8377. saveLog(result, request, "2202", "退号")
  8378. userJSONBytes, _ := json.Marshal(dat)
  8379. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8380. utils.ErrorLog("解析失败:%v", err)
  8381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8382. return
  8383. }
  8384. } else {
  8385. var api3 string
  8386. if miConfig.Code == "H15049901371" {
  8387. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8388. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8389. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8390. } else {
  8391. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8392. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8393. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8394. }
  8395. resp3, requestErr3 := http.Get(api3)
  8396. if requestErr3 != nil {
  8397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8398. return
  8399. }
  8400. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8401. if ioErr3 != nil {
  8402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. return
  8405. }
  8406. var respJSON3 map[string]interface{}
  8407. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8410. return
  8411. }
  8412. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8413. userJSONBytes3, _ := json.Marshal(respJSON3)
  8414. if miConfig.Code == "H15049901371" {
  8415. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8416. utils.ErrorLog("解析失败:%v", err)
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. return
  8419. }
  8420. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8421. res2.Output = resSix10265.Output
  8422. res2.ErrMsg = resSix10265.ErrMsg
  8423. res2.Cainfo = resSix10265.Cainfo
  8424. res2.WarnMsg = resSix10265.WarnMsg
  8425. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8426. res2.Infcode = infocode
  8427. } else {
  8428. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8429. utils.ErrorLog("解析失败:%v", err)
  8430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8431. return
  8432. }
  8433. }
  8434. }
  8435. if res2.Infcode == 0 {
  8436. if err == nil {
  8437. c.ServeSuccessJSON(map[string]interface{}{
  8438. "msg": "退号成功",
  8439. })
  8440. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8441. } else {
  8442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8443. return
  8444. }
  8445. } else {
  8446. c.ServeSuccessJSON(map[string]interface{}{
  8447. "code": -10,
  8448. "msg": res2.ErrMsg,
  8449. })
  8450. }
  8451. } else {
  8452. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8453. //if err == nil {
  8454. // c.ServeSuccessJSON(map[string]interface{}{
  8455. // "msg": "退费成功",
  8456. // })
  8457. //} else {
  8458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8459. // return
  8460. //}
  8461. }
  8462. }
  8463. func (c *HisApiController) RefundDetail() {
  8464. order_id, _ := c.GetInt64("order_id")
  8465. admin_user_id, _ := c.GetInt64("admin_user_id")
  8466. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8467. number := c.GetString("number")
  8468. record_time := c.GetString("record_time")
  8469. patient_id, _ := c.GetInt64("patient_id")
  8470. //med_type, _ := c.GetInt64("med_type")
  8471. timeLayout := "2006-01-02"
  8472. loc, _ := time.LoadLocation("Local")
  8473. adminUser := c.GetAdminUserInfo()
  8474. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8475. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8476. fmt.Println(err)
  8477. if err != nil {
  8478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8479. return
  8480. }
  8481. recordDateTime := theTime.Unix()
  8482. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8483. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8484. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8485. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8486. var order models.HisOrder
  8487. order, _ = service.GetHisOrderByID(order_id)
  8488. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8489. if config.IsOpen == 1 { //对接了医保,走医保流程
  8490. var res2 ResultSix
  8491. if miConfig.MdtrtareaAdmvs == "421300" {
  8492. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8493. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8495. resp3, requestErr3 := http.Get(api3)
  8496. if requestErr3 != nil {
  8497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8498. return
  8499. }
  8500. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8501. if ioErr3 != nil {
  8502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8504. return
  8505. }
  8506. var respJSON3 map[string]interface{}
  8507. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8510. return
  8511. }
  8512. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8513. userJSONBytes3, _ := json.Marshal(respJSON3)
  8514. fmt.Println("log")
  8515. fmt.Println(string(userJSONBytes3))
  8516. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8517. utils.ErrorLog("解析失败:%v", err)
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8522. if err == nil {
  8523. c.ServeSuccessJSON(map[string]interface{}{
  8524. "msg": "撤销明细成功",
  8525. })
  8526. return
  8527. } else {
  8528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8529. return
  8530. }
  8531. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8532. var resSix10265 ResultSix10265
  8533. var api3 string
  8534. if miConfig.MdtrtareaAdmvs == "320921" {
  8535. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8536. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8537. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8538. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8539. } else {
  8540. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8541. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8542. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8543. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8544. }
  8545. resp3, requestErr3 := http.Get(api3)
  8546. if requestErr3 != nil {
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8551. if ioErr3 != nil {
  8552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8554. return
  8555. }
  8556. var respJSON3 map[string]interface{}
  8557. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8560. return
  8561. }
  8562. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8563. userJSONBytes3, _ := json.Marshal(respJSON3)
  8564. fmt.Println("log")
  8565. fmt.Println(string(userJSONBytes3))
  8566. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8567. utils.ErrorLog("解析失败:%v", err)
  8568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8569. return
  8570. }
  8571. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8572. res2.Output = resSix10265.Output
  8573. res2.ErrMsg = resSix10265.ErrMsg
  8574. res2.Cainfo = resSix10265.Cainfo
  8575. res2.WarnMsg = resSix10265.WarnMsg
  8576. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8577. res2.Infcode = infocode
  8578. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8579. if err == nil {
  8580. c.ServeSuccessJSON(map[string]interface{}{
  8581. "msg": "撤销明细成功",
  8582. })
  8583. return
  8584. } else {
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8586. return
  8587. }
  8588. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8589. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8590. var dat map[string]interface{}
  8591. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8592. fmt.Println(dat)
  8593. } else {
  8594. fmt.Println(err)
  8595. }
  8596. saveLog(result2, src_request, "2205", "撤销明细")
  8597. userJSONBytes, _ := json.Marshal(dat)
  8598. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8599. utils.ErrorLog("解析失败:%v", err)
  8600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8601. return
  8602. }
  8603. if res2.Infcode == 0 {
  8604. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8605. if err == nil {
  8606. c.ServeSuccessJSON(map[string]interface{}{
  8607. "msg": "撤销明细成功",
  8608. })
  8609. return
  8610. } else {
  8611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8612. return
  8613. }
  8614. } else {
  8615. c.ServeSuccessJSON(map[string]interface{}{
  8616. "code": -10,
  8617. "msg": res2.ErrMsg,
  8618. })
  8619. }
  8620. } else {
  8621. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8622. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8624. resp2, requestErr2 := http.Get(api2)
  8625. if requestErr2 != nil {
  8626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8627. return
  8628. }
  8629. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8630. if ioErr2 != nil {
  8631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8633. return
  8634. }
  8635. var respJSON2 map[string]interface{}
  8636. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8639. return
  8640. }
  8641. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8642. if err == nil {
  8643. c.ServeSuccessJSON(map[string]interface{}{
  8644. "msg": "撤销明细成功",
  8645. })
  8646. return
  8647. } else {
  8648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8649. return
  8650. }
  8651. }
  8652. } else {
  8653. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8654. if err == nil {
  8655. c.ServeSuccessJSON(map[string]interface{}{
  8656. "msg": "退费成功",
  8657. })
  8658. } else {
  8659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8660. return
  8661. }
  8662. }
  8663. }
  8664. //对账
  8665. func (c *HisApiController) GetCheckAccount() {
  8666. start_time := c.GetString("start_time")
  8667. end_time := c.GetString("end_time")
  8668. insutype := c.GetString("insutype")
  8669. clr_type := c.GetString("clr_type")
  8670. clr_org := c.GetString("clr_optins")
  8671. admin_user_id, _ := c.GetInt64("admin_user_id")
  8672. adminUser := c.GetAdminUserInfo()
  8673. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8674. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8675. if len(clr_org) == 0 {
  8676. clr_org = miConfig.MdtrtareaAdmvs
  8677. }
  8678. timeLayout := "2006-01-02"
  8679. loc, _ := time.LoadLocation("Local")
  8680. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8681. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8682. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8683. fixmedins_setl_cnt := int64(len(orders))
  8684. var medfee_sumamt float64
  8685. var acct_pay float64
  8686. var fund_pay_sumamt float64
  8687. for _, item := range orders {
  8688. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8689. acct_pay = acct_pay + item.AcctPay
  8690. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8691. }
  8692. var user_name string
  8693. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8694. if role.ID == 0 {
  8695. user_name = "xxx"
  8696. } else {
  8697. user_name = role.UserName
  8698. }
  8699. var res ResultEight
  8700. var res10188 ResultEightFor10188
  8701. if config.IsOpen == 1 {
  8702. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8703. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8704. "insutype=" + insutype +
  8705. "&clr_type=" + clr_type +
  8706. "&setl_optins=" + clr_org +
  8707. "&stmt_begndate=" + start_time +
  8708. "&stm_enddate=" + end_time +
  8709. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8710. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8711. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8712. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8713. "&fixmedins_code=" + miConfig.Code +
  8714. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8715. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8716. "&secret_key=" + miConfig.SecretKey +
  8717. "&org_name=" + miConfig.OrgName +
  8718. "&doctor=" + user_name +
  8719. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8720. fmt.Println(api)
  8721. resp, requestErr := http.Get(api)
  8722. if requestErr != nil {
  8723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8724. return
  8725. }
  8726. body, ioErr := ioutil.ReadAll(resp.Body)
  8727. fmt.Println(body)
  8728. if ioErr != nil {
  8729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8731. return
  8732. }
  8733. var respJSON map[string]interface{}
  8734. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8737. return
  8738. }
  8739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8740. userJSONBytes, _ := json.Marshal(respJSON)
  8741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8742. utils.ErrorLog("解析失败:%v", err)
  8743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8744. return
  8745. }
  8746. res.InfRefmsgid = res10188.InfRefmsgid
  8747. res.Output = res10188.Output
  8748. res.ErrMsg = res10188.ErrMsg
  8749. res.Cainfo = res10188.Cainfo
  8750. res.WarnMsg = res10188.WarnMsg
  8751. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8752. res.Infcode = infocode
  8753. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8754. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8755. "insutype=" + insutype +
  8756. "&clr_type=" + clr_type +
  8757. "&setl_optins=" + clr_org +
  8758. "&stmt_begndate=" + start_time +
  8759. "&stm_enddate=" + end_time +
  8760. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8761. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8762. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8763. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8764. "&fixmedins_code=" + miConfig.Code +
  8765. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8766. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8767. "&secret_key=" + miConfig.SecretKey +
  8768. "&org_name=" + miConfig.OrgName +
  8769. "&doctor=" + user_name
  8770. resp, requestErr := http.Get(api)
  8771. if requestErr != nil {
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. return
  8774. }
  8775. body, ioErr := ioutil.ReadAll(resp.Body)
  8776. if ioErr != nil {
  8777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8779. return
  8780. }
  8781. var respJSON map[string]interface{}
  8782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8785. return
  8786. }
  8787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8788. result, _ := json.Marshal(respJSON)
  8789. fmt.Println("log")
  8790. fmt.Println(string(result))
  8791. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8792. utils.ErrorLog("解析失败:%v", err)
  8793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8794. return
  8795. }
  8796. res.InfRefmsgid = res10188.InfRefmsgid
  8797. res.Output = res10188.Output
  8798. res.ErrMsg = res10188.ErrMsg
  8799. res.Cainfo = res10188.Cainfo
  8800. res.WarnMsg = res10188.WarnMsg
  8801. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8802. res.Infcode = infocode
  8803. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8804. var baseParams models.BaseParams
  8805. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8806. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8807. baseParams.SecretKey = miConfig.SecretKey
  8808. baseParams.OrgName = miConfig.OrgName
  8809. baseParams.EncKey = miConfig.EncKey
  8810. baseParams.AppSecret = miConfig.AppSecret
  8811. baseParams.SignKey = miConfig.SignKey
  8812. baseParams.AppID = miConfig.Code
  8813. baseParams.RequestUrl = miConfig.Url
  8814. businessParams := models.BusinessParams{
  8815. Insutype: insutype,
  8816. ClrType: clr_type,
  8817. SetlOptins: clr_org,
  8818. StmtBegndate: start_time,
  8819. StmtEnddate: end_time,
  8820. MedfeeSumamt: medfee_sumamt,
  8821. FundPaySumamt: fund_pay_sumamt,
  8822. AcctPay: acct_pay,
  8823. FixmedinsSetlCnt: fixmedins_setl_cnt,
  8824. }
  8825. result, requestLog := service.FJyb3201(baseParams, businessParams)
  8826. fmt.Println(requestLog)
  8827. fmt.Println(result)
  8828. } else {
  8829. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8830. "insutype=" + insutype +
  8831. "&clr_type=" + clr_type +
  8832. "&setl_optins=" + clr_org +
  8833. "&stmt_begndate=" + start_time +
  8834. "&stm_enddate=" + end_time +
  8835. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8836. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8837. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8838. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8839. "&fixmedins_code=" + miConfig.Code +
  8840. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8841. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8842. "&secret_key=" + miConfig.SecretKey +
  8843. "&org_name=" + miConfig.OrgName +
  8844. "&doctor=" + user_name
  8845. fmt.Println(api)
  8846. resp, requestErr := http.Get(api)
  8847. if requestErr != nil {
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. body, ioErr := ioutil.ReadAll(resp.Body)
  8852. fmt.Println(body)
  8853. if ioErr != nil {
  8854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8856. return
  8857. }
  8858. var respJSON map[string]interface{}
  8859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8862. return
  8863. }
  8864. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8865. userJSONBytes, _ := json.Marshal(respJSON)
  8866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8867. utils.ErrorLog("解析失败:%v", err)
  8868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8869. return
  8870. }
  8871. }
  8872. if res.Infcode == 0 {
  8873. if res.Output.Stmtinfo.StmtRslt == "0" {
  8874. micc := &models.MedicalInsuranceCostCompare{
  8875. StartTime: startime.Unix(),
  8876. EndTime: endtime.Unix(),
  8877. Insutype: insutype,
  8878. CheckType: 1,
  8879. Num: fixmedins_setl_cnt,
  8880. Mtime: time.Now().Unix(),
  8881. Status: 1,
  8882. UserOrgId: adminUser.CurrentOrgId,
  8883. CostTotal: medfee_sumamt,
  8884. FuncTotal: fund_pay_sumamt,
  8885. PsnPay: acct_pay,
  8886. Creator: admin_user_id,
  8887. Ctime: time.Now().Unix(),
  8888. ClrType: clr_type,
  8889. }
  8890. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8891. if err == nil {
  8892. c.ServeSuccessJSON(map[string]interface{}{
  8893. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8894. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8895. })
  8896. } else {
  8897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8898. }
  8899. } else {
  8900. c.ServeSuccessJSON(map[string]interface{}{
  8901. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8902. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8903. })
  8904. }
  8905. } else {
  8906. c.ServeSuccessJSON(map[string]interface{}{
  8907. "code": -10,
  8908. "msg": res.ErrMsg,
  8909. })
  8910. }
  8911. }
  8912. }
  8913. func (c *HisApiController) Check310() {
  8914. adminUser := c.GetAdminUserInfo()
  8915. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8916. var user_name string
  8917. user_name = "高慧裕"
  8918. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8919. "insutype=" + "310" +
  8920. "&clr_type=" + "" +
  8921. "&setl_optins=" + "441202" +
  8922. "&stmt_begndate=" + "2022-03-01" +
  8923. "&stm_enddate=" + "2022-03-31" +
  8924. "&medfee_sumamt=" + "194930.12" +
  8925. "&fund_pay_sumamt=" + "188741.46" +
  8926. "&acct_pay=" + "0" +
  8927. "&fixmedins_setl_cnt=" + "452" +
  8928. "&fixmedins_code=" + miConfig.Code +
  8929. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8930. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8931. "&secret_key=" + miConfig.SecretKey +
  8932. "&org_name=" + miConfig.OrgName +
  8933. "&doctor=" + user_name
  8934. fmt.Println(api)
  8935. resp, requestErr := http.Get(api)
  8936. if requestErr != nil {
  8937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8938. return
  8939. }
  8940. body, ioErr := ioutil.ReadAll(resp.Body)
  8941. fmt.Println(body)
  8942. if ioErr != nil {
  8943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8945. return
  8946. }
  8947. var respJSON map[string]interface{}
  8948. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8951. return
  8952. }
  8953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8954. userJSONBytes, _ := json.Marshal(respJSON)
  8955. var res ResultEight
  8956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8957. utils.ErrorLog("解析失败:%v", err)
  8958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8959. return
  8960. }
  8961. }
  8962. func (c *HisApiController) Check390() {
  8963. adminUser := c.GetAdminUserInfo()
  8964. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8965. var user_name string
  8966. user_name = "高慧裕"
  8967. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8968. "insutype=" + "390" +
  8969. "&clr_type=" + "" +
  8970. "&setl_optins=" + "441202" +
  8971. "&stmt_begndate=" + "2022-03-01" +
  8972. "&stm_enddate=" + "2022-03-31" +
  8973. "&medfee_sumamt=" + "1068448.89" +
  8974. "&fund_pay_sumamt=" + "1014677.62" +
  8975. "&acct_pay=" + "0" +
  8976. "&fixmedins_setl_cnt=" + "1950" +
  8977. "&fixmedins_code=" + miConfig.Code +
  8978. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8979. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8980. "&secret_key=" + miConfig.SecretKey +
  8981. "&org_name=" + miConfig.OrgName +
  8982. "&doctor=" + user_name
  8983. fmt.Println(api)
  8984. resp, requestErr := http.Get(api)
  8985. if requestErr != nil {
  8986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8987. return
  8988. }
  8989. body, ioErr := ioutil.ReadAll(resp.Body)
  8990. fmt.Println(body)
  8991. if ioErr != nil {
  8992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8994. return
  8995. }
  8996. var respJSON map[string]interface{}
  8997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9000. return
  9001. }
  9002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9003. userJSONBytes, _ := json.Marshal(respJSON)
  9004. var res ResultEight
  9005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9006. utils.ErrorLog("解析失败:%v", err)
  9007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9008. return
  9009. }
  9010. }
  9011. //对账明细
  9012. func (c *HisApiController) GetCheckDetailAccount() {
  9013. start_time := c.GetString("start_time")
  9014. end_time := c.GetString("end_time")
  9015. admin_user_id, _ := c.GetInt64("admin_user_id")
  9016. adminUser := c.GetAdminUserInfo()
  9017. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9018. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9019. timeLayout := "2006-01-02"
  9020. loc, _ := time.LoadLocation("Local")
  9021. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9022. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9023. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9024. rand.Seed(time.Now().UnixNano())
  9025. num := rand.Intn(30000)
  9026. Mkdir(miConfig.OrgName)
  9027. file := strconv.FormatInt(int64(num), 10)
  9028. file_name := file + ".txt"
  9029. zip_name := file + ".zip"
  9030. zip_path := miConfig.OrgName + "/" + zip_name
  9031. file_path := miConfig.OrgName + "/" + file_name
  9032. decimal.DivisionPrecision = 2
  9033. var medfee_sumamt float64
  9034. var psn_cash_pay float64
  9035. var fund_pay_sumamt float64
  9036. fixmedins_setl_cnt := int64(len(orders))
  9037. for _, item := range orders {
  9038. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9039. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9040. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9041. }
  9042. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9043. defer f.Close()
  9044. if err != nil {
  9045. fmt.Println(err.Error())
  9046. } else {
  9047. for _, item := range orders {
  9048. var refd_setl_flag string
  9049. if item.OrderStatus == 2 {
  9050. refd_setl_flag = "0"
  9051. var str string
  9052. str = item.SetlId + " " +
  9053. item.MdtrtId + " " +
  9054. item.PsnNo + " " +
  9055. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9056. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9057. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9058. _, err = f.Write([]byte(str))
  9059. }
  9060. if item.OrderStatus == 3 {
  9061. var str string
  9062. str = item.SetlId + " " +
  9063. item.MdtrtId + " " +
  9064. item.PsnNo + " " +
  9065. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9066. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9067. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9068. _, err = f.Write([]byte(str))
  9069. var str2 string
  9070. str2 = item.SetlId + " " +
  9071. item.MdtrtId + " " +
  9072. item.PsnNo + " " +
  9073. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9074. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9075. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9076. _, err = f.Write([]byte(str2))
  9077. }
  9078. }
  9079. }
  9080. Zip(file_path, zip_path)
  9081. fmt.Println(ReadFile(zip_path))
  9082. fmt.Println(string(ReadFile(zip_path)))
  9083. if config.IsOpen == 1 {
  9084. var user_name string
  9085. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9086. if role.ID == 0 {
  9087. user_name = "管理员"
  9088. } else {
  9089. user_name = role.UserName
  9090. }
  9091. baseParams := models.BaseParams{
  9092. SecretKey: miConfig.SecretKey,
  9093. FixmedinsCode: miConfig.Code,
  9094. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9095. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9096. OrgName: miConfig.OrgName,
  9097. Doctor: user_name,
  9098. }
  9099. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9100. var dat map[string]interface{}
  9101. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9102. fmt.Println(dat)
  9103. } else {
  9104. fmt.Println(err)
  9105. }
  9106. userJSONBytes, _ := json.Marshal(dat)
  9107. var res ResultNine
  9108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9109. utils.ErrorLog("解析失败:%v", err)
  9110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9111. return
  9112. }
  9113. if res.Infcode == 0 {
  9114. fileNo := res.Output.FileQuryNo
  9115. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9116. "file_qury_no=" + fileNo +
  9117. "&setl_optins=" + "定点医保中心" +
  9118. "&stmt_begndate=" + start_time +
  9119. "&stm_enddate=" + end_time +
  9120. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9121. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9122. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9123. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9124. "&fixmedins_code=" + miConfig.Code +
  9125. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9126. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9127. "&secret_key=" + miConfig.SecretKey +
  9128. "&org_name=" + miConfig.OrgName +
  9129. "&doctor=" + user_name
  9130. resp, requestErr := http.Get(api)
  9131. if requestErr != nil {
  9132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9133. return
  9134. }
  9135. body, ioErr := ioutil.ReadAll(resp.Body)
  9136. if ioErr != nil {
  9137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9139. return
  9140. }
  9141. var respJSON map[string]interface{}
  9142. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9145. return
  9146. }
  9147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9148. userJSONBytes, _ := json.Marshal(respJSON)
  9149. var res ResultTen
  9150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9151. utils.ErrorLog("解析失败:%v", err)
  9152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9153. return
  9154. }
  9155. if res.Infcode == 0 {
  9156. service.Gdyb9102(baseParams, zip_name, fileNo)
  9157. micc := &models.MedicalInsuranceCostCompare{
  9158. StartTime: startime.Unix(),
  9159. EndTime: endtime.Unix(),
  9160. Insutype: "0",
  9161. CheckType: 2,
  9162. Num: fixmedins_setl_cnt,
  9163. Mtime: time.Now().Unix(),
  9164. Status: 1,
  9165. UserOrgId: adminUser.CurrentOrgId,
  9166. CostTotal: medfee_sumamt,
  9167. FuncTotal: fund_pay_sumamt,
  9168. PsnPay: psn_cash_pay,
  9169. Creator: admin_user_id,
  9170. Ctime: time.Now().Unix(),
  9171. }
  9172. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9173. c.ServeSuccessJSON(map[string]interface{}{
  9174. "msg": "明细对账成功",
  9175. })
  9176. }
  9177. } else {
  9178. }
  9179. }
  9180. }
  9181. type CustomOrderInfo struct {
  9182. Name string
  9183. Spec string
  9184. Unit string
  9185. Count float64
  9186. Price float64
  9187. Total float64
  9188. }
  9189. func (c *HisApiController) GetSettleAccounts() {
  9190. //id, _ := c.GetInt64("id")
  9191. //record_time := c.GetString("record_time")
  9192. order_id, _ := c.GetInt64("order_id")
  9193. admin_user_id, _ := c.GetInt64("admin_user_id")
  9194. //timeLayout := "2006-01-02"
  9195. //loc, _ := time.LoadLocation("Local")
  9196. //
  9197. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9198. //if err != nil {
  9199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9200. // return
  9201. //}
  9202. //recordDateTime := theTime.Unix()
  9203. adminUser := c.GetAdminUserInfo()
  9204. order, _ := service.GetHisOrderByID(order_id)
  9205. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9206. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9207. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9208. orderInfos = append(orderInfos, orderInfos_two...)
  9209. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9210. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9211. var diagnosis_ids []string
  9212. if his.ID > 0 {
  9213. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9214. } else {
  9215. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9216. }
  9217. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9218. var dia_config []*models.HisXtDiagnoseConfig
  9219. var name string
  9220. for _, item := range diagnosis_ids {
  9221. id, _ := strconv.ParseInt(item, 10, 64)
  9222. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9223. dia_config = append(dia_config, &diagnosisConfig)
  9224. if len(name) == 0 {
  9225. name = diagnosisConfig.ClassName
  9226. } else {
  9227. name = name + "," + diagnosisConfig.ClassName
  9228. }
  9229. }
  9230. var bedCostTotal float64 = 0 //床位总费
  9231. var bedCostSelfTotal float64 = 0 //床位自费
  9232. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9233. var operationCostTotal float64 = 0 //手术费
  9234. var operationCostSelfTotal float64 = 0 //手术费
  9235. var operationCostPartSelfTotal float64 = 0 //手术费
  9236. var otherCostTotal float64 = 0 //其他费用
  9237. var otherCostSelfTotal float64 = 0 //其他费用
  9238. var otherCostPartSelfTotal float64 = 0 //其他费用
  9239. var materialCostTotal float64 = 0 //材料费
  9240. var materialCostSelfTotal float64 = 0 //材料费
  9241. var materialCostPartSelfTotal float64 = 0 //材料费
  9242. var westernMedicineCostTotal float64 = 0 //西药费
  9243. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9244. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9245. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9246. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9247. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9248. var checkCostTotal float64 = 0 //检查费
  9249. var checkCostSelfTotal float64 = 0 //检查费
  9250. var checkCostPartSelfTotal float64 = 0 //检查费
  9251. var laboratoryCostTotal float64 = 0 //化验费
  9252. var laboratoryCostSelfTotal float64 = 0 //化验费
  9253. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9254. var treatCostTotal float64 = 0 //治疗费用
  9255. var treatCostSelfTotal float64 = 0 //治疗费用
  9256. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9257. decimal.DivisionPrecision = 2
  9258. for _, item := range orderInfos {
  9259. if item.MedChrgitmType == "01" { //床位费
  9260. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9261. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9262. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9263. }
  9264. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9265. if item.MedChrgitmType == "03" { //检查费
  9266. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9267. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9268. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9269. }
  9270. } else {
  9271. if item.MedChrgitmType == "03" { //检查费
  9272. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9273. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9274. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9275. }
  9276. }
  9277. if item.MedChrgitmType == "04" { //化验费
  9278. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9279. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9280. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9281. }
  9282. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9283. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9284. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9285. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9286. }
  9287. if item.MedChrgitmType == "06" { //手术费
  9288. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9289. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9290. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9291. }
  9292. if item.MedChrgitmType == "08" { //材料费
  9293. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9294. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9295. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9296. }
  9297. if item.MedChrgitmType == "09" { //西药费
  9298. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9299. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9300. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9301. }
  9302. if item.MedChrgitmType == "11" { //中成费
  9303. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9304. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9305. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9306. }
  9307. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9308. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9309. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9310. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9311. }
  9312. }
  9313. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9314. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9315. var user_name string
  9316. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9317. if role.ID == 0 {
  9318. user_name = "管理员"
  9319. } else {
  9320. user_name = role.UserName
  9321. }
  9322. baseParams := models.BaseParams{
  9323. SecretKey: miConfig.SecretKey,
  9324. FixmedinsCode: miConfig.Code,
  9325. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9326. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9327. OrgName: miConfig.OrgName,
  9328. Doctor: user_name,
  9329. }
  9330. businessParams := models.BusinessParams{
  9331. PsnNo: order.PsnNo,
  9332. MdtrtId: order.MdtrtId,
  9333. SetlId: order.SetlId,
  9334. }
  9335. var res ResultEleven
  9336. var resEleven10265 ResultEleven10265
  9337. if config.IsOpen == 1 {
  9338. if miConfig.MdtrtareaAdmvs == "421300" {
  9339. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9340. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9341. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9342. resp, requestErr := http.Get(api)
  9343. if requestErr != nil {
  9344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9345. return
  9346. }
  9347. body, ioErr := ioutil.ReadAll(resp.Body)
  9348. if ioErr != nil {
  9349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9351. return
  9352. }
  9353. var respJSON map[string]interface{}
  9354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9357. return
  9358. }
  9359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9360. result, _ := json.Marshal(respJSON)
  9361. fmt.Println("log")
  9362. fmt.Println(string(result))
  9363. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9364. utils.ErrorLog("解析失败:%v", err)
  9365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9366. return
  9367. }
  9368. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9369. var api string
  9370. if miConfig.MdtrtareaAdmvs == "320921" {
  9371. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9372. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9373. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9374. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9375. } else {
  9376. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9377. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9378. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9379. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9380. }
  9381. resp, requestErr := http.Get(api)
  9382. if requestErr != nil {
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9384. return
  9385. }
  9386. body, ioErr := ioutil.ReadAll(resp.Body)
  9387. if ioErr != nil {
  9388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9390. return
  9391. }
  9392. var respJSON map[string]interface{}
  9393. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9396. return
  9397. }
  9398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9399. result, _ := json.Marshal(respJSON)
  9400. fmt.Println("log")
  9401. fmt.Println(string(result))
  9402. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9403. utils.ErrorLog("解析失败:%v", err)
  9404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9405. return
  9406. }
  9407. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9408. res.Output = resEleven10265.Output
  9409. res.ErrMsg = resEleven10265.ErrMsg
  9410. res.Cainfo = resEleven10265.Cainfo
  9411. res.WarnMsg = resEleven10265.WarnMsg
  9412. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9413. res.Infcode = infocode
  9414. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9415. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9416. saveLog(result, requestLog, "5203", "结算单")
  9417. var dat map[string]interface{}
  9418. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9419. fmt.Println(dat)
  9420. } else {
  9421. fmt.Println(err)
  9422. }
  9423. userJSONBytes, _ := json.Marshal(dat)
  9424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9425. utils.ErrorLog("解析失败:%v", err)
  9426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9427. return
  9428. }
  9429. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9430. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9431. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9432. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9433. resp, requestErr := http.Get(api)
  9434. if requestErr != nil {
  9435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9436. return
  9437. }
  9438. body, ioErr := ioutil.ReadAll(resp.Body)
  9439. if ioErr != nil {
  9440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9442. return
  9443. }
  9444. var respJSON map[string]interface{}
  9445. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9448. return
  9449. }
  9450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9451. result, _ := json.Marshal(respJSON)
  9452. fmt.Println("log")
  9453. fmt.Println(string(result))
  9454. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9455. utils.ErrorLog("解析失败:%v", err)
  9456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9457. return
  9458. }
  9459. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9460. res.Output = resEleven10265.Output
  9461. res.ErrMsg = resEleven10265.ErrMsg
  9462. res.Cainfo = resEleven10265.Cainfo
  9463. res.WarnMsg = resEleven10265.WarnMsg
  9464. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9465. res.Infcode = infocode
  9466. } else {
  9467. result := service.Gdyb5203(baseParams, businessParams)
  9468. //service.Gdyb5204(baseParams, businessParams)
  9469. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9470. var dat map[string]interface{}
  9471. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9472. fmt.Println(dat)
  9473. } else {
  9474. fmt.Println(err)
  9475. }
  9476. userJSONBytes, _ := json.Marshal(dat)
  9477. if miConfig.Code == "H15049901371" {
  9478. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9479. utils.ErrorLog("解析失败:%v", err)
  9480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9481. return
  9482. }
  9483. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9484. res.Output = resEleven10265.Output
  9485. res.ErrMsg = resEleven10265.ErrMsg
  9486. res.Cainfo = resEleven10265.Cainfo
  9487. res.WarnMsg = resEleven10265.WarnMsg
  9488. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9489. res.Infcode = infocode
  9490. } else {
  9491. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9492. utils.ErrorLog("解析失败:%v", err)
  9493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9494. return
  9495. }
  9496. }
  9497. }
  9498. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9499. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9500. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9501. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9502. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9503. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9504. var doctor_name string
  9505. if roles.ID == 0 {
  9506. doctor_name = "管理员"
  9507. } else {
  9508. doctor_name = roles.UserName
  9509. }
  9510. yiliao_leibie := ""
  9511. switch order.MedType {
  9512. case "11":
  9513. yiliao_leibie = "普通门诊"
  9514. break
  9515. case "12":
  9516. yiliao_leibie = "门诊挂号"
  9517. break
  9518. case "13":
  9519. yiliao_leibie = "急诊"
  9520. break
  9521. case "14":
  9522. yiliao_leibie = "门诊特殊病"
  9523. break
  9524. case "15":
  9525. yiliao_leibie = "门诊统筹"
  9526. break
  9527. case "16":
  9528. yiliao_leibie = "门诊慢性病"
  9529. break
  9530. case "21":
  9531. yiliao_leibie = "普通住院"
  9532. break
  9533. }
  9534. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9535. if res.Infcode == 0 {
  9536. c.ServeSuccessJSON(map[string]interface{}{
  9537. "diagnosis": name,
  9538. "order_infos": orderInfos,
  9539. "number": order.MdtrtId,
  9540. "date": order.SettleAccountsDate,
  9541. "charge_admin": charge_admin,
  9542. "printor_admin": printor_admin,
  9543. "info": res.Output.Setlinfo,
  9544. "order": order,
  9545. "bedCostTotal": bedCostTotal,
  9546. "bedCostSelfTotal": bedCostSelfTotal,
  9547. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9548. "operationCostTotal": operationCostTotal,
  9549. "operationCostSelfTotal": operationCostSelfTotal,
  9550. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9551. "otherCostTotal": otherCostTotal,
  9552. "otherCostSelfTotal": otherCostSelfTotal,
  9553. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9554. "materialCostTotal": materialCostTotal,
  9555. "materialCostSelfTotal": materialCostSelfTotal,
  9556. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9557. "westernMedicineCostTotal": westernMedicineCostTotal,
  9558. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9559. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9560. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9561. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9562. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9563. "checkCostTotal": checkCostTotal,
  9564. "checkCostSelfTotal": checkCostSelfTotal,
  9565. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9566. "laboratoryCostTotal": laboratoryCostTotal,
  9567. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9568. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9569. "treatCostTotal": treatCostTotal,
  9570. "treatCostSelfTotal": treatCostSelfTotal,
  9571. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9572. "doctor_info": doctor_info,
  9573. "doctor_code": adminRole_two.DoctorCode,
  9574. "doctor_name": doctor_name,
  9575. "health_card_no": order.PsnNo,
  9576. "department": departments.Name,
  9577. "yiliao_leibie": yiliao_leibie,
  9578. "after_money": order.AccountPrice,
  9579. "patient": patient,
  9580. "org_name": miConfig.OrgName,
  9581. "org_code": miConfig.Code,
  9582. "order_number": order.Number,
  9583. "his_hospital": his_hospital,
  9584. "his": his,
  9585. "dia_config": dia_config,
  9586. //"check_order_info": cus_slice,
  9587. })
  9588. }
  9589. }
  9590. }
  9591. func (c *HisApiController) CheckTreatment() {
  9592. patient_id, _ := c.GetInt64("patient_id")
  9593. id_card_no := c.GetString("id_card_no")
  9594. insutype := c.GetString("insutype")
  9595. med_type := c.GetString("med_type")
  9596. admin_user_id, _ := c.GetInt64("admin_user_id")
  9597. adminUser := c.GetAdminUserInfo()
  9598. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9599. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9600. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9601. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9602. if miConfig.MdtrtareaAdmvs == "421300" {
  9603. var res ResultTwo
  9604. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9605. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9606. "&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)
  9607. resp, requestErr := http.Get(api)
  9608. if requestErr != nil {
  9609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9610. return
  9611. }
  9612. body, ioErr := ioutil.ReadAll(resp.Body)
  9613. if ioErr != nil {
  9614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9616. return
  9617. }
  9618. var respJSON map[string]interface{}
  9619. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9622. return
  9623. }
  9624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9625. result, _ := json.Marshal(respJSON)
  9626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9627. utils.ErrorLog("解析失败:%v", err)
  9628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9629. return
  9630. }
  9631. if res.Infcode == 0 {
  9632. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9633. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9634. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9635. resp, requestErr := http.Get(api)
  9636. if requestErr != nil {
  9637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9638. return
  9639. }
  9640. body, ioErr := ioutil.ReadAll(resp.Body)
  9641. if ioErr != nil {
  9642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9644. return
  9645. }
  9646. var respJSON map[string]interface{}
  9647. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9650. return
  9651. }
  9652. var res Result2001
  9653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9654. result2, _ := json.Marshal(respJSON)
  9655. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9656. utils.ErrorLog("解析失败:%v", err)
  9657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9658. return
  9659. }
  9660. if res.Infcode == 0 {
  9661. c.ServeSuccessJSON(map[string]interface{}{
  9662. "msg": res.Output.Trtinfo,
  9663. })
  9664. }
  9665. } else {
  9666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9667. return
  9668. }
  9669. } else {
  9670. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9671. var dat map[string]interface{}
  9672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9673. fmt.Println(dat)
  9674. } else {
  9675. fmt.Println(err)
  9676. }
  9677. userJSONBytes, _ := json.Marshal(dat)
  9678. var res ResultTwo
  9679. var res10265 ResultTwo10265
  9680. if miConfig.Code == "H15049901371" {
  9681. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9682. utils.ErrorLog("解析失败:%v", err)
  9683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9684. return
  9685. }
  9686. res.ErrMsg = res10265.ErrMsg
  9687. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9688. res.Infcode = infocode
  9689. res.Output = res10265.Output
  9690. res.InfRefmsgid = res10265.InfRefmsgid
  9691. } else {
  9692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9693. utils.ErrorLog("解析失败:%v", err)
  9694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9695. return
  9696. }
  9697. }
  9698. var user_name string
  9699. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9700. if role.ID == 0 {
  9701. user_name = "xxx"
  9702. } else {
  9703. user_name = role.UserName
  9704. }
  9705. baseParams := models.BaseParams{
  9706. SecretKey: miConfig.SecretKey,
  9707. FixmedinsCode: miConfig.Code,
  9708. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9709. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9710. OrgName: miConfig.OrgName,
  9711. Doctor: user_name,
  9712. }
  9713. if config.IsOpen == 1 {
  9714. if miConfig.Code == "H15049901371" {
  9715. if med_type == "14" {
  9716. if insutype == "390" {
  9717. med_type = "9933"
  9718. } else if insutype == "310" {
  9719. med_type = "990502"
  9720. }
  9721. } else if med_type == "11" {
  9722. med_type = "11"
  9723. }
  9724. }
  9725. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9726. var dat map[string]interface{}
  9727. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9728. fmt.Println(dat)
  9729. } else {
  9730. fmt.Println(err)
  9731. }
  9732. var res Result2001
  9733. var res10265 Result2001Org10265
  9734. if miConfig.Code == "H15049901371" {
  9735. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9736. utils.ErrorLog("解析失败:%v", err)
  9737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9738. return
  9739. }
  9740. res.ErrMsg = res10265.ErrMsg
  9741. res.Output = res10265.Output
  9742. res.InfRefmsgid = res10265.InfRefmsgid
  9743. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9744. res.Infcode = infocode
  9745. } else {
  9746. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9747. utils.ErrorLog("解析失败:%v", err)
  9748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9749. return
  9750. }
  9751. }
  9752. if res.Infcode == 0 {
  9753. c.ServeSuccessJSON(map[string]interface{}{
  9754. "msg": res.Output.Trtinfo,
  9755. })
  9756. }
  9757. }
  9758. }
  9759. }
  9760. //func (c *HisApiController) PutRecord() {
  9761. // id, _ := c.GetInt64("id")
  9762. // record_time := c.GetString("record_time")
  9763. // timeLayout := "2006-01-02"
  9764. // loc, _ := time.LoadLocation("Local")
  9765. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9766. // if err != nil {
  9767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9768. // return
  9769. // }
  9770. // recordDateTime := theTime.Unix()
  9771. //
  9772. // adminInfo := c.GetAdminUserInfo()
  9773. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9774. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9775. //
  9776. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9777. //
  9778. // fmt.Println(miConfig.SecretKey)
  9779. //
  9780. // if patient == nil {
  9781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9782. // return
  9783. // }
  9784. // if len(patient.IdCardNo) == 0 {
  9785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9786. // return
  9787. // }
  9788. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9789. // if config.IsOpen == 1 {
  9790. // 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
  9791. // resp, requestErr := http.Get(api)
  9792. // if requestErr != nil {
  9793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9794. // return
  9795. // }
  9796. // defer resp.Body.Close()
  9797. // body, ioErr := ioutil.ReadAll(resp.Body)
  9798. // if ioErr != nil {
  9799. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9801. // return
  9802. // }
  9803. // var respJSON map[string]interface{}
  9804. //
  9805. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9806. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9808. // return
  9809. // }
  9810. //
  9811. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9812. // userJSONBytes, _ := json.Marshal(userJSON)
  9813. // var res ResultTwo
  9814. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9815. // utils.ErrorLog("解析失败:%v", err)
  9816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9817. // return
  9818. // }
  9819. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9820. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9821. // infoStr := string(Iinfos)
  9822. // idetinfoStr := string(Idetinfos)
  9823. //
  9824. // if res.Infcode == 0 {
  9825. // his := models.VMHisPatient{
  9826. // Status: 1,
  9827. // Ctime: time.Now().Unix(),
  9828. // Mtime: time.Now().Unix(),
  9829. // PsnNo: res.Output.Baseinfo.PsnNo,
  9830. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9831. // Certno: res.Output.Baseinfo.Certno,
  9832. // PsnName: res.Output.Baseinfo.PsnName,
  9833. // Gend: res.Output.Baseinfo.Gend,
  9834. // Naty: res.Output.Baseinfo.Naty,
  9835. // Brdy: res.Output.Baseinfo.Brdy,
  9836. // Age: res.Output.Baseinfo.Age,
  9837. // Iinfo: infoStr,
  9838. // Idetinfo: idetinfoStr,
  9839. // PatientId: patient.ID,
  9840. // RecordDate: theTime.Unix(),
  9841. // UserOrgId: adminInfo.CurrentOrgId,
  9842. // AdminUserId: adminInfo.AdminUser.Id,
  9843. // IsReturn: 1,
  9844. // }
  9845. //
  9846. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9847. // //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")
  9848. // //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")
  9849. //
  9850. // //var dat map[string]interface{}
  9851. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9852. // // fmt.Println(dat)
  9853. // //} else {
  9854. // // fmt.Println(err)
  9855. // //}
  9856. //
  9857. // var dat2 map[string]interface{}
  9858. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9859. // fmt.Println(dat2)
  9860. // } else {
  9861. // fmt.Println(err)
  9862. // }
  9863. //
  9864. // } else {
  9865. // adminUser := c.GetAdminUserInfo()
  9866. // errlog := &models.HisOrderError{
  9867. // UserOrgId: adminUser.CurrentOrgId,
  9868. // Ctime: time.Now().Unix(),
  9869. // Mtime: time.Now().Unix(),
  9870. // ErrMsg: res.ErrMsg,
  9871. // Status: 1,
  9872. // PatientId: id,
  9873. // RecordTime: recordDateTime,
  9874. // Stage: 1,
  9875. // }
  9876. // service.CreateErrMsgLog(errlog)
  9877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9878. // return
  9879. // }
  9880. // }
  9881. //
  9882. //}
  9883. //func (c *HisApiController) GetUploadDiag() {
  9884. // id, _ := c.GetInt64("id")
  9885. // record_time := c.GetString("record_time")
  9886. //
  9887. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9888. // sick_type, _ := c.GetInt64("sick_type")
  9889. // reg_type, _ := c.GetInt64("reg_type")
  9890. //
  9891. // timeLayout := "2006-01-02"
  9892. // loc, _ := time.LoadLocation("Local")
  9893. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9894. // if err != nil {
  9895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9896. // return
  9897. // }
  9898. //
  9899. // var patientPrescription models.HisPrescriptionInfo
  9900. // recordDateTime := theTime.Unix()
  9901. // adminInfo := c.GetAdminUserInfo()
  9902. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9903. //
  9904. // if patientPrescription.ID == 0 {
  9905. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9906. // }
  9907. //
  9908. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9909. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9910. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9911. // sickConfig, _ := service.FindSickById(sick_type)
  9912. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9913. //
  9914. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9915. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9916. // "&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 +
  9917. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9918. // resp2, requestErr2 := http.Get(api2)
  9919. // if requestErr2 != nil {
  9920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9921. // return
  9922. // }
  9923. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9924. // if ioErr2 != nil {
  9925. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9927. // return
  9928. // }
  9929. // var respJSON2 map[string]interface{}
  9930. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9931. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9933. // return
  9934. // }
  9935. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9936. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9937. //
  9938. // var res2 ResultSix
  9939. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9940. // utils.ErrorLog("解析失败:%v", err)
  9941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. // return
  9943. // }
  9944. // if res2.Infcode != 0 {
  9945. // adminUser := c.GetAdminUserInfo()
  9946. // errlog := &models.HisOrderError{
  9947. // UserOrgId: adminUser.CurrentOrgId,
  9948. // Ctime: time.Now().Unix(),
  9949. // Mtime: time.Now().Unix(),
  9950. // ErrMsg: res2.ErrMsg,
  9951. // Status: 1,
  9952. // PatientId: id,
  9953. // RecordTime: recordDateTime,
  9954. // Stage: 3,
  9955. // }
  9956. // service.CreateErrMsgLog(errlog)
  9957. //
  9958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9959. // return
  9960. // }
  9961. //
  9962. // c.ServeSuccessJSON(map[string]interface{}{
  9963. // "msg": "上传成功",
  9964. // })
  9965. //
  9966. //}
  9967. type QueryResult struct {
  9968. ID int64
  9969. Name string
  9970. Code string
  9971. List_type_code string
  9972. }
  9973. func (c *HisApiController) GetCheckCode() {
  9974. ids_str := c.GetString("ids")
  9975. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9976. ids_arr := strings.Split(ids_str, ",")
  9977. var queryResult []QueryResult
  9978. ids := make([]int64, 0)
  9979. for _, item := range ids_arr {
  9980. id, _ := strconv.ParseInt(item, 10, 64)
  9981. ids = append(ids, id)
  9982. }
  9983. if record_type == 1 {
  9984. drugs, _ := service.GetBatchDrugList(ids)
  9985. for _, item := range drugs {
  9986. result := QueryResult{
  9987. ID: item.ID,
  9988. Name: item.DrugName,
  9989. Code: item.MedicalInsuranceNumber,
  9990. List_type_code: "101",
  9991. }
  9992. queryResult = append(queryResult, result)
  9993. }
  9994. } else if record_type == 2 {
  9995. goods, _ := service.GetBatchGoodInformationList(ids)
  9996. for _, item := range goods {
  9997. result := QueryResult{
  9998. ID: item.ID,
  9999. Name: item.GoodName,
  10000. Code: item.MedicalInsuranceNumber,
  10001. List_type_code: "301",
  10002. }
  10003. queryResult = append(queryResult, result)
  10004. }
  10005. } else if record_type == 3 {
  10006. projects, _ := service.GetBathchMyPorjecgList(ids)
  10007. for _, item := range projects {
  10008. result := QueryResult{
  10009. ID: item.ID,
  10010. Name: item.ProjectName,
  10011. Code: item.MedicalCode,
  10012. List_type_code: "201",
  10013. }
  10014. queryResult = append(queryResult, result)
  10015. }
  10016. }
  10017. admin_user_id, _ := c.GetInt64("admin_user_id")
  10018. adminUser := c.GetAdminUserInfo()
  10019. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10020. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10021. var user_name string
  10022. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10023. if role.ID == 0 {
  10024. user_name = "xxx"
  10025. } else {
  10026. user_name = role.UserName
  10027. }
  10028. baseParams := &models.BaseParams{
  10029. SecretKey: miConfig.SecretKey,
  10030. FixmedinsCode: miConfig.Code,
  10031. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10032. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10033. OrgName: miConfig.OrgName,
  10034. Doctor: user_name,
  10035. }
  10036. if config.IsOpen == 1 {
  10037. for _, item := range queryResult {
  10038. var result string
  10039. if record_type == 1 {
  10040. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10041. } else if record_type == 2 {
  10042. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10043. } else if record_type == 3 {
  10044. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10045. }
  10046. var dat map[string]interface{}
  10047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10048. fmt.Println(dat)
  10049. } else {
  10050. fmt.Println(err)
  10051. }
  10052. userJSONBytes, _ := json.Marshal(dat)
  10053. var res ResultSix
  10054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10055. utils.ErrorLog("解析失败:%v", err)
  10056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10057. return
  10058. }
  10059. if res.Infcode == 0 {
  10060. if record_type == 1 {
  10061. service.UpdateBaseDrugById(item.ID)
  10062. } else if record_type == 2 {
  10063. service.UpdateGoodInformaitonByDetail(item.ID)
  10064. } else if record_type == 3 {
  10065. service.UpdateProjectById(item.ID)
  10066. }
  10067. c.ServeSuccessJSON(map[string]interface{}{
  10068. "failed_code": 0,
  10069. "msg": "目录对照成功",
  10070. })
  10071. } else {
  10072. c.ServeSuccessJSON(map[string]interface{}{
  10073. "failed_code": -10,
  10074. "msg": res.ErrMsg,
  10075. })
  10076. }
  10077. }
  10078. }
  10079. }
  10080. func (c *HisApiController) UnCheckCode() {
  10081. ids_str := c.GetString("ids")
  10082. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10083. admin_user_id, _ := c.GetInt64("admin_user_id")
  10084. ids_arr := strings.Split(ids_str, ",")
  10085. var queryResult []QueryResult
  10086. ids := make([]int64, 0)
  10087. for _, item := range ids_arr {
  10088. id, _ := strconv.ParseInt(item, 10, 64)
  10089. ids = append(ids, id)
  10090. }
  10091. if record_type == 1 {
  10092. drugs, _ := service.GetBatchDrugList(ids)
  10093. for _, item := range drugs {
  10094. result := QueryResult{
  10095. ID: item.ID,
  10096. Name: item.DrugName,
  10097. Code: item.MedicalInsuranceNumber,
  10098. List_type_code: "101",
  10099. }
  10100. queryResult = append(queryResult, result)
  10101. }
  10102. } else if record_type == 2 {
  10103. goods, _ := service.GetBatchGoodInformationList(ids)
  10104. for _, item := range goods {
  10105. result := QueryResult{
  10106. ID: item.ID,
  10107. Name: item.GoodName,
  10108. Code: item.MedicalInsuranceNumber,
  10109. List_type_code: "301",
  10110. }
  10111. queryResult = append(queryResult, result)
  10112. }
  10113. } else if record_type == 3 {
  10114. projects, _ := service.GetBathchMyPorjecgList(ids)
  10115. for _, item := range projects {
  10116. result := QueryResult{
  10117. ID: item.ID,
  10118. Name: item.ProjectName,
  10119. Code: item.MedicalCode,
  10120. List_type_code: "201",
  10121. }
  10122. queryResult = append(queryResult, result)
  10123. }
  10124. }
  10125. adminUser := c.GetAdminUserInfo()
  10126. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10127. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10128. var user_name string
  10129. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10130. if role.ID == 0 {
  10131. user_name = "xxx"
  10132. } else {
  10133. user_name = role.UserName
  10134. }
  10135. baseParams := &models.BaseParams{
  10136. SecretKey: miConfig.SecretKey,
  10137. FixmedinsCode: miConfig.Code,
  10138. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10139. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10140. OrgName: miConfig.OrgName,
  10141. Doctor: user_name,
  10142. }
  10143. if config.IsOpen == 1 {
  10144. for _, item := range queryResult {
  10145. var result string
  10146. if record_type == 1 {
  10147. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10148. } else if record_type == 2 {
  10149. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10150. } else if record_type == 3 {
  10151. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10152. }
  10153. var dat2 map[string]interface{}
  10154. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10155. fmt.Println(dat2)
  10156. } else {
  10157. fmt.Println(err)
  10158. }
  10159. userJSONBytes, _ := json.Marshal(dat2)
  10160. var res ResultSix
  10161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10162. utils.ErrorLog("解析失败:%v", err)
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. if res.Infcode == 0 {
  10167. if record_type == 1 {
  10168. service.UpdateDrugByIdDetail(item.ID)
  10169. } else if record_type == 2 {
  10170. service.UpdateGoodInfoById(item.ID)
  10171. } else if record_type == 3 {
  10172. service.UpdateMyProjectById(item.ID)
  10173. }
  10174. c.ServeSuccessJSON(map[string]interface{}{
  10175. "failed_code": 0,
  10176. "msg": "撤销目录对照成功",
  10177. })
  10178. } else {
  10179. c.ServeSuccessJSON(map[string]interface{}{
  10180. "failed_code": -10,
  10181. "msg": res.ErrMsg,
  10182. })
  10183. }
  10184. }
  10185. }
  10186. }
  10187. func (c *HisApiController) GetPatientInfo() {
  10188. id_card_no := c.GetString("id_card_no")
  10189. admin_user_id, _ := c.GetInt64("admin_user_id")
  10190. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10191. if patient.ID == 0 {
  10192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10193. return
  10194. }
  10195. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10196. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10197. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10198. if config.IsOpen == 1 {
  10199. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10200. var dat map[string]interface{}
  10201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10202. fmt.Println(dat)
  10203. } else {
  10204. fmt.Println(err)
  10205. }
  10206. userJSONBytes, _ := json.Marshal(dat)
  10207. var res ResultTwo
  10208. var res10265 ResultTwo10265
  10209. if miConfig.Code == "H15049901371" {
  10210. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10211. utils.ErrorLog("解析失败:%v", err)
  10212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10213. return
  10214. }
  10215. res.ErrMsg = res10265.ErrMsg
  10216. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10217. res.Infcode = infocode
  10218. res.Output = res10265.Output
  10219. res.InfRefmsgid = res10265.InfRefmsgid
  10220. } else {
  10221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10222. utils.ErrorLog("解析失败:%v", err)
  10223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10224. return
  10225. }
  10226. }
  10227. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10228. // utils.ErrorLog("解析失败:%v", err)
  10229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10230. // return
  10231. //}
  10232. if res.Infcode != 0 {
  10233. c.ServeSuccessJSON(map[string]interface{}{
  10234. "failed_code": -10,
  10235. "msg": res.ErrMsg,
  10236. })
  10237. } else {
  10238. c.ServeSuccessJSON(map[string]interface{}{
  10239. "failed_code": 0,
  10240. "info": res,
  10241. })
  10242. }
  10243. }
  10244. }
  10245. func (c *HisApiController) PsnPutOnRecord() {
  10246. record_type, _ := c.GetInt64("type")
  10247. patient_id, _ := c.GetInt64("patient_id")
  10248. admin_user_id, _ := c.GetInt64("admin_user_id")
  10249. start_time := c.GetString("start_time")
  10250. end_time := c.GetString("end_time")
  10251. adminUser := c.GetAdminUserInfo()
  10252. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10253. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10254. var patients []*models.Patients
  10255. if record_type == 1 { //全部备案
  10256. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10257. patients = append(patients, patient...)
  10258. } else { //单个备案
  10259. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10260. patients = append(patients, patient)
  10261. }
  10262. var user_name string
  10263. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10264. if role.ID == 0 {
  10265. user_name = "xxx"
  10266. } else {
  10267. user_name = role.UserName
  10268. }
  10269. if config.IsOpen == 1 {
  10270. for _, item := range patients {
  10271. 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
  10272. resp, requestErr := http.Get(api)
  10273. if requestErr != nil {
  10274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10275. return
  10276. }
  10277. defer resp.Body.Close()
  10278. body, ioErr := ioutil.ReadAll(resp.Body)
  10279. if ioErr != nil {
  10280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10282. return
  10283. }
  10284. var respJSON map[string]interface{}
  10285. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10288. return
  10289. }
  10290. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10291. userJSONBytes, _ := json.Marshal(userJSON)
  10292. var res ResultTwo
  10293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10294. utils.ErrorLog("解析失败:%v", err)
  10295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10296. return
  10297. }
  10298. if res.Infcode == 0 {
  10299. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10300. var dat map[string]interface{}
  10301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10302. fmt.Println(dat)
  10303. } else {
  10304. fmt.Println(err)
  10305. }
  10306. userJSONBytes, _ := json.Marshal(dat)
  10307. var res2 ResultThirteen
  10308. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10309. utils.ErrorLog("解析失败:%v", err)
  10310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10311. return
  10312. }
  10313. if res2.Infcode == 0 {
  10314. psnResult := &models.GdybPsnRecord{
  10315. UserOrgId: adminUser.CurrentOrgId,
  10316. PatientId: item.ID,
  10317. PsnNo: res.Output.Baseinfo.PsnNo,
  10318. Ctime: time.Now().Unix(),
  10319. Mtime: time.Now().Unix(),
  10320. Status: 1,
  10321. IsCancel: 1,
  10322. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10323. }
  10324. service.CreatePsnRecord(psnResult)
  10325. } else {
  10326. c.ServeSuccessJSON(map[string]interface{}{
  10327. "failed_code": -10,
  10328. "msg": res2.ErrMsg,
  10329. })
  10330. return
  10331. }
  10332. }
  10333. }
  10334. }
  10335. }
  10336. func (c *HisApiController) PsnUnPutOnRecord() {
  10337. id, _ := c.GetInt64("id")
  10338. //record_type, _ := c.GetInt64("type")
  10339. admin_user_id, _ := c.GetInt64("admin_user_id")
  10340. adminUser := c.GetAdminUserInfo()
  10341. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10342. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10343. var user_name string
  10344. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10345. if role.ID == 0 {
  10346. user_name = "xxx"
  10347. } else {
  10348. user_name = role.UserName
  10349. }
  10350. psn_record, _ := service.GetPsnRecordById(id)
  10351. if psn_record.ID == 0 {
  10352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10353. return
  10354. }
  10355. if config.IsOpen == 1 {
  10356. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10357. var dat map[string]interface{}
  10358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10359. fmt.Println(dat)
  10360. } else {
  10361. fmt.Println(err)
  10362. }
  10363. userJSONBytes, _ := json.Marshal(dat)
  10364. var res ResultFourteen
  10365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10366. utils.ErrorLog("解析失败:%v", err)
  10367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10368. return
  10369. }
  10370. if res.Infcode == 0 {
  10371. psn_record.IsCancel = 2
  10372. service.CreatePsnRecord(&psn_record)
  10373. } else {
  10374. c.ServeSuccessJSON(map[string]interface{}{
  10375. "failed_code": -10,
  10376. "msg": res.ErrMsg,
  10377. })
  10378. return
  10379. }
  10380. }
  10381. }
  10382. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10383. patient_id, _ := c.GetInt64("patient_id")
  10384. insutype_two := c.GetString("insutype")
  10385. psn_no := c.GetString("psn_no")
  10386. doctor_id, _ := c.GetInt64("doctor_id")
  10387. sick_id, _ := c.GetInt64("sick_id")
  10388. department_id, _ := c.GetInt64("department_id")
  10389. start_time := c.GetString("start_time")
  10390. end_time := c.GetString("end_time")
  10391. check_time := c.GetString("check_time")
  10392. adminUser := c.GetAdminUserInfo()
  10393. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10394. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10395. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10396. sick, _ := service.FindSickById(sick_id)
  10397. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10398. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10399. var res ResultTwo
  10400. var res10265 ResultTwo10265
  10401. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10402. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10403. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10404. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10405. "&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
  10406. resp, requestErr := http.Get(api)
  10407. if requestErr != nil {
  10408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10409. return
  10410. }
  10411. body, ioErr := ioutil.ReadAll(resp.Body)
  10412. if ioErr != nil {
  10413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10415. return
  10416. }
  10417. var respJSON map[string]interface{}
  10418. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10421. return
  10422. }
  10423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10424. result, _ := json.Marshal(respJSON)
  10425. fmt.Println("log")
  10426. fmt.Println(string(result))
  10427. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10428. utils.ErrorLog("解析失败:%v", err)
  10429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10430. return
  10431. }
  10432. res.ErrMsg = res10265.ErrMsg
  10433. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10434. res.Infcode = infocode
  10435. res.Output = res10265.Output
  10436. res.InfRefmsgid = res10265.InfRefmsgid
  10437. } else {
  10438. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10439. if miConfig.Code == "H15049901371" {
  10440. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10441. utils.ErrorLog("解析失败:%v", err)
  10442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10443. return
  10444. }
  10445. res.ErrMsg = res10265.ErrMsg
  10446. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10447. res.Infcode = infocode
  10448. res.Output = res10265.Output
  10449. res.InfRefmsgid = res10265.InfRefmsgid
  10450. } else {
  10451. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10452. utils.ErrorLog("解析失败:%v", err)
  10453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10454. return
  10455. }
  10456. }
  10457. }
  10458. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10459. infoStr := string(Iinfos)
  10460. var rf []*ResultFive
  10461. json.Unmarshal([]byte(infoStr), &rf)
  10462. var insuplc_admdvs string
  10463. var insutype string
  10464. var is390 int = 0
  10465. var is310 int = 0
  10466. var insutypes []*ResultFive
  10467. for _, item := range rf {
  10468. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10469. insutypes = append(insutypes, item)
  10470. }
  10471. }
  10472. if len(insutypes) == 1 {
  10473. insutype = insutypes[0].Insutype
  10474. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10475. } else {
  10476. for _, i := range insutypes {
  10477. if i.Insutype == "390" {
  10478. is390 = 1
  10479. }
  10480. if i.Insutype == "310" {
  10481. is310 = 1
  10482. }
  10483. }
  10484. }
  10485. if is390 == 1 {
  10486. insutype = "390"
  10487. }
  10488. if is310 == 1 {
  10489. insutype = "310"
  10490. }
  10491. if len(insutypes) == 2 {
  10492. insutype = insutype_two
  10493. }
  10494. if len(insutypes) == 0 {
  10495. insutype = "310"
  10496. }
  10497. insutype = insutype_two
  10498. fmt.Println(insutype)
  10499. for _, item := range rf {
  10500. fmt.Println(item.Insutype)
  10501. fmt.Println(insutype)
  10502. if item.Insutype == insutype {
  10503. fmt.Println(item.Insutype)
  10504. fmt.Println(insutype)
  10505. insuplc_admdvs = item.InsuplcAdmdvs
  10506. }
  10507. }
  10508. fmt.Println(insuplc_admdvs)
  10509. var res2 ResultThirteen
  10510. var res10265_2 ResultThirteen10265
  10511. if config.IsOpen == 1 {
  10512. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10513. } else {
  10514. 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)
  10515. var dat map[string]interface{}
  10516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10517. fmt.Println(dat)
  10518. } else {
  10519. fmt.Println(err)
  10520. }
  10521. userJSONBytes, _ := json.Marshal(dat)
  10522. if miConfig.Code == "H15049901371" {
  10523. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10524. utils.ErrorLog("解析失败:%v", err)
  10525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10526. return
  10527. }
  10528. res2.ErrMsg = res10265_2.ErrMsg
  10529. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10530. res2.Infcode = infocode
  10531. res2.Output = res10265_2.Output
  10532. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10533. } else {
  10534. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10535. utils.ErrorLog("解析失败:%v", err)
  10536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10537. return
  10538. }
  10539. }
  10540. }
  10541. if res2.Infcode == 0 {
  10542. psnResult := &models.GdybPsnNcdsRecord{
  10543. UserOrgId: adminUser.CurrentOrgId,
  10544. PatientId: patient.ID,
  10545. PsnNo: psn_no,
  10546. DoctorId: doctor.AdminUserId,
  10547. DepartmentId: department_id,
  10548. SickType: sick_id,
  10549. Insutype: insutype,
  10550. Ctime: time.Now().Unix(),
  10551. Mtime: time.Now().Unix(),
  10552. Status: 1,
  10553. IsCancel: 1,
  10554. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10555. }
  10556. service.CreatePsnNCDSRecord(psnResult)
  10557. c.ServeSuccessJSON(map[string]interface{}{
  10558. "failed_code": 0,
  10559. "msg": "备案成功",
  10560. "result": psnResult,
  10561. })
  10562. } else {
  10563. c.ServeSuccessJSON(map[string]interface{}{
  10564. "failed_code": -10,
  10565. "msg": res2.ErrMsg,
  10566. })
  10567. return
  10568. }
  10569. }
  10570. }
  10571. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10572. id, _ := c.GetInt64("id")
  10573. admin_user_id, _ := c.GetInt64("admin_user_id")
  10574. adminUser := c.GetAdminUserInfo()
  10575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10576. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10577. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10578. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10579. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10580. //var user_name string
  10581. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10582. //if role.ID == 0 {
  10583. // user_name = "xxx"
  10584. //} else {
  10585. // user_name = role.UserName
  10586. //}
  10587. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10588. if psn_record.ID == 0 {
  10589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10590. return
  10591. }
  10592. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10593. var res ResultTwo
  10594. var res10265 ResultTwo10265
  10595. if miConfig.Code == "H15049901371" {
  10596. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10597. utils.ErrorLog("解析失败:%v", err)
  10598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10599. return
  10600. }
  10601. res.ErrMsg = res10265.ErrMsg
  10602. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10603. res.Infcode = infocode
  10604. res.Output = res10265.Output
  10605. res.InfRefmsgid = res10265.InfRefmsgid
  10606. } else {
  10607. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10608. utils.ErrorLog("解析失败:%v", err)
  10609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10610. return
  10611. }
  10612. }
  10613. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10614. infoStr := string(Iinfos)
  10615. var rf []*ResultFive
  10616. json.Unmarshal([]byte(infoStr), &rf)
  10617. var insuplc_admdvs string
  10618. var insutype string
  10619. var is390 int = 0
  10620. var is310 int = 0
  10621. var insutypes []*ResultFive
  10622. for _, item := range rf {
  10623. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10624. insutypes = append(insutypes, item)
  10625. }
  10626. }
  10627. if len(insutypes) == 1 {
  10628. insutype = insutypes[0].Insutype
  10629. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10630. } else {
  10631. for _, i := range insutypes {
  10632. if i.Insutype == "390" {
  10633. is390 = 1
  10634. }
  10635. if i.Insutype == "310" {
  10636. is310 = 1
  10637. }
  10638. }
  10639. }
  10640. if is390 == 1 {
  10641. insutype = "390"
  10642. }
  10643. if is310 == 1 {
  10644. insutype = "310"
  10645. }
  10646. if len(insutypes) == 0 {
  10647. insutype = "310"
  10648. }
  10649. insutype = psn_record.Insutype
  10650. for _, item := range rf {
  10651. if item.Insutype == insutype {
  10652. insuplc_admdvs = item.InsuplcAdmdvs
  10653. }
  10654. }
  10655. if config.IsOpen == 1 {
  10656. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10657. var dat map[string]interface{}
  10658. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10659. fmt.Println(dat)
  10660. } else {
  10661. fmt.Println(err)
  10662. }
  10663. userJSONBytes, _ := json.Marshal(dat)
  10664. var res ResultFourteen
  10665. var res10265 ResultFourteen10265
  10666. if miConfig.Code == "H15049901371" {
  10667. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10668. utils.ErrorLog("解析失败:%v", err)
  10669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10670. return
  10671. }
  10672. res.ErrMsg = res10265.ErrMsg
  10673. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10674. res.Infcode = infocode
  10675. res.Output = res10265.Output
  10676. res.InfRefmsgid = res10265.InfRefmsgid
  10677. } else {
  10678. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10679. utils.ErrorLog("解析失败:%v", err)
  10680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10681. return
  10682. }
  10683. }
  10684. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10685. // utils.ErrorLog("解析失败:%v", err)
  10686. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10687. // return
  10688. //}
  10689. if res.Infcode == 0 {
  10690. psn_record.IsCancel = 2
  10691. service.CreatePsnNCDSRecord(&psn_record)
  10692. c.ServeSuccessJSON(map[string]interface{}{
  10693. "failed_code": 0,
  10694. "msg": "撤销备案成功",
  10695. })
  10696. } else {
  10697. c.ServeSuccessJSON(map[string]interface{}{
  10698. "failed_code": -10,
  10699. "msg": res.ErrMsg,
  10700. })
  10701. return
  10702. }
  10703. }
  10704. }
  10705. func (c *HisApiController) TestTest() {
  10706. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10707. fmt.Println(patient.Iinfo)
  10708. }
  10709. type CustomData struct {
  10710. MsgId string
  10711. PsnNo string
  10712. Info string
  10713. }
  10714. func (c *HisApiController) ReversalData() {
  10715. var customData []*CustomData
  10716. custom := &CustomData{
  10717. MsgId: "H44022900158202103301714472004",
  10718. PsnNo: "44020000001101329945",
  10719. Info: "2207",
  10720. }
  10721. customData = append(customData, custom)
  10722. custom1 := &CustomData{
  10723. MsgId: "H4402290015820210330172057803",
  10724. PsnNo: "44020000001101161813",
  10725. Info: "2207",
  10726. }
  10727. customData = append(customData, custom1)
  10728. custom2 := &CustomData{
  10729. MsgId: "H44022900158202103301705198813",
  10730. PsnNo: "44190000133097375417",
  10731. Info: "2207",
  10732. }
  10733. customData = append(customData, custom2)
  10734. custom3 := &CustomData{
  10735. MsgId: "H44022900158202103301715524756",
  10736. PsnNo: "44020000001100187221",
  10737. Info: "2207",
  10738. }
  10739. customData = append(customData, custom3)
  10740. custom4 := &CustomData{
  10741. MsgId: "H44022900158202103301730376224",
  10742. PsnNo: "44020000001101959155",
  10743. Info: "2207",
  10744. }
  10745. customData = append(customData, custom4)
  10746. custom5 := &CustomData{
  10747. MsgId: "H44022900158202103301748008725",
  10748. PsnNo: "44020000001104246641",
  10749. Info: "2207",
  10750. }
  10751. customData = append(customData, custom5)
  10752. custom6 := &CustomData{
  10753. MsgId: "H44022900158202103301718096755",
  10754. PsnNo: "44020000001102211860",
  10755. Info: "2207",
  10756. }
  10757. customData = append(customData, custom6)
  10758. custom7 := &CustomData{
  10759. MsgId: "H44022900158202103301736551640",
  10760. PsnNo: "44020000001102687718",
  10761. Info: "2207",
  10762. }
  10763. customData = append(customData, custom7)
  10764. custom8 := &CustomData{
  10765. MsgId: "H44022900158202103301743097676",
  10766. PsnNo: "44020000001102127785",
  10767. Info: "2207",
  10768. }
  10769. customData = append(customData, custom8)
  10770. custom9 := &CustomData{
  10771. MsgId: "H44022900158202103301712304203",
  10772. PsnNo: "44020000001101518097",
  10773. Info: "2207",
  10774. }
  10775. customData = append(customData, custom9)
  10776. custom10 := &CustomData{
  10777. MsgId: "H44022900158202103301738448785",
  10778. PsnNo: "44020000001100500813",
  10779. Info: "2207",
  10780. }
  10781. customData = append(customData, custom10)
  10782. custom11 := &CustomData{
  10783. MsgId: "H44022900158202103301732455843",
  10784. PsnNo: "44020000001102690557",
  10785. Info: "2207",
  10786. }
  10787. customData = append(customData, custom11)
  10788. custom12 := &CustomData{
  10789. MsgId: "H44022900158202103301745421708",
  10790. PsnNo: "44020000001102211928",
  10791. Info: "2207",
  10792. }
  10793. customData = append(customData, custom12)
  10794. custom1212 := &CustomData{
  10795. MsgId: "H440229001582021033017351627",
  10796. PsnNo: "44020000001102481733",
  10797. Info: "2207",
  10798. }
  10799. customData = append(customData, custom1212)
  10800. custom13 := &CustomData{
  10801. MsgId: "H44022900158202103301740327951",
  10802. PsnNo: "44020000001103174866",
  10803. Info: "2207",
  10804. }
  10805. customData = append(customData, custom13)
  10806. custom14 := &CustomData{
  10807. MsgId: "H4402290015820210330174922668",
  10808. PsnNo: "44020000001102927272",
  10809. Info: "2207",
  10810. }
  10811. customData = append(customData, custom14)
  10812. custom15 := &CustomData{
  10813. MsgId: "H44022900158202103301752362273",
  10814. PsnNo: "44020000001102942890",
  10815. Info: "2207",
  10816. }
  10817. customData = append(customData, custom15)
  10818. custom16 := &CustomData{
  10819. MsgId: "H44022900158202103301751082917",
  10820. PsnNo: "44020000001101662162",
  10821. Info: "2207",
  10822. }
  10823. customData = append(customData, custom16)
  10824. custom17 := &CustomData{
  10825. MsgId: "H44022900158202103301754147728",
  10826. PsnNo: "44020000000229014511",
  10827. Info: "2207",
  10828. }
  10829. customData = append(customData, custom17)
  10830. adminUser := c.GetAdminUserInfo()
  10831. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10832. for _, item := range customData {
  10833. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10834. fmt.Println(result)
  10835. }
  10836. }
  10837. //func (c *HisApiController) GetAllopatry() {
  10838. // year := c.GetString("year")
  10839. // month := c.GetString("month")
  10840. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10841. // adminUser := c.GetAdminUserInfo()
  10842. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10843. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10844. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10845. //
  10846. // var dat map[string]interface{}
  10847. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10848. // fmt.Println(dat)
  10849. // } else {
  10850. // fmt.Println(err)
  10851. // }
  10852. // userJSONBytes, _ := json.Marshal(dat)
  10853. // var res models.Result9001
  10854. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10855. // utils.ErrorLog("解析失败:%v", err)
  10856. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10857. // return
  10858. // }
  10859. //
  10860. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10861. // var dat2 map[string]interface{}
  10862. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10863. // fmt.Println(dat)
  10864. // } else {
  10865. // fmt.Println(err)
  10866. // }
  10867. // userJSONBytes2, _ := json.Marshal(dat2)
  10868. // var res2 models.Result3260
  10869. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10870. // utils.ErrorLog("解析失败:%v", err)
  10871. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10872. // return
  10873. // }
  10874. // if res2.Infcode == 0 {
  10875. // c.ServeSuccessJSON(map[string]interface{}{
  10876. // "list": res2.Output.Data,
  10877. // })
  10878. // return
  10879. // } else {
  10880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10881. // return
  10882. // }
  10883. //
  10884. //}
  10885. //func (c *HisApiController) ComfirmAllopatry() {
  10886. // year := c.GetString("year")
  10887. // month := c.GetString("month")
  10888. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10889. // adminUser := c.GetAdminUserInfo()
  10890. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10891. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10892. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10893. // var dat map[string]interface{}
  10894. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10895. // fmt.Println(dat)
  10896. // } else {
  10897. // fmt.Println(err)
  10898. // }
  10899. // userJSONBytes, _ := json.Marshal(dat)
  10900. // var res models.Result9001
  10901. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10902. // utils.ErrorLog("解析失败:%v", err)
  10903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10904. // return
  10905. // }
  10906. //
  10907. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10908. // var dat2 map[string]interface{}
  10909. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10910. // fmt.Println(dat)
  10911. // } else {
  10912. // fmt.Println(err)
  10913. // }
  10914. // userJSONBytes2, _ := json.Marshal(dat2)
  10915. // var res2 models.Result3260
  10916. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10917. // utils.ErrorLog("解析失败:%v", err)
  10918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10919. // return
  10920. // }
  10921. //
  10922. // if res2.Infcode == 0 {
  10923. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10924. // var dat map[string]interface{}
  10925. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10926. // fmt.Println(dat)
  10927. // } else {
  10928. // fmt.Println(err)
  10929. // }
  10930. // userJSONBytes, _ := json.Marshal(dat)
  10931. // var res3 models.Result3261
  10932. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10933. // utils.ErrorLog("解析失败:%v", err)
  10934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10935. // return
  10936. // }
  10937. //
  10938. // if res3.Infcode == 0 {
  10939. // record := &models.HisYidiClearRecord{
  10940. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10941. // Ctime: time.Now().Unix(),
  10942. // Mtime: time.Now().Unix(),
  10943. // Status: 1,
  10944. // MsgId: msgId,
  10945. // }
  10946. // service.SaveClearRecord(record)
  10947. // c.ServeSuccessJSON(map[string]interface{}{
  10948. // "msg": "提取成功",
  10949. // })
  10950. // }
  10951. // }
  10952. //}
  10953. func (c *HisApiController) RefundAllopatry() {
  10954. year := c.GetString("year")
  10955. month := c.GetString("month")
  10956. id, _ := c.GetInt64("id")
  10957. admin_user_id, _ := c.GetInt64("admin_user_id")
  10958. adminUser := c.GetAdminUserInfo()
  10959. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10960. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10961. record, _ := service.GetClearRecordById(id)
  10962. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10963. var dat map[string]interface{}
  10964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10965. fmt.Println(dat)
  10966. } else {
  10967. fmt.Println(err)
  10968. }
  10969. userJSONBytes, _ := json.Marshal(dat)
  10970. var empty ResultFourteen
  10971. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10972. utils.ErrorLog("解析失败:%v", err)
  10973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10974. return
  10975. }
  10976. if empty.Infcode == 0 {
  10977. c.ServeSuccessJSON(map[string]interface{}{
  10978. "msg": "撤销成功",
  10979. })
  10980. return
  10981. }
  10982. }
  10983. func (c *HisApiController) ReversalOtherData() {
  10984. var customData []*CustomData
  10985. custom := &CustomData{
  10986. MsgId: "H44022900158202103301714472004",
  10987. PsnNo: "44020000001101329945",
  10988. Info: "2208",
  10989. }
  10990. customData = append(customData, custom)
  10991. custom1 := &CustomData{
  10992. MsgId: "H4402290015820210330172057803",
  10993. PsnNo: "44020000001101161813",
  10994. Info: "2208",
  10995. }
  10996. customData = append(customData, custom1)
  10997. custom2 := &CustomData{
  10998. MsgId: "H44022900158202103301705198813",
  10999. PsnNo: "44190000133097375417",
  11000. Info: "2208",
  11001. }
  11002. customData = append(customData, custom2)
  11003. custom3 := &CustomData{
  11004. MsgId: "H44022900158202103301715524756",
  11005. PsnNo: "44020000001100187221",
  11006. Info: "2208",
  11007. }
  11008. customData = append(customData, custom3)
  11009. custom4 := &CustomData{
  11010. MsgId: "H44022900158202103301730376224",
  11011. PsnNo: "44020000001101959155",
  11012. Info: "2208",
  11013. }
  11014. customData = append(customData, custom4)
  11015. custom5 := &CustomData{
  11016. MsgId: "H44022900158202103301748008725",
  11017. PsnNo: "44020000001104246641",
  11018. Info: "2208",
  11019. }
  11020. customData = append(customData, custom5)
  11021. custom6 := &CustomData{
  11022. MsgId: "H44022900158202103301718096755",
  11023. PsnNo: "44020000001102211860",
  11024. Info: "2208",
  11025. }
  11026. customData = append(customData, custom6)
  11027. custom7 := &CustomData{
  11028. MsgId: "H44022900158202103301736551640",
  11029. PsnNo: "44020000001102687718",
  11030. Info: "2208",
  11031. }
  11032. customData = append(customData, custom7)
  11033. custom8 := &CustomData{
  11034. MsgId: "H44022900158202103301743097676",
  11035. PsnNo: "44020000001102127785",
  11036. Info: "2208",
  11037. }
  11038. customData = append(customData, custom8)
  11039. custom9 := &CustomData{
  11040. MsgId: "H44022900158202103301712304203",
  11041. PsnNo: "44020000001101518097",
  11042. Info: "2208",
  11043. }
  11044. customData = append(customData, custom9)
  11045. custom10 := &CustomData{
  11046. MsgId: "H44022900158202103301738448785",
  11047. PsnNo: "44020000001100500813",
  11048. Info: "2208",
  11049. }
  11050. customData = append(customData, custom10)
  11051. custom11 := &CustomData{
  11052. MsgId: "H44022900158202103301732455843",
  11053. PsnNo: "44020000001102690557",
  11054. Info: "2208",
  11055. }
  11056. customData = append(customData, custom11)
  11057. custom12 := &CustomData{
  11058. MsgId: "H44022900158202103301745421708",
  11059. PsnNo: "44020000001102211928",
  11060. Info: "2208",
  11061. }
  11062. customData = append(customData, custom12)
  11063. custom1212 := &CustomData{
  11064. MsgId: "H440229001582021033017351627",
  11065. PsnNo: "44020000001102481733",
  11066. Info: "2208",
  11067. }
  11068. customData = append(customData, custom1212)
  11069. custom13 := &CustomData{
  11070. MsgId: "H44022900158202103301740327951",
  11071. PsnNo: "44020000001103174866",
  11072. Info: "2208",
  11073. }
  11074. customData = append(customData, custom13)
  11075. custom14 := &CustomData{
  11076. MsgId: "H4402290015820210330174922668",
  11077. PsnNo: "44020000001102927272",
  11078. Info: "2208",
  11079. }
  11080. customData = append(customData, custom14)
  11081. custom15 := &CustomData{
  11082. MsgId: "H44022900158202103301752362273",
  11083. PsnNo: "44020000001102942890",
  11084. Info: "2208",
  11085. }
  11086. customData = append(customData, custom15)
  11087. custom16 := &CustomData{
  11088. MsgId: "H44022900158202103301751082917",
  11089. PsnNo: "44020000001101662162",
  11090. Info: "2208",
  11091. }
  11092. customData = append(customData, custom16)
  11093. custom17 := &CustomData{
  11094. MsgId: "H44022900158202103301754147728",
  11095. PsnNo: "44020000000229014511",
  11096. Info: "2208",
  11097. }
  11098. customData = append(customData, custom17)
  11099. adminUser := c.GetAdminUserInfo()
  11100. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11101. for _, item := range customData {
  11102. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11103. fmt.Println(result)
  11104. }
  11105. }
  11106. func PathExists(path string) (bool, error) {
  11107. _, err := os.Stat(path)
  11108. if err == nil {
  11109. return true, nil
  11110. }
  11111. if os.IsNotExist(err) {
  11112. return false, nil
  11113. }
  11114. return false, err
  11115. }
  11116. //创建文件夹
  11117. func Mkdir(dir string) {
  11118. // 创建文件夹
  11119. exist, err := PathExists(dir)
  11120. if err != nil {
  11121. fmt.Println(err.Error())
  11122. } else {
  11123. if exist {
  11124. fmt.Println(dir + "文件夹已存在!")
  11125. } else {
  11126. // 文件夹名称,权限
  11127. err := os.Mkdir(dir, os.ModePerm)
  11128. if err != nil {
  11129. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11130. } else {
  11131. fmt.Println(dir + "文件夹创建成功!")
  11132. }
  11133. }
  11134. }
  11135. }
  11136. //压缩文件
  11137. func Zip(srcFile string, destZip string) error {
  11138. zipfile, err := os.Create(destZip)
  11139. if err != nil {
  11140. return err
  11141. }
  11142. defer zipfile.Close()
  11143. archive := zip.NewWriter(zipfile)
  11144. defer archive.Close()
  11145. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11146. if err != nil {
  11147. return err
  11148. }
  11149. header, err := zip.FileInfoHeader(info)
  11150. if err != nil {
  11151. return err
  11152. }
  11153. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11154. // header.Name = path
  11155. if info.IsDir() {
  11156. header.Name += "/"
  11157. } else {
  11158. header.Method = zip.Deflate
  11159. }
  11160. writer, err := archive.CreateHeader(header)
  11161. if err != nil {
  11162. return err
  11163. }
  11164. if !info.IsDir() {
  11165. file, err := os.Open(path)
  11166. if err != nil {
  11167. return err
  11168. }
  11169. defer file.Close()
  11170. _, err = io.Copy(writer, file)
  11171. }
  11172. return err
  11173. })
  11174. return err
  11175. }
  11176. func ReadFile(filePath string) []byte {
  11177. f, err := os.Open(filePath)
  11178. if err != nil {
  11179. fmt.Println("read file fail", err)
  11180. return nil
  11181. }
  11182. defer f.Close()
  11183. fd, err := ioutil.ReadAll(f)
  11184. if err != nil {
  11185. fmt.Println("read to fd fail", err)
  11186. return nil
  11187. }
  11188. return fd
  11189. }
  11190. func saveLog(result string, request string, infno string, desc string) {
  11191. org_id, _ := beego.AppConfig.Int64("org_id")
  11192. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11193. dir := miConfig.OrgName + "日志"
  11194. utils.Mkdir(dir)
  11195. month := time.Unix(1557042972, 0).Format("1")
  11196. year := time.Now().Format("2006")
  11197. month = time.Now().Format("01")
  11198. day := time.Now().Format("02")
  11199. hour := time.Now().Format("15")
  11200. min := time.Now().Format("04")
  11201. sec := time.Now().Format("05")
  11202. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11203. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11204. file_name := file + ".txt"
  11205. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11206. exist, _ := utils.PathExists(file_path)
  11207. if exist { //存在
  11208. fmt.Println("存在")
  11209. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11210. if err != nil {
  11211. fmt.Println("read fail")
  11212. }
  11213. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11214. n, _ := f.Seek(0, 2)
  11215. _, err = f.WriteAt([]byte(content), n)
  11216. } else { //不存在
  11217. fmt.Println("文件不存在,创建文件")
  11218. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11219. defer f.Close()
  11220. if err != nil {
  11221. } else {
  11222. _, err = f.Write([]byte("记录日志"))
  11223. }
  11224. }
  11225. }
  11226. type Charset string
  11227. const (
  11228. UTF8 = Charset("UTF-8")
  11229. GB18030 = Charset("GB18030")
  11230. )
  11231. func ConvertToString(src string, srcCode string, tagCode string) string {
  11232. srcCoder := mahonia.NewDecoder(srcCode)
  11233. srcResult := srcCoder.ConvertString(src)
  11234. tagCoder := mahonia.NewDecoder(tagCode)
  11235. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11236. result := string(cdata)
  11237. return result
  11238. }
  11239. func (c *HisApiController) ReadEleCard() {
  11240. id_card_type, _ := c.GetInt64("id_card_type")
  11241. admin_user_id, _ := c.GetInt64("admin_user_id")
  11242. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11243. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11244. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11245. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11246. var api string
  11247. if miConfig.MdtrtareaAdmvs == "320921" {
  11248. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11249. "&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
  11250. fmt.Println(api)
  11251. } else {
  11252. 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 +
  11253. "&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
  11254. }
  11255. resp, requestErr := http.Get(api)
  11256. if requestErr != nil {
  11257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11258. return
  11259. }
  11260. body, ioErr := ioutil.ReadAll(resp.Body)
  11261. if ioErr != nil {
  11262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11264. return
  11265. }
  11266. var respJSON map[string]interface{}
  11267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11270. return
  11271. }
  11272. var status string
  11273. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11274. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11275. var token string
  11276. var res ResultTwo //1101结果
  11277. var res10265 ResultTwo10265 //1101结果
  11278. if status == "0" { //读卡成功
  11279. var card_info string //卡信息
  11280. var busi_card_info string
  11281. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11282. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11283. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11284. fmt.Println(card_info)
  11285. fmt.Println(busi_card_info)
  11286. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11287. result, _ := json.Marshal(respJSON)
  11288. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11289. utils.ErrorLog("解析失败:%v", err)
  11290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11291. return
  11292. }
  11293. res.ErrMsg = res10265.ErrMsg
  11294. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11295. res.Infcode = infocode
  11296. res.Output = res10265.Output
  11297. res.InfRefmsgid = res10265.InfRefmsgid
  11298. if res.Infcode == 0 {
  11299. c.ServeSuccessJSON(map[string]interface{}{
  11300. "number": token,
  11301. })
  11302. }
  11303. } else {
  11304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11305. return
  11306. }
  11307. } else { //读卡失败
  11308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11309. return
  11310. }
  11311. }
  11312. func DeleteExtraSpaceTwo(s string) string {
  11313. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11314. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11315. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11316. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11317. s2 := make([]byte, len(s1)) //定义字符数组切片
  11318. copy(s2, s1) //将字符串复制到切片
  11319. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11320. for len(spc_index) > 0 { //找到适配项
  11321. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11322. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11323. }
  11324. return string(s2)
  11325. }
  11326. func Remove0000(s string) string {
  11327. str := make([]rune, 0, len(s))
  11328. for _, v := range []rune(s) {
  11329. if v == 0 {
  11330. continue
  11331. }
  11332. str = append(str, v)
  11333. }
  11334. return string(str)
  11335. }
  11336. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11337. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11338. readCard := DllDef.MustFindProc("EcQuery")
  11339. pCardInfo := make([]byte, 8192)
  11340. pBusiCardInfo := make([]byte, 8192)
  11341. data := make(map[string]interface{})
  11342. //pData := make(map[string]interface{})
  11343. inputData := make(map[string]interface{})
  11344. inputData["orgId"] = code
  11345. inputData["businessType"] = "01101"
  11346. inputData["operatorId"] = operator_id
  11347. inputData["operatorName"] = operator_name
  11348. inputData["officeId"] = "001"
  11349. inputData["officeName"] = "血透室"
  11350. //
  11351. data["data"] = inputData
  11352. data["transType"] = "ec.query"
  11353. data["orgId"] = code
  11354. bytesData, _ := json.Marshal(data)
  11355. pCardInfo = bytesData
  11356. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11357. fmt.Println(ret2)
  11358. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11359. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11360. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11361. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11362. if ret2 != 0 {
  11363. return "", ""
  11364. }
  11365. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11366. }
  11367. func DeleteExtraSpace(s string) string {
  11368. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11369. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11370. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11371. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11372. s2 := make([]byte, len(s1)) //定义字符数组切片
  11373. copy(s2, s1) //将字符串复制到切片
  11374. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11375. for len(spc_index) > 0 { //找到适配项
  11376. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11377. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11378. }
  11379. return string(s2)
  11380. }