his_api_controller.go 508KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997
  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. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. }
  81. type Result3101 struct {
  82. Infcode string `json:"infcode"`
  83. InfRefmsgid string `json:"inf_refmsgid"`
  84. RefmsgTime string `json:"refmsg_time"`
  85. RespondTime string `json:"respond_time"`
  86. Enctype string `json:"enctype"`
  87. Signtype string `json:"signtype"`
  88. ErrMsg string `json:"err_msg"`
  89. Output struct {
  90. Result []struct {
  91. JudgeResultDetailDtos []struct {
  92. VolaItemType string `json:"vola_item_type"`
  93. MdtrtID string `json:"mdtrt_id"`
  94. JrdID string `json:"jrd_id"`
  95. PatnID string `json:"patn_id"`
  96. RxID string `json:"rx_id"`
  97. VolaAmt interface{} `json:"vola_amt"`
  98. } `json:"judge_result_detail_dtos"`
  99. RuleID string `json:"rule_id"`
  100. VolaEvid string `json:"vola_evid"`
  101. MdtrtID string `json:"mdtrt_id"`
  102. RuleName string `json:"rule_name"`
  103. VolaAmtStas string `json:"vola_amt_stas"`
  104. JrID string `json:"jr_id"`
  105. PatnID string `json:"patn_id"`
  106. SevDeg string `json:"sev_deg"`
  107. VolaAmt float64 `json:"vola_amt"`
  108. VolaBhvrType string `json:"vola_bhvr_type"`
  109. VolaCont string `json:"vola_cont"`
  110. } `json:"result"`
  111. } `json:"output"`
  112. }
  113. func (c *HisApiController) Get9001() {
  114. adminUser := c.GetAdminUserInfo()
  115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  116. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  117. if miConfig.MdtrtareaAdmvs == "350500" {
  118. service.GetFjAuthorizationInfo(miConfig.Code)
  119. } else {
  120. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  121. var dat map[string]interface{}
  122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  123. fmt.Println(dat)
  124. } else {
  125. fmt.Println(err)
  126. }
  127. userJSONBytes, _ := json.Marshal(dat)
  128. var res models.Result9001
  129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  130. utils.ErrorLog("解析失败:%v", err)
  131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  132. return
  133. }
  134. }
  135. }
  136. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  137. var res Result3101
  138. adminUser := c.GetAdminUserInfo()
  139. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  140. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  141. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  142. //record_time := c.GetString("record_time")
  143. //trig_scen := c.GetString("trig_scen")
  144. timeLayout := "2006-01-02"
  145. loc, _ := time.LoadLocation("Local")
  146. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  147. if err != nil {
  148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  149. return res
  150. }
  151. recordDateTime := theTime.Unix()
  152. var patientPrescription models.HisPrescriptionInfo
  153. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  154. //if patientPrescription.ID == 0 {
  155. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  156. //}
  157. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  158. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  159. //
  160. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  161. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  162. var pp models.PublicParams
  163. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  164. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  165. pp.FixmedinsName = miConfig.OrgName
  166. pp.FixmedinsCode = miConfig.Code
  167. pp.RequestUrl = miConfig.Url
  168. pp.Cainfo = miConfig.Cainfo
  169. pp.SecretKey = miConfig.SecretKey
  170. pp.AccessKey = miConfig.AccessKey
  171. pp.OpterName = roles.UserName
  172. var config []*models.HisXtDiagnoseConfig
  173. for _, item := range diagnosis_ids {
  174. id, _ := strconv.ParseInt(item, 10, 64)
  175. diagnosisConfig, _ := service.FindDiagnoseById(id)
  176. config = append(config, &diagnosisConfig)
  177. }
  178. var pd models.PatientDtos
  179. pd.PatnID = his.PsnNo
  180. pd.PatnName = his.Name
  181. pd.Gend = his.Gend
  182. pd.Brdy = his.Brdy
  183. pd.Poolarea = miConfig.MdtrtareaAdmvs
  184. pd.CurrMdtrtID = his.Number
  185. var fed models.FsiEncounterDtos
  186. fed.MdtrtID = his.Number
  187. fed.MedinsID = miConfig.Code
  188. fed.MedinsName = miConfig.OrgName
  189. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  190. fed.MedMdtrtType = "1"
  191. fed.MedinsType = "1"
  192. fed.MedinsLv = "11"
  193. tm := time.Unix(his.RecordDate, 0)
  194. s_tm := tm.Format("2006-01-02 15:04:05")
  195. fed.AdmDate = s_tm
  196. fed.DscgDate = s_tm
  197. fed.DscgMainDiseCodg = config[0].CountryCode
  198. fed.DscgMainDiseName = config[0].CountryContentName
  199. //诊断信息
  200. var fdds []*models.FsiDiagnoseDtos
  201. for index, item := range config {
  202. if index == 0 {
  203. var fdd models.FsiDiagnoseDtos
  204. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  205. fdd.InoutDiseType = "1"
  206. fdd.MaindiseFlag = "1"
  207. fdd.DiseDate = s_tm
  208. fdd.DiasSrtNo = "1"
  209. fdd.DiseName = item.CountryContentName
  210. fdd.DiseCodg = item.CountryCode
  211. fdds = append(fdds, &fdd)
  212. } else {
  213. var fdd models.FsiDiagnoseDtos
  214. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  215. fdd.InoutDiseType = "1"
  216. fdd.MaindiseFlag = "1"
  217. fdd.DiseDate = s_tm
  218. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  219. fdd.DiseName = item.CountryContentName
  220. fdd.DiseCodg = item.CountryCode
  221. fdds = append(fdds, &fdd)
  222. }
  223. }
  224. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  225. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  226. fed.AdmDeptName = department.Name
  227. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  228. fed.DscgDeptName = department.Name
  229. fed.MedMdtrtType = "1"
  230. fed.MedType = "11"
  231. //if his.Insutype == "390" {
  232. // fed.MedType = "1402"
  233. //} else {
  234. // fed.MedType = "9933"
  235. //}
  236. var orders []*models.FsiOrderDtos
  237. if trig_scen == "2" {
  238. //处方医嘱信息
  239. for _, item := range prescriptions {
  240. for _, subItem := range item.HisDoctorAdviceInfo {
  241. var order models.FsiOrderDtos
  242. order.RxID = strconv.FormatInt(item.ID, 10)
  243. order.Rxno = strconv.FormatInt(item.ID, 10)
  244. order.LongDrordFlag = "0"
  245. order.HilistType = "1"
  246. order.ChrgType = "1"
  247. order.DrordBhvr = "-"
  248. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  249. order.HosplistName = subItem.BaseDrugLib.DrugName
  250. order.HilistLv = "1"
  251. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  252. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  253. order.HosplistName = subItem.BaseDrugLib.DrugName
  254. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  255. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  256. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  257. order.OwnpayAmt = ""
  258. order.SelfpayAmt = ""
  259. order.Spec = ""
  260. order.SpecUnt = ""
  261. order.DrordBegnDate = s_tm
  262. order.DrordStopDate = ""
  263. order.DrordDrCodg = "1"
  264. order.DrordDeptName = department.Name
  265. order.DrordDrCodg = "1"
  266. order.DrordDrName = doctor_info.UserName
  267. order.DrordDrProfttl = ""
  268. order.CurrDrordFlag = "1"
  269. orders = append(orders, &order)
  270. }
  271. for _, subItem := range item.HisPrescriptionProject {
  272. if subItem.Type == 2 {
  273. var order models.FsiOrderDtos
  274. order.RxID = strconv.FormatInt(item.ID, 10)
  275. order.Rxno = strconv.FormatInt(item.ID, 10)
  276. order.LongDrordFlag = "0"
  277. order.HilistType = "1"
  278. order.ChrgType = "1"
  279. order.DrordBhvr = "-"
  280. order.HilistCode = subItem.HisProject.MedicalCode
  281. order.HosplistName = subItem.HisProject.ProjectName
  282. order.HilistLv = "1"
  283. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  284. order.HosplistCode = subItem.HisProject.MedicalCode
  285. order.HosplistName = subItem.HisProject.ProjectName
  286. order.Cnt = subItem.Count
  287. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  288. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  289. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  290. order.OwnpayAmt = ""
  291. order.SelfpayAmt = ""
  292. order.Spec = ""
  293. order.SpecUnt = ""
  294. order.DrordBegnDate = s_tm
  295. order.DrordStopDate = ""
  296. order.DrordDrCodg = "1"
  297. order.DrordDeptName = department.Name
  298. order.DrordDrCodg = "1"
  299. order.DrordDrName = doctor_info.UserName
  300. order.DrordDrProfttl = ""
  301. order.CurrDrordFlag = "1"
  302. orders = append(orders, &order)
  303. }
  304. if subItem.Type == 3 {
  305. var order models.FsiOrderDtos
  306. order.RxID = strconv.FormatInt(item.ID, 10)
  307. order.Rxno = strconv.FormatInt(item.ID, 10)
  308. order.LongDrordFlag = "0"
  309. order.HilistType = "1"
  310. order.ChrgType = "1"
  311. order.DrordBhvr = "-"
  312. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  313. order.HosplistName = subItem.GoodInfo.GoodName
  314. order.HilistLv = "1"
  315. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  316. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  317. order.HosplistName = subItem.GoodInfo.GoodName
  318. order.Cnt = subItem.Count
  319. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  320. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  321. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  322. order.OwnpayAmt = ""
  323. order.SelfpayAmt = ""
  324. order.Spec = ""
  325. order.SpecUnt = ""
  326. order.DrordBegnDate = s_tm
  327. order.DrordStopDate = ""
  328. order.DrordDrCodg = "1"
  329. order.DrordDeptName = department.Name
  330. order.DrordDrCodg = "1"
  331. order.DrordDrName = doctor_info.UserName
  332. order.DrordDrProfttl = ""
  333. order.CurrDrordFlag = "1"
  334. orders = append(orders, &order)
  335. }
  336. }
  337. }
  338. //处方医嘱信息
  339. }
  340. fed.MatnStas = "0"
  341. fed.MedfeeSumamt = "0"
  342. fed.OwnpayAmt = "0"
  343. fed.SelfpayAmt = "0"
  344. fed.AcctPayamt = "0"
  345. fed.MaAmt = "0"
  346. fed.HifpPayamt = "0"
  347. fed.SetlTotlnum = "1"
  348. fed.Insutype = his.Insutype
  349. fed.ReimFlag = "0"
  350. fed.OutSetlFlag = "0"
  351. var fopd []*models.FsiOperationDtosData
  352. data := make(map[string]interface{})
  353. data["fed"] = fed
  354. data["fdd"] = fdds
  355. data["fod"] = orders
  356. data["pd"] = pd
  357. data["pp"] = pp
  358. data["fopd"] = fopd
  359. data["trig_scen"] = trig_scen
  360. fmt.Println(data)
  361. fmt.Println(fed)
  362. fmt.Println(fdds)
  363. fmt.Println(orders)
  364. fmt.Println(pd)
  365. fmt.Println(pp)
  366. fmt.Println(fopd)
  367. client := &http.Client{}
  368. bytesData, _ := json.Marshal(data)
  369. var req *http.Request
  370. if miConfig.MdtrtareaAdmvs == "320921" {
  371. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  372. } else {
  373. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  374. }
  375. resp, _ := client.Do(req)
  376. defer resp.Body.Close()
  377. body, ioErr := ioutil.ReadAll(resp.Body)
  378. if ioErr != nil {
  379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  381. return res
  382. }
  383. var respJSON map[string]interface{}
  384. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  387. return res
  388. }
  389. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  390. fmt.Println(respJSON)
  391. result, _ := json.Marshal(respJSON)
  392. fmt.Println(result)
  393. if err := json.Unmarshal([]byte(result), &res); err != nil {
  394. utils.ErrorLog("解析失败:%v", err)
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return res
  397. }
  398. return res
  399. }
  400. 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) {
  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. //trig_scen := c.GetString("trig_scen")
  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 res
  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(patientPrescription.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.MedMdtrtType = "1"
  493. fed.MedType = "11"
  494. //if his.Insutype == "390" {
  495. // fed.MedType = "1402"
  496. //} else {
  497. // fed.MedType = "9933"
  498. //}
  499. var orders []*models.FsiOrderDtos
  500. if trig_scen == "2" {
  501. //处方医嘱信息
  502. for _, item := range prescriptions {
  503. for _, subItem := range item.HisDoctorAdviceInfo {
  504. var order models.FsiOrderDtos
  505. order.RxID = strconv.FormatInt(item.ID, 10)
  506. order.Rxno = strconv.FormatInt(item.ID, 10)
  507. order.LongDrordFlag = "0"
  508. order.HilistType = "1"
  509. order.ChrgType = "1"
  510. order.DrordBhvr = "-"
  511. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  512. order.HosplistName = subItem.BaseDrugLib.DrugName
  513. order.HilistLv = "1"
  514. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  515. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  516. order.HosplistName = subItem.BaseDrugLib.DrugName
  517. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  518. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  519. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  520. order.OwnpayAmt = ""
  521. order.SelfpayAmt = ""
  522. order.Spec = ""
  523. order.SpecUnt = ""
  524. order.DrordBegnDate = s_tm
  525. order.DrordStopDate = ""
  526. order.DrordDrCodg = "1"
  527. order.DrordDeptName = department.Name
  528. order.DrordDrCodg = "1"
  529. order.DrordDrName = doctor_info.UserName
  530. order.DrordDrProfttl = ""
  531. order.CurrDrordFlag = "1"
  532. orders = append(orders, &order)
  533. }
  534. for _, subItem := range item.HisPrescriptionProject {
  535. if subItem.Type == 2 {
  536. var order models.FsiOrderDtos
  537. order.RxID = strconv.FormatInt(item.ID, 10)
  538. order.Rxno = strconv.FormatInt(item.ID, 10)
  539. order.LongDrordFlag = "0"
  540. order.HilistType = "1"
  541. order.ChrgType = "1"
  542. order.DrordBhvr = "-"
  543. order.HilistCode = subItem.HisProject.MedicalCode
  544. order.HosplistName = subItem.HisProject.ProjectName
  545. order.HilistLv = "1"
  546. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  547. order.HosplistCode = subItem.HisProject.MedicalCode
  548. order.HosplistName = subItem.HisProject.ProjectName
  549. order.Cnt = subItem.Count
  550. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  551. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  552. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  553. order.OwnpayAmt = ""
  554. order.SelfpayAmt = ""
  555. order.Spec = ""
  556. order.SpecUnt = ""
  557. order.DrordBegnDate = s_tm
  558. order.DrordStopDate = ""
  559. order.DrordDrCodg = "1"
  560. order.DrordDeptName = department.Name
  561. order.DrordDrCodg = "1"
  562. order.DrordDrName = doctor_info.UserName
  563. order.DrordDrProfttl = ""
  564. order.CurrDrordFlag = "1"
  565. orders = append(orders, &order)
  566. }
  567. if subItem.Type == 3 {
  568. var order models.FsiOrderDtos
  569. order.RxID = strconv.FormatInt(item.ID, 10)
  570. order.Rxno = strconv.FormatInt(item.ID, 10)
  571. order.LongDrordFlag = "0"
  572. order.HilistType = "1"
  573. order.ChrgType = "1"
  574. order.DrordBhvr = "-"
  575. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  576. order.HosplistName = subItem.GoodInfo.GoodName
  577. order.HilistLv = "1"
  578. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  579. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  580. order.HosplistName = subItem.GoodInfo.GoodName
  581. order.Cnt = subItem.Count
  582. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  583. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  584. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  585. order.OwnpayAmt = ""
  586. order.SelfpayAmt = ""
  587. order.Spec = ""
  588. order.SpecUnt = ""
  589. order.DrordBegnDate = s_tm
  590. order.DrordStopDate = ""
  591. order.DrordDrCodg = "1"
  592. order.DrordDeptName = department.Name
  593. order.DrordDrCodg = "1"
  594. order.DrordDrName = doctor_info.UserName
  595. order.DrordDrProfttl = ""
  596. order.CurrDrordFlag = "1"
  597. orders = append(orders, &order)
  598. }
  599. }
  600. }
  601. //处方医嘱信息
  602. }
  603. fed.MatnStas = "0"
  604. fed.MedfeeSumamt = "0"
  605. fed.OwnpayAmt = "0"
  606. fed.SelfpayAmt = "0"
  607. fed.AcctPayamt = "0"
  608. fed.MaAmt = "0"
  609. fed.HifpPayamt = "0"
  610. fed.SetlTotlnum = "1"
  611. fed.Insutype = his.Insutype
  612. fed.ReimFlag = "0"
  613. fed.OutSetlFlag = "0"
  614. var fopd []*models.FsiOperationDtosData
  615. data := make(map[string]interface{})
  616. data["fed"] = fed
  617. data["fdd"] = fdds
  618. data["fod"] = orders
  619. data["pd"] = pd
  620. data["pp"] = pp
  621. data["fopd"] = fopd
  622. data["trig_scen"] = trig_scen
  623. fmt.Println(data)
  624. fmt.Println(fed)
  625. fmt.Println(fdds)
  626. fmt.Println(orders)
  627. fmt.Println(pd)
  628. fmt.Println(pp)
  629. fmt.Println(fopd)
  630. client := &http.Client{}
  631. bytesData, _ := json.Marshal(data)
  632. var req *http.Request
  633. if miConfig.MdtrtareaAdmvs == "320921" {
  634. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  635. } else {
  636. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  637. }
  638. resp, _ := client.Do(req)
  639. defer resp.Body.Close()
  640. body, ioErr := ioutil.ReadAll(resp.Body)
  641. if ioErr != nil {
  642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  644. return res
  645. }
  646. var respJSON map[string]interface{}
  647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  650. return res
  651. }
  652. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  653. result, _ := json.Marshal(respJSON)
  654. if err := json.Unmarshal([]byte(result), &res); err != nil {
  655. utils.ErrorLog("解析失败:%v", err)
  656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  657. return res
  658. }
  659. return res
  660. }
  661. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  662. ////patient_id, _ := c.GetInt64("patient_id")
  663. //order_id, _ := c.GetInt64("order_id")
  664. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  665. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  666. //trig_scen := c.GetString("trig_scen")
  667. adminUser := c.GetAdminUserInfo()
  668. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  669. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  670. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  671. record_time := c.GetString("record_time")
  672. order, _ := service.GetHisOrderByID(order_id)
  673. timeLayout := "2006-01-02"
  674. loc, _ := time.LoadLocation("Local")
  675. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  676. if err != nil {
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  678. return
  679. }
  680. recordDateTime := theTime.Unix()
  681. var patientPrescription models.HisPrescriptionInfo
  682. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  683. if patientPrescription.ID == 0 {
  684. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  685. }
  686. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  687. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  688. //
  689. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  690. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  691. var pp models.PublicParams
  692. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  693. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  694. pp.FixmedinsName = miConfig.OrgName
  695. pp.FixmedinsCode = miConfig.Code
  696. pp.RequestUrl = miConfig.Url
  697. pp.Cainfo = miConfig.Cainfo
  698. pp.SecretKey = miConfig.SecretKey
  699. pp.AccessKey = miConfig.AccessKey
  700. pp.OpterName = roles.UserName
  701. var config []*models.HisXtDiagnoseConfig
  702. for _, item := range diagnosis_ids {
  703. id, _ := strconv.ParseInt(item, 10, 64)
  704. diagnosisConfig, _ := service.FindDiagnoseById(id)
  705. config = append(config, &diagnosisConfig)
  706. }
  707. var pd models.PatientDtos
  708. pd.PatnID = his.PsnNo
  709. pd.PatnName = his.Name
  710. pd.Gend = his.Gend
  711. pd.Brdy = his.Brdy
  712. pd.Poolarea = his.InsuplcAdmdvs
  713. pd.CurrMdtrtID = his.Number
  714. var fed models.FsiEncounterDtos
  715. fed.MdtrtID = his.Number
  716. fed.MedinsID = miConfig.Code
  717. fed.MedinsName = miConfig.OrgName
  718. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  719. fed.MedMdtrtType = "1"
  720. fed.MedinsType = "1"
  721. fed.MedinsLv = "11"
  722. tm := time.Unix(his.RecordDate, 0)
  723. s_tm := tm.Format("2006-01-02 15:04:05")
  724. fed.AdmDate = s_tm
  725. fed.DscgDate = s_tm
  726. fed.DscgMainDiseCodg = config[0].CountryCode
  727. fed.DscgMainDiseName = config[0].CountryContentName
  728. //诊断信息
  729. var fdds []*models.FsiDiagnoseDtos
  730. for index, item := range config {
  731. if index == 0 {
  732. var fdd models.FsiDiagnoseDtos
  733. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  734. fdd.InoutDiseType = "1"
  735. fdd.MaindiseFlag = "1"
  736. fdd.DiseDate = s_tm
  737. fdd.DiasSrtNo = "1"
  738. fdd.DiseName = item.CountryContentName
  739. fdd.DiseCodg = item.CountryCode
  740. fdds = append(fdds, &fdd)
  741. } else {
  742. var fdd models.FsiDiagnoseDtos
  743. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  744. fdd.InoutDiseType = "1"
  745. fdd.MaindiseFlag = "1"
  746. fdd.DiseDate = s_tm
  747. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  748. fdd.DiseName = item.CountryContentName
  749. fdd.DiseCodg = item.CountryCode
  750. fdds = append(fdds, &fdd)
  751. }
  752. }
  753. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  754. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  755. fed.AdmDeptName = department.Name
  756. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  757. fed.DscgDeptName = department.Name
  758. fed.MedType = order.MedType
  759. //处方医嘱信息
  760. var orders []*models.FsiOrderDtos
  761. //for _, item := range prescriptions {
  762. // for _, subItem := range item.HisDoctorAdviceInfo {
  763. // var order models.FsiOrderDtos
  764. // order.RxID = strconv.FormatInt(item.ID, 10)
  765. // order.Rxno = strconv.FormatInt(item.ID, 10)
  766. // order.LongDrordFlag = "0"
  767. // order.HilistType = "1"
  768. // order.ChrgType = "1"
  769. // order.DrordBhvr = "-"
  770. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  771. // order.HosplistName = subItem.BaseDrugLib.DrugName
  772. // order.HilistLv = "1"
  773. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  774. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  775. // order.HosplistName = subItem.BaseDrugLib.DrugName
  776. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  777. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  778. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  779. // order.OwnpayAmt = ""
  780. // order.SelfpayAmt = ""
  781. // order.Spec = ""
  782. // order.SpecUnt = ""
  783. // order.DrordBegnDate = s_tm
  784. // order.DrordStopDate = ""
  785. // order.DrordDrCodg = "1"
  786. // order.DrordDeptName = department.Name
  787. // order.DrordDrCodg = "1"
  788. // order.DrordDrName = doctor_info.UserName
  789. // order.DrordDrProfttl = ""
  790. // order.CurrDrordFlag = "1"
  791. // orders = append(orders, &order)
  792. // }
  793. // for _, subItem := range item.HisPrescriptionProject {
  794. // if subItem.Type == 2 {
  795. // var order models.FsiOrderDtos
  796. // order.RxID = strconv.FormatInt(item.ID, 10)
  797. // order.Rxno = strconv.FormatInt(item.ID, 10)
  798. // order.LongDrordFlag = "0"
  799. // order.HilistType = "1"
  800. // order.ChrgType = "1"
  801. // order.DrordBhvr = "-"
  802. // order.HilistCode = subItem.HisProject.MedicalCode
  803. // order.HosplistName = subItem.HisProject.ProjectName
  804. // order.HilistLv = "1"
  805. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  806. // order.HosplistCode = subItem.HisProject.MedicalCode
  807. // order.HosplistName = subItem.HisProject.ProjectName
  808. // order.Cnt = subItem.Count
  809. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  810. //
  811. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  812. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  813. // order.OwnpayAmt = ""
  814. // order.SelfpayAmt = ""
  815. // order.Spec = ""
  816. // order.SpecUnt = ""
  817. // order.DrordBegnDate = s_tm
  818. // order.DrordStopDate = ""
  819. // order.DrordDrCodg = "1"
  820. // order.DrordDeptName = department.Name
  821. // order.DrordDrCodg = "1"
  822. // order.DrordDrName = doctor_info.UserName
  823. // order.DrordDrProfttl = ""
  824. // order.CurrDrordFlag = "1"
  825. // orders = append(orders, &order)
  826. //
  827. // }
  828. // if subItem.Type == 3 {
  829. //
  830. // var order models.FsiOrderDtos
  831. // order.RxID = strconv.FormatInt(item.ID, 10)
  832. // order.Rxno = strconv.FormatInt(item.ID, 10)
  833. // order.LongDrordFlag = "0"
  834. // order.HilistType = "1"
  835. // order.ChrgType = "1"
  836. // order.DrordBhvr = "-"
  837. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  838. // order.HosplistName = subItem.GoodInfo.GoodName
  839. // order.HilistLv = "1"
  840. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  841. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  842. // order.HosplistName = subItem.GoodInfo.GoodName
  843. // order.Cnt = subItem.Count
  844. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  845. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  846. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  847. // order.OwnpayAmt = ""
  848. // order.SelfpayAmt = ""
  849. // order.Spec = ""
  850. // order.SpecUnt = ""
  851. // order.DrordBegnDate = s_tm
  852. // order.DrordStopDate = ""
  853. // order.DrordDrCodg = "1"
  854. // order.DrordDeptName = department.Name
  855. // order.DrordDrCodg = "1"
  856. // order.DrordDrName = doctor_info.UserName
  857. // order.DrordDrProfttl = ""
  858. // order.CurrDrordFlag = "1"
  859. // orders = append(orders, &order)
  860. //
  861. // }
  862. // }
  863. //}
  864. for _, item := range prescriptions {
  865. for _, subItem := range item.HisDoctorAdviceInfo {
  866. var order models.FsiOrderDtos
  867. order.RxID = strconv.FormatInt(item.ID, 10)
  868. order.Rxno = strconv.FormatInt(item.ID, 10)
  869. order.LongDrordFlag = "0"
  870. order.HilistType = "1"
  871. order.ChrgType = "1"
  872. order.DrordBhvr = "-"
  873. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  874. order.HosplistName = subItem.BaseDrugLib.DrugName
  875. order.HilistLv = "1"
  876. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  877. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  878. order.HosplistName = subItem.BaseDrugLib.DrugName
  879. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  880. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  881. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  882. order.OwnpayAmt = ""
  883. order.SelfpayAmt = ""
  884. order.Spec = ""
  885. order.SpecUnt = ""
  886. order.DrordBegnDate = s_tm
  887. order.DrordStopDate = ""
  888. order.DrordDrCodg = "1"
  889. order.DrordDeptName = department.Name
  890. order.DrordDrCodg = "1"
  891. order.DrordDrName = doctor_info.UserName
  892. order.DrordDrProfttl = ""
  893. order.CurrDrordFlag = "1"
  894. orders = append(orders, &order)
  895. }
  896. for _, subItem := range item.HisPrescriptionProject {
  897. if subItem.Type == 2 {
  898. var order models.FsiOrderDtos
  899. order.RxID = strconv.FormatInt(item.ID, 10)
  900. order.Rxno = strconv.FormatInt(item.ID, 10)
  901. order.LongDrordFlag = "0"
  902. order.HilistType = "1"
  903. order.ChrgType = "1"
  904. order.DrordBhvr = "-"
  905. order.HilistCode = subItem.HisProject.MedicalCode
  906. order.HosplistName = subItem.HisProject.ProjectName
  907. order.HilistLv = "1"
  908. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  909. order.HosplistCode = subItem.HisProject.MedicalCode
  910. order.HosplistName = subItem.HisProject.ProjectName
  911. order.Cnt = subItem.Count
  912. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  913. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  914. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  915. order.OwnpayAmt = ""
  916. order.SelfpayAmt = ""
  917. order.Spec = ""
  918. order.SpecUnt = ""
  919. order.DrordBegnDate = s_tm
  920. order.DrordStopDate = ""
  921. order.DrordDrCodg = "1"
  922. order.DrordDeptName = department.Name
  923. order.DrordDrCodg = "1"
  924. order.DrordDrName = doctor_info.UserName
  925. order.DrordDrProfttl = ""
  926. order.CurrDrordFlag = "1"
  927. orders = append(orders, &order)
  928. }
  929. if subItem.Type == 3 {
  930. var order models.FsiOrderDtos
  931. order.RxID = strconv.FormatInt(item.ID, 10)
  932. order.Rxno = strconv.FormatInt(item.ID, 10)
  933. order.LongDrordFlag = "0"
  934. order.HilistType = "1"
  935. order.ChrgType = "1"
  936. order.DrordBhvr = "-"
  937. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  938. order.HosplistName = subItem.GoodInfo.GoodName
  939. order.HilistLv = "1"
  940. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  941. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  942. order.HosplistName = subItem.GoodInfo.GoodName
  943. order.Cnt = subItem.Count
  944. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  945. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  946. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  947. order.OwnpayAmt = ""
  948. order.SelfpayAmt = ""
  949. order.Spec = ""
  950. order.SpecUnt = ""
  951. order.DrordBegnDate = s_tm
  952. order.DrordStopDate = ""
  953. order.DrordDrCodg = "1"
  954. order.DrordDeptName = department.Name
  955. order.DrordDrCodg = "1"
  956. order.DrordDrName = doctor_info.UserName
  957. order.DrordDrProfttl = ""
  958. order.CurrDrordFlag = "1"
  959. orders = append(orders, &order)
  960. }
  961. }
  962. }
  963. //处方医嘱信息
  964. fed.MatnStas = "0"
  965. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  966. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  967. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  968. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  969. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  970. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  971. fed.SetlTotlnum = "1"
  972. fed.Insutype = his.Insutype
  973. fed.ReimFlag = "0"
  974. fed.OutSetlFlag = "0"
  975. var fopd []*models.FsiOperationDtosData
  976. data := make(map[string]interface{})
  977. data["fed"] = fed
  978. data["fdd"] = fdds
  979. data["fod"] = orders
  980. data["pd"] = pd
  981. data["pp"] = pp
  982. data["fopd"] = fopd
  983. data["trig_scen"] = trig_scen
  984. client := &http.Client{}
  985. bytesData, _ := json.Marshal(data)
  986. var req *http.Request
  987. if miConfig.MdtrtareaAdmvs == "320921" {
  988. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  989. } else {
  990. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  991. }
  992. resp, _ := client.Do(req)
  993. defer resp.Body.Close()
  994. body, ioErr := ioutil.ReadAll(resp.Body)
  995. if ioErr != nil {
  996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  998. return res
  999. }
  1000. var respJSON map[string]interface{}
  1001. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1004. return res
  1005. }
  1006. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1007. result, _ := json.Marshal(respJSON)
  1008. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1009. utils.ErrorLog("解析失败:%v", err)
  1010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1011. return res
  1012. }
  1013. return res
  1014. //手术操作集合
  1015. //手术操作集合
  1016. }
  1017. func (c *HisApiController) Check() {
  1018. psn_no := c.GetString("psn_no")
  1019. in := c.GetString("in")
  1020. mt := c.GetString("mt")
  1021. baseParams := models.BaseParams{
  1022. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1023. FixmedinsCode: "H15049901371",
  1024. InsuplcAdmdvs: "150499",
  1025. MdtrtareaAdmvs: "150499",
  1026. OrgName: "赤峰费森血液透析中心",
  1027. Doctor: "1111",
  1028. }
  1029. service.Gdyb2001(baseParams, psn_no, in, mt)
  1030. }
  1031. func (c *HisApiController) GetPsnNcdsInfo() {
  1032. admin_user_id, _ := c.GetInt64("admin_user_id")
  1033. patient_id, _ := c.GetInt64("patient_id")
  1034. id, _ := c.GetInt64("id")
  1035. adminUser := c.GetAdminUserInfo()
  1036. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1037. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1038. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1039. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1040. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1041. //
  1042. //if psn_record.ID == 0 {
  1043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1044. // return
  1045. //}
  1046. var res Result5301
  1047. var res10265 Result5301For10265
  1048. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1049. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1050. var api string
  1051. if miConfig.MdtrtareaAdmvs == "320921" {
  1052. 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 +
  1053. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1054. } else {
  1055. 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 +
  1056. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1057. }
  1058. resp, requestErr := http.Get(api)
  1059. if requestErr != nil {
  1060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1061. return
  1062. }
  1063. body, ioErr := ioutil.ReadAll(resp.Body)
  1064. if ioErr != nil {
  1065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1067. return
  1068. }
  1069. var respJSON map[string]interface{}
  1070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1073. return
  1074. }
  1075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1076. result, _ := json.Marshal(respJSON)
  1077. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1078. utils.ErrorLog("解析失败:%v", err)
  1079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1080. return
  1081. }
  1082. res.ErrMsg = res10265.ErrMsg
  1083. res.Output = res10265.Output
  1084. res.InfRefmsgid = res10265.InfRefmsgid
  1085. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1086. res.Infcode = infocode
  1087. } else {
  1088. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1089. var dat map[string]interface{}
  1090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1091. fmt.Println(dat)
  1092. } else {
  1093. fmt.Println(err)
  1094. }
  1095. userJSONBytes, _ := json.Marshal(dat)
  1096. if miConfig.Code == "H15049901371" {
  1097. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1098. utils.ErrorLog("解析失败:%v", err)
  1099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1100. return
  1101. }
  1102. res.InfRefmsgid = res10265.InfRefmsgid
  1103. res.Output = res10265.Output
  1104. res.ErrMsg = res10265.ErrMsg
  1105. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1106. res.Infcode = infocode
  1107. } else {
  1108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1109. utils.ErrorLog("解析失败:%v", err)
  1110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1111. return
  1112. }
  1113. }
  1114. }
  1115. if res.Infcode == 0 {
  1116. c.ServeSuccessJSON(map[string]interface{}{
  1117. "result": res.Output.Result,
  1118. })
  1119. }
  1120. }
  1121. func (c *HisApiController) CheckInsutype() {
  1122. his_patient_id, _ := c.GetInt64("his_patient_id")
  1123. admin_user_id, _ := c.GetInt64("admin_user_id")
  1124. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1125. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1126. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1127. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1128. var dat map[string]interface{}
  1129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1130. fmt.Println(dat)
  1131. } else {
  1132. fmt.Println(err)
  1133. }
  1134. userJSONBytes, _ := json.Marshal(dat)
  1135. var res Result90100
  1136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. if res.Infcode != 0 {
  1142. c.ServeSuccessJSON(map[string]interface{}{
  1143. "failed_code": -10,
  1144. "msg": res.ErrMsg,
  1145. })
  1146. return
  1147. } else {
  1148. fmt.Println(res)
  1149. }
  1150. }
  1151. func (c *HisApiController) CheckCardPWD() {
  1152. card_pwd := c.GetString("card_pwd")
  1153. his_patient_id, _ := c.GetInt64("his_patient_id")
  1154. admin_user_id, _ := c.GetInt64("admin_user_id")
  1155. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1156. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1157. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1158. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1159. bas := strings.Split(psn.CardInfo, "|")
  1160. basNumber := bas[2]
  1161. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1162. var dat map[string]interface{}
  1163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1164. fmt.Println(dat)
  1165. } else {
  1166. fmt.Println(err)
  1167. }
  1168. userJSONBytes, _ := json.Marshal(dat)
  1169. var res Result90991
  1170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1171. utils.ErrorLog("解析失败:%v", err)
  1172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1173. return
  1174. }
  1175. if res.Infcode != 0 {
  1176. c.ServeSuccessJSON(map[string]interface{}{
  1177. "failed_code": -10,
  1178. "msg": res.ErrMsg,
  1179. })
  1180. return
  1181. } else {
  1182. if res.Output.Result.SscnoCheckStat == "0" {
  1183. var msg string
  1184. switch res.Output.Result.CardStat {
  1185. case "00":
  1186. msg = "未激活"
  1187. break
  1188. case "10":
  1189. msg = "激活"
  1190. break
  1191. case "20":
  1192. msg = "窗口挂失"
  1193. break
  1194. case "21":
  1195. msg = "电话挂失"
  1196. break
  1197. case "22":
  1198. msg = "单位网上申报挂失"
  1199. break
  1200. case "23":
  1201. msg = "保健办挂失"
  1202. break
  1203. case "24":
  1204. msg = "个人网上挂失"
  1205. break
  1206. case "25":
  1207. msg = "网上服务大厅挂失"
  1208. break
  1209. case "30":
  1210. msg = "注销"
  1211. break
  1212. case "40":
  1213. msg = "回收"
  1214. break
  1215. case "99":
  1216. msg = "制卡中(无效卡)"
  1217. break
  1218. }
  1219. c.ServeSuccessJSON(map[string]interface{}{
  1220. "failed_code": -10,
  1221. "msg": msg,
  1222. })
  1223. return
  1224. } else {
  1225. c.ServeSuccessJSON(map[string]interface{}{
  1226. "msg": "校验成功",
  1227. })
  1228. return
  1229. }
  1230. }
  1231. }
  1232. func (c *HisApiController) CheckCardPWDTwo() {
  1233. //card_pwd := c.GetString("card_pwd")
  1234. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1235. admin_user_id, _ := c.GetInt64("admin_user_id")
  1236. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1237. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1238. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1239. var dat map[string]interface{}
  1240. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1241. fmt.Println(dat)
  1242. } else {
  1243. fmt.Println(err)
  1244. }
  1245. userJSONBytes, _ := json.Marshal(dat)
  1246. var res Result90991
  1247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1248. utils.ErrorLog("解析失败:%v", err)
  1249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1250. return
  1251. }
  1252. if res.Infcode != 0 {
  1253. c.ServeSuccessJSON(map[string]interface{}{
  1254. "failed_code": -10,
  1255. "msg": res.ErrMsg,
  1256. })
  1257. return
  1258. } else {
  1259. if res.Output.Result.SscnoCheckStat == "0" {
  1260. var msg string
  1261. switch res.Output.Result.CardStat {
  1262. case "00":
  1263. msg = "未激活"
  1264. break
  1265. case "10":
  1266. msg = "激活"
  1267. break
  1268. case "20":
  1269. msg = "窗口挂失"
  1270. break
  1271. case "21":
  1272. msg = "电话挂失"
  1273. break
  1274. case "22":
  1275. msg = "单位网上申报挂失"
  1276. break
  1277. case "23":
  1278. msg = "保健办挂失"
  1279. break
  1280. case "24":
  1281. msg = "个人网上挂失"
  1282. break
  1283. case "25":
  1284. msg = "网上服务大厅挂失"
  1285. break
  1286. case "30":
  1287. msg = "注销"
  1288. break
  1289. case "40":
  1290. msg = "回收"
  1291. break
  1292. case "99":
  1293. msg = "制卡中(无效卡)"
  1294. break
  1295. }
  1296. c.ServeSuccessJSON(map[string]interface{}{
  1297. "failed_code": -10,
  1298. "msg": msg,
  1299. })
  1300. return
  1301. } else {
  1302. c.ServeSuccessJSON(map[string]interface{}{
  1303. "msg": "校验成功",
  1304. })
  1305. return
  1306. }
  1307. }
  1308. }
  1309. type ELeCertData struct {
  1310. Data struct {
  1311. Extra string `json:"extra"`
  1312. IDNo string `json:"idNo"`
  1313. IDType string `json:"idType"`
  1314. EcToken string `json:"ecToken"`
  1315. InsuOrg string `json:"insuOrg"`
  1316. UserName string `json:"userName"`
  1317. EcIndexNo string `json:"ecIndexNo"`
  1318. Gender string `json:"gender"`
  1319. Birthday string `json:"birthday"`
  1320. Nationality string `json:"nationality"`
  1321. Email string `json:"email"`
  1322. } `json:"OutData"`
  1323. }
  1324. func (c *HisApiController) ReadCard() {
  1325. id_card_type, _ := c.GetInt64("id_card_type")
  1326. admin_user_id, _ := c.GetInt64("admin_user_id")
  1327. certificates, _ := c.GetInt64("certificates")
  1328. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1329. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1331. switch id_card_type {
  1332. case 1:
  1333. if miConfig.MdtrtareaAdmvs == "421300" {
  1334. var res ResultTwo
  1335. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1336. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1337. "&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)
  1338. resp, requestErr := http.Get(api)
  1339. if requestErr != nil {
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. return
  1342. }
  1343. body, ioErr := ioutil.ReadAll(resp.Body)
  1344. if ioErr != nil {
  1345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1347. return
  1348. }
  1349. var respJSON map[string]interface{}
  1350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1353. return
  1354. }
  1355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1356. result, _ := json.Marshal(respJSON)
  1357. fmt.Println("log")
  1358. fmt.Println(string(result))
  1359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1360. utils.ErrorLog("解析失败:%v", err)
  1361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1362. return
  1363. }
  1364. if res.Infcode == 0 {
  1365. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1366. if err == gorm.ErrRecordNotFound {
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1368. return
  1369. } else if err != nil {
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1371. return
  1372. } else {
  1373. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1374. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1375. infoStr := string(Iinfos)
  1376. idetinfoStr := string(Idetinfos)
  1377. psn := &models.HisPsn{
  1378. PsnNo: res.Output.Baseinfo.PsnNo,
  1379. Age: res.Output.Baseinfo.Age,
  1380. PatientId: patient.ID,
  1381. Certno: res.Output.Baseinfo.Certno,
  1382. Brdy: res.Output.Baseinfo.Brdy,
  1383. Gend: res.Output.Baseinfo.Gend,
  1384. Naty: res.Output.Baseinfo.Naty,
  1385. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1386. PsnName: res.Output.Baseinfo.PsnName,
  1387. Idetinfo: idetinfoStr,
  1388. Insuinfo: infoStr,
  1389. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1390. }
  1391. service.CreateHisPsn(psn)
  1392. c.ServeSuccessJSON(map[string]interface{}{
  1393. "patient": patient,
  1394. "number": res.Output.Baseinfo.Certno,
  1395. })
  1396. }
  1397. } else {
  1398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1399. return
  1400. }
  1401. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1402. var api string
  1403. if miConfig.MdtrtareaAdmvs == "320921" {
  1404. 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 +
  1405. "&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
  1406. fmt.Println(api)
  1407. } else {
  1408. 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 +
  1409. "&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)
  1410. }
  1411. resp, requestErr := http.Get(api)
  1412. if requestErr != nil {
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1414. return
  1415. }
  1416. body, ioErr := ioutil.ReadAll(resp.Body)
  1417. if ioErr != nil {
  1418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1420. return
  1421. }
  1422. var respJSON map[string]interface{}
  1423. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1426. return
  1427. }
  1428. var status string
  1429. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1430. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1431. //console.log()
  1432. fmt.Println("type===")
  1433. fmt.Println(card_type)
  1434. var token string
  1435. var res ResultTwo //1101结果
  1436. var res10265 ResultTwo10265 //1101结果
  1437. var card_info string //卡信息
  1438. var busi_card_info string
  1439. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1440. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1441. if status == "0" { //读卡成功
  1442. if card_type == "1" {
  1443. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1444. result, _ := json.Marshal(respJSON)
  1445. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1446. utils.ErrorLog("解析失败:%v", err)
  1447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1448. return
  1449. }
  1450. res.ErrMsg = res10265.ErrMsg
  1451. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1452. res.Infcode = infocode
  1453. res.Output = res10265.Output
  1454. res.InfRefmsgid = res10265.InfRefmsgid
  1455. } else {
  1456. //var card_info string //卡信息
  1457. //var busi_card_info string
  1458. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1459. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1460. //fmt.Println(card_info)
  1461. //fmt.Println(busi_card_info)
  1462. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1463. result, _ := json.Marshal(respJSON)
  1464. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1465. utils.ErrorLog("解析失败:%v", err)
  1466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1467. return
  1468. }
  1469. res.ErrMsg = res10265.ErrMsg
  1470. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1471. res.Infcode = infocode
  1472. res.Output = res10265.Output
  1473. res.InfRefmsgid = res10265.InfRefmsgid
  1474. }
  1475. if res.Infcode == 0 {
  1476. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1477. if err == gorm.ErrRecordNotFound {
  1478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1479. return
  1480. } else if err != nil {
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1482. return
  1483. } else {
  1484. if card_type == "1" {
  1485. bas := strings.Split(card_info, "|")
  1486. basNumber := bas[2]
  1487. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1488. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1489. infoStr := string(Iinfos)
  1490. idetinfoStr := string(Idetinfos)
  1491. psn := &models.HisPsn{
  1492. PsnNo: res.Output.Baseinfo.PsnNo,
  1493. Age: res.Output.Baseinfo.Age,
  1494. PatientId: patient.ID,
  1495. Certno: res.Output.Baseinfo.Certno,
  1496. Brdy: res.Output.Baseinfo.Brdy,
  1497. Gend: res.Output.Baseinfo.Gend,
  1498. Naty: res.Output.Baseinfo.Naty,
  1499. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1500. PsnName: res.Output.Baseinfo.PsnName,
  1501. Idetinfo: idetinfoStr,
  1502. Insuinfo: infoStr,
  1503. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1504. CardInfo: card_info,
  1505. VerifyNumber: busi_card_info,
  1506. }
  1507. service.CreateHisPsn(psn)
  1508. var rf []*ResultFive
  1509. json.Unmarshal([]byte(infoStr), &rf)
  1510. var insutypes []*ResultFive
  1511. var insutype string
  1512. var is390 int = 0
  1513. var is310 int = 0
  1514. for _, item := range rf {
  1515. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1516. insutypes = append(insutypes, item)
  1517. }
  1518. }
  1519. if len(insutypes) == 1 {
  1520. insutype = insutypes[0].Insutype
  1521. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1522. } else {
  1523. for _, i := range insutypes {
  1524. if i.Insutype == "390" {
  1525. is390 = 1
  1526. }
  1527. if i.Insutype == "310" {
  1528. is310 = 1
  1529. }
  1530. }
  1531. }
  1532. if is390 == 1 {
  1533. insutype = "390"
  1534. }
  1535. if is310 == 1 {
  1536. insutype = "310"
  1537. }
  1538. if len(insutypes) == 0 {
  1539. insutype = "310"
  1540. }
  1541. c.ServeSuccessJSON(map[string]interface{}{
  1542. "patient": patient,
  1543. "number": basNumber,
  1544. "insutype": insutype,
  1545. })
  1546. } else {
  1547. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1548. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1549. infoStr := string(Iinfos)
  1550. idetinfoStr := string(Idetinfos)
  1551. psn := &models.HisPsn{
  1552. PsnNo: res.Output.Baseinfo.PsnNo,
  1553. Age: res.Output.Baseinfo.Age,
  1554. PatientId: patient.ID,
  1555. Certno: res.Output.Baseinfo.Certno,
  1556. Brdy: res.Output.Baseinfo.Brdy,
  1557. Gend: res.Output.Baseinfo.Gend,
  1558. Naty: res.Output.Baseinfo.Naty,
  1559. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1560. PsnName: res.Output.Baseinfo.PsnName,
  1561. Idetinfo: idetinfoStr,
  1562. Insuinfo: infoStr,
  1563. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1564. CardInfo: card_info,
  1565. VerifyNumber: token,
  1566. }
  1567. service.CreateHisPsn(psn)
  1568. c.ServeSuccessJSON(map[string]interface{}{
  1569. "patient": patient,
  1570. "number": token,
  1571. })
  1572. }
  1573. }
  1574. } else {
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1576. return
  1577. }
  1578. } else { //读卡失败
  1579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1580. return
  1581. }
  1582. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1583. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1584. cardnum = DeleteExtraSpaceTwo(cardnum)
  1585. cardCode = DeleteExtraSpaceTwo(cardCode)
  1586. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1587. name = DeleteExtraSpaceTwo(name)
  1588. errmsg = DeleteExtraSpaceTwo(errmsg)
  1589. cardnum = Remove0000(cardnum)
  1590. cardCode = Remove0000(cardCode)
  1591. id_card_no = Remove0000(id_card_no)
  1592. name = Remove0000(name)
  1593. errmsg = Remove0000(errmsg)
  1594. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1595. 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)
  1596. saveLog(result, requestLog, "1101", "获取人员信息")
  1597. fmt.Println(errMsgLog)
  1598. if len(errMsgLog) > 0 {
  1599. } else {
  1600. var dat map[string]interface{}
  1601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1602. fmt.Println(dat)
  1603. } else {
  1604. fmt.Println(err)
  1605. }
  1606. userJSONBytes, _ := json.Marshal(dat)
  1607. var res ResultTwo
  1608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1609. utils.ErrorLog("解析失败:%v", err)
  1610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1611. return
  1612. }
  1613. res.ErrMsg = errMsgLog
  1614. if res.Infcode == 0 {
  1615. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1616. if err == gorm.ErrRecordNotFound {
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1618. return
  1619. } else if err != nil {
  1620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1621. return
  1622. } else {
  1623. fmt.Println(res)
  1624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1626. infoStr := string(Iinfos)
  1627. idetinfoStr := string(Idetinfos)
  1628. psn := &models.HisPsn{
  1629. PsnNo: res.Output.Baseinfo.PsnNo,
  1630. Age: res.Output.Baseinfo.Age,
  1631. PatientId: patient.ID,
  1632. Certno: res.Output.Baseinfo.Certno,
  1633. Brdy: res.Output.Baseinfo.Brdy,
  1634. Gend: res.Output.Baseinfo.Gend,
  1635. Naty: res.Output.Baseinfo.Naty,
  1636. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1637. PsnName: res.Output.Baseinfo.PsnName,
  1638. Idetinfo: idetinfoStr,
  1639. Insuinfo: infoStr,
  1640. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1641. CardInfo: basStr,
  1642. VerifyNumber: "",
  1643. }
  1644. service.CreateHisPsn(psn)
  1645. var rf []*ResultFive
  1646. json.Unmarshal([]byte(infoStr), &rf)
  1647. var insutypes []*ResultFive
  1648. var insutype string
  1649. var is390 int = 0
  1650. var is310 int = 0
  1651. for _, item := range rf {
  1652. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1653. insutypes = append(insutypes, item)
  1654. }
  1655. }
  1656. if len(insutypes) == 1 {
  1657. insutype = insutypes[0].Insutype
  1658. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1659. } else {
  1660. for _, i := range insutypes {
  1661. if i.Insutype == "390" {
  1662. is390 = 1
  1663. }
  1664. if i.Insutype == "310" {
  1665. is310 = 1
  1666. }
  1667. }
  1668. }
  1669. if is390 == 1 {
  1670. insutype = "390"
  1671. }
  1672. if is310 == 1 {
  1673. insutype = "310"
  1674. }
  1675. if len(insutypes) == 0 {
  1676. insutype = "310"
  1677. }
  1678. c.ServeSuccessJSON(map[string]interface{}{
  1679. "patient": patient,
  1680. "number": cardnum,
  1681. "insutype": insutype,
  1682. })
  1683. }
  1684. } else {
  1685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1686. return
  1687. }
  1688. }
  1689. } else {
  1690. if initFlag == 0 {
  1691. c.TestGetBasBaseInit()
  1692. }
  1693. basStr := c.GetBasBaseInfo()
  1694. if len(basStr) == 0 {
  1695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1696. return
  1697. }
  1698. fmt.Println(basStr)
  1699. bas := strings.Split(basStr, "|")
  1700. basNumber := bas[1]
  1701. fmt.Println(basNumber)
  1702. card_sn := bas[3]
  1703. fmt.Println(card_sn)
  1704. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1705. var dat map[string]interface{}
  1706. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1707. fmt.Println(dat)
  1708. } else {
  1709. fmt.Println(err)
  1710. }
  1711. userJSONBytes, _ := json.Marshal(dat)
  1712. var res ResultTwo
  1713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1714. utils.ErrorLog("解析失败:%v", err)
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1716. return
  1717. }
  1718. if res.Infcode == 0 {
  1719. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1720. if err == gorm.ErrRecordNotFound {
  1721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1722. return
  1723. } else if err != nil {
  1724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1725. return
  1726. } else {
  1727. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1728. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1729. infoStr := string(Iinfos)
  1730. idetinfoStr := string(Idetinfos)
  1731. psn := &models.HisPsn{
  1732. PsnNo: res.Output.Baseinfo.PsnNo,
  1733. Age: res.Output.Baseinfo.Age,
  1734. PatientId: patient.ID,
  1735. Certno: res.Output.Baseinfo.Certno,
  1736. Brdy: res.Output.Baseinfo.Brdy,
  1737. Gend: res.Output.Baseinfo.Gend,
  1738. Naty: res.Output.Baseinfo.Naty,
  1739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1740. PsnName: res.Output.Baseinfo.PsnName,
  1741. Idetinfo: idetinfoStr,
  1742. Insuinfo: infoStr,
  1743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1744. CardInfo: basStr,
  1745. VerifyNumber: "",
  1746. }
  1747. service.CreateHisPsn(psn)
  1748. c.ServeSuccessJSON(map[string]interface{}{
  1749. "patient": patient,
  1750. "number": basNumber,
  1751. })
  1752. }
  1753. } else {
  1754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1755. return
  1756. }
  1757. break
  1758. }
  1759. case 2:
  1760. SFZStr := c.GetSFZBaseInfo()
  1761. id_card_str := strings.Split(SFZStr, "^")
  1762. id_card_number := id_card_str[0]
  1763. card_sn := ""
  1764. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1765. var dat map[string]interface{}
  1766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1767. fmt.Println(dat)
  1768. } else {
  1769. fmt.Println(err)
  1770. }
  1771. userJSONBytes, _ := json.Marshal(dat)
  1772. var res ResultTwo
  1773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1774. utils.ErrorLog("解析失败:%v", err)
  1775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1776. return
  1777. }
  1778. if res.Infcode == 0 {
  1779. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1780. if err == gorm.ErrRecordNotFound {
  1781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1782. return
  1783. } else if err != nil {
  1784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1785. return
  1786. } else {
  1787. c.ServeSuccessJSON(map[string]interface{}{
  1788. "patient": patient,
  1789. "number": id_card_number,
  1790. })
  1791. }
  1792. } else {
  1793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1794. return
  1795. }
  1796. break
  1797. case 3:
  1798. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1799. var api string
  1800. if miConfig.MdtrtareaAdmvs == "320921" {
  1801. 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 +
  1802. "&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
  1803. fmt.Println(api)
  1804. } else {
  1805. 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 +
  1806. "&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)
  1807. }
  1808. resp, requestErr := http.Get(api)
  1809. if requestErr != nil {
  1810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. return
  1812. }
  1813. body, ioErr := ioutil.ReadAll(resp.Body)
  1814. if ioErr != nil {
  1815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1817. return
  1818. }
  1819. var respJSON map[string]interface{}
  1820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. return
  1824. }
  1825. var status string
  1826. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1827. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1828. var token string
  1829. var res ResultTwo //1101结果
  1830. var res10265 ResultTwo10265 //1101结果
  1831. var card_info string //卡信息
  1832. var busi_card_info string
  1833. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1834. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1835. if status == "0" { //读卡成功
  1836. if card_type == "1" {
  1837. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1838. result, _ := json.Marshal(respJSON)
  1839. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1840. utils.ErrorLog("解析失败:%v", err)
  1841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1842. return
  1843. }
  1844. res.ErrMsg = res10265.ErrMsg
  1845. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1846. res.Infcode = infocode
  1847. res.Output = res10265.Output
  1848. res.InfRefmsgid = res10265.InfRefmsgid
  1849. } else {
  1850. //var card_info string //卡信息
  1851. //var busi_card_info string
  1852. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1853. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1854. //fmt.Println(card_info)
  1855. //fmt.Println(busi_card_info)
  1856. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1857. result, _ := json.Marshal(respJSON)
  1858. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1859. utils.ErrorLog("解析失败:%v", err)
  1860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1861. return
  1862. }
  1863. res.ErrMsg = res10265.ErrMsg
  1864. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1865. res.Infcode = infocode
  1866. res.Output = res10265.Output
  1867. res.InfRefmsgid = res10265.InfRefmsgid
  1868. }
  1869. if res.Infcode == 0 {
  1870. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1871. if err == gorm.ErrRecordNotFound {
  1872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1873. return
  1874. } else if err != nil {
  1875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1876. return
  1877. } else {
  1878. if card_type == "1" {
  1879. bas := strings.Split(card_info, "|")
  1880. basNumber := bas[2]
  1881. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1882. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1883. infoStr := string(Iinfos)
  1884. idetinfoStr := string(Idetinfos)
  1885. psn := &models.HisPsn{
  1886. PsnNo: res.Output.Baseinfo.PsnNo,
  1887. Age: res.Output.Baseinfo.Age,
  1888. PatientId: patient.ID,
  1889. Certno: res.Output.Baseinfo.Certno,
  1890. Brdy: res.Output.Baseinfo.Brdy,
  1891. Gend: res.Output.Baseinfo.Gend,
  1892. Naty: res.Output.Baseinfo.Naty,
  1893. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1894. PsnName: res.Output.Baseinfo.PsnName,
  1895. Idetinfo: idetinfoStr,
  1896. Insuinfo: infoStr,
  1897. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1898. CardInfo: card_info,
  1899. VerifyNumber: busi_card_info,
  1900. }
  1901. service.CreateHisPsn(psn)
  1902. c.ServeSuccessJSON(map[string]interface{}{
  1903. "patient": patient,
  1904. "number": basNumber,
  1905. })
  1906. } else {
  1907. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1908. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1909. infoStr := string(Iinfos)
  1910. idetinfoStr := string(Idetinfos)
  1911. psn := &models.HisPsn{
  1912. PsnNo: res.Output.Baseinfo.PsnNo,
  1913. Age: res.Output.Baseinfo.Age,
  1914. PatientId: patient.ID,
  1915. Certno: res.Output.Baseinfo.Certno,
  1916. Brdy: res.Output.Baseinfo.Brdy,
  1917. Gend: res.Output.Baseinfo.Gend,
  1918. Naty: res.Output.Baseinfo.Naty,
  1919. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1920. PsnName: res.Output.Baseinfo.PsnName,
  1921. Idetinfo: idetinfoStr,
  1922. Insuinfo: infoStr,
  1923. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1924. CardInfo: card_info,
  1925. VerifyNumber: token,
  1926. }
  1927. service.CreateHisPsn(psn)
  1928. var rf []*ResultFive
  1929. json.Unmarshal([]byte(infoStr), &rf)
  1930. var insutypes []*ResultFive
  1931. var insutype string
  1932. var is390 int = 0
  1933. var is310 int = 0
  1934. for _, item := range rf {
  1935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1936. insutypes = append(insutypes, item)
  1937. }
  1938. }
  1939. if len(insutypes) == 1 {
  1940. insutype = insutypes[0].Insutype
  1941. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1942. } else {
  1943. for _, i := range insutypes {
  1944. if i.Insutype == "390" {
  1945. is390 = 1
  1946. }
  1947. if i.Insutype == "310" {
  1948. is310 = 1
  1949. }
  1950. }
  1951. }
  1952. if is390 == 1 {
  1953. insutype = "390"
  1954. }
  1955. if is310 == 1 {
  1956. insutype = "310"
  1957. }
  1958. if len(insutypes) == 0 {
  1959. insutype = "310"
  1960. }
  1961. c.ServeSuccessJSON(map[string]interface{}{
  1962. "patient": patient,
  1963. "number": token,
  1964. "insutype": insutype,
  1965. })
  1966. }
  1967. }
  1968. } else {
  1969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1970. return
  1971. }
  1972. } else { //读卡失败
  1973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1974. return
  1975. }
  1976. }
  1977. break
  1978. case 4:
  1979. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1980. var api string
  1981. if miConfig.MdtrtareaAdmvs == "320921" {
  1982. 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 +
  1983. "&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
  1984. fmt.Println(api)
  1985. } else {
  1986. 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 +
  1987. "&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)
  1988. }
  1989. resp, requestErr := http.Get(api)
  1990. if requestErr != nil {
  1991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1992. return
  1993. }
  1994. body, ioErr := ioutil.ReadAll(resp.Body)
  1995. if ioErr != nil {
  1996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1998. return
  1999. }
  2000. var respJSON map[string]interface{}
  2001. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2004. return
  2005. }
  2006. var status string
  2007. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2008. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2009. var token string
  2010. var res ResultTwo //1101结果
  2011. var res10265 ResultTwo10265 //1101结果
  2012. if status == "0" { //读卡成功
  2013. var card_info string //卡信息
  2014. var busi_card_info string
  2015. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2016. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2017. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2018. fmt.Println(card_info)
  2019. fmt.Println(busi_card_info)
  2020. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2021. result, _ := json.Marshal(respJSON)
  2022. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2023. utils.ErrorLog("解析失败:%v", err)
  2024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2025. return
  2026. }
  2027. res.ErrMsg = res10265.ErrMsg
  2028. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2029. res.Infcode = infocode
  2030. res.Output = res10265.Output
  2031. res.InfRefmsgid = res10265.InfRefmsgid
  2032. if res.Infcode == 0 {
  2033. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2034. if err == gorm.ErrRecordNotFound {
  2035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2036. return
  2037. } else if err != nil {
  2038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2039. return
  2040. } else {
  2041. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2042. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2043. infoStr := string(Iinfos)
  2044. idetinfoStr := string(Idetinfos)
  2045. psn := &models.HisPsn{
  2046. PsnNo: res.Output.Baseinfo.PsnNo,
  2047. Age: res.Output.Baseinfo.Age,
  2048. PatientId: patient.ID,
  2049. Certno: res.Output.Baseinfo.Certno,
  2050. Brdy: res.Output.Baseinfo.Brdy,
  2051. Gend: res.Output.Baseinfo.Gend,
  2052. Naty: res.Output.Baseinfo.Naty,
  2053. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2054. PsnName: res.Output.Baseinfo.PsnName,
  2055. Idetinfo: idetinfoStr,
  2056. Insuinfo: infoStr,
  2057. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2058. CardInfo: card_info,
  2059. VerifyNumber: token,
  2060. }
  2061. service.CreateHisPsn(psn)
  2062. c.ServeSuccessJSON(map[string]interface{}{
  2063. "patient": patient,
  2064. "number": token,
  2065. })
  2066. }
  2067. } else {
  2068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2069. return
  2070. }
  2071. } else { //读卡失败
  2072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2073. return
  2074. }
  2075. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2076. c.GetEleBaseInfo()
  2077. //result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2078. //saveLog(result, requestLog, "6101", "电子凭证")
  2079. //var ele ELeCertData
  2080. //err := json.Unmarshal([]byte(result), &ele)
  2081. //if err != nil {
  2082. // utils.ErrorLog("解析失败:%v", err)
  2083. //}
  2084. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  2085. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  2086. //
  2087. //var res ResultTwo
  2088. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2089. // utils.ErrorLog("解析失败:%v", err)
  2090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2091. // return
  2092. //}
  2093. //
  2094. //if res.Infcode == 0 {
  2095. // patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2096. // if err == gorm.ErrRecordNotFound {
  2097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2098. // return
  2099. // } else if err != nil {
  2100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2101. // return
  2102. //
  2103. // } else {
  2104. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2105. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2106. // infoStr := string(Iinfos)
  2107. // idetinfoStr := string(Idetinfos)
  2108. // psn := &models.HisPsn{
  2109. // PsnNo: res.Output.Baseinfo.PsnNo,
  2110. // Age: res.Output.Baseinfo.Age,
  2111. // PatientId: patient.ID,
  2112. // Certno: res.Output.Baseinfo.Certno,
  2113. // Brdy: res.Output.Baseinfo.Brdy,
  2114. // Gend: res.Output.Baseinfo.Gend,
  2115. // Naty: res.Output.Baseinfo.Naty,
  2116. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  2117. // PsnName: res.Output.Baseinfo.PsnName,
  2118. // Idetinfo: idetinfoStr,
  2119. // Insuinfo: infoStr,
  2120. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2121. // CardInfo: "",
  2122. // VerifyNumber: ele.Data.EcToken,
  2123. // }
  2124. // service.CreateHisPsn(psn)
  2125. //
  2126. // c.ServeSuccessJSON(map[string]interface{}{
  2127. // "patient": patient,
  2128. // "number": ele.Data.EcToken,
  2129. // })
  2130. // }
  2131. //} else {
  2132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2133. // return
  2134. //}
  2135. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2136. type ELeData struct {
  2137. Data struct {
  2138. IdNo string `json:"idNo"`
  2139. IdType string `json:"idType"`
  2140. UserName string `json:"userName"`
  2141. EcToken string `json:"ecToken"`
  2142. InsuOrg string `json:"insuOrg"`
  2143. Gender string `json:"gender"`
  2144. Birthday string `json:"birthday"`
  2145. Nationality string `json:"nationality"`
  2146. Email string `json:"email"`
  2147. Extra string `json:"extra"`
  2148. } `json:"data"`
  2149. Code int `json:"code"`
  2150. Message string `json:"message"`
  2151. }
  2152. inputInfo, outPutInfo, errMsg := service.ReadEleCard(miConfig.Code)
  2153. fmt.Println(errMsg)
  2154. if len(errMsg) == 0 {
  2155. var ele ELeData
  2156. err := json.Unmarshal([]byte(outPutInfo), &ele)
  2157. if err != nil {
  2158. utils.ErrorLog("解析失败:%v", err)
  2159. }
  2160. token := ele.Data.EcToken
  2161. fmt.Println(inputInfo)
  2162. fmt.Println(outPutInfo)
  2163. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IdNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token)
  2164. saveLog(result, requestLog, "1101", "获取人员信息")
  2165. fmt.Println(errMsgLog)
  2166. if len(errMsgLog) > 0 {
  2167. } else {
  2168. var dat map[string]interface{}
  2169. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2170. fmt.Println(dat)
  2171. } else {
  2172. fmt.Println(err)
  2173. }
  2174. userJSONBytes, _ := json.Marshal(dat)
  2175. var res ResultTwo
  2176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2177. utils.ErrorLog("解析失败:%v", err)
  2178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2179. return
  2180. }
  2181. res.ErrMsg = errMsgLog
  2182. if res.Infcode == 0 {
  2183. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2184. if err == gorm.ErrRecordNotFound {
  2185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2186. return
  2187. } else if err != nil {
  2188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2189. return
  2190. } else {
  2191. fmt.Println(res)
  2192. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2193. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2194. infoStr := string(Iinfos)
  2195. idetinfoStr := string(Idetinfos)
  2196. psn := &models.HisPsn{
  2197. PsnNo: res.Output.Baseinfo.PsnNo,
  2198. Age: res.Output.Baseinfo.Age,
  2199. PatientId: patient.ID,
  2200. Certno: res.Output.Baseinfo.Certno,
  2201. Brdy: res.Output.Baseinfo.Brdy,
  2202. Gend: res.Output.Baseinfo.Gend,
  2203. Naty: res.Output.Baseinfo.Naty,
  2204. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2205. PsnName: res.Output.Baseinfo.PsnName,
  2206. Idetinfo: idetinfoStr,
  2207. Insuinfo: infoStr,
  2208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2209. CardInfo: outPutInfo,
  2210. VerifyNumber: token,
  2211. }
  2212. service.CreateHisPsn(psn)
  2213. var rf []*ResultFive
  2214. json.Unmarshal([]byte(infoStr), &rf)
  2215. var insutypes []*ResultFive
  2216. var insutype string
  2217. var is390 int = 0
  2218. var is310 int = 0
  2219. for _, item := range rf {
  2220. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2221. insutypes = append(insutypes, item)
  2222. }
  2223. }
  2224. if len(insutypes) == 1 {
  2225. insutype = insutypes[0].Insutype
  2226. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2227. } else {
  2228. for _, i := range insutypes {
  2229. if i.Insutype == "390" {
  2230. is390 = 1
  2231. }
  2232. if i.Insutype == "310" {
  2233. is310 = 1
  2234. }
  2235. }
  2236. }
  2237. if is390 == 1 {
  2238. insutype = "390"
  2239. }
  2240. if is310 == 1 {
  2241. insutype = "310"
  2242. }
  2243. if len(insutypes) == 0 {
  2244. insutype = "310"
  2245. }
  2246. c.ServeSuccessJSON(map[string]interface{}{
  2247. "patient": patient,
  2248. "number": token,
  2249. "insutype": insutype,
  2250. })
  2251. }
  2252. } else {
  2253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2254. return
  2255. }
  2256. }
  2257. }
  2258. }
  2259. break
  2260. }
  2261. }
  2262. var initFlag int64 = 0
  2263. func (c *HisApiController) TestGetBasBaseInit() {
  2264. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2265. Iinit := DllDef.MustFindProc("Init")
  2266. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2267. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  2268. if ret != 0 {
  2269. fmt.Println("SSCard的报错原因:", err)
  2270. fmt.Println("SSCard的运算结果为:", ret)
  2271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2272. return
  2273. }
  2274. result := int(ret)
  2275. fmt.Println("SSCard的运算结果为1:", result)
  2276. initFlag = 1
  2277. return
  2278. }
  2279. func (c *HisApiController) GetSFZBaseInfo() string {
  2280. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2281. readCard := DllDef.MustFindProc("ReadSFZ")
  2282. if readCard == nil {
  2283. fmt.Println("readcard is nil")
  2284. readCard = DllDef.MustFindProc("ReadSFZ")
  2285. }
  2286. str := make([]byte, 256)
  2287. str1 := make([]byte, 256)
  2288. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2289. fmt.Println(r)
  2290. return string(str)
  2291. }
  2292. func (c *HisApiController) GetEleBaseInfo() string {
  2293. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2294. readCard := DllDef.MustFindProc("GetQRBase")
  2295. if readCard == nil {
  2296. fmt.Println("readcard is nil")
  2297. readCard = DllDef.MustFindProc("GetQRBase")
  2298. }
  2299. str := make([]byte, 1024)
  2300. str1 := make([]byte, 1024)
  2301. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2302. fmt.Println(string(str1))
  2303. fmt.Println(string(str))
  2304. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2305. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2306. if ret2 != 0 {
  2307. return ""
  2308. }
  2309. return string(str1)
  2310. }
  2311. func (c *HisApiController) GetBasBaseInfo() string {
  2312. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2313. readCard := DllDef.MustFindProc("ReadCardBas")
  2314. if readCard == nil {
  2315. fmt.Println("readcard is nil")
  2316. readCard = DllDef.MustFindProc("ReadCardBas")
  2317. }
  2318. str := make([]byte, 1024)
  2319. str1 := make([]byte, 1024)
  2320. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2321. fmt.Println(string(str1))
  2322. fmt.Println(string(str))
  2323. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2324. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2325. if ret2 != 0 {
  2326. return ""
  2327. }
  2328. return string(str)
  2329. }
  2330. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  2331. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2332. readCard := DllDef.MustFindProc("read_cardinfo")
  2333. if readCard == nil {
  2334. fmt.Println("readcard is nil")
  2335. readCard = DllDef.MustFindProc("read_cardinfo")
  2336. }
  2337. str := make([]byte, 1024) //卡号
  2338. str1 := make([]byte, 1024) //卡识别码
  2339. str2 := make([]byte, 1024) //身份证号
  2340. str3 := make([]byte, 1024) //姓名
  2341. str4 := make([]byte, 1024) //错误信息
  2342. 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])))
  2343. fmt.Println(string(str1))
  2344. fmt.Println(string(str))
  2345. fmt.Println(string(str2))
  2346. fmt.Println(string(str3))
  2347. fmt.Println(string(str4))
  2348. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2349. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2350. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  2351. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  2352. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  2353. if ret2 != 0 {
  2354. return "", "", "", "", ""
  2355. }
  2356. return string(str), string(str1), string(str2), string(str3), string(str4)
  2357. }
  2358. type CustomFundPay struct {
  2359. FundPayType string `json:"fund_pay_type"`
  2360. FundPayamt float64 `json:"fund_payamt"`
  2361. }
  2362. func (c *HisApiController) GetSettleList() {
  2363. order_id, _ := c.GetInt64("order_id")
  2364. admin_user_id, _ := c.GetInt64("admin_user_id")
  2365. order, _ := service.GetHisOrderByIDTwo(order_id)
  2366. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2367. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2368. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2369. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2370. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2371. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2372. if order.ID == 0 {
  2373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2374. return
  2375. }
  2376. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2377. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2378. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2379. fmt.Println(count)
  2380. var zero string
  2381. number := count + 1
  2382. if number >= 1000 {
  2383. zero = "0000" + strconv.FormatInt(number, 10)
  2384. } else if number >= 10000 {
  2385. zero = "000" + strconv.FormatInt(number, 10)
  2386. } else if number >= 100000 {
  2387. zero = "00" + strconv.FormatInt(number, 10)
  2388. } else if number >= 1000000 {
  2389. zero = "0" + strconv.FormatInt(number, 10)
  2390. } else {
  2391. zero = strconv.FormatInt(number, 10)
  2392. }
  2393. fmt.Println(zero)
  2394. struct4101 := service.Struct4101{
  2395. PsnNo: order.PsnNo,
  2396. MdtrtId: order.MdtrtId,
  2397. SetlId: order.SetlId,
  2398. PsnName: order.PsnName,
  2399. Gend: order.Gend,
  2400. Brdy: his.Brdy,
  2401. Age: his.Age,
  2402. Naty: order.Naty,
  2403. PatnCertType: "01",
  2404. Certno: order.Certno,
  2405. Prfs: "90",
  2406. ConerName: roles[0].UserName,
  2407. PatnRlts: "99",
  2408. ConerAddr: miConfig.OrgName,
  2409. ConerTel: admin.Mobile,
  2410. HiType: order.Insutype,
  2411. Insuplc: miConfig.InsuplcAdmdvs,
  2412. MaindiagFlag: "1",
  2413. BillCode: last_order.FaPiaoCode,
  2414. BillNo: zero,
  2415. BizSn: order.Number,
  2416. PsnSelfPay: order.PsnPartAmt,
  2417. PsnOwnPay: order.PsnPartAmt,
  2418. AcctPay: order.AcctPay,
  2419. PsnCashpay: order.PsnCashPay,
  2420. HiPaymtd: "1",
  2421. Hsorg: miConfig.InsuplcAdmdvs,
  2422. HsorgOpter: miConfig.InsuplcAdmdvs,
  2423. MedinsFillPsn: curRoles.UserName,
  2424. MedinsFillDept: depart.Name,
  2425. IptMedType: "2",
  2426. }
  2427. struct4101.SetlBegnDate = order.SetlTime
  2428. struct4101.SetlEndDate = order.SetlTime
  2429. time_arr := strings.Split(order.SetlTime, " ")
  2430. struct4101.AdmTime = time_arr[0]
  2431. struct4101.AdmEndTime = time_arr[0]
  2432. var rf []CustomFundPay
  2433. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2434. var tempFunPays []service.CustomStruct
  2435. for _, item := range rf {
  2436. var tempFunPay service.CustomStruct
  2437. tempFunPay.FundPayamt = item.FundPayamt
  2438. tempFunPay.FundPayType = item.FundPayType
  2439. tempFunPays = append(tempFunPays, tempFunPay)
  2440. }
  2441. struct4101.CustomStruct = tempFunPays
  2442. var tempDiaginfos []service.DiaginfoStructTwo
  2443. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2444. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2445. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2446. var config []*models.HisXtDiagnoseConfig
  2447. for _, item := range diagnosis_ids {
  2448. id, _ := strconv.ParseInt(item, 10, 64)
  2449. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2450. config = append(config, &diagnosisConfig)
  2451. }
  2452. for index, item := range config {
  2453. if index == 0 {
  2454. var tempDiaginfo service.DiaginfoStructTwo
  2455. tempDiaginfo.DiagCode = item.CountryCode
  2456. tempDiaginfo.DiagName = item.CountryContentName
  2457. tempDiaginfo.DiagType = "1"
  2458. tempDiaginfo.MaindiagFlag = "1"
  2459. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2460. } else {
  2461. var tempDiaginfo service.DiaginfoStructTwo
  2462. tempDiaginfo.DiagCode = item.CountryCode
  2463. tempDiaginfo.DiagName = item.CountryContentName
  2464. tempDiaginfo.DiagType = "2"
  2465. tempDiaginfo.MaindiagFlag = "0"
  2466. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2467. }
  2468. }
  2469. struct4101.Diseinfo = tempDiaginfos
  2470. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2471. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2472. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2473. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2474. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2475. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2476. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2477. var iteminfo service.IteminfoStruct
  2478. var bedCostTotal float64 = 0 //床位总费
  2479. var bedCostSelfTotal float64 = 0 //床位自费
  2480. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2481. var operationCostTotal float64 = 0 //手术费
  2482. var operationCostSelfTotal float64 = 0 //手术费
  2483. var operationCostPartSelfTotal float64 = 0 //手术费
  2484. var otherCostTotal float64 = 0 //其他费用
  2485. var otherCostSelfTotal float64 = 0 //其他费用
  2486. var otherCostPartSelfTotal float64 = 0 //其他费用
  2487. var materialCostTotal float64 = 0 //材料费
  2488. var materialCostSelfTotal float64 = 0 //材料费
  2489. var materialCostPartSelfTotal float64 = 0 //材料费
  2490. var westernMedicineCostTotal float64 = 0 //西药费
  2491. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2492. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2493. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2494. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2495. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2496. var checkCostTotal float64 = 0 //检查费
  2497. var checkCostSelfTotal float64 = 0 //检查费
  2498. var checkCostPartSelfTotal float64 = 0 //检查费
  2499. var laboratoryCostTotal float64 = 0 //化验费
  2500. var laboratoryCostSelfTotal float64 = 0 //化验费
  2501. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2502. var treatCostTotal float64 = 0 //治疗费用
  2503. var treatCostSelfTotal float64 = 0 //治疗费用
  2504. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2505. decimal.DivisionPrecision = 2
  2506. var bed_fulamt_ownpay_amt float64 = 0
  2507. var operation_fulamt_ownpay_amt float64 = 0
  2508. var other_fulamt_ownpay_amt float64 = 0
  2509. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2510. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2511. var check_fulamt_ownpay_amt float64 = 0
  2512. var material_fulamt_ownpay_amt float64 = 0
  2513. var laboratory_fulamt_ownpay_amt float64 = 0
  2514. var treat_fulamt_ownpay_amt float64 = 0
  2515. var bed_claa_sunmfee float64 = 0
  2516. var bed_clab_amt float64 = 0
  2517. var bed_other_amt float64 = 0
  2518. var operation_claa_sunmfee float64 = 0
  2519. var operation_clab_amt float64 = 0
  2520. var operation_other_amt float64 = 0
  2521. var other_claa_sunmfee float64 = 0
  2522. var other_clab_amt float64 = 0
  2523. var other_other_amt float64 = 0
  2524. var westernMedicine_claa_sunmfee float64 = 0
  2525. var westernMedicine_clab_amt float64 = 0
  2526. var westernMedicine_other_amt float64 = 0
  2527. var chineseTraditional_claa_sunmfee float64 = 0
  2528. var chineseTraditional_clab_amt float64 = 0
  2529. var chineseTraditional_other_amt float64 = 0
  2530. var check_claa_sunmfee float64 = 0
  2531. var check_clab_amt float64 = 0
  2532. var check_other_amt float64 = 0
  2533. var material_claa_sunmfee float64 = 0
  2534. var material_clab_amt float64 = 0
  2535. var material_other_amt float64 = 0
  2536. var laboratory_claa_sunmfee float64 = 0
  2537. var laboratory_clab_amt float64 = 0
  2538. var laboratory_other_amt float64 = 0
  2539. var treat_claa_sunmfee float64 = 0
  2540. var treat_clab_amt float64 = 0
  2541. var treat_other_amt float64 = 0
  2542. for _, item := range order.HisOrderInfo {
  2543. if item.MedChrgitmType == "01" { //床位费
  2544. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2545. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2546. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2547. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2548. if item.ChrgitmLv == "1" {
  2549. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2550. }
  2551. if item.ChrgitmLv == "2" {
  2552. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2553. }
  2554. if item.ChrgitmLv == "3" {
  2555. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2556. }
  2557. }
  2558. if item.MedChrgitmType == "03" { //检查费
  2559. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2560. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2561. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2562. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2563. if item.ChrgitmLv == "1" {
  2564. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2565. }
  2566. if item.ChrgitmLv == "2" {
  2567. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2568. }
  2569. if item.ChrgitmLv == "3" {
  2570. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2571. }
  2572. }
  2573. if item.MedChrgitmType == "04" { //化验费
  2574. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2575. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2576. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2577. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2578. if item.ChrgitmLv == "1" {
  2579. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2580. }
  2581. if item.ChrgitmLv == "2" {
  2582. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2583. }
  2584. if item.ChrgitmLv == "3" {
  2585. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2586. }
  2587. }
  2588. if item.MedChrgitmType == "05" { //治疗费
  2589. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2590. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2591. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2592. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2593. if item.ChrgitmLv == "1" {
  2594. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2595. }
  2596. if item.ChrgitmLv == "2" {
  2597. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2598. }
  2599. if item.ChrgitmLv == "3" {
  2600. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2601. }
  2602. }
  2603. if item.MedChrgitmType == "06" { //手术费
  2604. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2605. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2606. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2607. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2608. if item.ChrgitmLv == "1" {
  2609. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2610. }
  2611. if item.ChrgitmLv == "2" {
  2612. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2613. }
  2614. if item.ChrgitmLv == "3" {
  2615. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2616. }
  2617. }
  2618. if item.MedChrgitmType == "08" { //材料费
  2619. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2620. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2621. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2622. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2623. if item.ChrgitmLv == "1" {
  2624. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2625. }
  2626. if item.ChrgitmLv == "2" {
  2627. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2628. }
  2629. if item.ChrgitmLv == "3" {
  2630. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2631. }
  2632. }
  2633. if item.MedChrgitmType == "09" { //西药费
  2634. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2635. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2636. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2637. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2638. if item.ChrgitmLv == "1" {
  2639. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2640. }
  2641. if item.ChrgitmLv == "2" {
  2642. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2643. }
  2644. if item.ChrgitmLv == "3" {
  2645. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2646. }
  2647. }
  2648. if item.MedChrgitmType == "11" { //中成费
  2649. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2650. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2651. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2652. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2653. if item.ChrgitmLv == "1" {
  2654. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2655. }
  2656. if item.ChrgitmLv == "2" {
  2657. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2658. }
  2659. if item.ChrgitmLv == "3" {
  2660. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2661. }
  2662. }
  2663. if item.MedChrgitmType == "14" { //其他费
  2664. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2665. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2666. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2667. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2668. if item.ChrgitmLv == "1" {
  2669. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2670. }
  2671. if item.ChrgitmLv == "2" {
  2672. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2673. }
  2674. if item.ChrgitmLv == "3" {
  2675. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2676. }
  2677. }
  2678. }
  2679. var iteminfoStructs []service.IteminfoStruct
  2680. if bedCostTotal != 0 {
  2681. iteminfo.MedChrgitm = "01"
  2682. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2683. iteminfo.Amt = bedCostTotal
  2684. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2685. iteminfo.ClabAmt = bed_clab_amt
  2686. iteminfo.OthAmt = bed_other_amt
  2687. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2688. }
  2689. if checkCostTotal != 0 {
  2690. iteminfo.MedChrgitm = "03"
  2691. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2692. iteminfo.Amt = checkCostTotal
  2693. iteminfo.ClaaSumfee = check_claa_sunmfee
  2694. iteminfo.ClabAmt = check_clab_amt
  2695. iteminfo.OthAmt = check_other_amt
  2696. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2697. }
  2698. if laboratoryCostTotal != 0 {
  2699. iteminfo.MedChrgitm = "04"
  2700. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2701. iteminfo.Amt = laboratoryCostTotal
  2702. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2703. iteminfo.ClabAmt = laboratory_clab_amt
  2704. iteminfo.OthAmt = laboratory_other_amt
  2705. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2706. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2707. }
  2708. if treatCostTotal != 0 {
  2709. iteminfo.MedChrgitm = "05"
  2710. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2711. iteminfo.Amt = treatCostTotal
  2712. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2713. iteminfo.ClabAmt = treat_clab_amt
  2714. iteminfo.OthAmt = treat_other_amt
  2715. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2716. //(struct4101.IteminfoStruct, iteminfo)
  2717. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2718. }
  2719. if operationCostTotal != 0 {
  2720. iteminfo.MedChrgitm = "06"
  2721. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2722. iteminfo.Amt = operationCostTotal
  2723. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2724. iteminfo.ClabAmt = operation_clab_amt
  2725. iteminfo.OthAmt = operation_other_amt
  2726. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2727. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2728. }
  2729. if materialCostTotal != 0 {
  2730. iteminfo.MedChrgitm = "08"
  2731. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2732. iteminfo.Amt = materialCostTotal
  2733. iteminfo.ClaaSumfee = material_claa_sunmfee
  2734. iteminfo.ClabAmt = material_clab_amt
  2735. iteminfo.OthAmt = material_other_amt
  2736. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2737. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2738. }
  2739. if westernMedicineCostTotal != 0 {
  2740. iteminfo.MedChrgitm = "09"
  2741. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2742. iteminfo.Amt = westernMedicineCostTotal
  2743. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2744. iteminfo.ClabAmt = westernMedicine_clab_amt
  2745. iteminfo.OthAmt = westernMedicine_other_amt
  2746. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2747. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2748. }
  2749. if chineseTraditionalMedicineCostTotal != 0 {
  2750. iteminfo.MedChrgitm = "11"
  2751. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2752. iteminfo.Amt = westernMedicineCostTotal
  2753. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2754. iteminfo.ClabAmt = westernMedicine_clab_amt
  2755. iteminfo.OthAmt = westernMedicine_other_amt
  2756. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2757. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2758. }
  2759. if otherCostTotal != 0 {
  2760. iteminfo.MedChrgitm = "14"
  2761. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2762. iteminfo.Amt = otherCostTotal
  2763. iteminfo.ClaaSumfee = other_claa_sunmfee
  2764. iteminfo.ClabAmt = other_clab_amt
  2765. iteminfo.OthAmt = other_other_amt
  2766. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2767. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2768. }
  2769. struct4101.IteminfoStruct = iteminfoStructs
  2770. struct4101.Ntly = "中国"
  2771. struct4101.AdmCaty = "A03.06"
  2772. var res ResultSeventeen
  2773. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2774. struct4101.BillCode = order.Number
  2775. struct4101.BillNo = order.SetlId
  2776. var resOther ResultSeventeenOther
  2777. var pp models.PublicParams
  2778. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2779. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2780. pp.FixmedinsName = miConfig.OrgName
  2781. pp.FixmedinsCode = miConfig.Code
  2782. pp.RequestUrl = miConfig.Url
  2783. pp.Cainfo = miConfig.Cainfo
  2784. pp.SecretKey = miConfig.SecretKey
  2785. pp.AccessKey = miConfig.AccessKey
  2786. pp.OpterName = curRoles.UserName
  2787. client := &http.Client{}
  2788. var req *http.Request
  2789. data := make(map[string]interface{})
  2790. data["struct4101"] = struct4101
  2791. data["pp"] = pp
  2792. bytesData, _ := json.Marshal(data)
  2793. if miConfig.MdtrtareaAdmvs == "320921" {
  2794. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2795. } else {
  2796. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2797. }
  2798. resp, _ := client.Do(req)
  2799. defer resp.Body.Close()
  2800. body, ioErr := ioutil.ReadAll(resp.Body)
  2801. if ioErr != nil {
  2802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2804. return
  2805. }
  2806. var respJSON map[string]interface{}
  2807. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2810. return
  2811. }
  2812. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2813. userJSONBytes, _ := json.Marshal(respJSON)
  2814. fmt.Println("log")
  2815. fmt.Println(string(userJSONBytes))
  2816. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2817. utils.ErrorLog("解析失败:%v", err)
  2818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2819. return
  2820. }
  2821. res.InfRefmsgid = resOther.InfRefmsgid
  2822. res.Output = resOther.Output
  2823. res.ErrMsg = resOther.ErrMsg
  2824. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2825. res.Infcode = infocode
  2826. } else {
  2827. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2828. var dat map[string]interface{}
  2829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2830. fmt.Println(dat)
  2831. } else {
  2832. fmt.Println(err)
  2833. }
  2834. userJSONBytes, _ := json.Marshal(dat)
  2835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2836. utils.ErrorLog("解析失败:%v", err)
  2837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2838. return
  2839. }
  2840. }
  2841. if res.Infcode != 0 {
  2842. c.ServeSuccessJSON(map[string]interface{}{
  2843. "failed_code": -10,
  2844. "msg": res.ErrMsg,
  2845. })
  2846. return
  2847. } else {
  2848. order.FaPiaoNumber = zero
  2849. order.FaPiaoCode = last_order.FaPiaoCode
  2850. service.UpdateOrder(order)
  2851. hisFundSettleListResult := &models.HisFundSettleListResult{
  2852. Number: res.Output.SetlListId,
  2853. Status: 1,
  2854. Ctime: time.Now().Unix(),
  2855. Mtime: time.Now().Unix(),
  2856. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2857. IsUpload: 1,
  2858. OrderId: order_id,
  2859. }
  2860. service.CreateUploadRecord(hisFundSettleListResult)
  2861. c.ServeSuccessJSON(map[string]interface{}{
  2862. "msg": "上传成功",
  2863. "result": hisFundSettleListResult,
  2864. })
  2865. return
  2866. }
  2867. }
  2868. func (c *HisApiController) GetSettleListHospital() {
  2869. order_id, _ := c.GetInt64("order_id")
  2870. admin_user_id, _ := c.GetInt64("admin_user_id")
  2871. order, _ := service.GetHisOrderByIDTwo(order_id)
  2872. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2873. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2874. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2875. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2876. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2877. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2878. if order.ID == 0 {
  2879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2880. return
  2881. }
  2882. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2883. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2884. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2885. fmt.Println(count)
  2886. var zero string
  2887. number := count + 1
  2888. if number >= 1000 {
  2889. zero = "0000" + strconv.FormatInt(number, 10)
  2890. } else if number >= 10000 {
  2891. zero = "000" + strconv.FormatInt(number, 10)
  2892. } else if number >= 100000 {
  2893. zero = "00" + strconv.FormatInt(number, 10)
  2894. } else if number >= 1000000 {
  2895. zero = "0" + strconv.FormatInt(number, 10)
  2896. } else {
  2897. zero = strconv.FormatInt(number, 10)
  2898. }
  2899. fmt.Println(zero)
  2900. struct4101 := service.Struct4101{
  2901. PsnNo: order.PsnNo,
  2902. MdtrtId: order.MdtrtId,
  2903. SetlId: order.SetlId,
  2904. PsnName: order.PsnName,
  2905. Gend: order.Gend,
  2906. Brdy: his.Brdy,
  2907. Age: int64(order.Age),
  2908. Naty: order.Naty,
  2909. PatnCertType: "01",
  2910. Certno: order.Certno,
  2911. Prfs: "90",
  2912. ConerName: roles[0].UserName,
  2913. PatnRlts: "99",
  2914. ConerAddr: miConfig.OrgName,
  2915. ConerTel: admin.Mobile,
  2916. HiType: order.Insutype,
  2917. Insuplc: miConfig.InsuplcAdmdvs,
  2918. MaindiagFlag: "1",
  2919. BillCode: order.FaPiaoCode,
  2920. BillNo: order.FaPiaoCode,
  2921. BizSn: order.Number,
  2922. PsnSelfPay: order.PsnPartAmt,
  2923. PsnOwnPay: order.PsnPartAmt,
  2924. AcctPay: order.AcctPay,
  2925. PsnCashpay: order.PsnCashPay,
  2926. HiPaymtd: "1",
  2927. Hsorg: miConfig.InsuplcAdmdvs,
  2928. HsorgOpter: miConfig.InsuplcAdmdvs,
  2929. MedinsFillPsn: curRoles.UserName,
  2930. MedinsFillDept: depart.Name,
  2931. IptMedType: "2",
  2932. AdmTime: his.InHosptialTime,
  2933. AdmEndTime: his.OutHosptialTime,
  2934. }
  2935. struct4101.SetlBegnDate = order.SetlTime
  2936. struct4101.SetlEndDate = order.SetlTime
  2937. var rf []CustomFundPay
  2938. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2939. var tempFunPays []service.CustomStruct
  2940. for _, item := range rf {
  2941. var tempFunPay service.CustomStruct
  2942. tempFunPay.FundPayamt = item.FundPayamt
  2943. tempFunPay.FundPayType = item.FundPayType
  2944. tempFunPays = append(tempFunPays, tempFunPay)
  2945. }
  2946. struct4101.CustomStruct = tempFunPays
  2947. var tempDiaginfos []service.DiaginfoStructTwo
  2948. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2949. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2950. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2951. var config []*models.HisXtDiagnoseConfig
  2952. for _, item := range diagnosis_ids {
  2953. id, _ := strconv.ParseInt(item, 10, 64)
  2954. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2955. config = append(config, &diagnosisConfig)
  2956. }
  2957. for index, item := range config {
  2958. if index == 0 {
  2959. var tempDiaginfo service.DiaginfoStructTwo
  2960. tempDiaginfo.DiagCode = item.CountryCode
  2961. tempDiaginfo.DiagName = item.CountryContentName
  2962. tempDiaginfo.DiagType = "1"
  2963. tempDiaginfo.MaindiagFlag = "1"
  2964. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2965. } else {
  2966. var tempDiaginfo service.DiaginfoStructTwo
  2967. tempDiaginfo.DiagCode = item.CountryCode
  2968. tempDiaginfo.DiagName = item.CountryContentName
  2969. tempDiaginfo.DiagType = "2"
  2970. tempDiaginfo.MaindiagFlag = "0"
  2971. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2972. }
  2973. }
  2974. struct4101.Diseinfo = tempDiaginfos
  2975. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2976. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2977. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2978. tempOpspdiseinfo2.OprnOprtCode = ""
  2979. tempOpspdiseinfo2.OprnOprtName = ""
  2980. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2981. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2982. var iteminfo service.IteminfoStruct
  2983. var bedCostTotal float64 = 0 //床位总费
  2984. var bedCostSelfTotal float64 = 0 //床位自费
  2985. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2986. var operationCostTotal float64 = 0 //手术费
  2987. var operationCostSelfTotal float64 = 0 //手术费
  2988. var operationCostPartSelfTotal float64 = 0 //手术费
  2989. var otherCostTotal float64 = 0 //其他费用
  2990. var otherCostSelfTotal float64 = 0 //其他费用
  2991. var otherCostPartSelfTotal float64 = 0 //其他费用
  2992. var materialCostTotal float64 = 0 //材料费
  2993. var materialCostSelfTotal float64 = 0 //材料费
  2994. var materialCostPartSelfTotal float64 = 0 //材料费
  2995. var westernMedicineCostTotal float64 = 0 //西药费
  2996. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2997. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2998. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2999. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3000. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3001. var checkCostTotal float64 = 0 //检查费
  3002. var checkCostSelfTotal float64 = 0 //检查费
  3003. var checkCostPartSelfTotal float64 = 0 //检查费
  3004. var laboratoryCostTotal float64 = 0 //化验费
  3005. var laboratoryCostSelfTotal float64 = 0 //化验费
  3006. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3007. var treatCostTotal float64 = 0 //治疗费用
  3008. var treatCostSelfTotal float64 = 0 //治疗费用
  3009. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3010. decimal.DivisionPrecision = 2
  3011. var bed_fulamt_ownpay_amt float64 = 0
  3012. var operation_fulamt_ownpay_amt float64 = 0
  3013. var other_fulamt_ownpay_amt float64 = 0
  3014. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3015. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3016. var check_fulamt_ownpay_amt float64 = 0
  3017. var material_fulamt_ownpay_amt float64 = 0
  3018. var laboratory_fulamt_ownpay_amt float64 = 0
  3019. var treat_fulamt_ownpay_amt float64 = 0
  3020. var bed_claa_sunmfee float64 = 0
  3021. var bed_clab_amt float64 = 0
  3022. var bed_other_amt float64 = 0
  3023. var operation_claa_sunmfee float64 = 0
  3024. var operation_clab_amt float64 = 0
  3025. var operation_other_amt float64 = 0
  3026. var other_claa_sunmfee float64 = 0
  3027. var other_clab_amt float64 = 0
  3028. var other_other_amt float64 = 0
  3029. var westernMedicine_claa_sunmfee float64 = 0
  3030. var westernMedicine_clab_amt float64 = 0
  3031. var westernMedicine_other_amt float64 = 0
  3032. var chineseTraditional_claa_sunmfee float64 = 0
  3033. var chineseTraditional_clab_amt float64 = 0
  3034. var chineseTraditional_other_amt float64 = 0
  3035. var check_claa_sunmfee float64 = 0
  3036. var check_clab_amt float64 = 0
  3037. var check_other_amt float64 = 0
  3038. var material_claa_sunmfee float64 = 0
  3039. var material_clab_amt float64 = 0
  3040. var material_other_amt float64 = 0
  3041. var laboratory_claa_sunmfee float64 = 0
  3042. var laboratory_clab_amt float64 = 0
  3043. var laboratory_other_amt float64 = 0
  3044. var treat_claa_sunmfee float64 = 0
  3045. var treat_clab_amt float64 = 0
  3046. var treat_other_amt float64 = 0
  3047. for _, item := range order.HisOrderInfo {
  3048. if item.MedChrgitmType == "01" { //床位费
  3049. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3050. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3051. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3052. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3053. if item.ChrgitmLv == "1" {
  3054. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3055. }
  3056. if item.ChrgitmLv == "2" {
  3057. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3058. }
  3059. if item.ChrgitmLv == "3" {
  3060. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3061. }
  3062. }
  3063. if item.MedChrgitmType == "03" { //检查费
  3064. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3065. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3066. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3067. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3068. if item.ChrgitmLv == "1" {
  3069. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3070. }
  3071. if item.ChrgitmLv == "2" {
  3072. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3073. }
  3074. if item.ChrgitmLv == "3" {
  3075. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3076. }
  3077. }
  3078. if item.MedChrgitmType == "04" { //化验费
  3079. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3080. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3081. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3082. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3083. if item.ChrgitmLv == "1" {
  3084. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3085. }
  3086. if item.ChrgitmLv == "2" {
  3087. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3088. }
  3089. if item.ChrgitmLv == "3" {
  3090. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3091. }
  3092. }
  3093. if item.MedChrgitmType == "05" { //治疗费
  3094. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3095. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3096. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3097. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3098. if item.ChrgitmLv == "1" {
  3099. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3100. }
  3101. if item.ChrgitmLv == "2" {
  3102. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3103. }
  3104. if item.ChrgitmLv == "3" {
  3105. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3106. }
  3107. }
  3108. if item.MedChrgitmType == "06" { //手术费
  3109. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3110. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3111. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3112. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3113. if item.ChrgitmLv == "1" {
  3114. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3115. }
  3116. if item.ChrgitmLv == "2" {
  3117. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3118. }
  3119. if item.ChrgitmLv == "3" {
  3120. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3121. }
  3122. }
  3123. if item.MedChrgitmType == "08" { //材料费
  3124. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3125. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3126. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3127. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3128. if item.ChrgitmLv == "1" {
  3129. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3130. }
  3131. if item.ChrgitmLv == "2" {
  3132. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3133. }
  3134. if item.ChrgitmLv == "3" {
  3135. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3136. }
  3137. }
  3138. if item.MedChrgitmType == "09" { //西药费
  3139. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3140. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3141. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3142. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3143. if item.ChrgitmLv == "1" {
  3144. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3145. }
  3146. if item.ChrgitmLv == "2" {
  3147. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3148. }
  3149. if item.ChrgitmLv == "3" {
  3150. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3151. }
  3152. }
  3153. if item.MedChrgitmType == "11" { //中成费
  3154. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3155. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3156. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3157. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3158. if item.ChrgitmLv == "1" {
  3159. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3160. }
  3161. if item.ChrgitmLv == "2" {
  3162. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3163. }
  3164. if item.ChrgitmLv == "3" {
  3165. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3166. }
  3167. }
  3168. if item.MedChrgitmType == "14" { //其他费
  3169. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3170. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3171. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3172. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3173. if item.ChrgitmLv == "1" {
  3174. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3175. }
  3176. if item.ChrgitmLv == "2" {
  3177. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3178. }
  3179. if item.ChrgitmLv == "3" {
  3180. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3181. }
  3182. }
  3183. }
  3184. var iteminfoStructs []service.IteminfoStruct
  3185. if bedCostTotal != 0 {
  3186. iteminfo.MedChrgitm = "01"
  3187. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3188. iteminfo.Amt = bedCostTotal
  3189. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3190. iteminfo.ClabAmt = bed_clab_amt
  3191. iteminfo.OthAmt = bed_other_amt
  3192. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3193. }
  3194. if checkCostTotal != 0 {
  3195. iteminfo.MedChrgitm = "03"
  3196. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3197. iteminfo.Amt = checkCostTotal
  3198. iteminfo.ClaaSumfee = check_claa_sunmfee
  3199. iteminfo.ClabAmt = check_clab_amt
  3200. iteminfo.OthAmt = check_other_amt
  3201. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3202. }
  3203. if laboratoryCostTotal != 0 {
  3204. iteminfo.MedChrgitm = "04"
  3205. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3206. iteminfo.Amt = laboratoryCostTotal
  3207. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3208. iteminfo.ClabAmt = laboratory_clab_amt
  3209. iteminfo.OthAmt = laboratory_other_amt
  3210. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3211. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3212. }
  3213. if treatCostTotal != 0 {
  3214. iteminfo.MedChrgitm = "05"
  3215. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3216. iteminfo.Amt = treatCostTotal
  3217. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3218. iteminfo.ClabAmt = treat_clab_amt
  3219. iteminfo.OthAmt = treat_other_amt
  3220. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3221. //(struct4101.IteminfoStruct, iteminfo)
  3222. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3223. }
  3224. if operationCostTotal != 0 {
  3225. iteminfo.MedChrgitm = "06"
  3226. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3227. iteminfo.Amt = operationCostTotal
  3228. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3229. iteminfo.ClabAmt = operation_clab_amt
  3230. iteminfo.OthAmt = operation_other_amt
  3231. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3232. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3233. }
  3234. if materialCostTotal != 0 {
  3235. iteminfo.MedChrgitm = "08"
  3236. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3237. iteminfo.Amt = materialCostTotal
  3238. iteminfo.ClaaSumfee = material_claa_sunmfee
  3239. iteminfo.ClabAmt = material_clab_amt
  3240. iteminfo.OthAmt = material_other_amt
  3241. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3242. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3243. }
  3244. if westernMedicineCostTotal != 0 {
  3245. iteminfo.MedChrgitm = "09"
  3246. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3247. iteminfo.Amt = westernMedicineCostTotal
  3248. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3249. iteminfo.ClabAmt = westernMedicine_clab_amt
  3250. iteminfo.OthAmt = westernMedicine_other_amt
  3251. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3252. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3253. }
  3254. if chineseTraditionalMedicineCostTotal != 0 {
  3255. iteminfo.MedChrgitm = "11"
  3256. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3257. iteminfo.Amt = westernMedicineCostTotal
  3258. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3259. iteminfo.ClabAmt = westernMedicine_clab_amt
  3260. iteminfo.OthAmt = westernMedicine_other_amt
  3261. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3263. }
  3264. if otherCostTotal != 0 {
  3265. iteminfo.MedChrgitm = "14"
  3266. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3267. iteminfo.Amt = otherCostTotal
  3268. iteminfo.ClaaSumfee = other_claa_sunmfee
  3269. iteminfo.ClabAmt = other_clab_amt
  3270. iteminfo.OthAmt = other_other_amt
  3271. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3272. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3273. }
  3274. struct4101.IteminfoStruct = iteminfoStructs
  3275. struct4101.Ntly = "中国"
  3276. struct4101.AdmCaty = "A03.06"
  3277. var resOther ResultSeventeenOther
  3278. var res ResultSeventeen
  3279. if miConfig.MdtrtareaAdmvs == "150499" {
  3280. var pp models.PublicParams
  3281. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3282. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3283. pp.FixmedinsName = miConfig.OrgName
  3284. pp.FixmedinsCode = miConfig.Code
  3285. pp.RequestUrl = miConfig.Url
  3286. pp.Cainfo = miConfig.Cainfo
  3287. pp.SecretKey = miConfig.SecretKey
  3288. pp.AccessKey = miConfig.AccessKey
  3289. pp.OpterName = curRoles.UserName
  3290. client := &http.Client{}
  3291. var req *http.Request
  3292. data := make(map[string]interface{})
  3293. data["struct4101"] = struct4101
  3294. data["pp"] = pp
  3295. bytesData, _ := json.Marshal(data)
  3296. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  3297. resp, _ := client.Do(req)
  3298. defer resp.Body.Close()
  3299. body, ioErr := ioutil.ReadAll(resp.Body)
  3300. if ioErr != nil {
  3301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3303. return
  3304. }
  3305. var respJSON map[string]interface{}
  3306. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3309. return
  3310. }
  3311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3312. userJSONBytes, _ := json.Marshal(respJSON)
  3313. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3314. utils.ErrorLog("解析失败:%v", err)
  3315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3316. return
  3317. }
  3318. res.InfRefmsgid = resOther.InfRefmsgid
  3319. res.Output = resOther.Output
  3320. res.ErrMsg = resOther.ErrMsg
  3321. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3322. res.Infcode = infocode
  3323. } else {
  3324. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3325. var dat map[string]interface{}
  3326. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3327. fmt.Println(dat)
  3328. } else {
  3329. fmt.Println(err)
  3330. }
  3331. userJSONBytes, _ := json.Marshal(dat)
  3332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3333. utils.ErrorLog("解析失败:%v", err)
  3334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3335. return
  3336. }
  3337. }
  3338. if res.Infcode != 0 {
  3339. c.ServeSuccessJSON(map[string]interface{}{
  3340. "failed_code": -10,
  3341. "msg": res.ErrMsg,
  3342. })
  3343. return
  3344. } else {
  3345. if miConfig.MdtrtareaAdmvs != "150499" {
  3346. order.FaPiaoNumber = zero
  3347. order.FaPiaoCode = last_order.FaPiaoCode
  3348. service.UpdateOrder(order)
  3349. }
  3350. hisFundSettleListResult := &models.HisFundSettleListResult{
  3351. Number: res.Output.SetlListId,
  3352. Status: 1,
  3353. Ctime: time.Now().Unix(),
  3354. Mtime: time.Now().Unix(),
  3355. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3356. IsUpload: 1,
  3357. OrderId: order_id,
  3358. }
  3359. service.CreateUploadRecord(hisFundSettleListResult)
  3360. c.ServeSuccessJSON(map[string]interface{}{
  3361. "msg": "上传成功",
  3362. "result": hisFundSettleListResult,
  3363. })
  3364. return
  3365. }
  3366. }
  3367. func (c *HisApiController) GetBatchSettleList() {
  3368. orders, _ := service.GetAllHisOrder(10106)
  3369. for _, item := range orders {
  3370. order_id := item.ID
  3371. order, _ := service.GetHisOrderByIDTwo(order_id)
  3372. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3373. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3374. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3375. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  3376. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3377. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3378. if order.ID == 0 {
  3379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3380. return
  3381. }
  3382. if his.BalanceAccountsType == 2 {
  3383. continue
  3384. }
  3385. struct4101 := service.Struct4101{
  3386. PsnNo: order.PsnNo,
  3387. MdtrtId: order.MdtrtId,
  3388. SetlId: order.SetlId,
  3389. PsnName: order.PsnName,
  3390. Gend: order.Gend,
  3391. Brdy: his.Brdy,
  3392. Age: his.Age,
  3393. Naty: order.Naty,
  3394. PatnCertType: "01",
  3395. Certno: order.Certno,
  3396. Prfs: "90",
  3397. ConerName: roles[0].UserName,
  3398. PatnRlts: "99",
  3399. ConerAddr: miConfig.OrgName,
  3400. ConerTel: admin.Mobile,
  3401. HiType: order.Insutype,
  3402. Insuplc: his.InsuplcAdmdvs,
  3403. MaindiagFlag: "1",
  3404. BillCode: order.FaPiaoCode,
  3405. BillNo: order.FaPiaoNumber,
  3406. BizSn: order.Number,
  3407. PsnSelfPay: order.PsnPartAmt,
  3408. PsnOwnPay: order.PsnPartAmt,
  3409. AcctPay: order.AcctPay,
  3410. PsnCashpay: order.PsnCashPay,
  3411. HiPaymtd: "1",
  3412. Hsorg: his.InsuplcAdmdvs,
  3413. HsorgOpter: his.InsuplcAdmdvs,
  3414. MedinsFillPsn: curRoles.UserName,
  3415. MedinsFillDept: depart.Name,
  3416. IptMedType: "2",
  3417. }
  3418. struct4101.SetlBegnDate = order.SetlTime
  3419. struct4101.SetlEndDate = order.SetlTime
  3420. //if order.SettleType == 1 {
  3421. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3422. // dateStr := t.Format("2006-01-02")
  3423. // struct4101.SetlBegnDate = dateStr
  3424. // struct4101.SetlEndDate = dateStr
  3425. //} else {
  3426. // t := time.Unix(int64(order.SettleStartTime), 0)
  3427. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3428. // dateStartStr := t.Format("2006-01-02")
  3429. // dateEndStr := t2.Format("2006-01-02")
  3430. // struct4101.SetlBegnDate = dateStartStr
  3431. // struct4101.SetlEndDate = dateEndStr
  3432. //}
  3433. var rf []CustomFundPay
  3434. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3435. var tempFunPays []service.CustomStruct
  3436. var tempFunPay610100 service.CustomStruct
  3437. for _, item := range rf {
  3438. if item.FundPayType == "610100" {
  3439. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3440. tempFunPay610100.FundPayType = item.FundPayType
  3441. } else {
  3442. var tempFunPay service.CustomStruct
  3443. tempFunPay.FundPayamt = item.FundPayamt
  3444. tempFunPay.FundPayType = item.FundPayType
  3445. tempFunPays = append(tempFunPays, tempFunPay)
  3446. }
  3447. }
  3448. tempFunPays = append(tempFunPays, tempFunPay610100)
  3449. struct4101.CustomStruct = tempFunPays
  3450. var tempDiaginfos []service.DiaginfoStructTwo
  3451. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3452. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3453. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3454. var config []*models.HisXtDiagnoseConfig
  3455. for _, item := range diagnosis_ids {
  3456. id, _ := strconv.ParseInt(item, 10, 64)
  3457. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3458. config = append(config, &diagnosisConfig)
  3459. }
  3460. for index, item := range config {
  3461. if index == 0 {
  3462. var tempDiaginfo service.DiaginfoStructTwo
  3463. tempDiaginfo.DiagCode = item.CountryCode
  3464. tempDiaginfo.DiagName = item.CountryContentName
  3465. tempDiaginfo.DiagType = "1"
  3466. tempDiaginfo.MaindiagFlag = "1"
  3467. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3468. } else {
  3469. var tempDiaginfo service.DiaginfoStructTwo
  3470. tempDiaginfo.DiagCode = item.CountryCode
  3471. tempDiaginfo.DiagName = item.CountryContentName
  3472. tempDiaginfo.DiagType = "2"
  3473. tempDiaginfo.MaindiagFlag = "0"
  3474. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3475. }
  3476. }
  3477. struct4101.Diseinfo = tempDiaginfos
  3478. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3479. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3480. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3481. tempOpspdiseinfo2.OprnOprtCode = ""
  3482. tempOpspdiseinfo2.OprnOprtName = ""
  3483. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3484. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3485. var iteminfo service.IteminfoStruct
  3486. var bedCostTotal float64 = 0 //床位总费
  3487. var bedCostSelfTotal float64 = 0 //床位自费
  3488. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3489. var examineCostTotal float64 = 0 //诊查总费
  3490. var examineCostSelfTotal float64 = 0 //诊查自费
  3491. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3492. var nursingCostTotal float64 = 0 //护理总费
  3493. var nursingCostSelfTotal float64 = 0 //护理自费
  3494. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3495. var chineseMedicineCostTotal float64 = 0 //中成药
  3496. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3497. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3498. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3499. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3500. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3501. var registerCostTotal float64 = 0 //一般诊疗费
  3502. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3503. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3504. var operationCostTotal float64 = 0 //手术费
  3505. var operationCostSelfTotal float64 = 0 //手术费
  3506. var operationCostPartSelfTotal float64 = 0 //手术费
  3507. var otherCostTotal float64 = 0 //其他费用
  3508. var otherCostSelfTotal float64 = 0 //其他费用
  3509. var otherCostPartSelfTotal float64 = 0 //其他费用
  3510. var materialCostTotal float64 = 0 //材料费
  3511. var materialCostSelfTotal float64 = 0 //材料费
  3512. var materialCostPartSelfTotal float64 = 0 //材料费
  3513. var westernMedicineCostTotal float64 = 0 //西药费
  3514. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3515. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3516. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3517. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3518. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3519. var checkCostTotal float64 = 0 //检查费
  3520. var checkCostSelfTotal float64 = 0 //检查费
  3521. var checkCostPartSelfTotal float64 = 0 //检查费
  3522. var laboratoryCostTotal float64 = 0 //化验费
  3523. var laboratoryCostSelfTotal float64 = 0 //化验费
  3524. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3525. var treatCostTotal float64 = 0 //治疗费用
  3526. var treatCostSelfTotal float64 = 0 //治疗费用
  3527. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3528. decimal.DivisionPrecision = 2
  3529. var bed_fulamt_ownpay_amt float64 = 0
  3530. var examine_fulamt_ownpay_amt float64 = 0
  3531. var nursing_fulamt_ownpay_amt float64 = 0
  3532. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3533. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3534. var register_fulamt_ownpay_amt float64 = 0
  3535. var operation_fulamt_ownpay_amt float64 = 0
  3536. var other_fulamt_ownpay_amt float64 = 0
  3537. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3538. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3539. var check_fulamt_ownpay_amt float64 = 0
  3540. var material_fulamt_ownpay_amt float64 = 0
  3541. var laboratory_fulamt_ownpay_amt float64 = 0
  3542. var treat_fulamt_ownpay_amt float64 = 0
  3543. var bed_claa_sunmfee float64 = 0
  3544. var bed_clab_amt float64 = 0
  3545. var bed_other_amt float64 = 0
  3546. var examine_claa_sunmfee float64 = 0
  3547. var examine_clab_amt float64 = 0
  3548. var examine_other_amt float64 = 0
  3549. var nursing_claa_sunmfee float64 = 0
  3550. var nursing_clab_amt float64 = 0
  3551. var nursing_other_amt float64 = 0
  3552. var chinese_medicine_claa_sunmfee float64 = 0
  3553. var chinese_medicine_clab_amt float64 = 0
  3554. var chinese_medicine_other_amt float64 = 0
  3555. var commonly_treatment_claa_sunmfee float64 = 0
  3556. var commonly_treatment_clab_amt float64 = 0
  3557. var commonly_treatment_other_amt float64 = 0
  3558. var operation_claa_sunmfee float64 = 0
  3559. var operation_clab_amt float64 = 0
  3560. var operation_other_amt float64 = 0
  3561. var other_claa_sunmfee float64 = 0
  3562. var other_clab_amt float64 = 0
  3563. var other_other_amt float64 = 0
  3564. var westernMedicine_claa_sunmfee float64 = 0
  3565. var westernMedicine_clab_amt float64 = 0
  3566. var westernMedicine_other_amt float64 = 0
  3567. var chineseTraditional_claa_sunmfee float64 = 0
  3568. var chineseTraditional_clab_amt float64 = 0
  3569. var chineseTraditional_other_amt float64 = 0
  3570. var check_claa_sunmfee float64 = 0
  3571. var check_clab_amt float64 = 0
  3572. var check_other_amt float64 = 0
  3573. var material_claa_sunmfee float64 = 0
  3574. var material_clab_amt float64 = 0
  3575. var material_other_amt float64 = 0
  3576. var laboratory_claa_sunmfee float64 = 0
  3577. var laboratory_clab_amt float64 = 0
  3578. var laboratory_other_amt float64 = 0
  3579. var treat_claa_sunmfee float64 = 0
  3580. var treat_clab_amt float64 = 0
  3581. var treat_other_amt float64 = 0
  3582. var register_claa_sunmfee float64 = 0
  3583. var register_clab_amt float64 = 0
  3584. var register_other_amt float64 = 0
  3585. for _, item := range order.HisOrderInfo {
  3586. if item.MedChrgitmType == "01" { //床位费
  3587. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3588. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3589. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3590. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3591. if item.ChrgitmLv == "1" {
  3592. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3593. }
  3594. if item.ChrgitmLv == "2" {
  3595. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3596. }
  3597. if item.ChrgitmLv == "3" {
  3598. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3599. }
  3600. }
  3601. if item.MedChrgitmType == "02" { //诊查
  3602. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3603. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3604. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3605. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3606. if item.ChrgitmLv == "1" {
  3607. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3608. }
  3609. if item.ChrgitmLv == "2" {
  3610. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3611. }
  3612. if item.ChrgitmLv == "3" {
  3613. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3614. }
  3615. }
  3616. if item.MedChrgitmType == "03" { //检查费
  3617. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3618. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3619. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3620. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3621. if item.ChrgitmLv == "1" {
  3622. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3623. }
  3624. if item.ChrgitmLv == "2" {
  3625. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3626. }
  3627. if item.ChrgitmLv == "3" {
  3628. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3629. }
  3630. }
  3631. if item.MedChrgitmType == "04" { //化验费
  3632. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3633. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3634. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3635. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3636. if item.ChrgitmLv == "1" {
  3637. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3638. }
  3639. if item.ChrgitmLv == "2" {
  3640. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3641. }
  3642. if item.ChrgitmLv == "3" {
  3643. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3644. }
  3645. }
  3646. if item.MedChrgitmType == "05" { //治疗费
  3647. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3648. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3649. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3650. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3651. if item.ChrgitmLv == "1" {
  3652. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3653. }
  3654. if item.ChrgitmLv == "2" {
  3655. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3656. }
  3657. if item.ChrgitmLv == "3" {
  3658. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3659. }
  3660. }
  3661. if item.MedChrgitmType == "06" { //手术费
  3662. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3663. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3664. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3665. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3666. if item.ChrgitmLv == "1" {
  3667. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3668. }
  3669. if item.ChrgitmLv == "2" {
  3670. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3671. }
  3672. if item.ChrgitmLv == "3" {
  3673. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3674. }
  3675. }
  3676. if item.MedChrgitmType == "07" { //手术费
  3677. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3678. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3679. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3680. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3681. if item.ChrgitmLv == "1" {
  3682. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3683. }
  3684. if item.ChrgitmLv == "2" {
  3685. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3686. }
  3687. if item.ChrgitmLv == "3" {
  3688. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3689. }
  3690. }
  3691. if item.MedChrgitmType == "08" { //材料费
  3692. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3693. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3694. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3695. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3696. if item.ChrgitmLv == "1" {
  3697. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3698. }
  3699. if item.ChrgitmLv == "2" {
  3700. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3701. }
  3702. if item.ChrgitmLv == "3" {
  3703. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3704. }
  3705. }
  3706. if item.MedChrgitmType == "09" { //西药费
  3707. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3708. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3709. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3710. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3711. if item.ChrgitmLv == "1" {
  3712. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3713. }
  3714. if item.ChrgitmLv == "2" {
  3715. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3716. }
  3717. if item.ChrgitmLv == "3" {
  3718. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3719. }
  3720. }
  3721. if item.MedChrgitmType == "10" { //中药饮片
  3722. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3723. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3724. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3725. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3726. if item.ChrgitmLv == "1" {
  3727. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3728. }
  3729. if item.ChrgitmLv == "2" {
  3730. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3731. }
  3732. if item.ChrgitmLv == "3" {
  3733. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3734. }
  3735. }
  3736. if item.MedChrgitmType == "11" { //中成费
  3737. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3738. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3739. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3740. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3741. if item.ChrgitmLv == "1" {
  3742. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3743. }
  3744. if item.ChrgitmLv == "2" {
  3745. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3746. }
  3747. if item.ChrgitmLv == "3" {
  3748. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3749. }
  3750. }
  3751. if item.MedChrgitmType == "12" { //中成费
  3752. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3753. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3754. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3755. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3756. if item.ChrgitmLv == "1" {
  3757. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3758. }
  3759. if item.ChrgitmLv == "2" {
  3760. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3761. }
  3762. if item.ChrgitmLv == "3" {
  3763. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3764. }
  3765. }
  3766. if item.MedChrgitmType == "13" { //中成费
  3767. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3768. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3769. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3770. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3771. if item.ChrgitmLv == "1" {
  3772. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3773. }
  3774. if item.ChrgitmLv == "2" {
  3775. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3776. }
  3777. if item.ChrgitmLv == "3" {
  3778. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3779. }
  3780. }
  3781. if item.MedChrgitmType == "14" { //其他费
  3782. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3783. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3784. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3785. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3786. if item.ChrgitmLv == "1" {
  3787. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3788. }
  3789. if item.ChrgitmLv == "2" {
  3790. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3791. }
  3792. if item.ChrgitmLv == "3" {
  3793. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3794. }
  3795. }
  3796. }
  3797. var iteminfoStructs []service.IteminfoStruct
  3798. if bedCostTotal != 0 {
  3799. iteminfo.MedChrgitm = "01"
  3800. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3801. iteminfo.Amt = bedCostTotal
  3802. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3803. iteminfo.ClabAmt = bed_clab_amt
  3804. iteminfo.OthAmt = bed_other_amt
  3805. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3806. }
  3807. if examineCostTotal != 0 {
  3808. iteminfo.MedChrgitm = "02"
  3809. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3810. iteminfo.Amt = examineCostTotal
  3811. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3812. iteminfo.ClabAmt = examine_clab_amt
  3813. iteminfo.OthAmt = examine_other_amt
  3814. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3815. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3816. }
  3817. if checkCostTotal != 0 {
  3818. iteminfo.MedChrgitm = "03"
  3819. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3820. iteminfo.Amt = checkCostTotal
  3821. iteminfo.ClaaSumfee = check_claa_sunmfee
  3822. iteminfo.ClabAmt = check_clab_amt
  3823. iteminfo.OthAmt = check_other_amt
  3824. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3825. }
  3826. if laboratoryCostTotal != 0 {
  3827. iteminfo.MedChrgitm = "04"
  3828. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3829. iteminfo.Amt = laboratoryCostTotal
  3830. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3831. iteminfo.ClabAmt = laboratory_clab_amt
  3832. iteminfo.OthAmt = laboratory_other_amt
  3833. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3834. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3835. }
  3836. if treatCostTotal != 0 {
  3837. iteminfo.MedChrgitm = "05"
  3838. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3839. iteminfo.Amt = treatCostTotal
  3840. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3841. iteminfo.ClabAmt = treat_clab_amt
  3842. iteminfo.OthAmt = treat_other_amt
  3843. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3844. //(struct4101.IteminfoStruct, iteminfo)
  3845. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3846. }
  3847. if operationCostTotal != 0 {
  3848. iteminfo.MedChrgitm = "06"
  3849. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3850. iteminfo.Amt = operationCostTotal
  3851. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3852. iteminfo.ClabAmt = operation_clab_amt
  3853. iteminfo.OthAmt = operation_other_amt
  3854. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3855. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3856. }
  3857. if nursingCostTotal != 0 {
  3858. iteminfo.MedChrgitm = "07"
  3859. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3860. iteminfo.Amt = nursingCostTotal
  3861. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3862. iteminfo.ClabAmt = nursing_clab_amt
  3863. iteminfo.OthAmt = nursing_other_amt
  3864. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3865. }
  3866. if materialCostTotal != 0 {
  3867. iteminfo.MedChrgitm = "08"
  3868. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3869. iteminfo.Amt = materialCostTotal
  3870. iteminfo.ClaaSumfee = material_claa_sunmfee
  3871. iteminfo.ClabAmt = material_clab_amt
  3872. iteminfo.OthAmt = material_other_amt
  3873. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3874. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3875. }
  3876. if westernMedicineCostTotal != 0 {
  3877. iteminfo.MedChrgitm = "09"
  3878. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3879. iteminfo.Amt = westernMedicineCostTotal
  3880. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3881. iteminfo.ClabAmt = westernMedicine_clab_amt
  3882. iteminfo.OthAmt = westernMedicine_other_amt
  3883. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3884. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3885. }
  3886. if chineseMedicineCostTotal != 0 {
  3887. iteminfo.MedChrgitm = "10"
  3888. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3889. iteminfo.Amt = chineseMedicineCostTotal
  3890. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3891. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3892. iteminfo.OthAmt = chinese_medicine_other_amt
  3893. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3894. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3895. }
  3896. if chineseTraditionalMedicineCostTotal != 0 {
  3897. iteminfo.MedChrgitm = "11"
  3898. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3899. iteminfo.Amt = westernMedicineCostTotal
  3900. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3901. iteminfo.ClabAmt = westernMedicine_clab_amt
  3902. iteminfo.OthAmt = westernMedicine_other_amt
  3903. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3904. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3905. }
  3906. if commonlyTreatmentCostTotal != 0 {
  3907. iteminfo.MedChrgitm = "12"
  3908. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3909. iteminfo.Amt = commonlyTreatmentCostTotal
  3910. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3911. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3912. iteminfo.OthAmt = commonly_treatment_other_amt
  3913. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3914. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3915. }
  3916. if registerCostTotal != 0 {
  3917. iteminfo.MedChrgitm = "13"
  3918. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3919. iteminfo.Amt = registerCostTotal
  3920. iteminfo.ClaaSumfee = register_claa_sunmfee
  3921. iteminfo.ClabAmt = register_clab_amt
  3922. iteminfo.OthAmt = register_other_amt
  3923. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3924. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3925. }
  3926. if otherCostTotal != 0 {
  3927. iteminfo.MedChrgitm = "14"
  3928. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3929. iteminfo.Amt = otherCostTotal
  3930. iteminfo.ClaaSumfee = other_claa_sunmfee
  3931. iteminfo.ClabAmt = other_clab_amt
  3932. iteminfo.OthAmt = other_other_amt
  3933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3934. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3935. }
  3936. struct4101.IteminfoStruct = iteminfoStructs
  3937. struct4101.Ntly = "中国"
  3938. struct4101.AdmCaty = "A03.06"
  3939. var res ResultSeventeen
  3940. if miConfig.MdtrtareaAdmvs == "421300" {
  3941. data := make(map[string]interface{})
  3942. data["struct4101"] = struct4101
  3943. data["secret_key"] = miConfig.SecretKey
  3944. data["org_name"] = miConfig.OrgName
  3945. data["opera"] = curRoles.UserName
  3946. data["code"] = miConfig.Code
  3947. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3948. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3949. client := &http.Client{}
  3950. bytesData, _ := json.Marshal(data)
  3951. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3952. resp, _ := client.Do(req)
  3953. defer resp.Body.Close()
  3954. body, ioErr := ioutil.ReadAll(resp.Body)
  3955. if ioErr != nil {
  3956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. return
  3959. }
  3960. var respJSON map[string]interface{}
  3961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return
  3965. }
  3966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3967. userJSONBytes, _ := json.Marshal(respJSON)
  3968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3969. utils.ErrorLog("解析失败:%v", err)
  3970. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3971. adminUser := c.GetAdminUserInfo()
  3972. errlog := &models.HisOrderError{
  3973. UserOrgId: adminUser.CurrentOrgId,
  3974. Ctime: time.Now().Unix(),
  3975. Mtime: time.Now().Unix(),
  3976. ErrMsg: res.ErrMsg + "解析失败",
  3977. Status: 1,
  3978. PatientId: order_id,
  3979. Stage: 10088,
  3980. }
  3981. service.CreateErrMsgLog(errlog)
  3982. continue
  3983. }
  3984. } else {
  3985. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3986. fmt.Println(result)
  3987. var dat map[string]interface{}
  3988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3989. fmt.Println(dat)
  3990. } else {
  3991. fmt.Println(err)
  3992. }
  3993. userJSONBytes, _ := json.Marshal(dat)
  3994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3995. utils.ErrorLog("解析失败:%v", err)
  3996. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3997. adminUser := c.GetAdminUserInfo()
  3998. errlog := &models.HisOrderError{
  3999. UserOrgId: adminUser.CurrentOrgId,
  4000. Ctime: time.Now().Unix(),
  4001. Mtime: time.Now().Unix(),
  4002. ErrMsg: res.ErrMsg + "解析失败",
  4003. Status: 1,
  4004. PatientId: order_id,
  4005. Stage: 10106,
  4006. }
  4007. service.CreateErrMsgLog(errlog)
  4008. continue
  4009. }
  4010. }
  4011. if res.Infcode != 0 {
  4012. adminUser := c.GetAdminUserInfo()
  4013. errlog := &models.HisOrderError{
  4014. UserOrgId: adminUser.CurrentOrgId,
  4015. Ctime: time.Now().Unix(),
  4016. Mtime: time.Now().Unix(),
  4017. ErrMsg: res.ErrMsg,
  4018. Status: 1,
  4019. PatientId: order_id,
  4020. Stage: 10106,
  4021. }
  4022. service.CreateErrMsgLog(errlog)
  4023. continue
  4024. } else {
  4025. hisFundSettleListResult := &models.HisFundSettleListResult{
  4026. Number: res.Output.SetlListId,
  4027. Status: 1,
  4028. Ctime: time.Now().Unix(),
  4029. Mtime: time.Now().Unix(),
  4030. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4031. IsUpload: 1,
  4032. OrderId: order_id,
  4033. }
  4034. service.CreateUploadRecord(hisFundSettleListResult)
  4035. continue
  4036. }
  4037. }
  4038. }
  4039. func (c *HisApiController) GetOrgInfo() {
  4040. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  4041. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  4042. }
  4043. func (c *HisApiController) GetHisPatientInfo() {
  4044. medical_insurance_card := c.GetString("medical_insurance_card")
  4045. id_card_type, _ := c.GetInt64("id_card_type")
  4046. id_card := c.GetString("id_card")
  4047. adminInfo := c.GetAdminUserInfo()
  4048. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4049. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4050. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  4051. IdCardNo := ""
  4052. if id_card_type == 1 {
  4053. IdCardNo = medical_insurance_card
  4054. } else if id_card_type == 2 {
  4055. IdCardNo = id_card
  4056. }
  4057. if config.IsOpen == 1 {
  4058. 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
  4059. resp, requestErr := http.Get(api)
  4060. if requestErr != nil {
  4061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4062. return
  4063. }
  4064. defer resp.Body.Close()
  4065. body, ioErr := ioutil.ReadAll(resp.Body)
  4066. if ioErr != nil {
  4067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4069. return
  4070. }
  4071. var respJSON map[string]interface{}
  4072. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4075. return
  4076. }
  4077. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4078. userJSONBytes, _ := json.Marshal(userJSON)
  4079. var res ResultTwo
  4080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4081. utils.ErrorLog("解析失败:%v", err)
  4082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4083. return
  4084. }
  4085. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4086. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4087. infoStr := string(Iinfos)
  4088. idetinfoStr := string(Idetinfos)
  4089. if res.Infcode == 0 {
  4090. his := models.VMHisPatient{
  4091. Status: 1,
  4092. Ctime: time.Now().Unix(),
  4093. Mtime: time.Now().Unix(),
  4094. PsnNo: res.Output.Baseinfo.PsnNo,
  4095. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4096. Certno: res.Output.Baseinfo.Certno,
  4097. PsnName: res.Output.Baseinfo.PsnName,
  4098. Gend: res.Output.Baseinfo.Gend,
  4099. Naty: res.Output.Baseinfo.Naty,
  4100. Brdy: res.Output.Baseinfo.Brdy,
  4101. Age: res.Output.Baseinfo.Age,
  4102. Iinfo: infoStr,
  4103. Idetinfo: idetinfoStr,
  4104. UserOrgId: adminInfo.CurrentOrgId,
  4105. IsReturn: 1,
  4106. IdCardType: id_card_type,
  4107. }
  4108. c.ServeSuccessJSON(map[string]interface{}{
  4109. "info": his,
  4110. })
  4111. } else {
  4112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4113. return
  4114. }
  4115. }
  4116. }
  4117. //func GetBasBaseInfo() (jsonStr string, err error) {
  4118. //
  4119. // handle := syscall.NewLazyDLL("SSCard.dll")
  4120. // add := handle.NewProc("ReadCardBas")
  4121. // str := make([]byte, 1024)
  4122. // str1 := make([]byte, 1024)
  4123. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  4124. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  4125. //
  4126. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  4127. //
  4128. // fmt.Println("> Add(4,5)的结果为:", ret)
  4129. // handle.Release()
  4130. //
  4131. // return "", nil
  4132. //
  4133. //}
  4134. //func GetQRBaseInfo() (jsonStr string, err error) {
  4135. // handle := syscall.LoadDLL("SSCard.dll")
  4136. // ReadCardBas := handle.FindProc("GetQRBase")
  4137. //
  4138. // str := make([]byte, 256)
  4139. // str1 := make([]byte, 256)
  4140. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  4141. //
  4142. // fmt.Println(string(str))
  4143. // fmt.Println(r)
  4144. // return string(str), nil
  4145. //}
  4146. //func CardInit() int {
  4147. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  4148. // add := DllTestDef.MustFindProc("Init")
  4149. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4150. // if err != nil {
  4151. // fmt.Println("SSCard的运算结果为:", ret)
  4152. // }
  4153. // result := int(ret)
  4154. // return result
  4155. //}
  4156. //func CardInit() int {
  4157. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4158. // if err != nil {
  4159. // fmt.Println("SSCard的运算结果为:", ret)
  4160. // }
  4161. // fmt.Println(err)
  4162. // result := int(ret)
  4163. // return result
  4164. //}
  4165. func IntPtr(n int) uintptr {
  4166. return uintptr(n)
  4167. }
  4168. func StrPtr(s string) uintptr {
  4169. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4170. }
  4171. type Result2001 struct {
  4172. Cainfo interface{} `json:"cainfo"`
  4173. ErrMsg string `json:"err_msg"`
  4174. InfRefmsgid string `json:"inf_refmsgid"`
  4175. Infcode int64 `json:"infcode"`
  4176. Output struct {
  4177. Trtinfo struct {
  4178. PsnNo string `json:"psn_no"`
  4179. TrtChkType string `json:"trt_chk_type"`
  4180. FundPayType string `json:"fund_pay_type"`
  4181. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4182. Begndate string `json:"begndate"`
  4183. Enddate string `json:"enddate"`
  4184. TrtChkRslt string `json:"trt_chk_rslt"`
  4185. } `json:"trtinfo"`
  4186. } `json:"output"`
  4187. RefmsgTime string `json:"refmsg_time"`
  4188. RespondTime string `json:"respond_time"`
  4189. Signtype interface{} `json:"signtype"`
  4190. WarnMsg interface{} `json:"warn_msg"`
  4191. }
  4192. type Result2001Org10265 struct {
  4193. Cainfo interface{} `json:"cainfo"`
  4194. ErrMsg string `json:"err_msg"`
  4195. InfRefmsgid string `json:"inf_refmsgid"`
  4196. Infcode string `json:"infcode"`
  4197. Output struct {
  4198. Trtinfo struct {
  4199. PsnNo string `json:"psn_no"`
  4200. TrtChkType string `json:"trt_chk_type"`
  4201. FundPayType string `json:"fund_pay_type"`
  4202. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4203. Begndate string `json:"begndate"`
  4204. Enddate string `json:"enddate"`
  4205. TrtChkRslt string `json:"trt_chk_rslt"`
  4206. } `json:"trtinfo"`
  4207. } `json:"output"`
  4208. RefmsgTime string `json:"refmsg_time"`
  4209. RespondTime string `json:"respond_time"`
  4210. Signtype interface{} `json:"signtype"`
  4211. WarnMsg interface{} `json:"warn_msg"`
  4212. }
  4213. type ResultTwo struct {
  4214. ErrMsg string `json:"err_msg"`
  4215. InfRefmsgid string `json:"inf_refmsgid"`
  4216. Infcode int64 `json:"infcode"`
  4217. Output struct {
  4218. Baseinfo struct {
  4219. Age float64 `json:"age"`
  4220. Brdy string `json:"brdy"`
  4221. Certno string `json:"certno"`
  4222. Gend string `json:"gend"`
  4223. Naty string `json:"naty"`
  4224. PsnCertType string `json:"psn_cert_type"`
  4225. PsnName string `json:"psn_name"`
  4226. PsnNo string `json:"psn_no"`
  4227. } `json:"baseinfo"`
  4228. Idetinfo []interface{} `json:"idetinfo"`
  4229. Iinfo []struct {
  4230. Balc float64 `json:"balc"`
  4231. CvlservFlag string `json:"cvlserv_flag"`
  4232. EmpName string `json:"emp_name"`
  4233. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4234. Insutype string `json:"insutype"`
  4235. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4236. PausInsuDate string `json:"paus_insu_date"`
  4237. PsnInsuDate string `json:"psn_insu_date"`
  4238. PsnInsuStas string `json:"psn_insu_stas"`
  4239. PsnType string `json:"psn_type"`
  4240. } `json:"insuinfo"`
  4241. } `json:"output"`
  4242. RefmsgTime string `json:"refmsg_time"`
  4243. RespondTime string `json:"respond_time"`
  4244. Signtype interface{} `json:"signtype"`
  4245. WarnInfo interface{} `json:"warn_info"`
  4246. }
  4247. type ResultTwo10265 struct {
  4248. ErrMsg string `json:"err_msg"`
  4249. InfRefmsgid string `json:"inf_refmsgid"`
  4250. Infcode string `json:"infcode"`
  4251. Output struct {
  4252. Baseinfo struct {
  4253. Age float64 `json:"age"`
  4254. Brdy string `json:"brdy"`
  4255. Certno string `json:"certno"`
  4256. Gend string `json:"gend"`
  4257. Naty string `json:"naty"`
  4258. PsnCertType string `json:"psn_cert_type"`
  4259. PsnName string `json:"psn_name"`
  4260. PsnNo string `json:"psn_no"`
  4261. } `json:"baseinfo"`
  4262. Idetinfo []interface{} `json:"idetinfo"`
  4263. Iinfo []struct {
  4264. Balc float64 `json:"balc"`
  4265. CvlservFlag string `json:"cvlserv_flag"`
  4266. EmpName string `json:"emp_name"`
  4267. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4268. Insutype string `json:"insutype"`
  4269. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4270. PausInsuDate string `json:"paus_insu_date"`
  4271. PsnInsuDate string `json:"psn_insu_date"`
  4272. PsnInsuStas string `json:"psn_insu_stas"`
  4273. PsnType string `json:"psn_type"`
  4274. } `json:"insuinfo"`
  4275. } `json:"output"`
  4276. RefmsgTime string `json:"refmsg_time"`
  4277. RespondTime string `json:"respond_time"`
  4278. Signtype interface{} `json:"signtype"`
  4279. WarnInfo interface{} `json:"warn_info"`
  4280. }
  4281. type ResultThree struct {
  4282. Cainfo interface{} `json:"cainfo"`
  4283. ErrMsg string `json:"err_msg"`
  4284. InfRefmsgid string `json:"inf_refmsgid"`
  4285. Infcode int64 `json:"infcode"`
  4286. Output struct {
  4287. Data struct {
  4288. IptOtpNo string `json:"ipt_otp_no"`
  4289. MdtrtID string `json:"mdtrt_id"`
  4290. PsnNo string `json:"psn_no"`
  4291. } `json:"data"`
  4292. } `json:"output"`
  4293. RefmsgTime string `json:"refmsg_time"`
  4294. RespondTime string `json:"respond_time"`
  4295. Signtype interface{} `json:"signtype"`
  4296. WarnMsg interface{} `json:"warn_msg"`
  4297. }
  4298. type ResultThree10265 struct {
  4299. Cainfo interface{} `json:"cainfo"`
  4300. ErrMsg string `json:"err_msg"`
  4301. InfRefmsgid string `json:"inf_refmsgid"`
  4302. Infcode string `json:"infcode"`
  4303. Output struct {
  4304. Data struct {
  4305. IptOtpNo string `json:"ipt_otp_no"`
  4306. MdtrtID string `json:"mdtrt_id"`
  4307. PsnNo string `json:"psn_no"`
  4308. } `json:"data"`
  4309. } `json:"output"`
  4310. RefmsgTime string `json:"refmsg_time"`
  4311. RespondTime string `json:"respond_time"`
  4312. Signtype interface{} `json:"signtype"`
  4313. WarnMsg interface{} `json:"warn_msg"`
  4314. }
  4315. type ResultFour struct {
  4316. Cainfo string `json:"cainfo"`
  4317. ErrMsg string `json:"err_msg"`
  4318. InfRefmsgid string `json:"inf_refmsgid"`
  4319. Infcode int64 `json:"infcode"`
  4320. Output struct {
  4321. Result []struct {
  4322. BasMednFlag string `json:"bas_medn_flag"`
  4323. ChldMedcFlag string `json:"chld_medc_flag"`
  4324. ChrgitmLv string `json:"chrgitm_lv"`
  4325. Cnt float64 `json:"cnt"`
  4326. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4327. DrtReimFlag string `json:"drt_reim_flag"`
  4328. FeedetlSn string `json:"feedetl_sn"`
  4329. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4330. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4331. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4332. ListSpItemFlag string `json:"list_sp_item_flag"`
  4333. LmtUsedFlag string `json:"lmt_used_flag"`
  4334. MedChrgitmType string `json:"med_chrgitm_type"`
  4335. Memo string `json:"memo"`
  4336. OverlmtAmt float64 `json:"overlmt_amt"`
  4337. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4338. Pric float64 `json:"pric"`
  4339. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4340. SelfpayProp float64 `json:"selfpay_prop"`
  4341. } `json:"result"`
  4342. } `json:"output"`
  4343. RefmsgTime string `json:"refmsg_time"`
  4344. RespondTime string `json:"respond_time"`
  4345. Signtype string `json:"signtype"`
  4346. WarnMsg string `json:"warn_msg"`
  4347. }
  4348. type ResultFour10265 struct {
  4349. Cainfo string `json:"cainfo"`
  4350. ErrMsg string `json:"err_msg"`
  4351. InfRefmsgid string `json:"inf_refmsgid"`
  4352. Infcode string `json:"infcode"`
  4353. Output struct {
  4354. Result []struct {
  4355. BasMednFlag string `json:"bas_medn_flag"`
  4356. ChldMedcFlag string `json:"chld_medc_flag"`
  4357. ChrgitmLv string `json:"chrgitm_lv"`
  4358. Cnt float64 `json:"cnt"`
  4359. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4360. DrtReimFlag string `json:"drt_reim_flag"`
  4361. FeedetlSn string `json:"feedetl_sn"`
  4362. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4363. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4364. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4365. ListSpItemFlag string `json:"list_sp_item_flag"`
  4366. LmtUsedFlag string `json:"lmt_used_flag"`
  4367. MedChrgitmType string `json:"med_chrgitm_type"`
  4368. Memo string `json:"memo"`
  4369. OverlmtAmt float64 `json:"overlmt_amt"`
  4370. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4371. Pric float64 `json:"pric"`
  4372. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4373. SelfpayProp float64 `json:"selfpay_prop"`
  4374. } `json:"result"`
  4375. } `json:"output"`
  4376. RefmsgTime string `json:"refmsg_time"`
  4377. RespondTime string `json:"respond_time"`
  4378. Signtype string `json:"signtype"`
  4379. WarnMsg string `json:"warn_msg"`
  4380. }
  4381. type ResultFive struct {
  4382. Balc float64 `json:"balc"`
  4383. CvlservFlag string `json:"cvlserv_flag"`
  4384. EmpName string `json:"emp_name"`
  4385. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4386. Insutype string `json:"insutype"`
  4387. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4388. PausInsuDate string `json:"paus_insu_date"`
  4389. PsnInsuDate string `json:"psn_insu_date"`
  4390. PsnInsuStas string `json:"psn_insu_stas"`
  4391. PsnType string `json:"psn_type"`
  4392. }
  4393. type ResultSix struct {
  4394. Cainfo interface{} `json:"cainfo"`
  4395. ErrMsg string `json:"err_msg"`
  4396. InfRefmsgid string `json:"inf_refmsgid"`
  4397. Infcode int64 `json:"infcode"`
  4398. Output struct {
  4399. } `json:"output"`
  4400. RefmsgTime string `json:"refmsg_time"`
  4401. RespondTime string `json:"respond_time"`
  4402. Signtype interface{} `json:"signtype"`
  4403. WarnMsg interface{} `json:"warn_msg"`
  4404. }
  4405. type ResultSix10265 struct {
  4406. Cainfo interface{} `json:"cainfo"`
  4407. ErrMsg string `json:"err_msg"`
  4408. InfRefmsgid string `json:"inf_refmsgid"`
  4409. Infcode string `json:"infcode"`
  4410. Output struct {
  4411. } `json:"output"`
  4412. RefmsgTime string `json:"refmsg_time"`
  4413. RespondTime string `json:"respond_time"`
  4414. Signtype interface{} `json:"signtype"`
  4415. WarnMsg interface{} `json:"warn_msg"`
  4416. }
  4417. type ResultSeven struct {
  4418. Cainfo string `json:"cainfo"`
  4419. ErrMsg string `json:"err_msg"`
  4420. InfRefmsgid string `json:"inf_refmsgid"`
  4421. Infcode int64 `json:"infcode"`
  4422. Output struct {
  4423. Setldetail []interface{} `json:"setldetail"`
  4424. Setlinfo struct {
  4425. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4426. AcctPay float64 `json:"acct_pay"`
  4427. ActPayDedc float64 `json:"act_pay_dedc"`
  4428. Age float64 `json:"age"`
  4429. Balc float64 `json:"balc"`
  4430. Brdy string `json:"brdy"`
  4431. Certno string `json:"certno"`
  4432. ClrOptins string `json:"clr_optins"`
  4433. ClrType string `json:"clr_type"`
  4434. ClrWay string `json:"clr_way"`
  4435. CvlservFlag string `json:"cvlserv_flag"`
  4436. CvlservPay float64 `json:"cvlserv_pay"`
  4437. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4438. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4439. Gend string `json:"gend"`
  4440. HifesPay float64 `json:"hifes_pay"`
  4441. HifmiPay float64 `json:"hifmi_pay"`
  4442. HifpPay float64 `json:"hifp_pay"`
  4443. HospPartAmt float64 `json:"hosp_part_amt"`
  4444. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4445. Insutype string `json:"insutype"`
  4446. MafPay float64 `json:"maf_pay"`
  4447. MdtrtCertType string `json:"mdtrt_cert_type"`
  4448. HifobPay float64 `json:"hifob_pay"`
  4449. MdtrtID string `json:"mdtrt_id"`
  4450. MedType string `json:"med_type"`
  4451. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4452. MedinsSetlID string `json:"medins_setl_id"`
  4453. Naty string `json:"naty"`
  4454. OthPay float64 `json:"oth_pay"`
  4455. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4456. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4457. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4458. PsnCashPay float64 `json:"psn_cash_pay"`
  4459. PsnCertType string `json:"psn_cert_type"`
  4460. PsnName string `json:"psn_name"`
  4461. PsnNo string `json:"psn_no"`
  4462. PsnPartAmt float64 `json:"psn_part_amt"`
  4463. PsnType string `json:"psn_type"`
  4464. SetlID string `json:"setl_id"`
  4465. SetlTime string `json:"setl_time"`
  4466. } `json:"setlinfo"`
  4467. } `json:"output"`
  4468. RefmsgTime string `json:"refmsg_time"`
  4469. RespondTime string `json:"respond_time"`
  4470. Signtype interface{} `json:"signtype"`
  4471. WarnMsg interface{} `json:"warn_msg"`
  4472. }
  4473. type ResultSeven10265 struct {
  4474. Cainfo string `json:"cainfo"`
  4475. ErrMsg string `json:"err_msg"`
  4476. InfRefmsgid string `json:"inf_refmsgid"`
  4477. Infcode string `json:"infcode"`
  4478. Output struct {
  4479. Setldetail []interface{} `json:"setldetail"`
  4480. Setlinfo struct {
  4481. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4482. AcctPay float64 `json:"acct_pay"`
  4483. ActPayDedc float64 `json:"act_pay_dedc"`
  4484. Age float64 `json:"age"`
  4485. Balc float64 `json:"balc"`
  4486. Brdy string `json:"brdy"`
  4487. Certno string `json:"certno"`
  4488. ClrOptins string `json:"clr_optins"`
  4489. ClrType string `json:"clr_type"`
  4490. ClrWay string `json:"clr_way"`
  4491. CvlservFlag string `json:"cvlserv_flag"`
  4492. CvlservPay float64 `json:"cvlserv_pay"`
  4493. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4494. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4495. Gend string `json:"gend"`
  4496. HifesPay float64 `json:"hifes_pay"`
  4497. HifmiPay float64 `json:"hifmi_pay"`
  4498. HifpPay float64 `json:"hifp_pay"`
  4499. HospPartAmt float64 `json:"hosp_part_amt"`
  4500. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4501. Insutype string `json:"insutype"`
  4502. MafPay float64 `json:"maf_pay"`
  4503. MdtrtCertType string `json:"mdtrt_cert_type"`
  4504. HifobPay float64 `json:"hifob_pay"`
  4505. MdtrtID string `json:"mdtrt_id"`
  4506. MedType string `json:"med_type"`
  4507. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4508. MedinsSetlID string `json:"medins_setl_id"`
  4509. Naty string `json:"naty"`
  4510. OthPay float64 `json:"oth_pay"`
  4511. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4512. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4513. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4514. PsnCashPay float64 `json:"psn_cash_pay"`
  4515. PsnCertType string `json:"psn_cert_type"`
  4516. PsnName string `json:"psn_name"`
  4517. PsnNo string `json:"psn_no"`
  4518. PsnPartAmt float64 `json:"psn_part_amt"`
  4519. PsnType string `json:"psn_type"`
  4520. SetlID string `json:"setl_id"`
  4521. SetlTime string `json:"setl_time"`
  4522. } `json:"setlinfo"`
  4523. } `json:"output"`
  4524. RefmsgTime string `json:"refmsg_time"`
  4525. RespondTime string `json:"respond_time"`
  4526. Signtype interface{} `json:"signtype"`
  4527. WarnMsg interface{} `json:"warn_msg"`
  4528. }
  4529. type ResultEight struct {
  4530. Cainfo string `json:"cainfo"`
  4531. ErrMsg string `json:"err_msg"`
  4532. InfRefmsgid string `json:"inf_refmsgid"`
  4533. Infcode int64 `json:"infcode"`
  4534. Output struct {
  4535. Stmtinfo struct {
  4536. SetlOptins string `json:"setl_optins"`
  4537. StmtRslt string `json:"stmt_rslt"`
  4538. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4539. } `json:"stmtinfo"`
  4540. } `json:"output"`
  4541. RefmsgTime string `json:"refmsg_time"`
  4542. RespondTime string `json:"respond_time"`
  4543. Signtype interface{} `json:"signtype"`
  4544. WarnMsg interface{} `json:"warn_msg"`
  4545. }
  4546. type ResultEightFor10188 struct {
  4547. Cainfo string `json:"cainfo"`
  4548. ErrMsg string `json:"err_msg"`
  4549. InfRefmsgid string `json:"inf_refmsgid"`
  4550. Infcode string `json:"infcode"`
  4551. Output struct {
  4552. Stmtinfo struct {
  4553. SetlOptins string `json:"setl_optins"`
  4554. StmtRslt string `json:"stmt_rslt"`
  4555. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4556. } `json:"stmtinfo"`
  4557. } `json:"output"`
  4558. RefmsgTime string `json:"refmsg_time"`
  4559. RespondTime string `json:"respond_time"`
  4560. Signtype interface{} `json:"signtype"`
  4561. WarnMsg interface{} `json:"warn_msg"`
  4562. }
  4563. type ResultNine struct {
  4564. Cainfo string `json:"cainfo"`
  4565. ErrMsg string `json:"err_msg"`
  4566. InfRefmsgid string `json:"inf_refmsgid"`
  4567. Infcode int64 `json:"infcode"`
  4568. Output struct {
  4569. FileQuryNo string `json:"file_qury_no"`
  4570. } `json:"output"`
  4571. RefmsgTime string `json:"refmsg_time"`
  4572. RespondTime string `json:"respond_time"`
  4573. Signtype interface{} `json:"signtype"`
  4574. WarnMsg interface{} `json:"warn_msg"`
  4575. }
  4576. type ResultTen struct {
  4577. Cainfo string `json:"cainfo"`
  4578. ErrMsg string `json:"err_msg"`
  4579. InfRefmsgid string `json:"inf_refmsgid"`
  4580. Infcode int64 `json:"infcode"`
  4581. Output struct {
  4582. DldEndtime string `json:"dld_endtime"`
  4583. FileQuryNo string `json:"file_qury_no"`
  4584. Filename string `json:"filename"`
  4585. } `json:"output"`
  4586. RefmsgTime string `json:"refmsg_time"`
  4587. RespondTime string `json:"respond_time"`
  4588. Signtype interface{} `json:"signtype"`
  4589. WarnMsg interface{} `json:"warn_msg"`
  4590. }
  4591. //type Autogenerated struct {
  4592. // Output struct {
  4593. // Setlinfo struct {
  4594. // SetlTime string `json:"setl_time"`
  4595. // CvlservPay float64 `json:"cvlserv_pay"`
  4596. // Year string `json:"year"`
  4597. // MedType string `json:"med_type"`
  4598. // PsnPay float64 `json:"psn_pay"`
  4599. // OpterID string `json:"opter_id"`
  4600. // Begndate string `json:"begndate"`
  4601. // FlxempeFlag string `json:"flxempe_flag"`
  4602. // HifmiPay float64 `json:"hifmi_pay"`
  4603. // PsnNo string `json:"psn_no"`
  4604. // ActPayDedc float64 `json:"act_pay_dedc"`
  4605. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4606. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4607. // ClrWay string `json:"clr_way"`
  4608. // OthPay float64 `json:"oth_pay"`
  4609. // Gend string `json:"gend"`
  4610. // MdtrtID string `json:"mdtrt_id"`
  4611. // AcctPay float64 `json:"acct_pay"`
  4612. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4613. // Insutype string `json:"insutype"`
  4614. // Invono interface{} `json:"invono"`
  4615. // Enddate string `json:"enddate"`
  4616. // CashPayamt float64 `json:"cash_payamt"`
  4617. // PsnType string `json:"psn_type"`
  4618. // FixmedinsName string `json:"fixmedins_name"`
  4619. // HifpPay float64 `json:"hifp_pay"`
  4620. // NewFlag interface{} `json:"new_flag"`
  4621. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4622. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4623. // PayLoc string `json:"pay_loc"`
  4624. // ClrType string `json:"clr_type"`
  4625. // RefdSetlFlag string `json:"refd_setl_flag"`
  4626. // CvlservFlag string `json:"cvlserv_flag"`
  4627. // EmpName string `json:"emp_name"`
  4628. // Brdy string `json:"brdy"`
  4629. // Naty string `json:"naty"`
  4630. // Certno string `json:"certno"`
  4631. // DiseCode string `json:"dise_code"`
  4632. // FixmedinsCode string `json:"fixmedins_code"`
  4633. // DedcHospLv string `json:"dedc_hosp_lv"`
  4634. // OpterName string `json:"opter_name"`
  4635. // Balc float64 `json:"balc"`
  4636. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4637. // PsnCertType string `json:"psn_cert_type"`
  4638. // HifobPay float64 `json:"hifob_pay"`
  4639. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4640. // HifesPay float64 `json:"hifes_pay"`
  4641. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4642. // OptTime string `json:"opt_time"`
  4643. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4644. // SetlID string `json:"setl_id"`
  4645. // MafPay float64 `json:"maf_pay"`
  4646. // PsnName string `json:"psn_name"`
  4647. // InsuOptins interface{} `json:"insu_optins"`
  4648. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4649. // ClrOptins string `json:"clr_optins"`
  4650. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4651. // DiseName string `json:"dise_name"`
  4652. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4653. // Age float64 `json:"age"`
  4654. // DtrtCertType string `json:"dtrt_cert_type"`
  4655. // HospLv string `json:"hosp_lv"`
  4656. // } `json:"setlinfo"`
  4657. // Setldetail []struct {
  4658. // FundPayType string `json:"fund_pay_type"`
  4659. // FundPayamt float64 `json:"fund_payamt"`
  4660. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4661. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4662. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4663. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4664. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4665. // } `json:"setldetail"`
  4666. // } `json:"output"`
  4667. // Infcode int `json:"infcode"`
  4668. // WarnMsg interface{} `json:"warn_msg"`
  4669. // Cainfo interface{} `json:"cainfo"`
  4670. // ErrMsg interface{} `json:"err_msg"`
  4671. // RefmsgTime string `json:"refmsg_time"`
  4672. // Signtype interface{} `json:"signtype"`
  4673. // RespondTime string `json:"respond_time"`
  4674. // InfRefmsgid string `json:"inf_refmsgid"`
  4675. //}
  4676. type ResultEleven struct {
  4677. Cainfo string `json:"cainfo"`
  4678. ErrMsg string `json:"err_msg"`
  4679. InfRefmsgid string `json:"inf_refmsgid"`
  4680. Infcode int64 `json:"infcode"`
  4681. Output struct {
  4682. Setlinfo struct {
  4683. SetlTime string `json:"setl_time"`
  4684. CvlservPay float64 `json:"cvlserv_pay"`
  4685. Year string `json:"year"`
  4686. MedType string `json:"med_type"`
  4687. PsnPay float64 `json:"psn_pay"`
  4688. OpterID string `json:"opter_id"`
  4689. Begndate string `json:"begndate"`
  4690. FlxempeFlag string `json:"flxempe_flag"`
  4691. HifmiPay float64 `json:"hifmi_pay"`
  4692. PsnNo string `json:"psn_no"`
  4693. ActPayDedc float64 `json:"act_pay_dedc"`
  4694. MedinsSetlID interface{} `json:"medins_setl_id"`
  4695. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4696. ClrWay string `json:"clr_way"`
  4697. OthPay float64 `json:"oth_pay"`
  4698. Gend string `json:"gend"`
  4699. MdtrtID string `json:"mdtrt_id"`
  4700. AcctPay float64 `json:"acct_pay"`
  4701. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4702. Insutype string `json:"insutype"`
  4703. Invono interface{} `json:"invono"`
  4704. Enddate string `json:"enddate"`
  4705. CashPayamt float64 `json:"cash_payamt"`
  4706. PsnType string `json:"psn_type"`
  4707. FixmedinsName string `json:"fixmedins_name"`
  4708. HifpPay float64 `json:"hifp_pay"`
  4709. NewFlag interface{} `json:"new_flag"`
  4710. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4711. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4712. PayLoc string `json:"pay_loc"`
  4713. ClrType string `json:"clr_type"`
  4714. RefdSetlFlag string `json:"refd_setl_flag"`
  4715. CvlservFlag string `json:"cvlserv_flag"`
  4716. EmpName string `json:"emp_name"`
  4717. Brdy string `json:"brdy"`
  4718. Naty string `json:"naty"`
  4719. Certno string `json:"certno"`
  4720. DiseCode string `json:"dise_code"`
  4721. FixmedinsCode string `json:"fixmedins_code"`
  4722. DedcHospLv string `json:"dedc_hosp_lv"`
  4723. OpterName string `json:"opter_name"`
  4724. Balc float64 `json:"balc"`
  4725. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4726. PsnCertType string `json:"psn_cert_type"`
  4727. HifobPay float64 `json:"hifob_pay"`
  4728. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4729. HifesPay float64 `json:"hifes_pay"`
  4730. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4731. OptTime string `json:"opt_time"`
  4732. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4733. SetlID string `json:"setl_id"`
  4734. MafPay float64 `json:"maf_pay"`
  4735. PsnName string `json:"psn_name"`
  4736. InsuOptins interface{} `json:"insu_optins"`
  4737. PrefFundPay interface{} `json:"pref_fund_pay"`
  4738. ClrOptins string `json:"clr_optins"`
  4739. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4740. DiseName string `json:"dise_name"`
  4741. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4742. Age float64 `json:"age"`
  4743. DtrtCertType string `json:"dtrt_cert_type"`
  4744. HospLv string `json:"hosp_lv"`
  4745. } `json:"setlinfo"`
  4746. } `json:"output"`
  4747. RefmsgTime string `json:"refmsg_time"`
  4748. RespondTime string `json:"respond_time"`
  4749. Signtype interface{} `json:"signtype"`
  4750. WarnMsg interface{} `json:"warn_msg"`
  4751. }
  4752. type ResultEleven10265 struct {
  4753. Cainfo string `json:"cainfo"`
  4754. ErrMsg string `json:"err_msg"`
  4755. InfRefmsgid string `json:"inf_refmsgid"`
  4756. Infcode string `json:"infcode"`
  4757. Output struct {
  4758. Setlinfo struct {
  4759. SetlTime string `json:"setl_time"`
  4760. CvlservPay float64 `json:"cvlserv_pay"`
  4761. Year string `json:"year"`
  4762. MedType string `json:"med_type"`
  4763. PsnPay float64 `json:"psn_pay"`
  4764. OpterID string `json:"opter_id"`
  4765. Begndate string `json:"begndate"`
  4766. FlxempeFlag string `json:"flxempe_flag"`
  4767. HifmiPay float64 `json:"hifmi_pay"`
  4768. PsnNo string `json:"psn_no"`
  4769. ActPayDedc float64 `json:"act_pay_dedc"`
  4770. MedinsSetlID interface{} `json:"medins_setl_id"`
  4771. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4772. ClrWay string `json:"clr_way"`
  4773. OthPay float64 `json:"oth_pay"`
  4774. Gend string `json:"gend"`
  4775. MdtrtID string `json:"mdtrt_id"`
  4776. AcctPay float64 `json:"acct_pay"`
  4777. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4778. Insutype string `json:"insutype"`
  4779. Invono interface{} `json:"invono"`
  4780. Enddate string `json:"enddate"`
  4781. CashPayamt float64 `json:"cash_payamt"`
  4782. PsnType string `json:"psn_type"`
  4783. FixmedinsName string `json:"fixmedins_name"`
  4784. HifpPay float64 `json:"hifp_pay"`
  4785. NewFlag interface{} `json:"new_flag"`
  4786. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4787. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4788. PayLoc string `json:"pay_loc"`
  4789. ClrType string `json:"clr_type"`
  4790. RefdSetlFlag string `json:"refd_setl_flag"`
  4791. CvlservFlag string `json:"cvlserv_flag"`
  4792. EmpName string `json:"emp_name"`
  4793. Brdy string `json:"brdy"`
  4794. Naty string `json:"naty"`
  4795. Certno string `json:"certno"`
  4796. DiseCode string `json:"dise_code"`
  4797. FixmedinsCode string `json:"fixmedins_code"`
  4798. DedcHospLv string `json:"dedc_hosp_lv"`
  4799. OpterName string `json:"opter_name"`
  4800. Balc float64 `json:"balc"`
  4801. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4802. PsnCertType string `json:"psn_cert_type"`
  4803. HifobPay float64 `json:"hifob_pay"`
  4804. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4805. HifesPay float64 `json:"hifes_pay"`
  4806. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4807. OptTime string `json:"opt_time"`
  4808. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4809. SetlID string `json:"setl_id"`
  4810. MafPay float64 `json:"maf_pay"`
  4811. PsnName string `json:"psn_name"`
  4812. InsuOptins interface{} `json:"insu_optins"`
  4813. PrefFundPay interface{} `json:"pref_fund_pay"`
  4814. ClrOptins string `json:"clr_optins"`
  4815. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4816. DiseName string `json:"dise_name"`
  4817. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4818. Age float64 `json:"age"`
  4819. DtrtCertType string `json:"dtrt_cert_type"`
  4820. HospLv string `json:"hosp_lv"`
  4821. } `json:"setlinfo"`
  4822. } `json:"output"`
  4823. RefmsgTime string `json:"refmsg_time"`
  4824. RespondTime string `json:"respond_time"`
  4825. Signtype interface{} `json:"signtype"`
  4826. WarnMsg interface{} `json:"warn_msg"`
  4827. }
  4828. type ResultTwelve struct {
  4829. Cainfo string `json:"cainfo"`
  4830. ErrMsg string `json:"err_msg"`
  4831. InfRefmsgid string `json:"inf_refmsgid"`
  4832. Infcode int64 `json:"infcode"`
  4833. Output struct {
  4834. MdtrtId string `json:"mdtrt_id"`
  4835. ChrgBchno string `json:"chrg_bchno"`
  4836. PsnNo string `json:"psn_no"`
  4837. } `json:"output"`
  4838. RefmsgTime string `json:"refmsg_time"`
  4839. RespondTime string `json:"respond_time"`
  4840. Signtype interface{} `json:"signtype"`
  4841. WarnMsg interface{} `json:"warn_msg"`
  4842. }
  4843. type ResultThirteen struct {
  4844. ErrMsg string `json:"err_msg"`
  4845. InfRefmsgid string `json:"inf_refmsgid"`
  4846. Infcode int64 `json:"infcode"`
  4847. Output struct {
  4848. Result struct {
  4849. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4850. } `json:"result"`
  4851. } `json:"output"`
  4852. RefmsgTime string `json:"refmsg_time"`
  4853. RespondTime string `json:"respond_time"`
  4854. Signtype interface{} `json:"signtype"`
  4855. WarnInfo interface{} `json:"warn_info"`
  4856. }
  4857. type ResultThirteen10265 struct {
  4858. ErrMsg string `json:"err_msg"`
  4859. InfRefmsgid string `json:"inf_refmsgid"`
  4860. Infcode string `json:"infcode"`
  4861. Output struct {
  4862. Result struct {
  4863. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4864. } `json:"result"`
  4865. } `json:"output"`
  4866. RefmsgTime string `json:"refmsg_time"`
  4867. RespondTime string `json:"respond_time"`
  4868. Signtype interface{} `json:"signtype"`
  4869. WarnInfo interface{} `json:"warn_info"`
  4870. }
  4871. type ResultFourteen struct {
  4872. ErrMsg string `json:"err_msg"`
  4873. InfRefmsgid string `json:"inf_refmsgid"`
  4874. Infcode int64 `json:"infcode"`
  4875. Output struct {
  4876. } `json:"output"`
  4877. RefmsgTime string `json:"refmsg_time"`
  4878. RespondTime string `json:"respond_time"`
  4879. Signtype interface{} `json:"signtype"`
  4880. WarnInfo interface{} `json:"warn_info"`
  4881. }
  4882. type ResultFourteen10265 struct {
  4883. ErrMsg string `json:"err_msg"`
  4884. InfRefmsgid string `json:"inf_refmsgid"`
  4885. Infcode string `json:"infcode"`
  4886. Output struct {
  4887. } `json:"output"`
  4888. RefmsgTime string `json:"refmsg_time"`
  4889. RespondTime string `json:"respond_time"`
  4890. Signtype interface{} `json:"signtype"`
  4891. WarnInfo interface{} `json:"warn_info"`
  4892. }
  4893. type ResultSixteen struct {
  4894. Cainfo string `json:"cainfo"`
  4895. ErrMsg string `json:"err_msg"`
  4896. InfRefmsgid string `json:"inf_refmsgid"`
  4897. Infcode int64 `json:"infcode"`
  4898. Output struct {
  4899. Setldetail []interface{} `json:"setldetail"`
  4900. Setlinfo struct {
  4901. MdtrtID string `json:"mdtrt_id"`
  4902. SetlID string `json:"setl_id"`
  4903. ClrOptins string `json:"clr_optins"`
  4904. SetlTime string `json:"setl_time"`
  4905. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4906. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4907. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4908. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4909. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4910. ActPayDedc float64 `json:"act_pay_dedc"`
  4911. HifpPay float64 `json:"hifp_pay"`
  4912. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4913. Lfpay float64 `json:"selfpay"`
  4914. CvlservPay float64 `json:"cvlserv_pay"`
  4915. HifesPay float64 `json:"hifes_pay"`
  4916. HifmiPay float64 `json:"hifmi_pay"`
  4917. HifobPay float64 `json:"hifob_pay"`
  4918. MafPay float64 `json:"maf_pay"`
  4919. OthPay float64 `json:"oth_pay"`
  4920. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4921. PsnPartAmt float64 `json:"psn_part_amt"`
  4922. AcctPay float64 `json:"acct_pay"`
  4923. Balc float64 `json:"balc"`
  4924. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4925. HospPartAmt float64 `json:"hosp_part_amt"`
  4926. MedinsSetlID string `json:"medins_setl_id"`
  4927. PdnCashPay string `json:"pdn_cash_pay"`
  4928. } `json:"setlinfo"`
  4929. } `json:"output"`
  4930. RefmsgTime string `json:"refmsg_time"`
  4931. RespondTime string `json:"respond_time"`
  4932. Signtype interface{} `json:"signtype"`
  4933. WarnMsg interface{} `json:"warn_msg"`
  4934. }
  4935. type ResultSixteen10265 struct {
  4936. Cainfo string `json:"cainfo"`
  4937. ErrMsg string `json:"err_msg"`
  4938. InfRefmsgid string `json:"inf_refmsgid"`
  4939. Infcode string `json:"infcode"`
  4940. Output struct {
  4941. Setldetail []interface{} `json:"setldetail"`
  4942. Setlinfo struct {
  4943. MdtrtID string `json:"mdtrt_id"`
  4944. SetlID string `json:"setl_id"`
  4945. ClrOptins string `json:"clr_optins"`
  4946. SetlTime string `json:"setl_time"`
  4947. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4948. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4949. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4950. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4951. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4952. ActPayDedc float64 `json:"act_pay_dedc"`
  4953. HifpPay float64 `json:"hifp_pay"`
  4954. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4955. Lfpay float64 `json:"selfpay"`
  4956. CvlservPay float64 `json:"cvlserv_pay"`
  4957. HifesPay float64 `json:"hifes_pay"`
  4958. HifmiPay float64 `json:"hifmi_pay"`
  4959. HifobPay float64 `json:"hifob_pay"`
  4960. MafPay float64 `json:"maf_pay"`
  4961. OthPay float64 `json:"oth_pay"`
  4962. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4963. PsnPartAmt float64 `json:"psn_part_amt"`
  4964. AcctPay float64 `json:"acct_pay"`
  4965. Balc float64 `json:"balc"`
  4966. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4967. HospPartAmt float64 `json:"hosp_part_amt"`
  4968. MedinsSetlID string `json:"medins_setl_id"`
  4969. PdnCashPay string `json:"pdn_cash_pay"`
  4970. } `json:"setlinfo"`
  4971. } `json:"output"`
  4972. RefmsgTime string `json:"refmsg_time"`
  4973. RespondTime string `json:"respond_time"`
  4974. Signtype interface{} `json:"signtype"`
  4975. WarnMsg interface{} `json:"warn_msg"`
  4976. }
  4977. type ResultSeventeen struct {
  4978. ErrMsg string `json:"err_msg"`
  4979. InfRefmsgid string `json:"inf_refmsgid"`
  4980. Infcode int64 `json:"infcode"`
  4981. Output struct {
  4982. SetlListId string `json:"setl_list_id"`
  4983. } `json:"output"`
  4984. RefmsgTime string `json:"refmsg_time"`
  4985. RespondTime string `json:"respond_time"`
  4986. Signtype string `json:"signtype"`
  4987. WarnInfo string `json:"warn_info"`
  4988. }
  4989. type ResultSeventeenOther struct {
  4990. ErrMsg string `json:"err_msg"`
  4991. InfRefmsgid string `json:"inf_refmsgid"`
  4992. Infcode string `json:"infcode"`
  4993. Output struct {
  4994. SetlListId string `json:"setl_list_id"`
  4995. } `json:"output"`
  4996. RefmsgTime string `json:"refmsg_time"`
  4997. RespondTime string `json:"respond_time"`
  4998. Signtype string `json:"signtype"`
  4999. WarnInfo string `json:"warn_info"`
  5000. }
  5001. type Result90991 struct {
  5002. ErrMsg string `json:"err_msg"`
  5003. InfRefmsgid string `json:"inf_refmsgid"`
  5004. Infcode int64 `json:"infcode"`
  5005. Output struct {
  5006. Result struct {
  5007. PsnNo string `json:"psn_no"`
  5008. CardStat string `json:"card_stat"`
  5009. Certno string `json:"certno"`
  5010. PsnName string `json:"psn_name"`
  5011. CheckStat string `json:"check_stat"`
  5012. SscnoCheckStat string `json:"sscno_check_stat"`
  5013. } `json:"result"`
  5014. } `json:"output"`
  5015. RefmsgTime string `json:"refmsg_time"`
  5016. RespondTime string `json:"respond_time"`
  5017. Signtype interface{} `json:"signtype"`
  5018. WarnInfo interface{} `json:"warn_info"`
  5019. }
  5020. type Result90100 struct {
  5021. ErrMsg string `json:"err_msg"`
  5022. InfRefmsgid string `json:"inf_refmsgid"`
  5023. Infcode int64 `json:"infcode"`
  5024. Output struct {
  5025. PoolareaNo string `json:"poolarea_no"`
  5026. PoolareaNoName string `json:"poolarea_no_name"`
  5027. Insutype string `json:"insutype"`
  5028. InsutypeName string `json:"insutype_name"`
  5029. ClctType string `json:"clct_type"`
  5030. ClctTypeName string `json:"clct_type_name"`
  5031. ClctFlag string `json:"clct_flag"`
  5032. ClctFlagName string `json:"clct_flag_name"`
  5033. AccrymBegn string `json:"accrym_begn"`
  5034. AccrymEnd string `json:"accrym_end"`
  5035. ClctTime string `json:"clct_time"`
  5036. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  5037. } `json:"output"`
  5038. RefmsgTime string `json:"refmsg_time"`
  5039. RespondTime string `json:"respond_time"`
  5040. Signtype interface{} `json:"signtype"`
  5041. WarnInfo interface{} `json:"warn_info"`
  5042. }
  5043. type Custom struct {
  5044. DetItemFeeSumamt string
  5045. Cut string
  5046. FeedetlSn string
  5047. Price string
  5048. MedListCodg string
  5049. Type int64
  5050. AdviceId int64
  5051. ProjectId int64
  5052. ItemId int64
  5053. }
  5054. type Result5301 struct {
  5055. ErrMsg string `json:"err_msg"`
  5056. InfRefmsgid string `json:"inf_refmsgid"`
  5057. Infcode int64 `json:"infcode"`
  5058. Output struct {
  5059. Result []struct {
  5060. OpspDiseCode string `json:"opsp_dise_code"`
  5061. OpspDiseName string `json:"opsp_dise_name"`
  5062. Begndate string `json:"begndate"`
  5063. Enddate string `json:"enddate"`
  5064. } `json:"feedetail"`
  5065. } `json:"output"`
  5066. RefmsgTime string `json:"refmsg_time"`
  5067. RespondTime string `json:"respond_time"`
  5068. Signtype interface{} `json:"signtype"`
  5069. WarnInfo interface{} `json:"warn_info"`
  5070. }
  5071. type Result5301For10265 struct {
  5072. ErrMsg string `json:"err_msg"`
  5073. InfRefmsgid string `json:"inf_refmsgid"`
  5074. Infcode string `json:"infcode"`
  5075. Output struct {
  5076. Result []struct {
  5077. OpspDiseCode string `json:"opsp_dise_code"`
  5078. OpspDiseName string `json:"opsp_dise_name"`
  5079. Begndate string `json:"begndate"`
  5080. Enddate string `json:"enddate"`
  5081. } `json:"feedetail"`
  5082. } `json:"output"`
  5083. RefmsgTime string `json:"refmsg_time"`
  5084. RespondTime string `json:"respond_time"`
  5085. Signtype interface{} `json:"signtype"`
  5086. WarnInfo interface{} `json:"warn_info"`
  5087. }
  5088. //获取个人信息----挂号-----上传就诊信息
  5089. func (c *HisApiController) GetRegisterInfo() {
  5090. id, _ := c.GetInt64("id")
  5091. record_time := c.GetString("record_time")
  5092. settlementValue, _ := c.GetInt64("settlement_value")
  5093. medical_insurance_card := c.GetString("medical_insurance_card")
  5094. name := c.GetString("name")
  5095. id_card_type, _ := c.GetInt64("id_card_type")
  5096. certificates, _ := c.GetInt64("certificates")
  5097. medical_care, _ := c.GetInt64("medical_care")
  5098. birthday := c.GetString("birthday")
  5099. id_card := c.GetString("id_card")
  5100. register_type, _ := c.GetInt64("register")
  5101. doctor, _ := c.GetInt64("doctor")
  5102. department, _ := c.GetInt64("department")
  5103. gender, _ := c.GetInt64("sex")
  5104. registration_fee, _ := c.GetFloat("registration_fee")
  5105. medical_expenses, _ := c.GetFloat("medical_expenses")
  5106. social_type, _ := c.GetInt64("social_type")
  5107. med_type := c.GetString("social_type")
  5108. admin_user_id, _ := c.GetInt64("admin_user_id")
  5109. insuplc_admdvs := c.GetString("insuplc_admdvs")
  5110. timeLayout := "2006-01-02"
  5111. loc, _ := time.LoadLocation("Local")
  5112. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  5113. birthUnix := birthdays.Unix()
  5114. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5115. if err != nil {
  5116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5117. return
  5118. }
  5119. recordDateTime := theTime.Unix()
  5120. adminInfo := c.GetAdminUserInfo()
  5121. var patient service.Patients
  5122. if id == 0 {
  5123. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  5124. } else {
  5125. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  5126. }
  5127. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5128. if patientPrescription.ID == 0 {
  5129. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5130. }
  5131. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5132. if patient.ID == 0 {
  5133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  5134. return
  5135. }
  5136. if len(patient.IdCardNo) == 0 {
  5137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  5138. return
  5139. }
  5140. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5141. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  5142. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  5143. //就诊结算未完成,不能进行二次挂号
  5144. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  5145. if len(his) >= 1 {
  5146. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  5147. if len(his) >= 1 && order.ID == 0 {
  5148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  5149. return
  5150. }
  5151. }
  5152. //var register_log string
  5153. if config.IsOpen == 1 {
  5154. var res ResultTwo
  5155. var res10265 ResultTwo10265
  5156. var PsnNo string
  5157. var PsnCertType string
  5158. var Certno string
  5159. var PsnName string
  5160. var Gend string
  5161. var Naty string
  5162. var Brdy string
  5163. var Age float64
  5164. var infoStr string
  5165. var idetinfoStr string
  5166. var infocode int64
  5167. var verify_number string
  5168. fmt.Println(verify_number)
  5169. if miConfig.MdtrtareaAdmvs == "421300" {
  5170. psn_info, _ := service.GetPsnByPatientId(id)
  5171. PsnNo = psn_info.PsnNo
  5172. PsnCertType = psn_info.PsnCertType
  5173. Certno = psn_info.Certno
  5174. PsnName = psn_info.PsnName
  5175. Gend = psn_info.Gend
  5176. Naty = psn_info.Naty
  5177. Brdy = psn_info.Brdy
  5178. Age = psn_info.Age
  5179. infoStr = psn_info.Insuinfo
  5180. idetinfoStr = psn_info.Idetinfo
  5181. infocode = 0
  5182. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5183. psn_info, _ := service.GetPsnByPatientId(id)
  5184. PsnNo = psn_info.PsnNo
  5185. PsnCertType = psn_info.PsnCertType
  5186. Certno = psn_info.Certno
  5187. PsnName = psn_info.PsnName
  5188. Gend = psn_info.Gend
  5189. Naty = psn_info.Naty
  5190. Brdy = psn_info.Brdy
  5191. Age = psn_info.Age
  5192. infoStr = psn_info.Insuinfo
  5193. idetinfoStr = psn_info.Idetinfo
  5194. infocode = 0
  5195. verify_number = psn_info.VerifyNumber
  5196. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5197. if id_card_type == 1 {
  5198. psn_info, _ := service.GetPsnByPatientId(id)
  5199. PsnNo = psn_info.PsnNo
  5200. PsnCertType = psn_info.PsnCertType
  5201. Certno = psn_info.Certno
  5202. PsnName = psn_info.PsnName
  5203. Gend = psn_info.Gend
  5204. Naty = psn_info.Naty
  5205. Brdy = psn_info.Brdy
  5206. Age = psn_info.Age
  5207. infoStr = psn_info.Insuinfo
  5208. idetinfoStr = psn_info.Idetinfo
  5209. infocode = 0
  5210. verify_number = psn_info.VerifyNumber
  5211. } else if id_card_type == 2 {
  5212. 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)
  5213. fmt.Println(errMsgLog)
  5214. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5215. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5216. utils.ErrorLog("解析失败:%v", err)
  5217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5218. return
  5219. }
  5220. PsnNo = res.Output.Baseinfo.PsnNo
  5221. PsnCertType = res.Output.Baseinfo.PsnCertType
  5222. Certno = res.Output.Baseinfo.Certno
  5223. PsnName = res.Output.Baseinfo.PsnName
  5224. Gend = res.Output.Baseinfo.Gend
  5225. Naty = res.Output.Baseinfo.Naty
  5226. Brdy = res.Output.Baseinfo.Brdy
  5227. Age = res.Output.Baseinfo.Age
  5228. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5229. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5230. infoStr = string(Iinfos)
  5231. idetinfoStr = string(Idetinfos)
  5232. infocode = res.Infcode
  5233. }
  5234. } else {
  5235. var result string
  5236. var requestLog string
  5237. if miConfig.UserOrgId == 10138 {
  5238. if id_card_type == 4 {
  5239. psn_info, _ := service.GetPsnByPatientId(id)
  5240. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5241. } else {
  5242. 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)
  5243. }
  5244. } else {
  5245. 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)
  5246. }
  5247. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5248. if miConfig.Code == "H15049901371" {
  5249. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5250. utils.ErrorLog("解析失败:%v", err)
  5251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5252. return
  5253. }
  5254. res.ErrMsg = res10265.ErrMsg
  5255. res.Output = res10265.Output
  5256. res.InfRefmsgid = res10265.InfRefmsgid
  5257. } else {
  5258. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5259. utils.ErrorLog("解析失败:%v", err)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. }
  5264. PsnNo = res.Output.Baseinfo.PsnNo
  5265. PsnCertType = res.Output.Baseinfo.PsnCertType
  5266. Certno = res.Output.Baseinfo.Certno
  5267. PsnName = res.Output.Baseinfo.PsnName
  5268. Gend = res.Output.Baseinfo.Gend
  5269. Naty = res.Output.Baseinfo.Naty
  5270. Brdy = res.Output.Baseinfo.Brdy
  5271. Age = res.Output.Baseinfo.Age
  5272. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5273. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5274. infoStr = string(Iinfos)
  5275. idetinfoStr = string(Idetinfos)
  5276. if miConfig.Code == "H15049901371" {
  5277. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5278. } else {
  5279. infocode = res.Infcode
  5280. }
  5281. }
  5282. if infocode == 0 {
  5283. his := models.VMHisPatient{
  5284. Name: name,
  5285. Gender: gender,
  5286. Birthday: birthUnix,
  5287. MedicalTreatmentType: medical_care,
  5288. IdType: certificates,
  5289. IdCardNo: id_card,
  5290. BalanceAccountsType: settlementValue,
  5291. SocialType: social_type,
  5292. MedicalInsuranceNumber: medical_insurance_card,
  5293. RegisterType: register_type,
  5294. RegisterCost: registration_fee,
  5295. TreatmentCost: medical_expenses,
  5296. Status: 1,
  5297. Ctime: time.Now().Unix(),
  5298. Mtime: time.Now().Unix(),
  5299. PsnNo: PsnNo,
  5300. PsnCertType: PsnCertType,
  5301. Certno: Certno,
  5302. PsnName: PsnName,
  5303. Gend: Gend,
  5304. Naty: Naty,
  5305. Brdy: Brdy,
  5306. Age: Age,
  5307. Iinfo: infoStr,
  5308. Idetinfo: idetinfoStr,
  5309. PatientId: patient.ID,
  5310. RecordDate: theTime.Unix(),
  5311. UserOrgId: adminInfo.CurrentOrgId,
  5312. AdminUserId: admin_user_id,
  5313. IsReturn: 1,
  5314. IdCardType: id_card_type,
  5315. Doctor: doctor,
  5316. Departments: department,
  5317. }
  5318. timestamp := time.Now().Unix()
  5319. tempTime := time.Unix(timestamp, 0)
  5320. timeFormat := tempTime.Format("20060102150405")
  5321. chrgBchno := rand.Intn(100000) + 10000
  5322. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5323. his.Number = ipt_otp_no
  5324. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5325. department, _ := service.GetDepartMentDetail(department)
  5326. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5327. IdCardNo := ""
  5328. if id_card_type == 1 {
  5329. // IdCardNo = medical_insurance_card
  5330. IdCardNo = patient.IdCardNo
  5331. } else {
  5332. IdCardNo = patient.IdCardNo
  5333. }
  5334. var rf []*ResultFive
  5335. json.Unmarshal([]byte(his.Iinfo), &rf)
  5336. var insutypes []*ResultFive
  5337. var insutype string
  5338. var insuplc_admdvs_temp string
  5339. var is390 int = 0
  5340. var is310 int = 0
  5341. for _, item := range rf {
  5342. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5343. insutypes = append(insutypes, item)
  5344. }
  5345. }
  5346. if len(insutypes) == 1 {
  5347. insutype = insutypes[0].Insutype
  5348. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5349. } else {
  5350. for _, i := range insutypes {
  5351. if i.Insutype == "390" {
  5352. is390 = 1
  5353. }
  5354. if i.Insutype == "310" {
  5355. is310 = 1
  5356. }
  5357. }
  5358. }
  5359. if is390 == 1 {
  5360. insutype = "390"
  5361. }
  5362. if is310 == 1 {
  5363. insutype = "310"
  5364. }
  5365. if len(insutypes) == 0 {
  5366. insutype = "310"
  5367. }
  5368. if len(insutypes) == 2 {
  5369. insutype = med_type
  5370. }
  5371. if len(med_type) > 0 {
  5372. insutype = med_type
  5373. }
  5374. var infocode int64
  5375. var resThree ResultThree
  5376. var resThree10265 ResultThree10265
  5377. if len(insuplc_admdvs) == 0 {
  5378. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5379. } else {
  5380. insuplc_admdvs_temp = insuplc_admdvs
  5381. }
  5382. if miConfig.MdtrtareaAdmvs == "421300" {
  5383. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5384. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5385. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5386. "&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
  5387. resp, requestErr := http.Get(api)
  5388. if requestErr != nil {
  5389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5390. return
  5391. }
  5392. body, ioErr := ioutil.ReadAll(resp.Body)
  5393. if ioErr != nil {
  5394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5396. return
  5397. }
  5398. var respJSON map[string]interface{}
  5399. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5402. return
  5403. }
  5404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5405. result, _ := json.Marshal(respJSON)
  5406. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5407. utils.ErrorLog("解析失败:%v", err)
  5408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5409. return
  5410. }
  5411. infocode = resThree.Infcode
  5412. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5413. psn_info, _ := service.GetPsnByPatientId(id)
  5414. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5415. var cert_no string
  5416. if id_card_type == 3 {
  5417. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5418. cert_no = IdCardNo
  5419. } else if id_card_type == 4 {
  5420. cert_no = IdCardNo
  5421. psn_info.VerifyNumber = psn_info.VerifyNumber
  5422. } else {
  5423. bas := strings.Split(psn_info.CardInfo, "|")
  5424. cert_no = bas[2]
  5425. }
  5426. var hisPrescription []*models.HisPrescription
  5427. for _, item := range rf {
  5428. if item.Insutype == insutype {
  5429. //insuplc_admdvs = item.InsuplcAdmdvs
  5430. his.InsuplcAdmdvs = insuplc_admdvs
  5431. }
  5432. }
  5433. his.Insutype = insutype
  5434. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5435. fmt.Println(res3101)
  5436. fmt.Println(res3101.Infcode)
  5437. if res3101.Infcode == "0" {
  5438. fmt.Println("33333333")
  5439. if len(res3101.Output.Result) > 0 {
  5440. fmt.Println("222222")
  5441. for _, item := range res3101.Output.Result {
  5442. if len(res3101.ErrMsg) == 0 {
  5443. res3101.ErrMsg = item.VolaCont
  5444. } else {
  5445. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5446. }
  5447. }
  5448. c.ServeSuccessJSON(map[string]interface{}{
  5449. "failed_code": -10,
  5450. "msg": res3101.ErrMsg,
  5451. })
  5452. return
  5453. } else {
  5454. fmt.Println("11111")
  5455. var api string
  5456. if miConfig.MdtrtareaAdmvs == "320921" {
  5457. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5458. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5459. "&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
  5460. } else {
  5461. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5462. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5463. "&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
  5464. }
  5465. resp, requestErr := http.Get(api)
  5466. if requestErr != nil {
  5467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5468. return
  5469. }
  5470. body, ioErr := ioutil.ReadAll(resp.Body)
  5471. if ioErr != nil {
  5472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5474. return
  5475. }
  5476. var respJSON map[string]interface{}
  5477. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5480. return
  5481. }
  5482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5483. result, _ := json.Marshal(respJSON)
  5484. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5485. utils.ErrorLog("解析失败:%v", err)
  5486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5487. return
  5488. }
  5489. resThree.ErrMsg = resThree10265.ErrMsg
  5490. resThree.Output = resThree10265.Output
  5491. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5492. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5493. }
  5494. } else if res3101.Infcode != "0" {
  5495. c.ServeSuccessJSON(map[string]interface{}{
  5496. "failed_code": -10,
  5497. "msg": res3101.ErrMsg,
  5498. })
  5499. return
  5500. }
  5501. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5502. psn_info, _ := service.GetPsnByPatientId(id)
  5503. var cert_no string
  5504. if id_card_type == 1 {
  5505. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5506. } else if id_card_type == 4 {
  5507. cert_no = psn_info.VerifyNumber
  5508. } else {
  5509. cert_no = psn_info.VerifyNumber
  5510. }
  5511. 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)
  5512. saveLog(result, requestLog, "2201", "挂号")
  5513. if miConfig.Code == "H15049901371" {
  5514. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5515. utils.ErrorLog("解析失败:%v", err)
  5516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5517. return
  5518. }
  5519. resThree.ErrMsg = resThree10265.ErrMsg
  5520. resThree.Output = resThree10265.Output
  5521. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5522. } else {
  5523. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5524. utils.ErrorLog("解析失败:%v", err)
  5525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5526. return
  5527. }
  5528. }
  5529. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5530. } else {
  5531. psn_info, _ := service.GetPsnByPatientId(id)
  5532. 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)
  5533. saveLog(result, requestLog, "2201A", "挂号")
  5534. if miConfig.Code == "H15049901371" {
  5535. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5536. utils.ErrorLog("解析失败:%v", err)
  5537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5538. return
  5539. }
  5540. resThree.ErrMsg = resThree10265.ErrMsg
  5541. resThree.Output = resThree10265.Output
  5542. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5543. } else {
  5544. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5545. utils.ErrorLog("解析失败:%v", err)
  5546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5547. return
  5548. }
  5549. }
  5550. if miConfig.Code == "H15049901371" {
  5551. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5552. } else {
  5553. infocode = resThree.Infcode
  5554. }
  5555. }
  5556. if infocode != 0 {
  5557. adminUser := c.GetAdminUserInfo()
  5558. errlog := &models.HisOrderError{
  5559. UserOrgId: adminUser.CurrentOrgId,
  5560. Ctime: time.Now().Unix(),
  5561. Mtime: time.Now().Unix(),
  5562. ErrMsg: resThree.ErrMsg,
  5563. Status: 1,
  5564. PatientId: id,
  5565. RecordTime: recordDateTime,
  5566. Stage: 2,
  5567. }
  5568. service.CreateErrMsgLog(errlog)
  5569. c.ServeSuccessJSON(map[string]interface{}{
  5570. "failed_code": -10,
  5571. "msg": resThree.ErrMsg,
  5572. })
  5573. return
  5574. }
  5575. his.Number = resThree.Output.Data.MdtrtID
  5576. his.PsnNo = resThree.Output.Data.PsnNo
  5577. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5578. his.IdCardNo = patient.IdCardNo
  5579. his.PhoneNumber = patient.Phone
  5580. his.UserOrgId = adminInfo.CurrentOrgId
  5581. his.Insutype = insutype
  5582. his.Ctime = time.Now().Unix()
  5583. his.Mtime = time.Now().Unix()
  5584. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5585. his.Status = 1
  5586. service.UpdateHisPatientStatus(&his)
  5587. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5588. c.ServeSuccessJSON(map[string]interface{}{
  5589. "his_info": his,
  5590. })
  5591. } else {
  5592. adminUser := c.GetAdminUserInfo()
  5593. errlog := &models.HisOrderError{
  5594. UserOrgId: adminUser.CurrentOrgId,
  5595. Ctime: time.Now().Unix(),
  5596. Mtime: time.Now().Unix(),
  5597. ErrMsg: res.ErrMsg,
  5598. Status: 1,
  5599. PatientId: id,
  5600. RecordTime: recordDateTime,
  5601. Stage: 1,
  5602. }
  5603. service.CreateErrMsgLog(errlog)
  5604. c.ServeSuccessJSON(map[string]interface{}{
  5605. "failed_code": -10,
  5606. "msg": res.ErrMsg,
  5607. })
  5608. return
  5609. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5610. }
  5611. }
  5612. }
  5613. //上传明细----预结算----确认订单
  5614. func (c *HisApiController) GetUploadInfo() {
  5615. id, _ := c.GetInt64("id")
  5616. record_time := c.GetString("record_time")
  5617. his_patient_id, _ := c.GetInt64("his_patient_id")
  5618. order_id, _ := c.GetInt64("order_id")
  5619. pay_way, _ := c.GetInt64("pay_way")
  5620. pay_price, _ := c.GetFloat("pay_price")
  5621. pay_card_no := c.GetString("pay_card_no")
  5622. discount_price, _ := c.GetFloat("discount_price")
  5623. preferential_price, _ := c.GetFloat("preferential_price")
  5624. reality_price, _ := c.GetFloat("reality_price")
  5625. found_price, _ := c.GetFloat("found_price")
  5626. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5627. private_price, _ := c.GetFloat("private_price")
  5628. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5629. admin_user_id, _ := c.GetInt64("admin_user_id")
  5630. fapiao_code := c.GetString("fapiao_code")
  5631. fapiao_number := c.GetString("fapiao_number")
  5632. diagnosis_id := c.GetString("diagnosis")
  5633. sick_type, _ := c.GetInt64("sick_type")
  5634. reg_type, _ := c.GetInt64("p_type")
  5635. begin_time := c.GetString("begin_time")
  5636. id_str := c.GetString("ids")
  5637. ids_arr := strings.Split(id_str, ",")
  5638. timeLayout := "2006-01-02"
  5639. loc, _ := time.LoadLocation("Local")
  5640. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5641. if err != nil {
  5642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5643. return
  5644. }
  5645. recordDateTime := theTime.Unix()
  5646. adminUser := c.GetAdminUserInfo()
  5647. var tempOrder models.HisOrder
  5648. tempOrder, _ = service.GetHisOrderByID(order_id)
  5649. var prescriptions []*models.HisPrescription
  5650. var start_time int64
  5651. var end_time int64
  5652. //押金模块
  5653. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5654. tmp_decimal := c.GetString("tmp_decimal")
  5655. var decimal float64 //本次使用的押金
  5656. var errmsg error
  5657. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5658. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5659. return
  5660. }
  5661. if len(tmp_decimal) > 0 {
  5662. if tmp_decimal[0] == 45 {
  5663. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5664. return
  5665. }
  5666. }
  5667. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5668. fmt.Println(errs)
  5669. decimal = tt
  5670. //if adminUser.CurrentOrgId == 10106{
  5671. // if len(fapiao_code) == 0{
  5672. // fapiao_code = "144072080589"
  5673. // }
  5674. // if len(fapiao_number) == 0{
  5675. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5676. // if order.ID == 0{
  5677. // fapiao_number = "00001520"
  5678. // }else{
  5679. // //fapiao_code = "00001520"
  5680. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5681. // var zero string
  5682. // if fpNumber >= 1000{
  5683. // zero = "0000" + strconv.Itoa(fpNumber)
  5684. // }else if fpNumber >= 10000{
  5685. // zero = "000" + strconv.Itoa(fpNumber)
  5686. // } else if fpNumber >= 100000{
  5687. // zero = "00" + strconv.Itoa(fpNumber)
  5688. // } else if fpNumber >= 1000000{
  5689. // zero = "0" + strconv.Itoa(fpNumber)
  5690. // }else {
  5691. // zero = strconv.Itoa(fpNumber)
  5692. // }
  5693. // fapiao_number = zero
  5694. // }
  5695. // }
  5696. //}
  5697. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5698. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5699. var patientPrescription models.HisPrescriptionInfo
  5700. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5701. if patientPrescription.ID == 0 {
  5702. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5703. }
  5704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5705. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5706. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5707. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5708. var config []*models.HisXtDiagnoseConfig
  5709. for _, item := range diagnosis_ids {
  5710. id, _ := strconv.ParseInt(item, 10, 64)
  5711. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5712. config = append(config, &diagnosisConfig)
  5713. }
  5714. sickConfig, _ := service.FindSickById(sick_type)
  5715. //if tempOrder.ID == 0 {
  5716. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5717. //}
  5718. if tempOrder.ID == 0 {
  5719. var result string
  5720. var requestLog string
  5721. var res2 ResultSix
  5722. var ressix10265 ResultSix10265
  5723. if miConfig.MdtrtareaAdmvs == "421300" {
  5724. data := make(map[string]interface{})
  5725. client := &http.Client{}
  5726. data["psn_no"] = his.PsnNo
  5727. data["mdtrt_id"] = his.Number
  5728. data["opter"] = roles.UserName
  5729. data["org_name"] = miConfig.OrgName
  5730. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5731. data["doctor_id"] = doctor_info.DoctorNumber
  5732. data["doctor_name"] = doctor_info.UserName
  5733. data["department"] = department.Name
  5734. data["fixmedins_code"] = miConfig.Code
  5735. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5736. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5737. data["secret_key"] = miConfig.SecretKey
  5738. data["sick_code"] = sickConfig.CountryCode
  5739. data["sick_name"] = sickConfig.ClassName
  5740. data["dept"] = strconv.FormatInt(department.ID, 10)
  5741. data["config"] = config
  5742. data["begin_time"] = begin_time
  5743. bytesData, _ := json.Marshal(data)
  5744. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5745. resp, _ := client.Do(req)
  5746. defer resp.Body.Close()
  5747. body, ioErr := ioutil.ReadAll(resp.Body)
  5748. if ioErr != nil {
  5749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5751. return
  5752. }
  5753. var respJSON map[string]interface{}
  5754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5757. return
  5758. }
  5759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5760. userJSONBytes, _ := json.Marshal(respJSON)
  5761. fmt.Println("log")
  5762. fmt.Println(string(userJSONBytes))
  5763. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5764. utils.ErrorLog("解析失败:%v", err)
  5765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5766. return
  5767. }
  5768. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5769. data := make(map[string]interface{})
  5770. client := &http.Client{}
  5771. data["psn_no"] = his.PsnNo
  5772. data["mdtrt_id"] = his.Number
  5773. data["doctor"] = roles.UserName
  5774. data["department"] = department.Name
  5775. data["org_name"] = miConfig.OrgName
  5776. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5777. data["doctor_id"] = doctor_info.DoctorNumber
  5778. data["new_doctor_name"] = doctor_info.UserName
  5779. data["fixmedins_code"] = miConfig.Code
  5780. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5782. data["secret_key"] = miConfig.SecretKey
  5783. data["sick_code"] = sickConfig.CountryCode
  5784. data["sick_name"] = sickConfig.ClassName
  5785. data["url"] = miConfig.Url
  5786. data["ak"] = miConfig.AccessKey
  5787. data["begin_time"] = begin_time
  5788. data["cainfo"] = miConfig.Cainfo
  5789. data["dept"] = strconv.FormatInt(department.ID, 10)
  5790. data["config"] = config
  5791. bytesData, _ := json.Marshal(data)
  5792. var req *http.Request
  5793. if miConfig.MdtrtareaAdmvs == "320921" {
  5794. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5795. //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 +
  5796. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5797. } else {
  5798. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5799. }
  5800. resp, _ := client.Do(req)
  5801. defer resp.Body.Close()
  5802. body, ioErr := ioutil.ReadAll(resp.Body)
  5803. if ioErr != nil {
  5804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5806. return
  5807. }
  5808. var respJSON map[string]interface{}
  5809. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5812. return
  5813. }
  5814. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5815. userJSONBytes, _ := json.Marshal(respJSON)
  5816. fmt.Println("log")
  5817. fmt.Println(string(userJSONBytes))
  5818. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5819. utils.ErrorLog("解析失败:%v", err)
  5820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5821. return
  5822. }
  5823. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5824. res2.Output = ressix10265.Output
  5825. res2.ErrMsg = ressix10265.ErrMsg
  5826. res2.Cainfo = ressix10265.Cainfo
  5827. res2.WarnMsg = ressix10265.WarnMsg
  5828. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5829. res2.Infcode = infocode
  5830. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5831. 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)
  5832. saveLog(result, requestLog, "2203", "上传就诊信息")
  5833. var respJSON2 map[string]interface{}
  5834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5837. return
  5838. }
  5839. userJSONBytes2, _ := json.Marshal(respJSON2)
  5840. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5841. utils.ErrorLog("解析失败:%v", err)
  5842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5843. return
  5844. }
  5845. } else {
  5846. if miConfig.MdtrtareaAdmvs == "440781" { //
  5847. 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)
  5848. } else {
  5849. if miConfig.Code == "H15049901371" {
  5850. //赤峰地区国家医保医疗类别
  5851. //职工透析:医疗类别选特殊情况门诊990502
  5852. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5853. var med_type string
  5854. if his.Insutype == "390" {
  5855. if reg_type == 14 {
  5856. med_type = "9933"
  5857. } else if reg_type == 11 {
  5858. med_type = "11"
  5859. }
  5860. } else if his.Insutype == "310" {
  5861. if reg_type == 14 {
  5862. med_type = "990502"
  5863. } else if reg_type == 11 {
  5864. med_type = "11"
  5865. }
  5866. }
  5867. 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)
  5868. } else {
  5869. 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)
  5870. }
  5871. }
  5872. saveLog(result, requestLog, "2203", "上传就诊信息")
  5873. var respJSON2 map[string]interface{}
  5874. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5877. return
  5878. }
  5879. userJSONBytes2, _ := json.Marshal(respJSON2)
  5880. if miConfig.Code == "H15049901371" {
  5881. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5882. utils.ErrorLog("解析失败:%v", err)
  5883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5884. return
  5885. }
  5886. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5887. res2.Output = ressix10265.Output
  5888. res2.ErrMsg = ressix10265.ErrMsg
  5889. res2.Cainfo = ressix10265.Cainfo
  5890. res2.WarnMsg = ressix10265.WarnMsg
  5891. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5892. res2.Infcode = infocode
  5893. } else {
  5894. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5895. utils.ErrorLog("解析失败:%v", err)
  5896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5897. return
  5898. }
  5899. }
  5900. }
  5901. if res2.Infcode != 0 {
  5902. adminUser := c.GetAdminUserInfo()
  5903. errlog := &models.HisOrderError{
  5904. UserOrgId: adminUser.CurrentOrgId,
  5905. Ctime: time.Now().Unix(),
  5906. Mtime: time.Now().Unix(),
  5907. ErrMsg: res2.ErrMsg,
  5908. Status: 1,
  5909. PatientId: id,
  5910. RecordTime: recordDateTime,
  5911. Stage: 3,
  5912. }
  5913. service.CreateErrMsgLog(errlog)
  5914. c.ServeSuccessJSON(map[string]interface{}{
  5915. "failed_code": -10,
  5916. "msg": res2.ErrMsg,
  5917. })
  5918. return
  5919. } else {
  5920. his.Diagnosis = diagnosis_id
  5921. his.SickType = sickConfig.ID
  5922. //var p_type int64
  5923. //if reg_type == 1111 || reg_type == 1112 {
  5924. // p_type = 11
  5925. //
  5926. //}
  5927. his.PType = fmt.Sprintf("%d", reg_type)
  5928. service.UpdateHisPatientThree(&his)
  5929. data := make(map[string]interface{})
  5930. if settle_accounts_type == 1 { //日结
  5931. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5932. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5933. } else {
  5934. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5935. }
  5936. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5937. data["pre"] = prescriptions
  5938. } else { //月结
  5939. start_time_str := c.GetString("start_time")
  5940. end_time_str := c.GetString("end_time")
  5941. timeLayout := "2006-01-02"
  5942. loc, _ := time.LoadLocation("Local")
  5943. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5944. if err != nil {
  5945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5946. return
  5947. }
  5948. recordStartTime := theStartTime.Unix()
  5949. start_time = recordStartTime
  5950. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5951. if err != nil {
  5952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5953. return
  5954. }
  5955. recordEndTime := theEndTime.Unix()
  5956. end_time = recordEndTime
  5957. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5958. data["pre"] = prescriptions
  5959. }
  5960. timestamp := time.Now().Unix()
  5961. tempTime := time.Unix(timestamp, 0)
  5962. timeFormat := tempTime.Format("20060102150405")
  5963. chrgBchno := rand.Intn(100000) + 10000
  5964. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5965. strconv.FormatInt(his.PatientId, 10)
  5966. client := &http.Client{}
  5967. data["psn_no"] = his.PsnNo
  5968. data["mdtrt_id"] = his.Number
  5969. data["chrg_bchno"] = chrg_bchno
  5970. data["org_name"] = miConfig.OrgName
  5971. data["doctor"] = doctor_info.UserName
  5972. data["doctor_id"] = doctor_info.DoctorNumber
  5973. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5974. data["fixmedins_code"] = miConfig.Code
  5975. data["opter"] = roles.UserName
  5976. data["dept_code"] = department.Number
  5977. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5978. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5979. data["secret_key"] = miConfig.SecretKey
  5980. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5981. data["url"] = miConfig.Url
  5982. data["ak"] = miConfig.AccessKey
  5983. data["new_doctor_name"] = patientPrescription.Doctor
  5984. data["diag_code"] = sickConfig.CountryCode
  5985. data["cainfo"] = miConfig.Cainfo
  5986. var ids []int64
  5987. for _, item := range prescriptions {
  5988. ids = append(ids, item.ID)
  5989. }
  5990. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5991. if config.IsOpen == 1 { //对接了医保,走医保流程
  5992. var res ResultFour
  5993. var resFour10265 ResultFour10265
  5994. if miConfig.MdtrtareaAdmvs == "421300" {
  5995. bytesData, _ := json.Marshal(data)
  5996. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5997. resp, _ := client.Do(req)
  5998. defer resp.Body.Close()
  5999. body, ioErr := ioutil.ReadAll(resp.Body)
  6000. if ioErr != nil {
  6001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6003. return
  6004. }
  6005. var respJSON map[string]interface{}
  6006. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6009. return
  6010. }
  6011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6012. userJSONBytes, _ := json.Marshal(respJSON)
  6013. fmt.Println("log")
  6014. fmt.Println(string(userJSONBytes))
  6015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6016. utils.ErrorLog("解析失败:%v", err)
  6017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6018. return
  6019. }
  6020. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6021. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  6022. if result3101.Infcode == "0" {
  6023. if len(result3101.Output.Result) > 0 {
  6024. var errMsgs []string
  6025. for _, item := range result3101.Output.Result {
  6026. errMsgs = append(errMsgs, item.VolaCont)
  6027. }
  6028. c.ServeSuccessJSON(map[string]interface{}{
  6029. "failed_code": -10,
  6030. "msg": errMsgs,
  6031. })
  6032. return
  6033. }
  6034. }
  6035. bytesData, _ := json.Marshal(data)
  6036. var req *http.Request
  6037. if miConfig.MdtrtareaAdmvs == "320921" {
  6038. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6039. } else {
  6040. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6041. }
  6042. resp, _ := client.Do(req)
  6043. defer resp.Body.Close()
  6044. body, ioErr := ioutil.ReadAll(resp.Body)
  6045. if ioErr != nil {
  6046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6048. return
  6049. }
  6050. var respJSON map[string]interface{}
  6051. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6054. return
  6055. }
  6056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6057. userJSONBytes, _ := json.Marshal(respJSON)
  6058. fmt.Println("log")
  6059. fmt.Println(string(userJSONBytes))
  6060. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6061. utils.ErrorLog("解析失败:%v", err)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. return
  6064. }
  6065. res.InfRefmsgid = resFour10265.InfRefmsgid
  6066. res.Output = resFour10265.Output
  6067. res.ErrMsg = resFour10265.ErrMsg
  6068. res.Cainfo = resFour10265.Cainfo
  6069. res.WarnMsg = resFour10265.WarnMsg
  6070. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6071. res.Infcode = infocode
  6072. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6073. 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)
  6074. var dat map[string]interface{}
  6075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6076. fmt.Println(dat)
  6077. } else {
  6078. fmt.Println(err)
  6079. }
  6080. saveLog(result, request_log, "2204", "上传费用明细")
  6081. userJSONBytes, _ := json.Marshal(dat)
  6082. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6083. utils.ErrorLog("解析失败:%v", err)
  6084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6085. return
  6086. }
  6087. res.InfRefmsgid = resFour10265.InfRefmsgid
  6088. res.Output = resFour10265.Output
  6089. res.ErrMsg = resFour10265.ErrMsg
  6090. res.Cainfo = resFour10265.Cainfo
  6091. res.WarnMsg = resFour10265.WarnMsg
  6092. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6093. res.Infcode = infocode
  6094. } else {
  6095. if miConfig.Code == "H15049901371" {
  6096. 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)
  6097. var dat map[string]interface{}
  6098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6099. fmt.Println(dat)
  6100. } else {
  6101. fmt.Println(err)
  6102. }
  6103. saveLog(result, request_log, "2204", "上传费用明细")
  6104. userJSONBytes, _ := json.Marshal(dat)
  6105. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6106. utils.ErrorLog("解析失败:%v", err)
  6107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6108. return
  6109. }
  6110. res.InfRefmsgid = resFour10265.InfRefmsgid
  6111. res.Output = resFour10265.Output
  6112. res.ErrMsg = resFour10265.ErrMsg
  6113. res.Cainfo = resFour10265.Cainfo
  6114. res.WarnMsg = resFour10265.WarnMsg
  6115. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6116. res.Infcode = infocode
  6117. } else {
  6118. 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)
  6119. var dat map[string]interface{}
  6120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6121. fmt.Println(dat)
  6122. } else {
  6123. fmt.Println(err)
  6124. }
  6125. saveLog(result, request_log, "2204", "上传费用明细")
  6126. userJSONBytes, _ := json.Marshal(dat)
  6127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6128. utils.ErrorLog("解析失败:%v", err)
  6129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6130. return
  6131. }
  6132. }
  6133. }
  6134. if res.Infcode == 0 {
  6135. order := &models.HisOrder{
  6136. UserOrgId: adminUser.CurrentOrgId,
  6137. HisPatientId: his.ID,
  6138. PatientId: his.PatientId,
  6139. SettleAccountsDate: recordDateTime,
  6140. MdtrtId: his.Number,
  6141. PsnNo: his.PsnNo,
  6142. MedType: strconv.FormatInt(reg_type, 10),
  6143. Ctime: time.Now().Unix(),
  6144. Mtime: time.Now().Unix(),
  6145. Status: 1,
  6146. Number: chrg_bchno,
  6147. Infcode: res.Infcode,
  6148. WarnMsg: res.WarnMsg,
  6149. Cainfo: res.Cainfo,
  6150. ErrMsg: res.ErrMsg,
  6151. RespondTime: res.RefmsgTime,
  6152. InfRefmsgid: res.InfRefmsgid,
  6153. OrderStatus: 1,
  6154. PayWay: pay_way,
  6155. PayPrice: pay_price,
  6156. PayCardNo: pay_card_no,
  6157. DiscountPrice: discount_price,
  6158. PreferentialPrice: preferential_price,
  6159. RealityPrice: reality_price,
  6160. FoundPrice: found_price,
  6161. MedicalInsurancePrice: medical_insurance_price,
  6162. PrivatePrice: private_price,
  6163. IsMedicineInsurance: 1,
  6164. SettleType: settle_accounts_type,
  6165. SettleStartTime: start_time,
  6166. SettleEndTime: end_time,
  6167. Creator: roles.AdminUserId,
  6168. Modify: roles.AdminUserId,
  6169. FaPiaoNumber: fapiao_number,
  6170. FaPiaoCode: fapiao_code,
  6171. PType: 2,
  6172. Diagnosis: diagnosis_id,
  6173. }
  6174. err = service.CreateOrder(order)
  6175. if err != nil {
  6176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6177. return
  6178. }
  6179. for _, item := range res.Output.Result {
  6180. temp := strings.Split(item.FeedetlSn, "-")
  6181. var advice_id int64 = 0
  6182. var project_id int64 = 0
  6183. var types int64 = 0
  6184. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6185. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6186. if temp[1] == "1" {
  6187. advice_id = id
  6188. project_id = 0
  6189. } else if temp[1] == "2" {
  6190. advice_id = 0
  6191. project_id = id
  6192. }
  6193. info := &models.HisOrderInfo{
  6194. OrderNumber: order.Number,
  6195. FeedetlSn: item.FeedetlSn,
  6196. UploadDate: time.Now().Unix(),
  6197. AdviceId: advice_id,
  6198. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6199. Cnt: item.Cnt,
  6200. Pric: float64(item.Pric),
  6201. PatientId: his.PatientId,
  6202. PricUplmtAmt: item.PricUplmtAmt,
  6203. SelfpayProp: item.SelfpayProp,
  6204. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6205. OverlmtAmt: item.OverlmtAmt,
  6206. PreselfpayAmt: item.PreselfpayAmt,
  6207. BasMednFlag: item.BasMednFlag,
  6208. MedChrgitmType: item.MedChrgitmType,
  6209. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6210. Status: 1,
  6211. Memo: item.Memo,
  6212. Mtime: time.Now().Unix(),
  6213. InscpScpAmt: item.InscpScpAmt,
  6214. DrtReimFlag: item.DrtReimFlag,
  6215. Ctime: time.Now().Unix(),
  6216. ListSpItemFlag: item.ListSpItemFlag,
  6217. ChldMedcFlag: item.ChldMedcFlag,
  6218. LmtUsedFlag: item.LmtUsedFlag,
  6219. ChrgitmLv: item.ChrgitmLv,
  6220. UserOrgId: adminUser.CurrentOrgId,
  6221. HisPatientId: his.ID,
  6222. OrderId: order.ID,
  6223. ProjectId: project_id,
  6224. Type: types,
  6225. }
  6226. service.CreateOrderInfo(info)
  6227. }
  6228. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6229. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6230. var total float64
  6231. for _, item := range prescriptions {
  6232. if item.Type == 1 { //药品
  6233. for _, subItem := range item.HisDoctorAdviceInfo {
  6234. total = total + (subItem.Price * subItem.PrescribingNumber)
  6235. }
  6236. }
  6237. if item.Type == 2 { //项目
  6238. for _, subItem := range item.HisPrescriptionProject {
  6239. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6240. total = total + (subItem.Price * cnt)
  6241. }
  6242. }
  6243. }
  6244. for _, item := range prescriptions {
  6245. for _, subItem := range item.HisAdditionalCharge {
  6246. total = total + (subItem.Price * float64(subItem.Count))
  6247. }
  6248. }
  6249. var allTotal string
  6250. if adminUser.CurrentOrgId == 9919 {
  6251. allTotal = fmt.Sprintf("%.4f", total)
  6252. } else {
  6253. allTotal = fmt.Sprintf("%.4f", total)
  6254. }
  6255. if res.Infcode == 0 {
  6256. var rf []*ResultFive
  6257. json.Unmarshal([]byte(his.Iinfo), &rf)
  6258. chrg_bchno := chrg_bchno
  6259. cert_no := his.Certno
  6260. var insutypes []string
  6261. var insutype string
  6262. var is390 int = 0
  6263. var is310 int = 0
  6264. for _, item := range rf {
  6265. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6266. insutypes = append(insutypes, item.Insutype)
  6267. }
  6268. }
  6269. if len(insutypes) == 1 {
  6270. insutype = insutypes[0]
  6271. } else {
  6272. for _, i := range insutypes {
  6273. if i == "390" {
  6274. is390 = 1
  6275. }
  6276. if i == "310" {
  6277. is310 = 1
  6278. }
  6279. }
  6280. }
  6281. if is390 == 1 {
  6282. insutype = "390"
  6283. }
  6284. if is310 == 1 {
  6285. insutype = "310"
  6286. }
  6287. if len(insutypes) == 0 {
  6288. insutype = "310"
  6289. }
  6290. if len(insutypes) == 2 {
  6291. insutype = strconv.FormatInt(his.SocialType, 10)
  6292. }
  6293. insutype = strconv.FormatInt(his.SocialType, 10)
  6294. //insutype = "390"
  6295. if his.IdCardType == 1 {
  6296. // cert_no = his.MedicalInsuranceNumber
  6297. cert_no = his.Certno
  6298. } else {
  6299. cert_no = his.Certno
  6300. }
  6301. var res ResultSeven
  6302. var resSeven10265 ResultSeven10265
  6303. var src_resquest string
  6304. var result2 string
  6305. var acct_used_flag string
  6306. fmt.Println("pay_way")
  6307. fmt.Println(pay_way)
  6308. fmt.Println("pay_way")
  6309. if pay_way == 4 {
  6310. acct_used_flag = "1"
  6311. } else {
  6312. acct_used_flag = "0"
  6313. }
  6314. if miConfig.MdtrtareaAdmvs == "421300" {
  6315. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6316. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6317. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6318. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6319. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6320. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6321. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6322. resp, requestErr := http.Get(api)
  6323. if requestErr != nil {
  6324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6325. return
  6326. }
  6327. body, ioErr := ioutil.ReadAll(resp.Body)
  6328. if ioErr != nil {
  6329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6331. return
  6332. }
  6333. var respJSON map[string]interface{}
  6334. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6337. return
  6338. }
  6339. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6340. result, _ := json.Marshal(respJSON)
  6341. if miConfig.Code == "H15049901371" {
  6342. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6343. utils.ErrorLog("解析失败:%v", err)
  6344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6345. return
  6346. }
  6347. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6348. res.Output = resSeven10265.Output
  6349. res.ErrMsg = resSeven10265.ErrMsg
  6350. res.Cainfo = resSeven10265.Cainfo
  6351. res.WarnMsg = resSeven10265.WarnMsg
  6352. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6353. res.Infcode = infocode
  6354. } else {
  6355. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6356. utils.ErrorLog("解析失败:%v", err)
  6357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6358. return
  6359. }
  6360. }
  6361. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6362. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  6363. if result3101.Infcode == "0" {
  6364. if len(result3101.Output.Result) > 0 {
  6365. var errMsgs []string
  6366. for _, item := range result3101.Output.Result {
  6367. errMsgs = append(errMsgs, item.VolaCont)
  6368. }
  6369. c.ServeSuccessJSON(map[string]interface{}{
  6370. "failed_code": -10,
  6371. "msg": errMsgs,
  6372. })
  6373. return
  6374. } else {
  6375. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6376. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6377. bas := strings.Split(psn_info.CardInfo, "|")
  6378. if his.IdCardType == 1 {
  6379. cert_no = bas[2]
  6380. } else if his.IdCardType == 3 {
  6381. cert_no = his.Certno
  6382. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6383. } else if his.IdCardType == 4 {
  6384. cert_no = his.Certno
  6385. psn_info.VerifyNumber = psn_info.VerifyNumber
  6386. }
  6387. var api string
  6388. if miConfig.MdtrtareaAdmvs == "320921" {
  6389. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6390. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6391. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6392. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6393. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6394. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6395. "&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
  6396. } else {
  6397. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6398. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6399. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6400. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6401. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6402. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6403. "&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
  6404. }
  6405. resp, requestErr := http.Get(api)
  6406. if requestErr != nil {
  6407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6408. return
  6409. }
  6410. body, ioErr := ioutil.ReadAll(resp.Body)
  6411. if ioErr != nil {
  6412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6414. return
  6415. }
  6416. var respJSON map[string]interface{}
  6417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. return
  6421. }
  6422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6423. result, _ := json.Marshal(respJSON)
  6424. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6425. utils.ErrorLog("解析失败:%v", err)
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. return
  6428. }
  6429. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6430. res.Output = resSeven10265.Output
  6431. res.ErrMsg = resSeven10265.ErrMsg
  6432. res.Cainfo = resSeven10265.Cainfo
  6433. res.WarnMsg = resSeven10265.WarnMsg
  6434. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6435. res.Infcode = infocode
  6436. }
  6437. }
  6438. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6439. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6440. var cert_no string
  6441. if his.IdCardType == 1 {
  6442. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6443. }
  6444. fmt.Println(cert_no)
  6445. 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)
  6446. //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)
  6447. var dat map[string]interface{}
  6448. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6449. fmt.Println(dat)
  6450. } else {
  6451. fmt.Println(err)
  6452. }
  6453. saveLog(result2, src_resquest, "2207", "结算")
  6454. userJSONBytes, _ := json.Marshal(dat)
  6455. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6456. utils.ErrorLog("解析失败:%v", err)
  6457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6458. return
  6459. }
  6460. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6461. res.Output = resSeven10265.Output
  6462. res.ErrMsg = resSeven10265.ErrMsg
  6463. res.Cainfo = resSeven10265.Cainfo
  6464. res.WarnMsg = resSeven10265.WarnMsg
  6465. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6466. res.Infcode = infocode
  6467. } else {
  6468. if miConfig.Code == "H15049901371" {
  6469. //赤峰地区国家医保医疗类别
  6470. //职工透析:医疗类别选特殊情况门诊990502
  6471. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6472. var med_type string
  6473. if his.Insutype == "390" {
  6474. if reg_type == 14 {
  6475. med_type = "9933"
  6476. } else if reg_type == 11 {
  6477. med_type = "11"
  6478. }
  6479. } else if his.Insutype == "310" {
  6480. if reg_type == 14 {
  6481. med_type = "990502"
  6482. } else if reg_type == 11 {
  6483. med_type = "11"
  6484. }
  6485. }
  6486. 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)
  6487. } else {
  6488. 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)
  6489. }
  6490. //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)
  6491. var dat map[string]interface{}
  6492. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6493. fmt.Println(dat)
  6494. } else {
  6495. fmt.Println(err)
  6496. }
  6497. saveLog(result2, src_resquest, "2207", "结算")
  6498. userJSONBytes, _ := json.Marshal(dat)
  6499. if miConfig.Code == "H15049901371" {
  6500. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6501. utils.ErrorLog("解析失败:%v", err)
  6502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6503. return
  6504. }
  6505. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6506. res.Output = resSeven10265.Output
  6507. res.ErrMsg = resSeven10265.ErrMsg
  6508. res.Cainfo = resSeven10265.Cainfo
  6509. res.WarnMsg = resSeven10265.WarnMsg
  6510. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6511. res.Infcode = infocode
  6512. } else {
  6513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6514. utils.ErrorLog("解析失败:%v", err)
  6515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6516. return
  6517. }
  6518. }
  6519. }
  6520. if res.Infcode != 0 {
  6521. errlog := &models.HisOrderError{
  6522. UserOrgId: adminUser.CurrentOrgId,
  6523. Ctime: time.Now().Unix(),
  6524. Mtime: time.Now().Unix(),
  6525. Number: chrg_bchno,
  6526. ErrMsg: res.ErrMsg,
  6527. Status: 1,
  6528. PatientId: id,
  6529. RecordTime: recordDateTime,
  6530. Stage: 6,
  6531. }
  6532. service.CreateErrMsgLog(errlog)
  6533. c.ServeSuccessJSON(map[string]interface{}{
  6534. "failed_code": -10,
  6535. "msg": res.ErrMsg,
  6536. })
  6537. return
  6538. } else {
  6539. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6540. order.OrderStatus = 2
  6541. order.Status = 1
  6542. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6543. order.SetlId = res.Output.Setlinfo.SetlID
  6544. order.PsnNo = res.Output.Setlinfo.PsnNo
  6545. order.PsnName = res.Output.Setlinfo.PsnName
  6546. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6547. order.Certno = res.Output.Setlinfo.Certno
  6548. order.Gend = res.Output.Setlinfo.Gend
  6549. order.Naty = res.Output.Setlinfo.Naty
  6550. order.Age = res.Output.Setlinfo.Age
  6551. order.Insutype = res.Output.Setlinfo.Insutype
  6552. order.PsnType = res.Output.Setlinfo.PsnType
  6553. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6554. order.SetlTime = res.Output.Setlinfo.SetlTime
  6555. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6556. if res.Output.Setlinfo.MedType == "140101" {
  6557. order.MedType = "14"
  6558. } else {
  6559. order.MedType = res.Output.Setlinfo.MedType
  6560. }
  6561. if reg_type == 1112 {
  6562. order.MedType = "1112"
  6563. }
  6564. if reg_type == 1111 {
  6565. order.MedType = "1111"
  6566. }
  6567. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6568. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6569. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6570. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6571. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6572. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6573. order.HifpPay = res.Output.Setlinfo.HifpPay
  6574. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6575. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6576. order.HifesPay = res.Output.Setlinfo.HifesPay
  6577. order.HifobPay = res.Output.Setlinfo.HifobPay
  6578. order.MafPay = res.Output.Setlinfo.MafPay
  6579. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6580. order.OthPay = res.Output.Setlinfo.OthPay
  6581. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6582. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6583. order.AcctPay = res.Output.Setlinfo.AcctPay
  6584. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6585. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6586. order.Balc = res.Output.Setlinfo.Balc
  6587. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6588. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6589. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6590. order.ClrType = res.Output.Setlinfo.ClrType
  6591. order.ClrWay = res.Output.Setlinfo.ClrWay
  6592. order.Creator = order.Creator
  6593. order.Modify = roles.AdminUserId
  6594. order.RequestLog = src_resquest
  6595. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6596. detailStr := string(setlDetail)
  6597. order.SetlDetail = detailStr
  6598. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6599. err = service.UpDateOrder(order)
  6600. if err == nil {
  6601. //判断是否使用了押金
  6602. if dec_way == "true" {
  6603. tmpstring := strconv.FormatInt(order.ID, 10)
  6604. order.Decimal = decimal
  6605. service.UpDateOrder(order)
  6606. //扣押金
  6607. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6608. if errmsg != nil {
  6609. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6610. return
  6611. }
  6612. }
  6613. c.ServeSuccessJSON(map[string]interface{}{
  6614. "msg": "结算成功",
  6615. })
  6616. } else {
  6617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6618. return
  6619. }
  6620. }
  6621. } else {
  6622. adminUser := c.GetAdminUserInfo()
  6623. errlog := &models.HisOrderError{
  6624. UserOrgId: adminUser.CurrentOrgId,
  6625. Ctime: time.Now().Unix(),
  6626. Mtime: time.Now().Unix(),
  6627. ErrMsg: res.ErrMsg,
  6628. Status: 1,
  6629. PatientId: id,
  6630. RecordTime: recordDateTime,
  6631. Stage: 4,
  6632. }
  6633. service.CreateErrMsgLog(errlog)
  6634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6635. return
  6636. }
  6637. } else {
  6638. adminUser := c.GetAdminUserInfo()
  6639. errlog := &models.HisOrderError{
  6640. UserOrgId: adminUser.CurrentOrgId,
  6641. Ctime: time.Now().Unix(),
  6642. Mtime: time.Now().Unix(),
  6643. ErrMsg: res.ErrMsg,
  6644. Status: 1,
  6645. PatientId: id,
  6646. RecordTime: recordDateTime,
  6647. Stage: 4,
  6648. }
  6649. service.CreateErrMsgLog(errlog)
  6650. c.ServeSuccessJSON(map[string]interface{}{
  6651. "failed_code": -10,
  6652. "msg": res.ErrMsg,
  6653. })
  6654. return
  6655. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6656. //return
  6657. }
  6658. }
  6659. }
  6660. } else if tempOrder.ID > 0 {
  6661. if tempOrder.IsPre == 1 {
  6662. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6663. var rf []*ResultFive
  6664. json.Unmarshal([]byte(his.Iinfo), &rf)
  6665. chrg_bchno := tempOrder.Number
  6666. cert_no := his.Certno
  6667. var insutypes []string
  6668. var insutype string
  6669. var is390 int = 0
  6670. var is310 int = 0
  6671. for _, item := range rf {
  6672. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6673. insutypes = append(insutypes, item.Insutype)
  6674. }
  6675. }
  6676. if len(insutypes) == 1 {
  6677. insutype = insutypes[0]
  6678. } else {
  6679. for _, i := range insutypes {
  6680. if i == "390" {
  6681. is390 = 1
  6682. }
  6683. if i == "310" {
  6684. is310 = 1
  6685. }
  6686. }
  6687. }
  6688. if is390 == 1 {
  6689. insutype = "390"
  6690. }
  6691. if is310 == 1 {
  6692. insutype = "310"
  6693. }
  6694. if len(insutypes) == 0 {
  6695. insutype = "310"
  6696. }
  6697. if len(insutypes) == 2 {
  6698. insutype = strconv.FormatInt(his.SocialType, 64)
  6699. }
  6700. //insutype = "390"
  6701. if his.IdCardType == 1 {
  6702. // cert_no = his.MedicalInsuranceNumber
  6703. cert_no = his.Certno
  6704. } else {
  6705. cert_no = his.Certno
  6706. }
  6707. var res ResultSeven
  6708. var resSeven10265 ResultSeven10265
  6709. var src_resquest string
  6710. var result2 string
  6711. var acct_used_flag string
  6712. fmt.Println("pay_way")
  6713. fmt.Println(pay_way)
  6714. fmt.Println("pay_way")
  6715. if pay_way == 4 {
  6716. acct_used_flag = "1"
  6717. } else {
  6718. acct_used_flag = "0"
  6719. }
  6720. if miConfig.MdtrtareaAdmvs == "421300" {
  6721. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6722. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6723. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6725. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6726. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6727. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6728. resp, requestErr := http.Get(api)
  6729. if requestErr != nil {
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. return
  6732. }
  6733. body, ioErr := ioutil.ReadAll(resp.Body)
  6734. if ioErr != nil {
  6735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6737. return
  6738. }
  6739. var respJSON map[string]interface{}
  6740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6743. return
  6744. }
  6745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6746. result, _ := json.Marshal(respJSON)
  6747. fmt.Println("log")
  6748. fmt.Println(string(result))
  6749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6750. utils.ErrorLog("解析失败:%v", err)
  6751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6752. return
  6753. }
  6754. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6755. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  6756. if result3101.Infcode == "0" {
  6757. if len(result3101.Output.Result) > 0 {
  6758. var errMsgs []string
  6759. for _, item := range result3101.Output.Result {
  6760. errMsgs = append(errMsgs, item.VolaCont)
  6761. }
  6762. c.ServeSuccessJSON(map[string]interface{}{
  6763. "failed_code": -10,
  6764. "msg": errMsgs,
  6765. })
  6766. return
  6767. } else {
  6768. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6769. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6770. //psn_info, _ := service.GetPsnByPatientId(id)
  6771. bas := strings.Split(psn_info.CardInfo, "|")
  6772. if his.IdCardType == 1 {
  6773. cert_no = bas[2]
  6774. } else {
  6775. cert_no = bas[1]
  6776. }
  6777. //江苏地区国家医保医疗类别
  6778. //职工透析:医疗类别选特殊情况门诊9933
  6779. //居民血透门慢: 医疗类别选门诊慢病1402
  6780. //var med_type string
  6781. //if his.Insutype == "310" {
  6782. // if reg_type == 14 {
  6783. // med_type = "9933"
  6784. // } else if reg_type == 11 {
  6785. // med_type = "11"
  6786. //
  6787. // }
  6788. //} else if his.Insutype == "390" {
  6789. // if reg_type == 14 {
  6790. // med_type = "1402"
  6791. // } else if reg_type == 11 {
  6792. // med_type = "11"
  6793. // }
  6794. //}
  6795. var api string
  6796. if miConfig.MdtrtareaAdmvs == "320921" {
  6797. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6798. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6799. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6801. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6802. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6803. "&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
  6804. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6805. } else {
  6806. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6807. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6808. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6809. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6810. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6811. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6812. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6813. "&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
  6814. }
  6815. resp, requestErr := http.Get(api)
  6816. if requestErr != nil {
  6817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6818. return
  6819. }
  6820. body, ioErr := ioutil.ReadAll(resp.Body)
  6821. if ioErr != nil {
  6822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6824. return
  6825. }
  6826. var respJSON map[string]interface{}
  6827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. return
  6831. }
  6832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6833. result, _ := json.Marshal(respJSON)
  6834. fmt.Println("log")
  6835. fmt.Println(string(result))
  6836. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6837. utils.ErrorLog("解析失败:%v", err)
  6838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6839. return
  6840. }
  6841. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6842. res.Output = resSeven10265.Output
  6843. res.ErrMsg = resSeven10265.ErrMsg
  6844. res.Cainfo = resSeven10265.Cainfo
  6845. res.WarnMsg = resSeven10265.WarnMsg
  6846. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6847. res.Infcode = infocode
  6848. }
  6849. }
  6850. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6851. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6852. var cert_no string
  6853. if his.IdCardType == 1 {
  6854. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6855. }
  6856. fmt.Println(cert_no)
  6857. 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)
  6858. var dat map[string]interface{}
  6859. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6860. fmt.Println(dat)
  6861. } else {
  6862. fmt.Println(err)
  6863. }
  6864. saveLog(result2, src_resquest, "2207", "结算")
  6865. userJSONBytes, _ := json.Marshal(dat)
  6866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6867. utils.ErrorLog("解析失败:%v", err)
  6868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6869. return
  6870. }
  6871. } else {
  6872. var src_resquest string
  6873. if miConfig.Code == "H15049901371" {
  6874. //赤峰地区国家医保医疗类别
  6875. //职工透析:医疗类别选特殊情况门诊990502
  6876. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6877. var med_type string
  6878. if his.Insutype == "390" {
  6879. if reg_type == 14 {
  6880. med_type = "9933"
  6881. } else if reg_type == 11 {
  6882. med_type = "11"
  6883. }
  6884. } else if his.Insutype == "310" {
  6885. if reg_type == 14 {
  6886. med_type = "990502"
  6887. } else if reg_type == 11 {
  6888. med_type = "11"
  6889. }
  6890. }
  6891. 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)
  6892. } else {
  6893. 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)
  6894. }
  6895. var dat map[string]interface{}
  6896. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6897. fmt.Println(dat)
  6898. } else {
  6899. fmt.Println(err)
  6900. }
  6901. saveLog(result2, src_resquest, "2207", "结算")
  6902. userJSONBytes, _ := json.Marshal(dat)
  6903. if miConfig.Code == "H15049901371" {
  6904. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6905. utils.ErrorLog("解析失败:%v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6910. res.Output = resSeven10265.Output
  6911. res.ErrMsg = resSeven10265.ErrMsg
  6912. res.Cainfo = resSeven10265.Cainfo
  6913. res.WarnMsg = resSeven10265.WarnMsg
  6914. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6915. res.Infcode = infocode
  6916. } else {
  6917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6918. utils.ErrorLog("解析失败:%v", err)
  6919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6920. return
  6921. }
  6922. }
  6923. }
  6924. if res.Infcode != 0 {
  6925. errlog := &models.HisOrderError{
  6926. UserOrgId: adminUser.CurrentOrgId,
  6927. Ctime: time.Now().Unix(),
  6928. Mtime: time.Now().Unix(),
  6929. Number: chrg_bchno,
  6930. ErrMsg: res.ErrMsg,
  6931. Status: 1,
  6932. PatientId: id,
  6933. RecordTime: recordDateTime,
  6934. Stage: 6,
  6935. }
  6936. service.CreateErrMsgLog(errlog)
  6937. c.ServeSuccessJSON(map[string]interface{}{
  6938. "failed_code": -10,
  6939. "msg": res.ErrMsg,
  6940. })
  6941. return
  6942. } else {
  6943. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6944. order.OrderStatus = 2
  6945. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6946. order.SetlId = res.Output.Setlinfo.SetlID
  6947. order.PsnNo = res.Output.Setlinfo.PsnNo
  6948. order.PsnName = res.Output.Setlinfo.PsnName
  6949. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6950. order.Certno = res.Output.Setlinfo.Certno
  6951. order.Gend = res.Output.Setlinfo.Gend
  6952. order.Naty = res.Output.Setlinfo.Naty
  6953. order.Age = res.Output.Setlinfo.Age
  6954. order.Insutype = res.Output.Setlinfo.Insutype
  6955. order.PsnType = res.Output.Setlinfo.PsnType
  6956. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6957. order.SetlTime = res.Output.Setlinfo.SetlTime
  6958. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6959. //order.MedType = res.Output.Setlinfo.MedType
  6960. if reg_type == 1112 {
  6961. order.MedType = "1112"
  6962. }
  6963. if reg_type == 1111 {
  6964. order.MedType = "1111"
  6965. }
  6966. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6967. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6968. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6969. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6970. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6971. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6972. order.HifpPay = res.Output.Setlinfo.HifpPay
  6973. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6974. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6975. order.HifesPay = res.Output.Setlinfo.HifesPay
  6976. order.HifobPay = res.Output.Setlinfo.HifobPay
  6977. order.MafPay = res.Output.Setlinfo.MafPay
  6978. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6979. order.OthPay = res.Output.Setlinfo.OthPay
  6980. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6981. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6982. order.AcctPay = res.Output.Setlinfo.AcctPay
  6983. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6984. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6985. order.Balc = res.Output.Setlinfo.Balc
  6986. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6987. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6988. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6989. order.ClrWay = res.Output.Setlinfo.ClrWay
  6990. order.Creator = order.Creator
  6991. order.Modify = roles.AdminUserId
  6992. order.RequestLog = src_resquest
  6993. order.Diagnosis = diagnosis_id
  6994. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6995. detailStr := string(setlDetail)
  6996. order.SetlDetail = detailStr
  6997. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6998. err = service.UpDateOrder(order)
  6999. if err == nil {
  7000. //判断是否使用了押金
  7001. if dec_way == "true" {
  7002. tmpstring := strconv.FormatInt(order.ID, 10)
  7003. //扣押金
  7004. order.Decimal = decimal
  7005. service.UpDateOrder(order)
  7006. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  7007. if errmsg != nil {
  7008. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  7009. return
  7010. }
  7011. }
  7012. c.ServeSuccessJSON(map[string]interface{}{
  7013. "msg": "结算成功",
  7014. })
  7015. } else {
  7016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7017. return
  7018. }
  7019. }
  7020. }
  7021. }
  7022. }
  7023. //func (c *HisApiController) GetPreUploadInfo() {
  7024. // id, _ := c.GetInt64("id")
  7025. // record_time := c.GetString("record_time")
  7026. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7027. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7028. //
  7029. // timeLayout := "2006-01-02"
  7030. // loc, _ := time.LoadLocation("Local")
  7031. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7032. // if err != nil {
  7033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7034. // return
  7035. // }
  7036. // recordDateTime := theTime.Unix()
  7037. // adminUser := c.GetAdminUserInfo()
  7038. //
  7039. // var prescriptions []*models.HisPrescription
  7040. //
  7041. // var start_time int64
  7042. // var end_time int64
  7043. //
  7044. // data := make(map[string]interface{})
  7045. // if settle_accounts_type == 1 { //日结
  7046. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7047. // data["pre"] = prescriptions
  7048. //
  7049. // } else { //月结
  7050. // start_time_str := c.GetString("start_time")
  7051. // end_time_str := c.GetString("end_time")
  7052. // timeLayout := "2006-01-02"
  7053. // loc, _ := time.LoadLocation("Local")
  7054. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7055. // if err != nil {
  7056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7057. // return
  7058. // }
  7059. // recordStartTime := theStartTime.Unix()
  7060. // start_time = recordStartTime
  7061. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7062. // if err != nil {
  7063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7064. // return
  7065. // }
  7066. // recordEndTime := theEndTime.Unix()
  7067. // end_time = recordEndTime
  7068. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7069. // data["pre"] = prescriptions
  7070. //
  7071. // }
  7072. //
  7073. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7074. //
  7075. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7076. // timestamp := time.Now().Unix()
  7077. // tempTime := time.Unix(timestamp, 0)
  7078. // timeFormat := tempTime.Format("20060102150405")
  7079. // chrgBchno := rand.Intn(100000) + 10000
  7080. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7081. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7082. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7083. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7084. // strconv.FormatInt(his.PatientId, 10)
  7085. // client := &http.Client{}
  7086. // data["psn_no"] = his.PsnNo
  7087. // data["mdtrt_id"] = his.Number
  7088. // data["chrg_bchno"] = chrg_bchno
  7089. // data["org_name"] = miConfig.OrgName
  7090. // data["doctor"] = roles.UserName
  7091. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7092. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7093. // data["fixmedins_code"] = miConfig.Code
  7094. // data["dept_code"] = department.Number
  7095. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7096. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7097. // data["secret_key"] = miConfig.SecretKey
  7098. // var ids []int64
  7099. //
  7100. // for _, item := range prescriptions {
  7101. // ids = append(ids, item.ID)
  7102. // }
  7103. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7104. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7105. // bytesData, _ := json.Marshal(data)
  7106. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  7107. // resp, _ := client.Do(req)
  7108. // defer resp.Body.Close()
  7109. // body, ioErr := ioutil.ReadAll(resp.Body)
  7110. // if ioErr != nil {
  7111. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7113. // return
  7114. // }
  7115. // var respJSON map[string]interface{}
  7116. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7117. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7119. // return
  7120. // }
  7121. //
  7122. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7123. // userJSONBytes, _ := json.Marshal(respJSON)
  7124. // var res ResultFour
  7125. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7126. // utils.ErrorLog("解析失败:%v", err)
  7127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7128. // return
  7129. // }
  7130. //
  7131. // if res.Infcode == 0 {
  7132. // order := &models.HisOrder{
  7133. // UserOrgId: adminUser.CurrentOrgId,
  7134. // HisPatientId: his.ID,
  7135. // PatientId: his.PatientId,
  7136. // SettleAccountsDate: recordDateTime,
  7137. // Ctime: time.Now().Unix(),
  7138. // Mtime: time.Now().Unix(),
  7139. // Status: 1,
  7140. // Number: chrg_bchno,
  7141. // Infcode: res.Infcode,
  7142. // WarnMsg: res.WarnMsg,
  7143. // Cainfo: res.Cainfo,
  7144. // ErrMsg: res.ErrMsg,
  7145. // RespondTime: res.RefmsgTime,
  7146. // InfRefmsgid: res.InfRefmsgid,
  7147. // OrderStatus: 1,
  7148. // IsMedicineInsurance: 1,
  7149. // SettleType: settle_accounts_type,
  7150. // SettleStartTime: start_time,
  7151. // SettleEndTime: end_time,
  7152. // Creator: roles.ID,
  7153. // Modify: roles.ID,
  7154. // PType: 2,
  7155. // }
  7156. // err = service.CreateOrder(order)
  7157. // if err != nil {
  7158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7159. // return
  7160. // }
  7161. //
  7162. // for _, item := range res.Output.Result {
  7163. // temp := strings.Split(item.FeedetlSn, "-")
  7164. // var advice_id int64 = 0
  7165. // var project_id int64 = 0
  7166. // var types int64 = 0
  7167. //
  7168. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  7169. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  7170. //
  7171. // if temp[1] == "1" {
  7172. // advice_id = id
  7173. // project_id = 0
  7174. // } else if temp[1] == "2" {
  7175. // advice_id = 0
  7176. // project_id = id
  7177. // }
  7178. //
  7179. // info := &models.HisOrderInfo{
  7180. // OrderNumber: order.Number,
  7181. // FeedetlSn: item.FeedetlSn,
  7182. // UploadDate: time.Now().Unix(),
  7183. // AdviceId: advice_id,
  7184. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  7185. // Cnt: item.Cnt,
  7186. // Pric: float64(item.Pric),
  7187. // PatientId: his.PatientId,
  7188. // PricUplmtAmt: item.PricUplmtAmt,
  7189. // SelfpayProp: item.SelfpayProp,
  7190. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7191. // OverlmtAmt: item.OverlmtAmt,
  7192. // PreselfpayAmt: item.PreselfpayAmt,
  7193. // BasMednFlag: item.BasMednFlag,
  7194. // MedChrgitmType: item.MedChrgitmType,
  7195. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  7196. // Status: 1,
  7197. // Memo: item.Memo,
  7198. // Mtime: time.Now().Unix(),
  7199. // InscpScpAmt: item.InscpScpAmt,
  7200. // DrtReimFlag: item.DrtReimFlag,
  7201. // Ctime: time.Now().Unix(),
  7202. // ListSpItemFlag: item.ListSpItemFlag,
  7203. // ChldMedcFlag: item.ChldMedcFlag,
  7204. // LmtUsedFlag: item.LmtUsedFlag,
  7205. // ChrgitmLv: item.ChrgitmLv,
  7206. // UserOrgId: adminUser.CurrentOrgId,
  7207. // HisPatientId: his.ID,
  7208. // OrderId: order.ID,
  7209. // ProjectId: project_id,
  7210. // Type: types,
  7211. // }
  7212. // service.CreateOrderInfo(info)
  7213. //
  7214. // }
  7215. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7216. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7217. //
  7218. // var total float64
  7219. // for _, item := range prescriptions {
  7220. // if item.Type == 1 { //药品
  7221. // for _, subItem := range item.HisDoctorAdviceInfo {
  7222. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7223. // }
  7224. // }
  7225. // if item.Type == 2 { //项目
  7226. // for _, subItem := range item.HisPrescriptionProject {
  7227. // total = total + (subItem.Price * float64(subItem.Count))
  7228. // }
  7229. // }
  7230. // }
  7231. //
  7232. // for _, item := range prescriptions {
  7233. // for _, subItem := range item.HisAdditionalCharge {
  7234. // total = total + (subItem.Price * float64(subItem.Count))
  7235. // }
  7236. // }
  7237. //
  7238. // allTotal := fmt.Sprintf("%.2f", total)
  7239. // if res.Infcode == 0 {
  7240. // var rf []*ResultFive
  7241. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7242. // psn_no := his.PsnNo
  7243. // mdtrt_id := his.Number
  7244. // chrg_bchno := chrg_bchno
  7245. // cert_no := his.Certno
  7246. // insutype := rf[0].Insutype
  7247. //
  7248. // if his.IdCardType == 1 {
  7249. // cert_no = his.MedicalInsuranceNumber
  7250. //
  7251. // } else {
  7252. //
  7253. // cert_no = his.Certno
  7254. //
  7255. // }
  7256. //
  7257. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7258. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7259. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7260. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7261. // resp, requestErr := http.Get(api)
  7262. // if requestErr != nil {
  7263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7264. // return
  7265. // }
  7266. // defer resp.Body.Close()
  7267. // body, ioErr := ioutil.ReadAll(resp.Body)
  7268. // if ioErr != nil {
  7269. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7271. // return
  7272. // }
  7273. // var respJSON map[string]interface{}
  7274. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7275. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7277. // return
  7278. // }
  7279. // fmt.Println(respJSON)
  7280. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7281. // userJSONBytes, _ := json.Marshal(respJSON)
  7282. // var res ResultSeven
  7283. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7284. // utils.ErrorLog("解析失败:%v", err)
  7285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. // return
  7287. // }
  7288. // if res.Infcode != 0 {
  7289. // errlog := &models.HisOrderError{
  7290. // UserOrgId: adminUser.CurrentOrgId,
  7291. // Ctime: time.Now().Unix(),
  7292. // Mtime: time.Now().Unix(),
  7293. // Number: chrg_bchno,
  7294. // ErrMsg: res.ErrMsg,
  7295. // Status: 1,
  7296. // PatientId: id,
  7297. // RecordTime: recordDateTime,
  7298. // Stage: 7,
  7299. // }
  7300. // service.CreateErrMsgLog(errlog)
  7301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7302. // return
  7303. // } else {
  7304. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7305. // order.OrderStatus = 1
  7306. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7307. // order.SetlId = res.Output.Setlinfo.SetlID
  7308. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7309. // order.PsnName = res.Output.Setlinfo.PsnName
  7310. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7311. // order.Certno = res.Output.Setlinfo.Certno
  7312. // order.Gend = res.Output.Setlinfo.Gend
  7313. // order.Naty = res.Output.Setlinfo.Naty
  7314. // order.Age = res.Output.Setlinfo.Age
  7315. // order.Insutype = res.Output.Setlinfo.Insutype
  7316. // order.PsnType = res.Output.Setlinfo.PsnType
  7317. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7318. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7319. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7320. // order.MedType = res.Output.Setlinfo.MedType
  7321. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7322. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7323. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7324. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7325. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7326. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7327. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7328. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7329. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7330. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7331. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7332. // order.MafPay = res.Output.Setlinfo.MafPay
  7333. // order.OthPay = res.Output.Setlinfo.OthPay
  7334. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7335. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7336. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7337. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7338. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7339. // order.Balc = res.Output.Setlinfo.Balc
  7340. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7341. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7342. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7343. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7344. // order.Creator = order.Creator
  7345. // order.Modify = roles.ID
  7346. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7347. // detailStr := string(setlDetail)
  7348. // order.SetlDetail = detailStr
  7349. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7350. // err = service.UpDateOrder(order)
  7351. // if err == nil {
  7352. // c.ServeSuccessJSON(map[string]interface{}{
  7353. // "msg": "预结算成功",
  7354. // })
  7355. // } else {
  7356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7357. // return
  7358. // }
  7359. // }
  7360. // } else {
  7361. // adminUser := c.GetAdminUserInfo()
  7362. // errlog := &models.HisOrderError{
  7363. // UserOrgId: adminUser.CurrentOrgId,
  7364. // Ctime: time.Now().Unix(),
  7365. // Mtime: time.Now().Unix(),
  7366. // ErrMsg: res.ErrMsg,
  7367. // Status: 1,
  7368. // PatientId: id,
  7369. // RecordTime: recordDateTime,
  7370. // Stage: 4,
  7371. // }
  7372. // service.CreateErrMsgLog(errlog)
  7373. //
  7374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7375. // return
  7376. // }
  7377. // } else {
  7378. // adminUser := c.GetAdminUserInfo()
  7379. // errlog := &models.HisOrderError{
  7380. // UserOrgId: adminUser.CurrentOrgId,
  7381. // Ctime: time.Now().Unix(),
  7382. // Mtime: time.Now().Unix(),
  7383. // ErrMsg: res.ErrMsg,
  7384. // Status: 1,
  7385. // PatientId: id,
  7386. // RecordTime: recordDateTime,
  7387. // Stage: 4,
  7388. // }
  7389. // service.CreateErrMsgLog(errlog)
  7390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7391. // return
  7392. // }
  7393. //
  7394. // } else {
  7395. // var total float64
  7396. // for _, item := range prescriptions {
  7397. // if item.Type == 1 { //药品
  7398. // for _, subItem := range item.HisDoctorAdviceInfo {
  7399. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7400. // }
  7401. // }
  7402. // if item.Type == 2 { //项目
  7403. // for _, subItem := range item.HisPrescriptionProject {
  7404. // total = total + (subItem.Price * float64(subItem.Count))
  7405. // }
  7406. // }
  7407. //
  7408. // for _, subItem := range item.HisAdditionalCharge {
  7409. // total = total + (subItem.Price * float64(subItem.Count))
  7410. // }
  7411. // }
  7412. //
  7413. // allTotal := fmt.Sprintf("%.2f", total)
  7414. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7415. // order := &models.HisOrder{
  7416. // UserOrgId: adminUser.CurrentOrgId,
  7417. // HisPatientId: his.ID,
  7418. // PatientId: id,
  7419. // SettleAccountsDate: recordDateTime,
  7420. // Ctime: time.Now().Unix(),
  7421. // Mtime: time.Now().Unix(),
  7422. // Status: 1,
  7423. // OrderStatus: 2,
  7424. // Number: chrg_bchno,
  7425. // MedfeeSumamt: totals,
  7426. // }
  7427. // err = service.CreateOrder(order)
  7428. // if err != nil {
  7429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7430. // return
  7431. // }
  7432. //
  7433. // var customs []*Custom
  7434. // for _, item := range prescriptions {
  7435. //
  7436. // if item.Type == 1 { //药品
  7437. // for _, subItem := range item.HisDoctorAdviceInfo {
  7438. // cus := &Custom{
  7439. // AdviceId: subItem.ID,
  7440. // ProjectId: 0,
  7441. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7442. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7443. // FeedetlSn: subItem.FeedetlSn,
  7444. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7445. // MedListCodg: subItem.MedListCodg,
  7446. // Type: 1,
  7447. // }
  7448. // customs = append(customs, cus)
  7449. // }
  7450. // }
  7451. //
  7452. // if item.Type == 2 { //项目
  7453. // for _, subItem := range item.HisPrescriptionProject {
  7454. //
  7455. // cus := &Custom{
  7456. // AdviceId: 0,
  7457. // ProjectId: subItem.ID,
  7458. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7459. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7460. // FeedetlSn: subItem.FeedetlSn,
  7461. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7462. // MedListCodg: subItem.MedListCodg,
  7463. // Type: 2,
  7464. // }
  7465. //
  7466. // customs = append(customs, cus)
  7467. // }
  7468. // }
  7469. //
  7470. // for _, item := range item.HisAdditionalCharge {
  7471. // cus := &Custom{
  7472. // ItemId: item.ID,
  7473. // AdviceId: 0,
  7474. // ProjectId: 0,
  7475. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7476. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7477. // FeedetlSn: item.FeedetlSn,
  7478. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7479. // MedListCodg: item.XtHisAddtionConfig.Code,
  7480. // Type: 3,
  7481. // }
  7482. //
  7483. // customs = append(customs, cus)
  7484. // }
  7485. //
  7486. // }
  7487. //
  7488. // for _, item := range customs {
  7489. // var advice_id int64 = 0
  7490. // var project_id int64 = 0
  7491. // var item_id int64 = 0
  7492. //
  7493. // var types int64 = 0
  7494. //
  7495. // if item.Type == 1 {
  7496. // advice_id = item.AdviceId
  7497. // project_id = 0
  7498. // item_id = 0
  7499. // } else if item.Type == 2 {
  7500. // advice_id = 0
  7501. // item_id = 0
  7502. //
  7503. // project_id = item.ProjectId
  7504. // } else if item.Type == 3 {
  7505. // advice_id = 0
  7506. // item_id = item.ItemId
  7507. // project_id = 0
  7508. // }
  7509. //
  7510. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7511. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7512. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7513. //
  7514. // info := &models.HisOrderInfo{
  7515. // OrderNumber: order.Number,
  7516. // UploadDate: time.Now().Unix(),
  7517. // AdviceId: advice_id,
  7518. // DetItemFeeSumamt: detItemFeeSumamt,
  7519. // Cnt: cut,
  7520. // Pric: pric,
  7521. // PatientId: id,
  7522. // Status: 1,
  7523. // Mtime: time.Now().Unix(),
  7524. // Ctime: time.Now().Unix(),
  7525. // UserOrgId: adminUser.CurrentOrgId,
  7526. // HisPatientId: his.ID,
  7527. // OrderId: order.ID,
  7528. // ProjectId: project_id,
  7529. // Type: types,
  7530. // ItemId: item_id,
  7531. // }
  7532. // service.CreateOrderInfo(info)
  7533. // }
  7534. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7535. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7536. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7537. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7538. // if err == nil {
  7539. // c.ServeSuccessJSON(map[string]interface{}{
  7540. // "msg": "结算成功",
  7541. // })
  7542. // } else {
  7543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7544. // return
  7545. // }
  7546. // }
  7547. //}
  7548. //上传明细-预结算-
  7549. func (c *HisApiController) GetPreUploadInfo() {
  7550. id, _ := c.GetInt64("id")
  7551. record_time := c.GetString("record_time")
  7552. his_patient_id, _ := c.GetInt64("his_patient_id")
  7553. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7554. admin_user_id, _ := c.GetInt64("admin_user_id")
  7555. diagnosis_id := c.GetString("diagnosis")
  7556. sick_type, _ := c.GetInt64("sick_type")
  7557. reg_type, _ := c.GetInt64("p_type")
  7558. begin_time := c.GetString("begin_time")
  7559. id_str := c.GetString("ids")
  7560. ids_arr := strings.Split(id_str, ",")
  7561. timeLayout := "2006-01-02"
  7562. loc, _ := time.LoadLocation("Local")
  7563. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7564. if err != nil {
  7565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7566. return
  7567. }
  7568. recordDateTime := theTime.Unix()
  7569. adminUser := c.GetAdminUserInfo()
  7570. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7571. var config []*models.HisXtDiagnoseConfig
  7572. for _, item := range diagnosis_ids {
  7573. id, _ := strconv.ParseInt(item, 10, 64)
  7574. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7575. config = append(config, &diagnosisConfig)
  7576. }
  7577. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7578. sickConfig, _ := service.FindSickById(sick_type)
  7579. var prescriptions []*models.HisPrescription
  7580. var start_time int64
  7581. var end_time int64
  7582. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7583. fmt.Println(his_patient_id)
  7584. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7585. timestamp := time.Now().Unix()
  7586. tempTime := time.Unix(timestamp, 0)
  7587. timeFormat := tempTime.Format("20060102150405")
  7588. chrgBchno := rand.Intn(100000) + 10000
  7589. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7590. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7591. var patientPrescription models.HisPrescriptionInfo
  7592. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7593. if patientPrescription.ID == 0 {
  7594. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7595. }
  7596. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7597. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7598. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7599. strconv.FormatInt(his.PatientId, 10)
  7600. var res2 ResultSix
  7601. var resSix10265 ResultSix10265
  7602. var time_stamp string
  7603. if miConfig.MdtrtareaAdmvs == "421300" {
  7604. data := make(map[string]interface{})
  7605. client := &http.Client{}
  7606. data["psn_no"] = his.PsnNo
  7607. data["mdtrt_id"] = his.Number
  7608. data["department"] = department.Name
  7609. data["org_name"] = miConfig.OrgName
  7610. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7611. data["doctor_id"] = doctor_info.DoctorNumber
  7612. data["doctor_name"] = roles.UserName
  7613. data["fixmedins_code"] = miConfig.Code
  7614. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7615. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7616. data["secret_key"] = miConfig.SecretKey
  7617. data["sick_code"] = sickConfig.CountryCode
  7618. data["sick_name"] = sickConfig.ClassName
  7619. data["begin_time"] = begin_time
  7620. data["dept"] = strconv.FormatInt(department.ID, 10)
  7621. data["config"] = config
  7622. data["opter"] = roles.UserName
  7623. fmt.Println(data)
  7624. bytesData, _ := json.Marshal(data)
  7625. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7626. resp, _ := client.Do(req)
  7627. defer resp.Body.Close()
  7628. body, ioErr := ioutil.ReadAll(resp.Body)
  7629. if ioErr != nil {
  7630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7632. return
  7633. }
  7634. var respJSON map[string]interface{}
  7635. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7638. return
  7639. }
  7640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7641. userJSONBytes, _ := json.Marshal(respJSON)
  7642. fmt.Println("log")
  7643. fmt.Println(string(userJSONBytes))
  7644. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7645. utils.ErrorLog("解析失败:%v", err)
  7646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7647. return
  7648. }
  7649. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7650. data := make(map[string]interface{})
  7651. client := &http.Client{}
  7652. data["psn_no"] = his.PsnNo
  7653. data["mdtrt_id"] = his.Number
  7654. data["doctor"] = roles.UserName
  7655. data["department"] = department.Name
  7656. data["org_name"] = miConfig.OrgName
  7657. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7658. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7659. data["fixmedins_code"] = miConfig.Code
  7660. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7661. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7662. data["secret_key"] = miConfig.SecretKey
  7663. data["sick_code"] = sickConfig.CountryCode
  7664. data["sick_name"] = sickConfig.ClassName
  7665. data["begin_time"] = begin_time
  7666. data["dept"] = strconv.FormatInt(department.ID, 10)
  7667. data["config"] = config
  7668. data["url"] = miConfig.Url
  7669. data["ak"] = miConfig.AccessKey
  7670. data["cainfo"] = miConfig.Cainfo
  7671. bytesData, _ := json.Marshal(data)
  7672. var req *http.Request
  7673. if miConfig.MdtrtareaAdmvs == "320921" {
  7674. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7675. } else {
  7676. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  7677. if len(tokens) > 0 {
  7678. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7679. } else {
  7680. c.ServeSuccessJSON(map[string]interface{}{
  7681. "failed_code": -10,
  7682. "msg": "token无效",
  7683. })
  7684. }
  7685. }
  7686. resp, _ := client.Do(req)
  7687. defer resp.Body.Close()
  7688. body, ioErr := ioutil.ReadAll(resp.Body)
  7689. if ioErr != nil {
  7690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. return
  7693. }
  7694. var respJSON map[string]interface{}
  7695. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. return
  7699. }
  7700. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7701. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7702. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7704. userJSONBytes, _ := json.Marshal(respJSON)
  7705. fmt.Println("log")
  7706. fmt.Println(string(userJSONBytes))
  7707. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7708. utils.ErrorLog("解析失败:%v", err)
  7709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7710. return
  7711. }
  7712. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7713. res2.Output = resSix10265.Output
  7714. res2.ErrMsg = resSix10265.ErrMsg
  7715. res2.Cainfo = resSix10265.Cainfo
  7716. res2.WarnMsg = resSix10265.WarnMsg
  7717. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7718. res2.Infcode = infocode
  7719. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7720. 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)
  7721. saveLog(result, requestLog, "2203", "上传就诊信息")
  7722. var respJSON2 map[string]interface{}
  7723. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7726. return
  7727. }
  7728. userJSONBytes2, _ := json.Marshal(respJSON2)
  7729. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7730. utils.ErrorLog("解析失败:%v", err)
  7731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7732. return
  7733. }
  7734. } else {
  7735. var result string
  7736. var requestLog string
  7737. if miConfig.MdtrtareaAdmvs == "440781" { //
  7738. 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)
  7739. } else {
  7740. if miConfig.Code == "H15049901371" {
  7741. //赤峰地区国家医保医疗类别
  7742. //职工透析:医疗类别选特殊情况门诊990502
  7743. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7744. var med_type string
  7745. if his.Insutype == "390" {
  7746. if reg_type == 14 {
  7747. med_type = "9933"
  7748. } else if reg_type == 11 {
  7749. med_type = "11"
  7750. }
  7751. } else if his.Insutype == "310" {
  7752. if reg_type == 14 {
  7753. med_type = "990502"
  7754. } else if reg_type == 11 {
  7755. med_type = "11"
  7756. }
  7757. }
  7758. 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)
  7759. } else {
  7760. 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)
  7761. }
  7762. saveLog(result, requestLog, "2203", "上传就诊信息")
  7763. var respJSON2 map[string]interface{}
  7764. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7767. return
  7768. }
  7769. userJSONBytes2, _ := json.Marshal(respJSON2)
  7770. if miConfig.Code == "H15049901371" {
  7771. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7772. utils.ErrorLog("解析失败:%v", err)
  7773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7774. return
  7775. }
  7776. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7777. res2.Output = resSix10265.Output
  7778. res2.ErrMsg = resSix10265.ErrMsg
  7779. res2.Cainfo = resSix10265.Cainfo
  7780. res2.WarnMsg = resSix10265.WarnMsg
  7781. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7782. res2.Infcode = infocode
  7783. } else {
  7784. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7785. utils.ErrorLog("解析失败:%v", err)
  7786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7787. return
  7788. }
  7789. }
  7790. }
  7791. }
  7792. if res2.Infcode != 0 {
  7793. adminUser := c.GetAdminUserInfo()
  7794. errlog := &models.HisOrderError{
  7795. UserOrgId: adminUser.CurrentOrgId,
  7796. Ctime: time.Now().Unix(),
  7797. Mtime: time.Now().Unix(),
  7798. ErrMsg: res2.ErrMsg,
  7799. Status: 1,
  7800. PatientId: id,
  7801. RecordTime: recordDateTime,
  7802. Stage: 3,
  7803. }
  7804. service.CreateErrMsgLog(errlog)
  7805. c.ServeSuccessJSON(map[string]interface{}{
  7806. "failed_code": -10,
  7807. "msg": res2.ErrMsg,
  7808. })
  7809. return
  7810. } else {
  7811. his.Diagnosis = diagnosis_id
  7812. his.SickType = sickConfig.ID
  7813. his.PType = fmt.Sprintf("%d", reg_type)
  7814. service.UpdateHisPatientThree(&his)
  7815. data := make(map[string]interface{})
  7816. if settle_accounts_type == 1 { //日结
  7817. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7818. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7819. } else {
  7820. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7821. }
  7822. data["pre"] = prescriptions
  7823. } else { //月结
  7824. start_time_str := c.GetString("start_time")
  7825. end_time_str := c.GetString("end_time")
  7826. timeLayout := "2006-01-02"
  7827. loc, _ := time.LoadLocation("Local")
  7828. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7829. if err != nil {
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7831. return
  7832. }
  7833. recordStartTime := theStartTime.Unix()
  7834. start_time = recordStartTime
  7835. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7836. if err != nil {
  7837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7838. return
  7839. }
  7840. recordEndTime := theEndTime.Unix()
  7841. end_time = recordEndTime
  7842. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7843. data["pre"] = prescriptions
  7844. }
  7845. client := &http.Client{}
  7846. data["psn_no"] = his.PsnNo
  7847. data["mdtrt_id"] = his.Number
  7848. data["chrg_bchno"] = chrg_bchno
  7849. data["org_name"] = miConfig.OrgName
  7850. data["doctor"] = roles.UserName
  7851. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7852. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7853. data["fixmedins_code"] = miConfig.Code
  7854. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7855. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7856. data["dept_code"] = "15"
  7857. } else {
  7858. data["dept_code"] = department.Number
  7859. }
  7860. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7861. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7862. data["secret_key"] = miConfig.SecretKey
  7863. data["url"] = miConfig.Url
  7864. data["ak"] = miConfig.AccessKey
  7865. data["new_doctor_name"] = patientPrescription.Doctor
  7866. data["diag_code"] = sickConfig.CountryCode
  7867. data["time_stamp"] = time_stamp
  7868. data["cainfo"] = miConfig.Cainfo
  7869. var ids []int64
  7870. for _, item := range prescriptions {
  7871. ids = append(ids, item.ID)
  7872. }
  7873. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7874. if config.IsOpen == 1 { //对接了医保,走医保流程
  7875. var res ResultFour
  7876. var resFour10265 ResultFour10265
  7877. if miConfig.MdtrtareaAdmvs == "421300" {
  7878. bytesData, _ := json.Marshal(data)
  7879. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7880. resp, _ := client.Do(req)
  7881. defer resp.Body.Close()
  7882. body, ioErr := ioutil.ReadAll(resp.Body)
  7883. if ioErr != nil {
  7884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. var respJSON map[string]interface{}
  7889. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7895. userJSONBytes, _ := json.Marshal(respJSON)
  7896. fmt.Println("log")
  7897. fmt.Println(string(userJSONBytes))
  7898. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7899. utils.ErrorLog("解析失败:%v", err)
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7904. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7905. if result3101.Infcode == "0" {
  7906. if len(result3101.Output.Result) > 0 {
  7907. var errMsgs []string
  7908. for _, item := range result3101.Output.Result {
  7909. errMsgs = append(errMsgs, item.VolaCont)
  7910. }
  7911. c.ServeSuccessJSON(map[string]interface{}{
  7912. "failed_code": -10,
  7913. "msg": errMsgs,
  7914. })
  7915. return
  7916. } else {
  7917. bytesData, _ := json.Marshal(data)
  7918. var req *http.Request
  7919. if miConfig.MdtrtareaAdmvs == "320921" {
  7920. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7921. } else {
  7922. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7923. }
  7924. resp, _ := client.Do(req)
  7925. defer resp.Body.Close()
  7926. body, ioErr := ioutil.ReadAll(resp.Body)
  7927. if ioErr != nil {
  7928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7930. return
  7931. }
  7932. var respJSON map[string]interface{}
  7933. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. return
  7937. }
  7938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7939. userJSONBytes, _ := json.Marshal(respJSON)
  7940. fmt.Println("log")
  7941. fmt.Println(string(userJSONBytes))
  7942. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7943. utils.ErrorLog("解析失败:%v", err)
  7944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7945. return
  7946. }
  7947. res.InfRefmsgid = resFour10265.InfRefmsgid
  7948. res.Output = resFour10265.Output
  7949. res.ErrMsg = resFour10265.ErrMsg
  7950. res.Cainfo = resFour10265.Cainfo
  7951. res.WarnMsg = resFour10265.WarnMsg
  7952. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7953. res.Infcode = infocode
  7954. }
  7955. }
  7956. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7957. 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)
  7958. var dat map[string]interface{}
  7959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7960. fmt.Println(dat)
  7961. } else {
  7962. fmt.Println(err)
  7963. }
  7964. saveLog(result, request_log, "2204", "上传费用明细")
  7965. userJSONBytes, _ := json.Marshal(dat)
  7966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7967. utils.ErrorLog("解析失败:%v", err)
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7969. return
  7970. }
  7971. } else {
  7972. if miConfig.Code == "H15049901371" {
  7973. 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)
  7974. var dat map[string]interface{}
  7975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7976. fmt.Println(dat)
  7977. } else {
  7978. fmt.Println(err)
  7979. }
  7980. saveLog(result, request_log, "2204", "上传费用明细")
  7981. userJSONBytes, _ := json.Marshal(dat)
  7982. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7983. utils.ErrorLog("解析失败:%v", err)
  7984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7985. return
  7986. }
  7987. res.InfRefmsgid = resFour10265.InfRefmsgid
  7988. res.Output = resFour10265.Output
  7989. res.ErrMsg = resFour10265.ErrMsg
  7990. res.Cainfo = resFour10265.Cainfo
  7991. res.WarnMsg = resFour10265.WarnMsg
  7992. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7993. res.Infcode = infocode
  7994. } else {
  7995. 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)
  7996. var dat map[string]interface{}
  7997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7998. fmt.Println(dat)
  7999. } else {
  8000. fmt.Println(err)
  8001. }
  8002. saveLog(result, request_log, "2204", "上传费用明细")
  8003. userJSONBytes, _ := json.Marshal(dat)
  8004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8005. utils.ErrorLog("解析失败:%v", err)
  8006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8007. return
  8008. }
  8009. }
  8010. }
  8011. if res.Infcode == 0 {
  8012. order := &models.HisOrder{
  8013. UserOrgId: adminUser.CurrentOrgId,
  8014. HisPatientId: his.ID,
  8015. PatientId: his.PatientId,
  8016. SettleAccountsDate: recordDateTime,
  8017. Ctime: time.Now().Unix(),
  8018. Mtime: time.Now().Unix(),
  8019. MdtrtId: his.Number,
  8020. PsnNo: his.PsnNo,
  8021. MedType: strconv.FormatInt(reg_type, 10),
  8022. Status: 1,
  8023. Number: chrg_bchno,
  8024. Infcode: res.Infcode,
  8025. WarnMsg: res.WarnMsg,
  8026. Cainfo: res.Cainfo,
  8027. ErrMsg: res.ErrMsg,
  8028. RespondTime: res.RefmsgTime,
  8029. InfRefmsgid: res.InfRefmsgid,
  8030. OrderStatus: 1,
  8031. IsMedicineInsurance: 1,
  8032. SettleType: settle_accounts_type,
  8033. SettleStartTime: start_time,
  8034. SettleEndTime: end_time,
  8035. Creator: roles.AdminUserId,
  8036. Modify: roles.AdminUserId,
  8037. PType: 2,
  8038. Diagnosis: diagnosis_id,
  8039. }
  8040. err = service.CreateOrder(order)
  8041. if err != nil {
  8042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8043. return
  8044. }
  8045. for _, item := range res.Output.Result {
  8046. temp := strings.Split(item.FeedetlSn, "-")
  8047. var advice_id int64 = 0
  8048. var project_id int64 = 0
  8049. var types int64 = 0
  8050. id, _ := strconv.ParseInt(temp[2], 10, 64)
  8051. types, _ = strconv.ParseInt(temp[1], 10, 64)
  8052. if temp[1] == "1" {
  8053. advice_id = id
  8054. project_id = 0
  8055. } else if temp[1] == "2" {
  8056. advice_id = 0
  8057. project_id = id
  8058. }
  8059. info := &models.HisOrderInfo{
  8060. OrderNumber: order.Number,
  8061. FeedetlSn: item.FeedetlSn,
  8062. UploadDate: time.Now().Unix(),
  8063. AdviceId: advice_id,
  8064. DetItemFeeSumamt: item.DetItemFeeSumamt,
  8065. Cnt: item.Cnt,
  8066. Pric: float64(item.Pric),
  8067. PatientId: his.PatientId,
  8068. PricUplmtAmt: item.PricUplmtAmt,
  8069. SelfpayProp: item.SelfpayProp,
  8070. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8071. OverlmtAmt: item.OverlmtAmt,
  8072. PreselfpayAmt: item.PreselfpayAmt,
  8073. BasMednFlag: item.BasMednFlag,
  8074. MedChrgitmType: item.MedChrgitmType,
  8075. HiNegoDrugFlag: item.HiNegoDrugFlag,
  8076. Status: 1,
  8077. Memo: item.Memo,
  8078. Mtime: time.Now().Unix(),
  8079. InscpScpAmt: item.InscpScpAmt,
  8080. DrtReimFlag: item.DrtReimFlag,
  8081. Ctime: time.Now().Unix(),
  8082. ListSpItemFlag: item.ListSpItemFlag,
  8083. ChldMedcFlag: item.ChldMedcFlag,
  8084. LmtUsedFlag: item.LmtUsedFlag,
  8085. ChrgitmLv: item.ChrgitmLv,
  8086. UserOrgId: adminUser.CurrentOrgId,
  8087. HisPatientId: his.ID,
  8088. OrderId: order.ID,
  8089. ProjectId: project_id,
  8090. Type: types,
  8091. }
  8092. service.CreateOrderInfo(info)
  8093. }
  8094. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8095. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  8096. var total float64
  8097. for _, item := range prescriptions {
  8098. if item.Type == 1 { //药品
  8099. for _, subItem := range item.HisDoctorAdviceInfo {
  8100. total = total + (subItem.Price * subItem.PrescribingNumber)
  8101. }
  8102. }
  8103. if item.Type == 2 { //项目
  8104. for _, subItem := range item.HisPrescriptionProject {
  8105. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  8106. total = total + (subItem.Price * cnt)
  8107. }
  8108. }
  8109. }
  8110. for _, item := range prescriptions {
  8111. for _, subItem := range item.HisAdditionalCharge {
  8112. total = total + (subItem.Price * float64(subItem.Count))
  8113. }
  8114. }
  8115. allTotal := fmt.Sprintf("%.4f", total)
  8116. if res.Infcode == 0 {
  8117. var rf []*ResultFive
  8118. json.Unmarshal([]byte(his.Iinfo), &rf)
  8119. chrg_bchno := chrg_bchno
  8120. cert_no := his.Certno
  8121. var insutypes []string
  8122. var insutype string
  8123. var is390 int = 0
  8124. var is310 int = 0
  8125. for _, item := range rf {
  8126. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8127. insutypes = append(insutypes, item.Insutype)
  8128. }
  8129. }
  8130. if len(insutypes) == 1 {
  8131. insutype = insutypes[0]
  8132. } else {
  8133. for _, i := range insutypes {
  8134. if i == "390" {
  8135. is390 = 1
  8136. }
  8137. if i == "310" {
  8138. is310 = 1
  8139. }
  8140. }
  8141. }
  8142. if is390 == 1 {
  8143. insutype = "390"
  8144. }
  8145. if is310 == 1 {
  8146. insutype = "310"
  8147. }
  8148. if len(insutypes) == 0 {
  8149. insutype = "310"
  8150. }
  8151. if len(insutypes) == 2 {
  8152. insutype = strconv.FormatInt(his.SocialType, 64)
  8153. }
  8154. //insutype = "390"
  8155. if his.IdCardType == 1 {
  8156. cert_no = his.MedicalInsuranceNumber
  8157. } else {
  8158. cert_no = his.Certno
  8159. }
  8160. var res ResultSeven
  8161. var resSeven10265 ResultSeven10265
  8162. if miConfig.MdtrtareaAdmvs == "421300" {
  8163. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8164. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8165. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8166. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8167. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8168. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8169. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  8170. resp, requestErr := http.Get(api)
  8171. if requestErr != nil {
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. body, ioErr := ioutil.ReadAll(resp.Body)
  8176. if ioErr != nil {
  8177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8179. return
  8180. }
  8181. var respJSON map[string]interface{}
  8182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8185. return
  8186. }
  8187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8188. result, _ := json.Marshal(respJSON)
  8189. fmt.Println("log")
  8190. fmt.Println(string(result))
  8191. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8192. utils.ErrorLog("解析失败:%v", err)
  8193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8194. return
  8195. }
  8196. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8197. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  8198. if result3101.Infcode == "0" {
  8199. if len(result3101.Output.Result) > 0 {
  8200. var errMsgs []string
  8201. for _, item := range result3101.Output.Result {
  8202. errMsgs = append(errMsgs, item.VolaCont)
  8203. }
  8204. c.ServeSuccessJSON(map[string]interface{}{
  8205. "failed_code": -10,
  8206. "msg": errMsgs,
  8207. })
  8208. return
  8209. } else {
  8210. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8211. if his.IdCardType != 4 {
  8212. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8213. }
  8214. bas := strings.Split(psn_info.CardInfo, "|")
  8215. if his.IdCardType == 1 {
  8216. cert_no = bas[2]
  8217. } else {
  8218. cert_no = bas[1]
  8219. }
  8220. //江苏地区国家医保医疗类别
  8221. //职工透析:医疗类别选特殊情况门诊9933
  8222. //居民血透门慢: 医疗类别选门诊慢病1402
  8223. //var med_type string
  8224. //if his.Insutype == "310" {
  8225. // if reg_type == 14 {
  8226. // med_type = "9933"
  8227. // } else if reg_type == 11 {
  8228. // med_type = "11"
  8229. //
  8230. // }
  8231. //} else if his.Insutype == "390" {
  8232. // if reg_type == 14 {
  8233. // med_type = "1402"
  8234. // } else if reg_type == 11 {
  8235. // med_type = "11"
  8236. // }
  8237. //}
  8238. var api string
  8239. if miConfig.MdtrtareaAdmvs == "320921" {
  8240. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8241. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8242. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8243. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8244. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8245. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8246. "&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
  8247. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8248. } else {
  8249. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8250. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8251. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8252. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8253. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8254. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8255. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8256. "&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
  8257. }
  8258. resp, requestErr := http.Get(api)
  8259. if requestErr != nil {
  8260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8261. return
  8262. }
  8263. body, ioErr := ioutil.ReadAll(resp.Body)
  8264. if ioErr != nil {
  8265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8267. return
  8268. }
  8269. var respJSON map[string]interface{}
  8270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8273. return
  8274. }
  8275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8276. result, _ := json.Marshal(respJSON)
  8277. fmt.Println("log")
  8278. fmt.Println(string(result))
  8279. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8280. utils.ErrorLog("解析失败:%v", err)
  8281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8282. return
  8283. }
  8284. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8285. res.Output = resSeven10265.Output
  8286. res.ErrMsg = resSeven10265.ErrMsg
  8287. res.Cainfo = resSeven10265.Cainfo
  8288. res.WarnMsg = resSeven10265.WarnMsg
  8289. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8290. res.Infcode = infocode
  8291. }
  8292. }
  8293. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8294. 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)
  8295. var dat map[string]interface{}
  8296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8297. fmt.Println(dat)
  8298. } else {
  8299. fmt.Println(err)
  8300. }
  8301. saveLog(result, request_log, "2206", "预结算")
  8302. userJSONBytes, _ := json.Marshal(dat)
  8303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8304. utils.ErrorLog("解析失败:%v", err)
  8305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8306. return
  8307. }
  8308. } else {
  8309. var result string
  8310. var request_log string
  8311. if miConfig.Code == "H15049901371" {
  8312. //赤峰地区国家医保医疗类别
  8313. //职工透析:医疗类别选特殊情况门诊990502
  8314. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8315. var med_type string
  8316. if his.Insutype == "390" {
  8317. if reg_type == 14 {
  8318. med_type = "9933"
  8319. } else if reg_type == 11 {
  8320. med_type = "11"
  8321. }
  8322. } else if his.Insutype == "310" {
  8323. if reg_type == 14 {
  8324. med_type = "990502"
  8325. } else if reg_type == 11 {
  8326. med_type = "11"
  8327. }
  8328. }
  8329. 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)
  8330. } else {
  8331. 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)
  8332. }
  8333. var dat map[string]interface{}
  8334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8335. fmt.Println(dat)
  8336. } else {
  8337. fmt.Println(err)
  8338. }
  8339. saveLog(result, request_log, "2206", "预结算")
  8340. //userJSONBytes, _ := json.Marshal(dat)
  8341. //
  8342. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8343. // utils.ErrorLog("解析失败:%v", err)
  8344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8345. // return
  8346. //}
  8347. userJSONBytes, _ := json.Marshal(dat)
  8348. if miConfig.Code == "H15049901371" {
  8349. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8350. utils.ErrorLog("解析失败:%v", err)
  8351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8352. return
  8353. }
  8354. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8355. res.Output = resSeven10265.Output
  8356. res.ErrMsg = resSeven10265.ErrMsg
  8357. res.Cainfo = resSeven10265.Cainfo
  8358. res.WarnMsg = resSeven10265.WarnMsg
  8359. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8360. res.Infcode = infocode
  8361. } else {
  8362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8363. utils.ErrorLog("解析失败:%v", err)
  8364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8365. return
  8366. }
  8367. }
  8368. }
  8369. if res.Infcode != 0 {
  8370. errlog := &models.HisOrderError{
  8371. UserOrgId: adminUser.CurrentOrgId,
  8372. Ctime: time.Now().Unix(),
  8373. Mtime: time.Now().Unix(),
  8374. Number: chrg_bchno,
  8375. ErrMsg: res.ErrMsg,
  8376. Status: 1,
  8377. PatientId: id,
  8378. RecordTime: recordDateTime,
  8379. Stage: 20,
  8380. }
  8381. service.CreateErrMsgLog(errlog)
  8382. c.ServeSuccessJSON(map[string]interface{}{
  8383. "failed_code": -10,
  8384. "msg": res.ErrMsg,
  8385. })
  8386. return
  8387. } else {
  8388. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8389. order.OrderStatus = 1
  8390. order.IsPre = 1
  8391. order.Status = 1
  8392. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8393. order.SetlId = res.Output.Setlinfo.SetlID
  8394. order.PsnNo = res.Output.Setlinfo.PsnNo
  8395. order.PsnName = res.Output.Setlinfo.PsnName
  8396. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8397. order.Certno = res.Output.Setlinfo.Certno
  8398. order.Gend = res.Output.Setlinfo.Gend
  8399. order.Naty = res.Output.Setlinfo.Naty
  8400. order.Age = res.Output.Setlinfo.Age
  8401. order.Insutype = res.Output.Setlinfo.Insutype
  8402. order.PsnType = res.Output.Setlinfo.PsnType
  8403. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8404. order.SetlTime = res.Output.Setlinfo.SetlTime
  8405. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8406. if res.Output.Setlinfo.MedType == "140101" {
  8407. order.MedType = "14"
  8408. } else {
  8409. order.MedType = res.Output.Setlinfo.MedType
  8410. }
  8411. if reg_type == 1112 {
  8412. order.MedType = "1112"
  8413. }
  8414. if reg_type == 1111 {
  8415. order.MedType = "1111"
  8416. }
  8417. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8418. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8419. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8420. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8421. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8422. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8423. order.HifpPay = res.Output.Setlinfo.HifpPay
  8424. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8425. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8426. order.HifesPay = res.Output.Setlinfo.HifesPay
  8427. order.HifobPay = res.Output.Setlinfo.HifobPay
  8428. order.MafPay = res.Output.Setlinfo.MafPay
  8429. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8430. order.OthPay = res.Output.Setlinfo.OthPay
  8431. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8432. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8433. order.AcctPay = res.Output.Setlinfo.AcctPay
  8434. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8435. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8436. order.Balc = res.Output.Setlinfo.Balc
  8437. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8438. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8439. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8440. order.ClrWay = res.Output.Setlinfo.ClrWay
  8441. order.Creator = order.Creator
  8442. order.Modify = roles.AdminUserId
  8443. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8444. detailStr := string(setlDetail)
  8445. order.SetlDetail = detailStr
  8446. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8447. err = service.UpDateOrder(order)
  8448. if err == nil {
  8449. c.ServeSuccessJSON(map[string]interface{}{
  8450. "msg": "预结算成功",
  8451. })
  8452. } else {
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8454. return
  8455. }
  8456. }
  8457. } else {
  8458. adminUser := c.GetAdminUserInfo()
  8459. errlog := &models.HisOrderError{
  8460. UserOrgId: adminUser.CurrentOrgId,
  8461. Ctime: time.Now().Unix(),
  8462. Mtime: time.Now().Unix(),
  8463. ErrMsg: res.ErrMsg,
  8464. Status: 1,
  8465. PatientId: id,
  8466. RecordTime: recordDateTime,
  8467. Stage: 4,
  8468. }
  8469. service.CreateErrMsgLog(errlog)
  8470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8471. return
  8472. }
  8473. } else {
  8474. adminUser := c.GetAdminUserInfo()
  8475. errlog := &models.HisOrderError{
  8476. UserOrgId: adminUser.CurrentOrgId,
  8477. Ctime: time.Now().Unix(),
  8478. Mtime: time.Now().Unix(),
  8479. ErrMsg: res.ErrMsg,
  8480. Status: 1,
  8481. PatientId: id,
  8482. RecordTime: recordDateTime,
  8483. Stage: 4,
  8484. }
  8485. service.CreateErrMsgLog(errlog)
  8486. c.ServeSuccessJSON(map[string]interface{}{
  8487. "failed_code": -10,
  8488. "msg": res.ErrMsg,
  8489. })
  8490. return
  8491. }
  8492. }
  8493. }
  8494. }
  8495. //退款
  8496. func (c *HisApiController) Refund() {
  8497. order_id, _ := c.GetInt64("order_id")
  8498. admin_user_id, _ := c.GetInt64("admin_user_id")
  8499. adminUser := c.GetAdminUserInfo()
  8500. var order models.HisOrder
  8501. order, _ = service.GetHisOrderByID(order_id)
  8502. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8503. if order.ID == 0 {
  8504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8505. return
  8506. }
  8507. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8508. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8509. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8510. if config.IsOpen == 1 { //对接了医保,走医保流程
  8511. var res ResultSixteen
  8512. var resSixteen10265 ResultSixteen10265
  8513. var src_resquest string
  8514. var result string
  8515. if miConfig.MdtrtareaAdmvs == "421300" {
  8516. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8517. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8518. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8519. resp3, requestErr3 := http.Get(api3)
  8520. if requestErr3 != nil {
  8521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8522. return
  8523. }
  8524. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8525. if ioErr3 != nil {
  8526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. var respJSON3 map[string]interface{}
  8531. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8534. return
  8535. }
  8536. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8537. userJSONBytes3, _ := json.Marshal(respJSON3)
  8538. fmt.Println("log")
  8539. fmt.Println(string(userJSONBytes3))
  8540. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8541. utils.ErrorLog("解析失败:%v", err)
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8543. return
  8544. }
  8545. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8546. var api3 string
  8547. if miConfig.MdtrtareaAdmvs == "320921" {
  8548. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8549. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8550. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8551. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8552. } else {
  8553. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8554. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8555. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8556. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8557. }
  8558. resp3, requestErr3 := http.Get(api3)
  8559. if requestErr3 != nil {
  8560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8561. return
  8562. }
  8563. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8564. if ioErr3 != nil {
  8565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8567. return
  8568. }
  8569. var respJSON3 map[string]interface{}
  8570. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8573. return
  8574. }
  8575. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8576. userJSONBytes3, _ := json.Marshal(respJSON3)
  8577. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8578. utils.ErrorLog("解析失败:%v", err)
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8583. res.Output = resSixteen10265.Output
  8584. res.ErrMsg = resSixteen10265.ErrMsg
  8585. res.Cainfo = resSixteen10265.Cainfo
  8586. res.WarnMsg = resSixteen10265.WarnMsg
  8587. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8588. res.Infcode = infocode
  8589. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8590. 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)
  8591. var dat map[string]interface{}
  8592. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8593. fmt.Println(dat)
  8594. } else {
  8595. fmt.Println(err)
  8596. }
  8597. saveLog(result, src_resquest, "2208", "退费")
  8598. userJSONBytes, _ := json.Marshal(dat)
  8599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8600. utils.ErrorLog("解析失败:%v", err)
  8601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8602. return
  8603. }
  8604. } else {
  8605. if miConfig.Code == "H15049901371" {
  8606. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8607. var dat map[string]interface{}
  8608. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8609. fmt.Println(dat)
  8610. } else {
  8611. fmt.Println(err)
  8612. }
  8613. saveLog(result, src_resquest, "2208", "退费")
  8614. userJSONBytes, _ := json.Marshal(dat)
  8615. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8616. utils.ErrorLog("解析失败:%v", err)
  8617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8618. return
  8619. }
  8620. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8621. res.Output = resSixteen10265.Output
  8622. res.ErrMsg = resSixteen10265.ErrMsg
  8623. res.Cainfo = resSixteen10265.Cainfo
  8624. res.WarnMsg = resSixteen10265.WarnMsg
  8625. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8626. res.Infcode = infocode
  8627. } else {
  8628. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8629. var dat map[string]interface{}
  8630. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8631. fmt.Println(dat)
  8632. } else {
  8633. fmt.Println(err)
  8634. }
  8635. saveLog(result, src_resquest, "2208", "退费")
  8636. userJSONBytes, _ := json.Marshal(dat)
  8637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8638. utils.ErrorLog("解析失败:%v", err)
  8639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8640. return
  8641. }
  8642. }
  8643. }
  8644. if res.Infcode == 0 {
  8645. var res2 ResultSix
  8646. var resSix10265 ResultSix10265
  8647. if miConfig.MdtrtareaAdmvs == "421300" {
  8648. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8649. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8650. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8651. resp3, requestErr3 := http.Get(api3)
  8652. if requestErr3 != nil {
  8653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8654. return
  8655. }
  8656. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8657. if ioErr3 != nil {
  8658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8660. return
  8661. }
  8662. var respJSON3 map[string]interface{}
  8663. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8666. return
  8667. }
  8668. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8669. userJSONBytes3, _ := json.Marshal(respJSON3)
  8670. fmt.Println("log")
  8671. fmt.Println(string(userJSONBytes3))
  8672. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8673. utils.ErrorLog("解析失败:%v", err)
  8674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8675. return
  8676. }
  8677. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8678. var api3 string
  8679. if miConfig.MdtrtareaAdmvs == "320921" {
  8680. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8681. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8682. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8683. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8684. } else {
  8685. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8686. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8687. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8688. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8689. }
  8690. resp3, requestErr3 := http.Get(api3)
  8691. if requestErr3 != nil {
  8692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8693. return
  8694. }
  8695. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8696. if ioErr3 != nil {
  8697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8699. return
  8700. }
  8701. var respJSON3 map[string]interface{}
  8702. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8705. return
  8706. }
  8707. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8708. userJSONBytes3, _ := json.Marshal(respJSON3)
  8709. fmt.Println("log")
  8710. fmt.Println(string(userJSONBytes3))
  8711. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8712. utils.ErrorLog("解析失败:%v", err)
  8713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8714. return
  8715. }
  8716. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8717. res2.Output = resSix10265.Output
  8718. res2.ErrMsg = resSix10265.ErrMsg
  8719. res2.Cainfo = resSix10265.Cainfo
  8720. res2.WarnMsg = resSix10265.WarnMsg
  8721. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8722. res2.Infcode = infocode
  8723. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8724. 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)
  8725. var dat map[string]interface{}
  8726. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8727. fmt.Println(dat)
  8728. } else {
  8729. fmt.Println(err)
  8730. }
  8731. saveLog(result2, src_request, "2205", "撤销明细")
  8732. userJSONBytes, _ := json.Marshal(dat)
  8733. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8734. utils.ErrorLog("解析失败:%v", err)
  8735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8736. return
  8737. }
  8738. } else {
  8739. if miConfig.Code == "H15049901371" {
  8740. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8741. var dat map[string]interface{}
  8742. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8743. fmt.Println(dat)
  8744. } else {
  8745. fmt.Println(err)
  8746. }
  8747. saveLog(result2, src_request, "2205", "撤销明细")
  8748. userJSONBytes, _ := json.Marshal(dat)
  8749. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8750. utils.ErrorLog("解析失败:%v", err)
  8751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8752. return
  8753. }
  8754. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8755. res2.Output = resSix10265.Output
  8756. res2.ErrMsg = resSix10265.ErrMsg
  8757. res2.Cainfo = resSix10265.Cainfo
  8758. res2.WarnMsg = resSix10265.WarnMsg
  8759. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8760. res2.Infcode = infocode
  8761. } else {
  8762. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8763. var dat map[string]interface{}
  8764. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8765. fmt.Println(dat)
  8766. } else {
  8767. fmt.Println(err)
  8768. }
  8769. saveLog(result2, src_request, "2205", "撤销明细")
  8770. userJSONBytes, _ := json.Marshal(dat)
  8771. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8772. utils.ErrorLog("解析失败:%v", err)
  8773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8774. return
  8775. }
  8776. }
  8777. }
  8778. if res2.Infcode == 0 {
  8779. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8780. if err == nil {
  8781. //当押金不为零时产生退费记录
  8782. if order.Decimal != 0 {
  8783. tmp := strconv.FormatInt(order.ID, 10)
  8784. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8785. if err != nil {
  8786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8787. return
  8788. }
  8789. }
  8790. c.ServeSuccessJSON(map[string]interface{}{
  8791. "msg": "退费成功",
  8792. })
  8793. } else {
  8794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8795. return
  8796. }
  8797. } else {
  8798. c.ServeSuccessJSON(map[string]interface{}{
  8799. "code": -10,
  8800. "msg": res2.ErrMsg,
  8801. })
  8802. }
  8803. } else {
  8804. c.ServeSuccessJSON(map[string]interface{}{
  8805. "code": -10,
  8806. "msg": res.ErrMsg,
  8807. })
  8808. }
  8809. }
  8810. }
  8811. func (c *HisApiController) RefundNumber() {
  8812. record_time := c.GetString("record_time")
  8813. //patient_id, _ := c.GetInt64("patient_id")
  8814. admin_user_id, _ := c.GetInt64("admin_user_id")
  8815. his_patient_id, _ := c.GetInt64("id")
  8816. timeLayout := "2006-01-02"
  8817. loc, _ := time.LoadLocation("Local")
  8818. adminUser := c.GetAdminUserInfo()
  8819. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8820. fmt.Println(err)
  8821. if err != nil {
  8822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8823. return
  8824. }
  8825. recordDateTime := theTime.Unix()
  8826. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8827. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8828. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8829. //order, _ := service.GetHisOrderByID(order_id)
  8830. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8831. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8832. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8833. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8834. if count > 0 {
  8835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8836. return
  8837. }
  8838. if config.IsOpen == 1 { //对接了医保,走医保流程
  8839. var res2 ResultSix
  8840. var resSix10265 ResultSix10265
  8841. if miConfig.MdtrtareaAdmvs == "421300" {
  8842. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8843. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8844. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8845. resp3, requestErr3 := http.Get(api3)
  8846. if requestErr3 != nil {
  8847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8848. return
  8849. }
  8850. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8851. if ioErr3 != nil {
  8852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8854. return
  8855. }
  8856. var respJSON3 map[string]interface{}
  8857. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8860. return
  8861. }
  8862. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8863. userJSONBytes3, _ := json.Marshal(respJSON3)
  8864. fmt.Println("log")
  8865. fmt.Println(string(userJSONBytes3))
  8866. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8867. utils.ErrorLog("解析失败:%v", err)
  8868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8869. return
  8870. }
  8871. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8872. var api3 string
  8873. if miConfig.MdtrtareaAdmvs == "320921" {
  8874. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8875. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8876. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8877. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8878. } else {
  8879. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8880. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8881. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8882. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8883. }
  8884. resp3, requestErr3 := http.Get(api3)
  8885. if requestErr3 != nil {
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8890. if ioErr3 != nil {
  8891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8893. return
  8894. }
  8895. var respJSON3 map[string]interface{}
  8896. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8899. return
  8900. }
  8901. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8902. userJSONBytes3, _ := json.Marshal(respJSON3)
  8903. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8904. utils.ErrorLog("解析失败:%v", err)
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. return
  8907. }
  8908. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8909. res2.Output = resSix10265.Output
  8910. res2.ErrMsg = resSix10265.ErrMsg
  8911. res2.Cainfo = resSix10265.Cainfo
  8912. res2.WarnMsg = resSix10265.WarnMsg
  8913. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8914. res2.Infcode = infocode
  8915. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8916. 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)
  8917. var dat map[string]interface{}
  8918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8919. fmt.Println(dat)
  8920. } else {
  8921. fmt.Println(err)
  8922. }
  8923. saveLog(result, request, "2202", "退号")
  8924. userJSONBytes, _ := json.Marshal(dat)
  8925. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8926. utils.ErrorLog("解析失败:%v", err)
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8928. return
  8929. }
  8930. } else {
  8931. var api3 string
  8932. if miConfig.Code == "H15049901371" {
  8933. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8934. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8935. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8936. } else {
  8937. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8938. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8939. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8940. }
  8941. resp3, requestErr3 := http.Get(api3)
  8942. if requestErr3 != nil {
  8943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8944. return
  8945. }
  8946. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8947. if ioErr3 != nil {
  8948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8950. return
  8951. }
  8952. var respJSON3 map[string]interface{}
  8953. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8956. return
  8957. }
  8958. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8959. userJSONBytes3, _ := json.Marshal(respJSON3)
  8960. if miConfig.Code == "H15049901371" {
  8961. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8962. utils.ErrorLog("解析失败:%v", err)
  8963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8964. return
  8965. }
  8966. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8967. res2.Output = resSix10265.Output
  8968. res2.ErrMsg = resSix10265.ErrMsg
  8969. res2.Cainfo = resSix10265.Cainfo
  8970. res2.WarnMsg = resSix10265.WarnMsg
  8971. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8972. res2.Infcode = infocode
  8973. } else {
  8974. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8975. utils.ErrorLog("解析失败:%v", err)
  8976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8977. return
  8978. }
  8979. }
  8980. }
  8981. if res2.Infcode == 0 {
  8982. if err == nil {
  8983. c.ServeSuccessJSON(map[string]interface{}{
  8984. "msg": "退号成功",
  8985. })
  8986. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8987. } else {
  8988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8989. return
  8990. }
  8991. } else {
  8992. c.ServeSuccessJSON(map[string]interface{}{
  8993. "code": -10,
  8994. "msg": res2.ErrMsg,
  8995. })
  8996. }
  8997. } else {
  8998. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8999. //if err == nil {
  9000. // c.ServeSuccessJSON(map[string]interface{}{
  9001. // "msg": "退费成功",
  9002. // })
  9003. //} else {
  9004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9005. // return
  9006. //}
  9007. }
  9008. }
  9009. func (c *HisApiController) RefundDetail() {
  9010. order_id, _ := c.GetInt64("order_id")
  9011. admin_user_id, _ := c.GetInt64("admin_user_id")
  9012. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9013. number := c.GetString("number")
  9014. record_time := c.GetString("record_time")
  9015. patient_id, _ := c.GetInt64("patient_id")
  9016. //med_type, _ := c.GetInt64("med_type")
  9017. timeLayout := "2006-01-02"
  9018. loc, _ := time.LoadLocation("Local")
  9019. adminUser := c.GetAdminUserInfo()
  9020. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9021. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9022. fmt.Println(err)
  9023. if err != nil {
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9025. return
  9026. }
  9027. recordDateTime := theTime.Unix()
  9028. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9029. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9030. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9031. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9032. var order models.HisOrder
  9033. order, _ = service.GetHisOrderByID(order_id)
  9034. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9035. if config.IsOpen == 1 { //对接了医保,走医保流程
  9036. var res2 ResultSix
  9037. if miConfig.MdtrtareaAdmvs == "421300" {
  9038. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  9039. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9040. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9041. resp3, requestErr3 := http.Get(api3)
  9042. if requestErr3 != nil {
  9043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9044. return
  9045. }
  9046. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9047. if ioErr3 != nil {
  9048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9050. return
  9051. }
  9052. var respJSON3 map[string]interface{}
  9053. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9056. return
  9057. }
  9058. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9059. userJSONBytes3, _ := json.Marshal(respJSON3)
  9060. fmt.Println("log")
  9061. fmt.Println(string(userJSONBytes3))
  9062. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  9063. utils.ErrorLog("解析失败:%v", err)
  9064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9065. return
  9066. }
  9067. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9068. if err == nil {
  9069. c.ServeSuccessJSON(map[string]interface{}{
  9070. "msg": "撤销明细成功",
  9071. })
  9072. return
  9073. } else {
  9074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9075. return
  9076. }
  9077. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9078. var resSix10265 ResultSix10265
  9079. var api3 string
  9080. if miConfig.MdtrtareaAdmvs == "320921" {
  9081. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  9082. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9083. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9084. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9085. } else {
  9086. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9087. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  9088. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9089. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9090. }
  9091. resp3, requestErr3 := http.Get(api3)
  9092. if requestErr3 != nil {
  9093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9094. return
  9095. }
  9096. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  9097. if ioErr3 != nil {
  9098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  9099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9100. return
  9101. }
  9102. var respJSON3 map[string]interface{}
  9103. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  9104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9106. return
  9107. }
  9108. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9109. userJSONBytes3, _ := json.Marshal(respJSON3)
  9110. fmt.Println("log")
  9111. fmt.Println(string(userJSONBytes3))
  9112. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  9113. utils.ErrorLog("解析失败:%v", err)
  9114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9115. return
  9116. }
  9117. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9118. res2.Output = resSix10265.Output
  9119. res2.ErrMsg = resSix10265.ErrMsg
  9120. res2.Cainfo = resSix10265.Cainfo
  9121. res2.WarnMsg = resSix10265.WarnMsg
  9122. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9123. res2.Infcode = infocode
  9124. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9125. if err == nil {
  9126. c.ServeSuccessJSON(map[string]interface{}{
  9127. "msg": "撤销明细成功",
  9128. })
  9129. return
  9130. } else {
  9131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9132. return
  9133. }
  9134. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9135. 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)
  9136. var dat map[string]interface{}
  9137. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9138. fmt.Println(dat)
  9139. } else {
  9140. fmt.Println(err)
  9141. }
  9142. saveLog(result2, src_request, "2205", "撤销明细")
  9143. userJSONBytes, _ := json.Marshal(dat)
  9144. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9145. utils.ErrorLog("解析失败:%v", err)
  9146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9147. return
  9148. }
  9149. if res2.Infcode == 0 {
  9150. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9151. if err == nil {
  9152. c.ServeSuccessJSON(map[string]interface{}{
  9153. "msg": "撤销明细成功",
  9154. })
  9155. return
  9156. } else {
  9157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9158. return
  9159. }
  9160. } else {
  9161. c.ServeSuccessJSON(map[string]interface{}{
  9162. "code": -10,
  9163. "msg": res2.ErrMsg,
  9164. })
  9165. }
  9166. } else {
  9167. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  9168. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9169. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9170. resp2, requestErr2 := http.Get(api2)
  9171. if requestErr2 != nil {
  9172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9173. return
  9174. }
  9175. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9176. if ioErr2 != nil {
  9177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9179. return
  9180. }
  9181. var respJSON2 map[string]interface{}
  9182. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9185. return
  9186. }
  9187. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9188. if err == nil {
  9189. c.ServeSuccessJSON(map[string]interface{}{
  9190. "msg": "撤销明细成功",
  9191. })
  9192. return
  9193. } else {
  9194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9195. return
  9196. }
  9197. }
  9198. } else {
  9199. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9200. if err == nil {
  9201. c.ServeSuccessJSON(map[string]interface{}{
  9202. "msg": "退费成功",
  9203. })
  9204. } else {
  9205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9206. return
  9207. }
  9208. }
  9209. }
  9210. //对账
  9211. func (c *HisApiController) GetCheckAccount() {
  9212. start_time := c.GetString("start_time")
  9213. end_time := c.GetString("end_time")
  9214. insutype := c.GetString("insutype")
  9215. clr_type := c.GetString("clr_type")
  9216. clr_org := c.GetString("clr_optins")
  9217. admin_user_id, _ := c.GetInt64("admin_user_id")
  9218. adminUser := c.GetAdminUserInfo()
  9219. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9220. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9221. if len(clr_org) == 0 {
  9222. clr_org = miConfig.MdtrtareaAdmvs
  9223. }
  9224. timeLayout := "2006-01-02"
  9225. loc, _ := time.LoadLocation("Local")
  9226. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9227. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9228. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9229. fixmedins_setl_cnt := int64(len(orders))
  9230. var medfee_sumamt float64
  9231. var acct_pay float64
  9232. var fund_pay_sumamt float64
  9233. for _, item := range orders {
  9234. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9235. acct_pay = acct_pay + item.AcctPay
  9236. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9237. }
  9238. var user_name string
  9239. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9240. if role.ID == 0 {
  9241. user_name = "xxx"
  9242. } else {
  9243. user_name = role.UserName
  9244. }
  9245. var res ResultEight
  9246. var res10188 ResultEightFor10188
  9247. if config.IsOpen == 1 {
  9248. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9249. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9250. "insutype=" + insutype +
  9251. "&clr_type=" + clr_type +
  9252. "&setl_optins=" + clr_org +
  9253. "&stmt_begndate=" + start_time +
  9254. "&stm_enddate=" + end_time +
  9255. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9256. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9257. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9258. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9259. "&fixmedins_code=" + miConfig.Code +
  9260. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9261. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9262. "&secret_key=" + miConfig.SecretKey +
  9263. "&org_name=" + miConfig.OrgName +
  9264. "&doctor=" + user_name +
  9265. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9266. fmt.Println(api)
  9267. resp, requestErr := http.Get(api)
  9268. if requestErr != nil {
  9269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9270. return
  9271. }
  9272. body, ioErr := ioutil.ReadAll(resp.Body)
  9273. fmt.Println(body)
  9274. if ioErr != nil {
  9275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9277. return
  9278. }
  9279. var respJSON map[string]interface{}
  9280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9283. return
  9284. }
  9285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9286. userJSONBytes, _ := json.Marshal(respJSON)
  9287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9288. utils.ErrorLog("解析失败:%v", err)
  9289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9290. return
  9291. }
  9292. res.InfRefmsgid = res10188.InfRefmsgid
  9293. res.Output = res10188.Output
  9294. res.ErrMsg = res10188.ErrMsg
  9295. res.Cainfo = res10188.Cainfo
  9296. res.WarnMsg = res10188.WarnMsg
  9297. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9298. res.Infcode = infocode
  9299. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9300. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9301. "insutype=" + insutype +
  9302. "&clr_type=" + clr_type +
  9303. "&setl_optins=" + clr_org +
  9304. "&stmt_begndate=" + start_time +
  9305. "&stm_enddate=" + end_time +
  9306. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9307. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9308. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9309. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9310. "&fixmedins_code=" + miConfig.Code +
  9311. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9312. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9313. "&secret_key=" + miConfig.SecretKey +
  9314. "&org_name=" + miConfig.OrgName +
  9315. "&doctor=" + user_name
  9316. resp, requestErr := http.Get(api)
  9317. if requestErr != nil {
  9318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9319. return
  9320. }
  9321. body, ioErr := ioutil.ReadAll(resp.Body)
  9322. if ioErr != nil {
  9323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9325. return
  9326. }
  9327. var respJSON map[string]interface{}
  9328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9331. return
  9332. }
  9333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9334. result, _ := json.Marshal(respJSON)
  9335. fmt.Println("log")
  9336. fmt.Println(string(result))
  9337. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  9338. utils.ErrorLog("解析失败:%v", err)
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. res.InfRefmsgid = res10188.InfRefmsgid
  9343. res.Output = res10188.Output
  9344. res.ErrMsg = res10188.ErrMsg
  9345. res.Cainfo = res10188.Cainfo
  9346. res.WarnMsg = res10188.WarnMsg
  9347. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9348. res.Infcode = infocode
  9349. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9350. var baseParams models.BaseParams
  9351. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9352. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9353. baseParams.SecretKey = miConfig.SecretKey
  9354. baseParams.OrgName = miConfig.OrgName
  9355. baseParams.FixmedinsCode = miConfig.Code
  9356. baseParams.EncKey = miConfig.EncKey
  9357. baseParams.AppSecret = miConfig.AppSecret
  9358. baseParams.SignKey = miConfig.SignKey
  9359. baseParams.AppID = miConfig.Code
  9360. baseParams.Doctor = role.UserName
  9361. baseParams.RequestUrl = miConfig.Url
  9362. businessParams := models.BusinessParams{
  9363. Insutype: insutype,
  9364. ClrType: clr_type,
  9365. SetlOptins: clr_org,
  9366. StmtBegndate: start_time,
  9367. StmtEnddate: end_time,
  9368. MedfeeSumamt: medfee_sumamt,
  9369. FundPaySumamt: fund_pay_sumamt,
  9370. AcctPay: acct_pay,
  9371. FixmedinsSetlCnt: fixmedins_setl_cnt,
  9372. }
  9373. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams)
  9374. fmt.Println(requestLog)
  9375. fmt.Println(result)
  9376. fmt.Println(err_msg)
  9377. } else {
  9378. if len(clr_type) == 0 {
  9379. clr_type = "11"
  9380. }
  9381. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9382. "insutype=" + insutype +
  9383. "&clr_type=" + clr_type +
  9384. "&setl_optins=" + clr_org +
  9385. "&stmt_begndate=" + start_time +
  9386. "&stm_enddate=" + end_time +
  9387. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9388. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9389. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9390. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9391. "&fixmedins_code=" + miConfig.Code +
  9392. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9393. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9394. "&secret_key=" + miConfig.SecretKey +
  9395. "&org_name=" + miConfig.OrgName +
  9396. "&doctor=" + user_name
  9397. fmt.Println(api)
  9398. resp, requestErr := http.Get(api)
  9399. if requestErr != nil {
  9400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9401. return
  9402. }
  9403. body, ioErr := ioutil.ReadAll(resp.Body)
  9404. fmt.Println(body)
  9405. if ioErr != nil {
  9406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9408. return
  9409. }
  9410. var respJSON map[string]interface{}
  9411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9414. return
  9415. }
  9416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9417. userJSONBytes, _ := json.Marshal(respJSON)
  9418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9419. utils.ErrorLog("解析失败:%v", err)
  9420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9421. return
  9422. }
  9423. }
  9424. if res.Infcode == 0 {
  9425. if res.Output.Stmtinfo.StmtRslt == "0" {
  9426. micc := &models.MedicalInsuranceCostCompare{
  9427. StartTime: startime.Unix(),
  9428. EndTime: endtime.Unix(),
  9429. Insutype: insutype,
  9430. CheckType: 1,
  9431. Num: fixmedins_setl_cnt,
  9432. Mtime: time.Now().Unix(),
  9433. Status: 1,
  9434. UserOrgId: adminUser.CurrentOrgId,
  9435. CostTotal: medfee_sumamt,
  9436. FuncTotal: fund_pay_sumamt,
  9437. PsnPay: acct_pay,
  9438. Creator: admin_user_id,
  9439. Ctime: time.Now().Unix(),
  9440. ClrType: clr_type,
  9441. }
  9442. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9443. if err == nil {
  9444. c.ServeSuccessJSON(map[string]interface{}{
  9445. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9446. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9447. })
  9448. } else {
  9449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9450. }
  9451. } else {
  9452. c.ServeSuccessJSON(map[string]interface{}{
  9453. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9454. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9455. })
  9456. }
  9457. } else {
  9458. c.ServeSuccessJSON(map[string]interface{}{
  9459. "code": -10,
  9460. "msg": res.ErrMsg,
  9461. })
  9462. }
  9463. }
  9464. }
  9465. func (c *HisApiController) Check310() {
  9466. adminUser := c.GetAdminUserInfo()
  9467. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9468. var user_name string
  9469. user_name = "高慧裕"
  9470. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9471. "insutype=" + "310" +
  9472. "&clr_type=" + "" +
  9473. "&setl_optins=" + "441202" +
  9474. "&stmt_begndate=" + "2022-03-01" +
  9475. "&stm_enddate=" + "2022-03-31" +
  9476. "&medfee_sumamt=" + "194930.12" +
  9477. "&fund_pay_sumamt=" + "188741.46" +
  9478. "&acct_pay=" + "0" +
  9479. "&fixmedins_setl_cnt=" + "452" +
  9480. "&fixmedins_code=" + miConfig.Code +
  9481. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9482. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9483. "&secret_key=" + miConfig.SecretKey +
  9484. "&org_name=" + miConfig.OrgName +
  9485. "&doctor=" + user_name
  9486. fmt.Println(api)
  9487. resp, requestErr := http.Get(api)
  9488. if requestErr != nil {
  9489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9490. return
  9491. }
  9492. body, ioErr := ioutil.ReadAll(resp.Body)
  9493. fmt.Println(body)
  9494. if ioErr != nil {
  9495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9497. return
  9498. }
  9499. var respJSON map[string]interface{}
  9500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9503. return
  9504. }
  9505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9506. userJSONBytes, _ := json.Marshal(respJSON)
  9507. var res ResultEight
  9508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9509. utils.ErrorLog("解析失败:%v", err)
  9510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9511. return
  9512. }
  9513. }
  9514. func (c *HisApiController) Check390() {
  9515. adminUser := c.GetAdminUserInfo()
  9516. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9517. var user_name string
  9518. user_name = "高慧裕"
  9519. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9520. "insutype=" + "390" +
  9521. "&clr_type=" + "" +
  9522. "&setl_optins=" + "441202" +
  9523. "&stmt_begndate=" + "2022-03-01" +
  9524. "&stm_enddate=" + "2022-03-31" +
  9525. "&medfee_sumamt=" + "1068448.89" +
  9526. "&fund_pay_sumamt=" + "1014677.62" +
  9527. "&acct_pay=" + "0" +
  9528. "&fixmedins_setl_cnt=" + "1950" +
  9529. "&fixmedins_code=" + miConfig.Code +
  9530. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9531. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9532. "&secret_key=" + miConfig.SecretKey +
  9533. "&org_name=" + miConfig.OrgName +
  9534. "&doctor=" + user_name
  9535. fmt.Println(api)
  9536. resp, requestErr := http.Get(api)
  9537. if requestErr != nil {
  9538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9539. return
  9540. }
  9541. body, ioErr := ioutil.ReadAll(resp.Body)
  9542. fmt.Println(body)
  9543. if ioErr != nil {
  9544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9546. return
  9547. }
  9548. var respJSON map[string]interface{}
  9549. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9552. return
  9553. }
  9554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9555. userJSONBytes, _ := json.Marshal(respJSON)
  9556. var res ResultEight
  9557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9558. utils.ErrorLog("解析失败:%v", err)
  9559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9560. return
  9561. }
  9562. }
  9563. //对账明细
  9564. func (c *HisApiController) GetCheckDetailAccount() {
  9565. start_time := c.GetString("start_time")
  9566. end_time := c.GetString("end_time")
  9567. admin_user_id, _ := c.GetInt64("admin_user_id")
  9568. adminUser := c.GetAdminUserInfo()
  9569. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9570. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9571. timeLayout := "2006-01-02"
  9572. loc, _ := time.LoadLocation("Local")
  9573. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9574. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9575. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9576. rand.Seed(time.Now().UnixNano())
  9577. num := rand.Intn(30000)
  9578. Mkdir(miConfig.OrgName)
  9579. file := strconv.FormatInt(int64(num), 10)
  9580. file_name := file + ".txt"
  9581. zip_name := file + ".zip"
  9582. zip_path := miConfig.OrgName + "/" + zip_name
  9583. file_path := miConfig.OrgName + "/" + file_name
  9584. decimal.DivisionPrecision = 2
  9585. var medfee_sumamt float64
  9586. var psn_cash_pay float64
  9587. var fund_pay_sumamt float64
  9588. fixmedins_setl_cnt := int64(len(orders))
  9589. for _, item := range orders {
  9590. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9591. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9592. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9593. }
  9594. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9595. defer f.Close()
  9596. if err != nil {
  9597. fmt.Println(err.Error())
  9598. } else {
  9599. for _, item := range orders {
  9600. var refd_setl_flag string
  9601. if item.OrderStatus == 2 {
  9602. refd_setl_flag = "0"
  9603. var str string
  9604. str = item.SetlId + " " +
  9605. item.MdtrtId + " " +
  9606. item.PsnNo + " " +
  9607. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9608. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9609. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9610. _, err = f.Write([]byte(str))
  9611. }
  9612. if item.OrderStatus == 3 {
  9613. var str string
  9614. str = item.SetlId + " " +
  9615. item.MdtrtId + " " +
  9616. item.PsnNo + " " +
  9617. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9618. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9619. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9620. _, err = f.Write([]byte(str))
  9621. var str2 string
  9622. str2 = item.SetlId + " " +
  9623. item.MdtrtId + " " +
  9624. item.PsnNo + " " +
  9625. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9626. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9627. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9628. _, err = f.Write([]byte(str2))
  9629. }
  9630. }
  9631. }
  9632. Zip(file_path, zip_path)
  9633. fmt.Println(ReadFile(zip_path))
  9634. fmt.Println(string(ReadFile(zip_path)))
  9635. if config.IsOpen == 1 {
  9636. var user_name string
  9637. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9638. if role.ID == 0 {
  9639. user_name = "管理员"
  9640. } else {
  9641. user_name = role.UserName
  9642. }
  9643. baseParams := models.BaseParams{
  9644. SecretKey: miConfig.SecretKey,
  9645. FixmedinsCode: miConfig.Code,
  9646. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9647. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9648. OrgName: miConfig.OrgName,
  9649. Doctor: user_name,
  9650. }
  9651. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9652. var dat map[string]interface{}
  9653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9654. fmt.Println(dat)
  9655. } else {
  9656. fmt.Println(err)
  9657. }
  9658. userJSONBytes, _ := json.Marshal(dat)
  9659. var res ResultNine
  9660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9661. utils.ErrorLog("解析失败:%v", err)
  9662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9663. return
  9664. }
  9665. if res.Infcode == 0 {
  9666. fileNo := res.Output.FileQuryNo
  9667. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9668. "file_qury_no=" + fileNo +
  9669. "&setl_optins=" + "定点医保中心" +
  9670. "&stmt_begndate=" + start_time +
  9671. "&stm_enddate=" + end_time +
  9672. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9673. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9674. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9675. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9676. "&fixmedins_code=" + miConfig.Code +
  9677. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9678. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9679. "&secret_key=" + miConfig.SecretKey +
  9680. "&org_name=" + miConfig.OrgName +
  9681. "&doctor=" + user_name
  9682. resp, requestErr := http.Get(api)
  9683. if requestErr != nil {
  9684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9685. return
  9686. }
  9687. body, ioErr := ioutil.ReadAll(resp.Body)
  9688. if ioErr != nil {
  9689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9691. return
  9692. }
  9693. var respJSON map[string]interface{}
  9694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9697. return
  9698. }
  9699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9700. userJSONBytes, _ := json.Marshal(respJSON)
  9701. var res ResultTen
  9702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9703. utils.ErrorLog("解析失败:%v", err)
  9704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9705. return
  9706. }
  9707. if res.Infcode == 0 {
  9708. service.Gdyb9102(baseParams, zip_name, fileNo)
  9709. micc := &models.MedicalInsuranceCostCompare{
  9710. StartTime: startime.Unix(),
  9711. EndTime: endtime.Unix(),
  9712. Insutype: "0",
  9713. CheckType: 2,
  9714. Num: fixmedins_setl_cnt,
  9715. Mtime: time.Now().Unix(),
  9716. Status: 1,
  9717. UserOrgId: adminUser.CurrentOrgId,
  9718. CostTotal: medfee_sumamt,
  9719. FuncTotal: fund_pay_sumamt,
  9720. PsnPay: psn_cash_pay,
  9721. Creator: admin_user_id,
  9722. Ctime: time.Now().Unix(),
  9723. }
  9724. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9725. c.ServeSuccessJSON(map[string]interface{}{
  9726. "msg": "明细对账成功",
  9727. })
  9728. }
  9729. } else {
  9730. }
  9731. }
  9732. }
  9733. type CustomOrderInfo struct {
  9734. Name string
  9735. Spec string
  9736. Unit string
  9737. Count float64
  9738. Price float64
  9739. Total float64
  9740. }
  9741. func (c *HisApiController) GetSettleAccounts() {
  9742. //id, _ := c.GetInt64("id")
  9743. //record_time := c.GetString("record_time")
  9744. order_id, _ := c.GetInt64("order_id")
  9745. admin_user_id, _ := c.GetInt64("admin_user_id")
  9746. //timeLayout := "2006-01-02"
  9747. //loc, _ := time.LoadLocation("Local")
  9748. //
  9749. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9750. //if err != nil {
  9751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9752. // return
  9753. //}
  9754. //recordDateTime := theTime.Unix()
  9755. adminUser := c.GetAdminUserInfo()
  9756. order, _ := service.GetHisOrderByID(order_id)
  9757. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9758. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9759. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9760. orderInfos = append(orderInfos, orderInfos_two...)
  9761. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9762. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9763. var diagnosis_ids []string
  9764. if his.ID > 0 {
  9765. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9766. } else {
  9767. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9768. }
  9769. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9770. var dia_config []*models.HisXtDiagnoseConfig
  9771. var name string
  9772. for _, item := range diagnosis_ids {
  9773. id, _ := strconv.ParseInt(item, 10, 64)
  9774. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9775. dia_config = append(dia_config, &diagnosisConfig)
  9776. if len(name) == 0 {
  9777. name = diagnosisConfig.ClassName
  9778. } else {
  9779. name = name + "," + diagnosisConfig.ClassName
  9780. }
  9781. }
  9782. var bedCostTotal float64 = 0 //床位总费
  9783. var bedCostSelfTotal float64 = 0 //床位自费
  9784. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9785. var operationCostTotal float64 = 0 //手术费
  9786. var operationCostSelfTotal float64 = 0 //手术费
  9787. var operationCostPartSelfTotal float64 = 0 //手术费
  9788. var otherCostTotal float64 = 0 //其他费用
  9789. var otherCostSelfTotal float64 = 0 //其他费用
  9790. var otherCostPartSelfTotal float64 = 0 //其他费用
  9791. var materialCostTotal float64 = 0 //材料费
  9792. var materialCostSelfTotal float64 = 0 //材料费
  9793. var materialCostPartSelfTotal float64 = 0 //材料费
  9794. var westernMedicineCostTotal float64 = 0 //西药费
  9795. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9796. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9797. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9798. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9799. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9800. var checkCostTotal float64 = 0 //检查费
  9801. var checkCostSelfTotal float64 = 0 //检查费
  9802. var checkCostPartSelfTotal float64 = 0 //检查费
  9803. var laboratoryCostTotal float64 = 0 //化验费
  9804. var laboratoryCostSelfTotal float64 = 0 //化验费
  9805. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9806. var treatCostTotal float64 = 0 //治疗费用
  9807. var treatCostSelfTotal float64 = 0 //治疗费用
  9808. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9809. decimal.DivisionPrecision = 2
  9810. for _, item := range orderInfos {
  9811. if item.MedChrgitmType == "01" { //床位费
  9812. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9813. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9814. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9815. }
  9816. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9817. if item.MedChrgitmType == "03" { //检查费
  9818. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9819. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9820. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9821. }
  9822. } else {
  9823. if item.MedChrgitmType == "03" { //检查费
  9824. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9825. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9826. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9827. }
  9828. }
  9829. if item.MedChrgitmType == "04" { //化验费
  9830. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9831. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9832. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9833. }
  9834. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9835. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9836. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9837. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9838. }
  9839. if item.MedChrgitmType == "06" { //手术费
  9840. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9841. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9842. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9843. }
  9844. if item.MedChrgitmType == "08" { //材料费
  9845. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9846. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9847. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9848. }
  9849. if item.MedChrgitmType == "09" { //西药费
  9850. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9851. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9852. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9853. }
  9854. if item.MedChrgitmType == "11" { //中成费
  9855. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9856. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9857. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9858. }
  9859. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9860. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9861. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9862. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9863. }
  9864. }
  9865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9866. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9867. var user_name string
  9868. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9869. if role.ID == 0 {
  9870. user_name = "管理员"
  9871. } else {
  9872. user_name = role.UserName
  9873. }
  9874. baseParams := models.BaseParams{
  9875. SecretKey: miConfig.SecretKey,
  9876. FixmedinsCode: miConfig.Code,
  9877. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9878. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9879. OrgName: miConfig.OrgName,
  9880. Doctor: user_name,
  9881. }
  9882. businessParams := models.BusinessParams{
  9883. PsnNo: order.PsnNo,
  9884. MdtrtId: order.MdtrtId,
  9885. SetlId: order.SetlId,
  9886. }
  9887. var res ResultEleven
  9888. var resEleven10265 ResultEleven10265
  9889. if config.IsOpen == 1 {
  9890. if miConfig.MdtrtareaAdmvs == "421300" {
  9891. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9892. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9893. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9894. resp, requestErr := http.Get(api)
  9895. if requestErr != nil {
  9896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9897. return
  9898. }
  9899. body, ioErr := ioutil.ReadAll(resp.Body)
  9900. if ioErr != nil {
  9901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9903. return
  9904. }
  9905. var respJSON map[string]interface{}
  9906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9909. return
  9910. }
  9911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9912. result, _ := json.Marshal(respJSON)
  9913. fmt.Println("log")
  9914. fmt.Println(string(result))
  9915. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9916. utils.ErrorLog("解析失败:%v", err)
  9917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9918. return
  9919. }
  9920. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9921. var api string
  9922. if miConfig.MdtrtareaAdmvs == "320921" {
  9923. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9924. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9925. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9926. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9927. } else {
  9928. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9929. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9930. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9931. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9932. }
  9933. resp, requestErr := http.Get(api)
  9934. if requestErr != nil {
  9935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9936. return
  9937. }
  9938. body, ioErr := ioutil.ReadAll(resp.Body)
  9939. if ioErr != nil {
  9940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. return
  9943. }
  9944. var respJSON map[string]interface{}
  9945. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9948. return
  9949. }
  9950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9951. result, _ := json.Marshal(respJSON)
  9952. fmt.Println("log")
  9953. fmt.Println(string(result))
  9954. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9955. utils.ErrorLog("解析失败:%v", err)
  9956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9957. return
  9958. }
  9959. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9960. res.Output = resEleven10265.Output
  9961. res.ErrMsg = resEleven10265.ErrMsg
  9962. res.Cainfo = resEleven10265.Cainfo
  9963. res.WarnMsg = resEleven10265.WarnMsg
  9964. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9965. res.Infcode = infocode
  9966. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9967. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9968. saveLog(result, requestLog, "5203", "结算单")
  9969. var dat map[string]interface{}
  9970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9971. fmt.Println(dat)
  9972. } else {
  9973. fmt.Println(err)
  9974. }
  9975. userJSONBytes, _ := json.Marshal(dat)
  9976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9977. utils.ErrorLog("解析失败:%v", err)
  9978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9979. return
  9980. }
  9981. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9982. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9983. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9984. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9985. resp, requestErr := http.Get(api)
  9986. if requestErr != nil {
  9987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9988. return
  9989. }
  9990. body, ioErr := ioutil.ReadAll(resp.Body)
  9991. if ioErr != nil {
  9992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9994. return
  9995. }
  9996. var respJSON map[string]interface{}
  9997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10000. return
  10001. }
  10002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10003. result, _ := json.Marshal(respJSON)
  10004. fmt.Println("log")
  10005. fmt.Println(string(result))
  10006. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  10007. utils.ErrorLog("解析失败:%v", err)
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return
  10010. }
  10011. res.InfRefmsgid = resEleven10265.InfRefmsgid
  10012. res.Output = resEleven10265.Output
  10013. res.ErrMsg = resEleven10265.ErrMsg
  10014. res.Cainfo = resEleven10265.Cainfo
  10015. res.WarnMsg = resEleven10265.WarnMsg
  10016. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  10017. res.Infcode = infocode
  10018. } else {
  10019. result := service.Gdyb5203(baseParams, businessParams)
  10020. //service.Gdyb5204(baseParams, businessParams)
  10021. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  10022. var dat map[string]interface{}
  10023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10024. fmt.Println(dat)
  10025. } else {
  10026. fmt.Println(err)
  10027. }
  10028. userJSONBytes, _ := json.Marshal(dat)
  10029. if miConfig.Code == "H15049901371" {
  10030. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  10031. utils.ErrorLog("解析失败:%v", err)
  10032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10033. return
  10034. }
  10035. res.InfRefmsgid = resEleven10265.InfRefmsgid
  10036. res.Output = resEleven10265.Output
  10037. res.ErrMsg = resEleven10265.ErrMsg
  10038. res.Cainfo = resEleven10265.Cainfo
  10039. res.WarnMsg = resEleven10265.WarnMsg
  10040. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  10041. res.Infcode = infocode
  10042. } else {
  10043. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10044. utils.ErrorLog("解析失败:%v", err)
  10045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10046. return
  10047. }
  10048. }
  10049. }
  10050. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10051. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  10052. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  10053. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10054. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  10055. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10056. var doctor_name string
  10057. if roles.ID == 0 {
  10058. doctor_name = "管理员"
  10059. } else {
  10060. doctor_name = roles.UserName
  10061. }
  10062. yiliao_leibie := ""
  10063. switch order.MedType {
  10064. case "11":
  10065. yiliao_leibie = "普通门诊"
  10066. break
  10067. case "12":
  10068. yiliao_leibie = "门诊挂号"
  10069. break
  10070. case "13":
  10071. yiliao_leibie = "急诊"
  10072. break
  10073. case "14":
  10074. yiliao_leibie = "门诊特殊病"
  10075. break
  10076. case "15":
  10077. yiliao_leibie = "门诊统筹"
  10078. break
  10079. case "16":
  10080. yiliao_leibie = "门诊慢性病"
  10081. break
  10082. case "21":
  10083. yiliao_leibie = "普通住院"
  10084. break
  10085. }
  10086. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10087. if res.Infcode == 0 {
  10088. c.ServeSuccessJSON(map[string]interface{}{
  10089. "diagnosis": name,
  10090. "order_infos": orderInfos,
  10091. "number": order.MdtrtId,
  10092. "date": order.SettleAccountsDate,
  10093. "charge_admin": charge_admin,
  10094. "printor_admin": printor_admin,
  10095. "info": res.Output.Setlinfo,
  10096. "order": order,
  10097. "bedCostTotal": bedCostTotal,
  10098. "bedCostSelfTotal": bedCostSelfTotal,
  10099. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  10100. "operationCostTotal": operationCostTotal,
  10101. "operationCostSelfTotal": operationCostSelfTotal,
  10102. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  10103. "otherCostTotal": otherCostTotal,
  10104. "otherCostSelfTotal": otherCostSelfTotal,
  10105. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  10106. "materialCostTotal": materialCostTotal,
  10107. "materialCostSelfTotal": materialCostSelfTotal,
  10108. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  10109. "westernMedicineCostTotal": westernMedicineCostTotal,
  10110. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  10111. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  10112. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  10113. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  10114. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  10115. "checkCostTotal": checkCostTotal,
  10116. "checkCostSelfTotal": checkCostSelfTotal,
  10117. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  10118. "laboratoryCostTotal": laboratoryCostTotal,
  10119. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  10120. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  10121. "treatCostTotal": treatCostTotal,
  10122. "treatCostSelfTotal": treatCostSelfTotal,
  10123. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  10124. "doctor_info": doctor_info,
  10125. "doctor_code": adminRole_two.DoctorCode,
  10126. "doctor_name": doctor_name,
  10127. "health_card_no": order.PsnNo,
  10128. "department": departments.Name,
  10129. "yiliao_leibie": yiliao_leibie,
  10130. "after_money": order.AccountPrice,
  10131. "patient": patient,
  10132. "org_name": miConfig.OrgName,
  10133. "org_code": miConfig.Code,
  10134. "order_number": order.Number,
  10135. "his_hospital": his_hospital,
  10136. "his": his,
  10137. "dia_config": dia_config,
  10138. //"check_order_info": cus_slice,
  10139. })
  10140. }
  10141. }
  10142. }
  10143. func (c *HisApiController) CheckTreatment() {
  10144. patient_id, _ := c.GetInt64("patient_id")
  10145. id_card_no := c.GetString("id_card_no")
  10146. insutype := c.GetString("insutype")
  10147. med_type := c.GetString("med_type")
  10148. admin_user_id, _ := c.GetInt64("admin_user_id")
  10149. adminUser := c.GetAdminUserInfo()
  10150. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10151. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10152. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10153. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10154. if miConfig.MdtrtareaAdmvs == "421300" {
  10155. var res ResultTwo
  10156. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  10157. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10158. "&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)
  10159. resp, requestErr := http.Get(api)
  10160. if requestErr != nil {
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. body, ioErr := ioutil.ReadAll(resp.Body)
  10165. if ioErr != nil {
  10166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10168. return
  10169. }
  10170. var respJSON map[string]interface{}
  10171. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10174. return
  10175. }
  10176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10177. result, _ := json.Marshal(respJSON)
  10178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10179. utils.ErrorLog("解析失败:%v", err)
  10180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10181. return
  10182. }
  10183. if res.Infcode == 0 {
  10184. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  10185. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10186. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  10187. resp, requestErr := http.Get(api)
  10188. if requestErr != nil {
  10189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10190. return
  10191. }
  10192. body, ioErr := ioutil.ReadAll(resp.Body)
  10193. if ioErr != nil {
  10194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10196. return
  10197. }
  10198. var respJSON map[string]interface{}
  10199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10202. return
  10203. }
  10204. var res Result2001
  10205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10206. result2, _ := json.Marshal(respJSON)
  10207. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10208. utils.ErrorLog("解析失败:%v", err)
  10209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10210. return
  10211. }
  10212. if res.Infcode == 0 {
  10213. c.ServeSuccessJSON(map[string]interface{}{
  10214. "msg": res.Output.Trtinfo,
  10215. })
  10216. }
  10217. } else {
  10218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10219. return
  10220. }
  10221. } else {
  10222. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10223. var dat map[string]interface{}
  10224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10225. fmt.Println(dat)
  10226. } else {
  10227. fmt.Println(err)
  10228. }
  10229. userJSONBytes, _ := json.Marshal(dat)
  10230. var res ResultTwo
  10231. var res10265 ResultTwo10265
  10232. if miConfig.Code == "H15049901371" {
  10233. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10234. utils.ErrorLog("解析失败:%v", err)
  10235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10236. return
  10237. }
  10238. res.ErrMsg = res10265.ErrMsg
  10239. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10240. res.Infcode = infocode
  10241. res.Output = res10265.Output
  10242. res.InfRefmsgid = res10265.InfRefmsgid
  10243. } else {
  10244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10245. utils.ErrorLog("解析失败:%v", err)
  10246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10247. return
  10248. }
  10249. }
  10250. var user_name string
  10251. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10252. if role.ID == 0 {
  10253. user_name = "xxx"
  10254. } else {
  10255. user_name = role.UserName
  10256. }
  10257. baseParams := models.BaseParams{
  10258. SecretKey: miConfig.SecretKey,
  10259. FixmedinsCode: miConfig.Code,
  10260. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10261. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10262. OrgName: miConfig.OrgName,
  10263. Doctor: user_name,
  10264. }
  10265. if config.IsOpen == 1 {
  10266. if miConfig.Code == "H15049901371" {
  10267. if med_type == "14" {
  10268. if insutype == "390" {
  10269. med_type = "9933"
  10270. } else if insutype == "310" {
  10271. med_type = "990502"
  10272. }
  10273. } else if med_type == "11" {
  10274. med_type = "11"
  10275. }
  10276. }
  10277. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10278. var dat map[string]interface{}
  10279. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10280. fmt.Println(dat)
  10281. } else {
  10282. fmt.Println(err)
  10283. }
  10284. var res Result2001
  10285. var res10265 Result2001Org10265
  10286. if miConfig.Code == "H15049901371" {
  10287. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10288. utils.ErrorLog("解析失败:%v", err)
  10289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10290. return
  10291. }
  10292. res.ErrMsg = res10265.ErrMsg
  10293. res.Output = res10265.Output
  10294. res.InfRefmsgid = res10265.InfRefmsgid
  10295. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10296. res.Infcode = infocode
  10297. } else {
  10298. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10299. utils.ErrorLog("解析失败:%v", err)
  10300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10301. return
  10302. }
  10303. }
  10304. if res.Infcode == 0 {
  10305. c.ServeSuccessJSON(map[string]interface{}{
  10306. "msg": res.Output.Trtinfo,
  10307. })
  10308. }
  10309. }
  10310. }
  10311. }
  10312. //func (c *HisApiController) PutRecord() {
  10313. // id, _ := c.GetInt64("id")
  10314. // record_time := c.GetString("record_time")
  10315. // timeLayout := "2006-01-02"
  10316. // loc, _ := time.LoadLocation("Local")
  10317. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10318. // if err != nil {
  10319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10320. // return
  10321. // }
  10322. // recordDateTime := theTime.Unix()
  10323. //
  10324. // adminInfo := c.GetAdminUserInfo()
  10325. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10326. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10327. //
  10328. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10329. //
  10330. // fmt.Println(miConfig.SecretKey)
  10331. //
  10332. // if patient == nil {
  10333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10334. // return
  10335. // }
  10336. // if len(patient.IdCardNo) == 0 {
  10337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10338. // return
  10339. // }
  10340. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10341. // if config.IsOpen == 1 {
  10342. // 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
  10343. // resp, requestErr := http.Get(api)
  10344. // if requestErr != nil {
  10345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10346. // return
  10347. // }
  10348. // defer resp.Body.Close()
  10349. // body, ioErr := ioutil.ReadAll(resp.Body)
  10350. // if ioErr != nil {
  10351. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10353. // return
  10354. // }
  10355. // var respJSON map[string]interface{}
  10356. //
  10357. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10358. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10360. // return
  10361. // }
  10362. //
  10363. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10364. // userJSONBytes, _ := json.Marshal(userJSON)
  10365. // var res ResultTwo
  10366. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10367. // utils.ErrorLog("解析失败:%v", err)
  10368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10369. // return
  10370. // }
  10371. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10372. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10373. // infoStr := string(Iinfos)
  10374. // idetinfoStr := string(Idetinfos)
  10375. //
  10376. // if res.Infcode == 0 {
  10377. // his := models.VMHisPatient{
  10378. // Status: 1,
  10379. // Ctime: time.Now().Unix(),
  10380. // Mtime: time.Now().Unix(),
  10381. // PsnNo: res.Output.Baseinfo.PsnNo,
  10382. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10383. // Certno: res.Output.Baseinfo.Certno,
  10384. // PsnName: res.Output.Baseinfo.PsnName,
  10385. // Gend: res.Output.Baseinfo.Gend,
  10386. // Naty: res.Output.Baseinfo.Naty,
  10387. // Brdy: res.Output.Baseinfo.Brdy,
  10388. // Age: res.Output.Baseinfo.Age,
  10389. // Iinfo: infoStr,
  10390. // Idetinfo: idetinfoStr,
  10391. // PatientId: patient.ID,
  10392. // RecordDate: theTime.Unix(),
  10393. // UserOrgId: adminInfo.CurrentOrgId,
  10394. // AdminUserId: adminInfo.AdminUser.Id,
  10395. // IsReturn: 1,
  10396. // }
  10397. //
  10398. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10399. // //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")
  10400. // //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")
  10401. //
  10402. // //var dat map[string]interface{}
  10403. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10404. // // fmt.Println(dat)
  10405. // //} else {
  10406. // // fmt.Println(err)
  10407. // //}
  10408. //
  10409. // var dat2 map[string]interface{}
  10410. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10411. // fmt.Println(dat2)
  10412. // } else {
  10413. // fmt.Println(err)
  10414. // }
  10415. //
  10416. // } else {
  10417. // adminUser := c.GetAdminUserInfo()
  10418. // errlog := &models.HisOrderError{
  10419. // UserOrgId: adminUser.CurrentOrgId,
  10420. // Ctime: time.Now().Unix(),
  10421. // Mtime: time.Now().Unix(),
  10422. // ErrMsg: res.ErrMsg,
  10423. // Status: 1,
  10424. // PatientId: id,
  10425. // RecordTime: recordDateTime,
  10426. // Stage: 1,
  10427. // }
  10428. // service.CreateErrMsgLog(errlog)
  10429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10430. // return
  10431. // }
  10432. // }
  10433. //
  10434. //}
  10435. //func (c *HisApiController) GetUploadDiag() {
  10436. // id, _ := c.GetInt64("id")
  10437. // record_time := c.GetString("record_time")
  10438. //
  10439. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10440. // sick_type, _ := c.GetInt64("sick_type")
  10441. // reg_type, _ := c.GetInt64("reg_type")
  10442. //
  10443. // timeLayout := "2006-01-02"
  10444. // loc, _ := time.LoadLocation("Local")
  10445. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10446. // if err != nil {
  10447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10448. // return
  10449. // }
  10450. //
  10451. // var patientPrescription models.HisPrescriptionInfo
  10452. // recordDateTime := theTime.Unix()
  10453. // adminInfo := c.GetAdminUserInfo()
  10454. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10455. //
  10456. // if patientPrescription.ID == 0 {
  10457. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10458. // }
  10459. //
  10460. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10461. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10462. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10463. // sickConfig, _ := service.FindSickById(sick_type)
  10464. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10465. //
  10466. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10467. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10468. // "&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 +
  10469. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10470. // resp2, requestErr2 := http.Get(api2)
  10471. // if requestErr2 != nil {
  10472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10473. // return
  10474. // }
  10475. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10476. // if ioErr2 != nil {
  10477. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10479. // return
  10480. // }
  10481. // var respJSON2 map[string]interface{}
  10482. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10483. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10485. // return
  10486. // }
  10487. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10488. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10489. //
  10490. // var res2 ResultSix
  10491. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10492. // utils.ErrorLog("解析失败:%v", err)
  10493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10494. // return
  10495. // }
  10496. // if res2.Infcode != 0 {
  10497. // adminUser := c.GetAdminUserInfo()
  10498. // errlog := &models.HisOrderError{
  10499. // UserOrgId: adminUser.CurrentOrgId,
  10500. // Ctime: time.Now().Unix(),
  10501. // Mtime: time.Now().Unix(),
  10502. // ErrMsg: res2.ErrMsg,
  10503. // Status: 1,
  10504. // PatientId: id,
  10505. // RecordTime: recordDateTime,
  10506. // Stage: 3,
  10507. // }
  10508. // service.CreateErrMsgLog(errlog)
  10509. //
  10510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10511. // return
  10512. // }
  10513. //
  10514. // c.ServeSuccessJSON(map[string]interface{}{
  10515. // "msg": "上传成功",
  10516. // })
  10517. //
  10518. //}
  10519. type QueryResult struct {
  10520. ID int64
  10521. Name string
  10522. Code string
  10523. List_type_code string
  10524. }
  10525. func (c *HisApiController) GetCheckCode() {
  10526. ids_str := c.GetString("ids")
  10527. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10528. ids_arr := strings.Split(ids_str, ",")
  10529. var queryResult []QueryResult
  10530. ids := make([]int64, 0)
  10531. for _, item := range ids_arr {
  10532. id, _ := strconv.ParseInt(item, 10, 64)
  10533. ids = append(ids, id)
  10534. }
  10535. if record_type == 1 {
  10536. drugs, _ := service.GetBatchDrugList(ids)
  10537. for _, item := range drugs {
  10538. result := QueryResult{
  10539. ID: item.ID,
  10540. Name: item.DrugName,
  10541. Code: item.MedicalInsuranceNumber,
  10542. List_type_code: "101",
  10543. }
  10544. queryResult = append(queryResult, result)
  10545. }
  10546. } else if record_type == 2 {
  10547. goods, _ := service.GetBatchGoodInformationList(ids)
  10548. for _, item := range goods {
  10549. result := QueryResult{
  10550. ID: item.ID,
  10551. Name: item.GoodName,
  10552. Code: item.MedicalInsuranceNumber,
  10553. List_type_code: "301",
  10554. }
  10555. queryResult = append(queryResult, result)
  10556. }
  10557. } else if record_type == 3 {
  10558. projects, _ := service.GetBathchMyPorjecgList(ids)
  10559. for _, item := range projects {
  10560. result := QueryResult{
  10561. ID: item.ID,
  10562. Name: item.ProjectName,
  10563. Code: item.MedicalCode,
  10564. List_type_code: "201",
  10565. }
  10566. queryResult = append(queryResult, result)
  10567. }
  10568. }
  10569. admin_user_id, _ := c.GetInt64("admin_user_id")
  10570. adminUser := c.GetAdminUserInfo()
  10571. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10572. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10573. var user_name string
  10574. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10575. if role.ID == 0 {
  10576. user_name = "xxx"
  10577. } else {
  10578. user_name = role.UserName
  10579. }
  10580. baseParams := &models.BaseParams{
  10581. SecretKey: miConfig.SecretKey,
  10582. FixmedinsCode: miConfig.Code,
  10583. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10584. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10585. OrgName: miConfig.OrgName,
  10586. Doctor: user_name,
  10587. }
  10588. if config.IsOpen == 1 {
  10589. for _, item := range queryResult {
  10590. var result string
  10591. if record_type == 1 {
  10592. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10593. } else if record_type == 2 {
  10594. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10595. } else if record_type == 3 {
  10596. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10597. }
  10598. var dat map[string]interface{}
  10599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10600. fmt.Println(dat)
  10601. } else {
  10602. fmt.Println(err)
  10603. }
  10604. userJSONBytes, _ := json.Marshal(dat)
  10605. var res ResultSix
  10606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10607. utils.ErrorLog("解析失败:%v", err)
  10608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10609. return
  10610. }
  10611. if res.Infcode == 0 {
  10612. if record_type == 1 {
  10613. service.UpdateBaseDrugById(item.ID)
  10614. } else if record_type == 2 {
  10615. service.UpdateGoodInformaitonByDetail(item.ID)
  10616. } else if record_type == 3 {
  10617. service.UpdateProjectById(item.ID)
  10618. }
  10619. c.ServeSuccessJSON(map[string]interface{}{
  10620. "failed_code": 0,
  10621. "msg": "目录对照成功",
  10622. })
  10623. } else {
  10624. c.ServeSuccessJSON(map[string]interface{}{
  10625. "failed_code": -10,
  10626. "msg": res.ErrMsg,
  10627. })
  10628. }
  10629. }
  10630. }
  10631. }
  10632. func (c *HisApiController) UnCheckCode() {
  10633. ids_str := c.GetString("ids")
  10634. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10635. admin_user_id, _ := c.GetInt64("admin_user_id")
  10636. ids_arr := strings.Split(ids_str, ",")
  10637. var queryResult []QueryResult
  10638. ids := make([]int64, 0)
  10639. for _, item := range ids_arr {
  10640. id, _ := strconv.ParseInt(item, 10, 64)
  10641. ids = append(ids, id)
  10642. }
  10643. if record_type == 1 {
  10644. drugs, _ := service.GetBatchDrugList(ids)
  10645. for _, item := range drugs {
  10646. result := QueryResult{
  10647. ID: item.ID,
  10648. Name: item.DrugName,
  10649. Code: item.MedicalInsuranceNumber,
  10650. List_type_code: "101",
  10651. }
  10652. queryResult = append(queryResult, result)
  10653. }
  10654. } else if record_type == 2 {
  10655. goods, _ := service.GetBatchGoodInformationList(ids)
  10656. for _, item := range goods {
  10657. result := QueryResult{
  10658. ID: item.ID,
  10659. Name: item.GoodName,
  10660. Code: item.MedicalInsuranceNumber,
  10661. List_type_code: "301",
  10662. }
  10663. queryResult = append(queryResult, result)
  10664. }
  10665. } else if record_type == 3 {
  10666. projects, _ := service.GetBathchMyPorjecgList(ids)
  10667. for _, item := range projects {
  10668. result := QueryResult{
  10669. ID: item.ID,
  10670. Name: item.ProjectName,
  10671. Code: item.MedicalCode,
  10672. List_type_code: "201",
  10673. }
  10674. queryResult = append(queryResult, result)
  10675. }
  10676. }
  10677. adminUser := c.GetAdminUserInfo()
  10678. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10679. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10680. var user_name string
  10681. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10682. if role.ID == 0 {
  10683. user_name = "xxx"
  10684. } else {
  10685. user_name = role.UserName
  10686. }
  10687. baseParams := &models.BaseParams{
  10688. SecretKey: miConfig.SecretKey,
  10689. FixmedinsCode: miConfig.Code,
  10690. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10691. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10692. OrgName: miConfig.OrgName,
  10693. Doctor: user_name,
  10694. }
  10695. if config.IsOpen == 1 {
  10696. for _, item := range queryResult {
  10697. var result string
  10698. if record_type == 1 {
  10699. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10700. } else if record_type == 2 {
  10701. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10702. } else if record_type == 3 {
  10703. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10704. }
  10705. var dat2 map[string]interface{}
  10706. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10707. fmt.Println(dat2)
  10708. } else {
  10709. fmt.Println(err)
  10710. }
  10711. userJSONBytes, _ := json.Marshal(dat2)
  10712. var res ResultSix
  10713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10714. utils.ErrorLog("解析失败:%v", err)
  10715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10716. return
  10717. }
  10718. if res.Infcode == 0 {
  10719. if record_type == 1 {
  10720. service.UpdateDrugByIdDetail(item.ID)
  10721. } else if record_type == 2 {
  10722. service.UpdateGoodInfoById(item.ID)
  10723. } else if record_type == 3 {
  10724. service.UpdateMyProjectById(item.ID)
  10725. }
  10726. c.ServeSuccessJSON(map[string]interface{}{
  10727. "failed_code": 0,
  10728. "msg": "撤销目录对照成功",
  10729. })
  10730. } else {
  10731. c.ServeSuccessJSON(map[string]interface{}{
  10732. "failed_code": -10,
  10733. "msg": res.ErrMsg,
  10734. })
  10735. }
  10736. }
  10737. }
  10738. }
  10739. func (c *HisApiController) GetPatientInfo() {
  10740. id_card_no := c.GetString("id_card_no")
  10741. admin_user_id, _ := c.GetInt64("admin_user_id")
  10742. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10743. if patient.ID == 0 {
  10744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10745. return
  10746. }
  10747. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10748. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10749. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10750. if config.IsOpen == 1 {
  10751. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10752. var dat map[string]interface{}
  10753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10754. fmt.Println(dat)
  10755. } else {
  10756. fmt.Println(err)
  10757. }
  10758. userJSONBytes, _ := json.Marshal(dat)
  10759. var res ResultTwo
  10760. var res10265 ResultTwo10265
  10761. if miConfig.Code == "H15049901371" {
  10762. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10763. utils.ErrorLog("解析失败:%v", err)
  10764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10765. return
  10766. }
  10767. res.ErrMsg = res10265.ErrMsg
  10768. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10769. res.Infcode = infocode
  10770. res.Output = res10265.Output
  10771. res.InfRefmsgid = res10265.InfRefmsgid
  10772. } else {
  10773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10774. utils.ErrorLog("解析失败:%v", err)
  10775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10776. return
  10777. }
  10778. }
  10779. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10780. // utils.ErrorLog("解析失败:%v", err)
  10781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. // return
  10783. //}
  10784. if res.Infcode != 0 {
  10785. c.ServeSuccessJSON(map[string]interface{}{
  10786. "failed_code": -10,
  10787. "msg": res.ErrMsg,
  10788. })
  10789. } else {
  10790. c.ServeSuccessJSON(map[string]interface{}{
  10791. "failed_code": 0,
  10792. "info": res,
  10793. })
  10794. }
  10795. }
  10796. }
  10797. func (c *HisApiController) PsnPutOnRecord() {
  10798. record_type, _ := c.GetInt64("type")
  10799. patient_id, _ := c.GetInt64("patient_id")
  10800. admin_user_id, _ := c.GetInt64("admin_user_id")
  10801. start_time := c.GetString("start_time")
  10802. end_time := c.GetString("end_time")
  10803. adminUser := c.GetAdminUserInfo()
  10804. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10805. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10806. var patients []*models.Patients
  10807. if record_type == 1 { //全部备案
  10808. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10809. patients = append(patients, patient...)
  10810. } else { //单个备案
  10811. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10812. patients = append(patients, patient)
  10813. }
  10814. var user_name string
  10815. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10816. if role.ID == 0 {
  10817. user_name = "xxx"
  10818. } else {
  10819. user_name = role.UserName
  10820. }
  10821. if config.IsOpen == 1 {
  10822. for _, item := range patients {
  10823. 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
  10824. resp, requestErr := http.Get(api)
  10825. if requestErr != nil {
  10826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10827. return
  10828. }
  10829. defer resp.Body.Close()
  10830. body, ioErr := ioutil.ReadAll(resp.Body)
  10831. if ioErr != nil {
  10832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10834. return
  10835. }
  10836. var respJSON map[string]interface{}
  10837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10840. return
  10841. }
  10842. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10843. userJSONBytes, _ := json.Marshal(userJSON)
  10844. var res ResultTwo
  10845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10846. utils.ErrorLog("解析失败:%v", err)
  10847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10848. return
  10849. }
  10850. if res.Infcode == 0 {
  10851. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10852. var dat map[string]interface{}
  10853. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10854. fmt.Println(dat)
  10855. } else {
  10856. fmt.Println(err)
  10857. }
  10858. userJSONBytes, _ := json.Marshal(dat)
  10859. var res2 ResultThirteen
  10860. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10861. utils.ErrorLog("解析失败:%v", err)
  10862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10863. return
  10864. }
  10865. if res2.Infcode == 0 {
  10866. psnResult := &models.GdybPsnRecord{
  10867. UserOrgId: adminUser.CurrentOrgId,
  10868. PatientId: item.ID,
  10869. PsnNo: res.Output.Baseinfo.PsnNo,
  10870. Ctime: time.Now().Unix(),
  10871. Mtime: time.Now().Unix(),
  10872. Status: 1,
  10873. IsCancel: 1,
  10874. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10875. }
  10876. service.CreatePsnRecord(psnResult)
  10877. } else {
  10878. c.ServeSuccessJSON(map[string]interface{}{
  10879. "failed_code": -10,
  10880. "msg": res2.ErrMsg,
  10881. })
  10882. return
  10883. }
  10884. }
  10885. }
  10886. }
  10887. }
  10888. func (c *HisApiController) PsnUnPutOnRecord() {
  10889. id, _ := c.GetInt64("id")
  10890. //record_type, _ := c.GetInt64("type")
  10891. admin_user_id, _ := c.GetInt64("admin_user_id")
  10892. adminUser := c.GetAdminUserInfo()
  10893. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10894. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10895. var user_name string
  10896. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10897. if role.ID == 0 {
  10898. user_name = "xxx"
  10899. } else {
  10900. user_name = role.UserName
  10901. }
  10902. psn_record, _ := service.GetPsnRecordById(id)
  10903. if psn_record.ID == 0 {
  10904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10905. return
  10906. }
  10907. if config.IsOpen == 1 {
  10908. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10909. var dat map[string]interface{}
  10910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10911. fmt.Println(dat)
  10912. } else {
  10913. fmt.Println(err)
  10914. }
  10915. userJSONBytes, _ := json.Marshal(dat)
  10916. var res ResultFourteen
  10917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10918. utils.ErrorLog("解析失败:%v", err)
  10919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10920. return
  10921. }
  10922. if res.Infcode == 0 {
  10923. psn_record.IsCancel = 2
  10924. service.CreatePsnRecord(&psn_record)
  10925. } else {
  10926. c.ServeSuccessJSON(map[string]interface{}{
  10927. "failed_code": -10,
  10928. "msg": res.ErrMsg,
  10929. })
  10930. return
  10931. }
  10932. }
  10933. }
  10934. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10935. patient_id, _ := c.GetInt64("patient_id")
  10936. insutype_two := c.GetString("insutype")
  10937. psn_no := c.GetString("psn_no")
  10938. doctor_id, _ := c.GetInt64("doctor_id")
  10939. sick_id, _ := c.GetInt64("sick_id")
  10940. department_id, _ := c.GetInt64("department_id")
  10941. start_time := c.GetString("start_time")
  10942. end_time := c.GetString("end_time")
  10943. check_time := c.GetString("check_time")
  10944. adminUser := c.GetAdminUserInfo()
  10945. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10946. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10947. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10948. sick, _ := service.FindSickById(sick_id)
  10949. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10950. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10951. var res ResultTwo
  10952. var res10265 ResultTwo10265
  10953. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10954. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10955. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10956. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10957. "&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
  10958. resp, requestErr := http.Get(api)
  10959. if requestErr != nil {
  10960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10961. return
  10962. }
  10963. body, ioErr := ioutil.ReadAll(resp.Body)
  10964. if ioErr != nil {
  10965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10967. return
  10968. }
  10969. var respJSON map[string]interface{}
  10970. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10973. return
  10974. }
  10975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10976. result, _ := json.Marshal(respJSON)
  10977. fmt.Println("log")
  10978. fmt.Println(string(result))
  10979. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10980. utils.ErrorLog("解析失败:%v", err)
  10981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10982. return
  10983. }
  10984. res.ErrMsg = res10265.ErrMsg
  10985. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10986. res.Infcode = infocode
  10987. res.Output = res10265.Output
  10988. res.InfRefmsgid = res10265.InfRefmsgid
  10989. } else {
  10990. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10991. if miConfig.Code == "H15049901371" {
  10992. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10993. utils.ErrorLog("解析失败:%v", err)
  10994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10995. return
  10996. }
  10997. res.ErrMsg = res10265.ErrMsg
  10998. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10999. res.Infcode = infocode
  11000. res.Output = res10265.Output
  11001. res.InfRefmsgid = res10265.InfRefmsgid
  11002. } else {
  11003. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11004. utils.ErrorLog("解析失败:%v", err)
  11005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11006. return
  11007. }
  11008. }
  11009. }
  11010. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11011. infoStr := string(Iinfos)
  11012. var rf []*ResultFive
  11013. json.Unmarshal([]byte(infoStr), &rf)
  11014. var insuplc_admdvs string
  11015. var insutype string
  11016. var is390 int = 0
  11017. var is310 int = 0
  11018. var insutypes []*ResultFive
  11019. for _, item := range rf {
  11020. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11021. insutypes = append(insutypes, item)
  11022. }
  11023. }
  11024. if len(insutypes) == 1 {
  11025. insutype = insutypes[0].Insutype
  11026. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11027. } else {
  11028. for _, i := range insutypes {
  11029. if i.Insutype == "390" {
  11030. is390 = 1
  11031. }
  11032. if i.Insutype == "310" {
  11033. is310 = 1
  11034. }
  11035. }
  11036. }
  11037. if is390 == 1 {
  11038. insutype = "390"
  11039. }
  11040. if is310 == 1 {
  11041. insutype = "310"
  11042. }
  11043. if len(insutypes) == 2 {
  11044. insutype = insutype_two
  11045. }
  11046. if len(insutypes) == 0 {
  11047. insutype = "310"
  11048. }
  11049. insutype = insutype_two
  11050. fmt.Println(insutype)
  11051. for _, item := range rf {
  11052. fmt.Println(item.Insutype)
  11053. fmt.Println(insutype)
  11054. if item.Insutype == insutype {
  11055. fmt.Println(item.Insutype)
  11056. fmt.Println(insutype)
  11057. insuplc_admdvs = item.InsuplcAdmdvs
  11058. }
  11059. }
  11060. fmt.Println(insuplc_admdvs)
  11061. var res2 ResultThirteen
  11062. var res10265_2 ResultThirteen10265
  11063. if config.IsOpen == 1 {
  11064. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11065. } else {
  11066. 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)
  11067. var dat map[string]interface{}
  11068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11069. fmt.Println(dat)
  11070. } else {
  11071. fmt.Println(err)
  11072. }
  11073. userJSONBytes, _ := json.Marshal(dat)
  11074. if miConfig.Code == "H15049901371" {
  11075. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  11076. utils.ErrorLog("解析失败:%v", err)
  11077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11078. return
  11079. }
  11080. res2.ErrMsg = res10265_2.ErrMsg
  11081. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  11082. res2.Infcode = infocode
  11083. res2.Output = res10265_2.Output
  11084. res2.InfRefmsgid = res10265_2.InfRefmsgid
  11085. } else {
  11086. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11087. utils.ErrorLog("解析失败:%v", err)
  11088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11089. return
  11090. }
  11091. }
  11092. }
  11093. if res2.Infcode == 0 {
  11094. psnResult := &models.GdybPsnNcdsRecord{
  11095. UserOrgId: adminUser.CurrentOrgId,
  11096. PatientId: patient.ID,
  11097. PsnNo: psn_no,
  11098. DoctorId: doctor.AdminUserId,
  11099. DepartmentId: department_id,
  11100. SickType: sick_id,
  11101. Insutype: insutype,
  11102. Ctime: time.Now().Unix(),
  11103. Mtime: time.Now().Unix(),
  11104. Status: 1,
  11105. IsCancel: 1,
  11106. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  11107. }
  11108. service.CreatePsnNCDSRecord(psnResult)
  11109. c.ServeSuccessJSON(map[string]interface{}{
  11110. "failed_code": 0,
  11111. "msg": "备案成功",
  11112. "result": psnResult,
  11113. })
  11114. } else {
  11115. c.ServeSuccessJSON(map[string]interface{}{
  11116. "failed_code": -10,
  11117. "msg": res2.ErrMsg,
  11118. })
  11119. return
  11120. }
  11121. }
  11122. }
  11123. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  11124. id, _ := c.GetInt64("id")
  11125. admin_user_id, _ := c.GetInt64("admin_user_id")
  11126. adminUser := c.GetAdminUserInfo()
  11127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11129. //config, _ := service.Ge(adminUser.CurrentOrgId)
  11130. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11131. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11132. //var user_name string
  11133. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11134. //if role.ID == 0 {
  11135. // user_name = "xxx"
  11136. //} else {
  11137. // user_name = role.UserName
  11138. //}
  11139. psn_record, _ := service.GetPsnNCDSRecordById(id)
  11140. if psn_record.ID == 0 {
  11141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11142. return
  11143. }
  11144. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  11145. var res ResultTwo
  11146. var res10265 ResultTwo10265
  11147. if miConfig.Code == "H15049901371" {
  11148. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11149. utils.ErrorLog("解析失败:%v", err)
  11150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11151. return
  11152. }
  11153. res.ErrMsg = res10265.ErrMsg
  11154. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11155. res.Infcode = infocode
  11156. res.Output = res10265.Output
  11157. res.InfRefmsgid = res10265.InfRefmsgid
  11158. } else {
  11159. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11160. utils.ErrorLog("解析失败:%v", err)
  11161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11162. return
  11163. }
  11164. }
  11165. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11166. infoStr := string(Iinfos)
  11167. var rf []*ResultFive
  11168. json.Unmarshal([]byte(infoStr), &rf)
  11169. var insuplc_admdvs string
  11170. var insutype string
  11171. var is390 int = 0
  11172. var is310 int = 0
  11173. var insutypes []*ResultFive
  11174. for _, item := range rf {
  11175. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11176. insutypes = append(insutypes, item)
  11177. }
  11178. }
  11179. if len(insutypes) == 1 {
  11180. insutype = insutypes[0].Insutype
  11181. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11182. } else {
  11183. for _, i := range insutypes {
  11184. if i.Insutype == "390" {
  11185. is390 = 1
  11186. }
  11187. if i.Insutype == "310" {
  11188. is310 = 1
  11189. }
  11190. }
  11191. }
  11192. if is390 == 1 {
  11193. insutype = "390"
  11194. }
  11195. if is310 == 1 {
  11196. insutype = "310"
  11197. }
  11198. if len(insutypes) == 0 {
  11199. insutype = "310"
  11200. }
  11201. insutype = psn_record.Insutype
  11202. for _, item := range rf {
  11203. if item.Insutype == insutype {
  11204. insuplc_admdvs = item.InsuplcAdmdvs
  11205. }
  11206. }
  11207. if config.IsOpen == 1 {
  11208. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11209. var dat map[string]interface{}
  11210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11211. fmt.Println(dat)
  11212. } else {
  11213. fmt.Println(err)
  11214. }
  11215. userJSONBytes, _ := json.Marshal(dat)
  11216. var res ResultFourteen
  11217. var res10265 ResultFourteen10265
  11218. if miConfig.Code == "H15049901371" {
  11219. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11220. utils.ErrorLog("解析失败:%v", err)
  11221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11222. return
  11223. }
  11224. res.ErrMsg = res10265.ErrMsg
  11225. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11226. res.Infcode = infocode
  11227. res.Output = res10265.Output
  11228. res.InfRefmsgid = res10265.InfRefmsgid
  11229. } else {
  11230. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11231. utils.ErrorLog("解析失败:%v", err)
  11232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11233. return
  11234. }
  11235. }
  11236. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11237. // utils.ErrorLog("解析失败:%v", err)
  11238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11239. // return
  11240. //}
  11241. if res.Infcode == 0 {
  11242. psn_record.IsCancel = 2
  11243. service.CreatePsnNCDSRecord(&psn_record)
  11244. c.ServeSuccessJSON(map[string]interface{}{
  11245. "failed_code": 0,
  11246. "msg": "撤销备案成功",
  11247. })
  11248. } else {
  11249. c.ServeSuccessJSON(map[string]interface{}{
  11250. "failed_code": -10,
  11251. "msg": res.ErrMsg,
  11252. })
  11253. return
  11254. }
  11255. }
  11256. }
  11257. func (c *HisApiController) TestTest() {
  11258. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11259. fmt.Println(patient.Iinfo)
  11260. }
  11261. type CustomData struct {
  11262. MsgId string
  11263. PsnNo string
  11264. Info string
  11265. }
  11266. func (c *HisApiController) ReversalData() {
  11267. var customData []*CustomData
  11268. custom := &CustomData{
  11269. MsgId: "H44022900158202103301714472004",
  11270. PsnNo: "44020000001101329945",
  11271. Info: "2207",
  11272. }
  11273. customData = append(customData, custom)
  11274. custom1 := &CustomData{
  11275. MsgId: "H4402290015820210330172057803",
  11276. PsnNo: "44020000001101161813",
  11277. Info: "2207",
  11278. }
  11279. customData = append(customData, custom1)
  11280. custom2 := &CustomData{
  11281. MsgId: "H44022900158202103301705198813",
  11282. PsnNo: "44190000133097375417",
  11283. Info: "2207",
  11284. }
  11285. customData = append(customData, custom2)
  11286. custom3 := &CustomData{
  11287. MsgId: "H44022900158202103301715524756",
  11288. PsnNo: "44020000001100187221",
  11289. Info: "2207",
  11290. }
  11291. customData = append(customData, custom3)
  11292. custom4 := &CustomData{
  11293. MsgId: "H44022900158202103301730376224",
  11294. PsnNo: "44020000001101959155",
  11295. Info: "2207",
  11296. }
  11297. customData = append(customData, custom4)
  11298. custom5 := &CustomData{
  11299. MsgId: "H44022900158202103301748008725",
  11300. PsnNo: "44020000001104246641",
  11301. Info: "2207",
  11302. }
  11303. customData = append(customData, custom5)
  11304. custom6 := &CustomData{
  11305. MsgId: "H44022900158202103301718096755",
  11306. PsnNo: "44020000001102211860",
  11307. Info: "2207",
  11308. }
  11309. customData = append(customData, custom6)
  11310. custom7 := &CustomData{
  11311. MsgId: "H44022900158202103301736551640",
  11312. PsnNo: "44020000001102687718",
  11313. Info: "2207",
  11314. }
  11315. customData = append(customData, custom7)
  11316. custom8 := &CustomData{
  11317. MsgId: "H44022900158202103301743097676",
  11318. PsnNo: "44020000001102127785",
  11319. Info: "2207",
  11320. }
  11321. customData = append(customData, custom8)
  11322. custom9 := &CustomData{
  11323. MsgId: "H44022900158202103301712304203",
  11324. PsnNo: "44020000001101518097",
  11325. Info: "2207",
  11326. }
  11327. customData = append(customData, custom9)
  11328. custom10 := &CustomData{
  11329. MsgId: "H44022900158202103301738448785",
  11330. PsnNo: "44020000001100500813",
  11331. Info: "2207",
  11332. }
  11333. customData = append(customData, custom10)
  11334. custom11 := &CustomData{
  11335. MsgId: "H44022900158202103301732455843",
  11336. PsnNo: "44020000001102690557",
  11337. Info: "2207",
  11338. }
  11339. customData = append(customData, custom11)
  11340. custom12 := &CustomData{
  11341. MsgId: "H44022900158202103301745421708",
  11342. PsnNo: "44020000001102211928",
  11343. Info: "2207",
  11344. }
  11345. customData = append(customData, custom12)
  11346. custom1212 := &CustomData{
  11347. MsgId: "H440229001582021033017351627",
  11348. PsnNo: "44020000001102481733",
  11349. Info: "2207",
  11350. }
  11351. customData = append(customData, custom1212)
  11352. custom13 := &CustomData{
  11353. MsgId: "H44022900158202103301740327951",
  11354. PsnNo: "44020000001103174866",
  11355. Info: "2207",
  11356. }
  11357. customData = append(customData, custom13)
  11358. custom14 := &CustomData{
  11359. MsgId: "H4402290015820210330174922668",
  11360. PsnNo: "44020000001102927272",
  11361. Info: "2207",
  11362. }
  11363. customData = append(customData, custom14)
  11364. custom15 := &CustomData{
  11365. MsgId: "H44022900158202103301752362273",
  11366. PsnNo: "44020000001102942890",
  11367. Info: "2207",
  11368. }
  11369. customData = append(customData, custom15)
  11370. custom16 := &CustomData{
  11371. MsgId: "H44022900158202103301751082917",
  11372. PsnNo: "44020000001101662162",
  11373. Info: "2207",
  11374. }
  11375. customData = append(customData, custom16)
  11376. custom17 := &CustomData{
  11377. MsgId: "H44022900158202103301754147728",
  11378. PsnNo: "44020000000229014511",
  11379. Info: "2207",
  11380. }
  11381. customData = append(customData, custom17)
  11382. adminUser := c.GetAdminUserInfo()
  11383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11384. for _, item := range customData {
  11385. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11386. fmt.Println(result)
  11387. }
  11388. }
  11389. //func (c *HisApiController) GetAllopatry() {
  11390. // year := c.GetString("year")
  11391. // month := c.GetString("month")
  11392. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11393. // adminUser := c.GetAdminUserInfo()
  11394. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11395. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11396. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11397. //
  11398. // var dat map[string]interface{}
  11399. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11400. // fmt.Println(dat)
  11401. // } else {
  11402. // fmt.Println(err)
  11403. // }
  11404. // userJSONBytes, _ := json.Marshal(dat)
  11405. // var res models.Result9001
  11406. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11407. // utils.ErrorLog("解析失败:%v", err)
  11408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11409. // return
  11410. // }
  11411. //
  11412. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11413. // var dat2 map[string]interface{}
  11414. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11415. // fmt.Println(dat)
  11416. // } else {
  11417. // fmt.Println(err)
  11418. // }
  11419. // userJSONBytes2, _ := json.Marshal(dat2)
  11420. // var res2 models.Result3260
  11421. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11422. // utils.ErrorLog("解析失败:%v", err)
  11423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11424. // return
  11425. // }
  11426. // if res2.Infcode == 0 {
  11427. // c.ServeSuccessJSON(map[string]interface{}{
  11428. // "list": res2.Output.Data,
  11429. // })
  11430. // return
  11431. // } else {
  11432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11433. // return
  11434. // }
  11435. //
  11436. //}
  11437. //func (c *HisApiController) ComfirmAllopatry() {
  11438. // year := c.GetString("year")
  11439. // month := c.GetString("month")
  11440. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11441. // adminUser := c.GetAdminUserInfo()
  11442. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11443. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11444. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11445. // var dat map[string]interface{}
  11446. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11447. // fmt.Println(dat)
  11448. // } else {
  11449. // fmt.Println(err)
  11450. // }
  11451. // userJSONBytes, _ := json.Marshal(dat)
  11452. // var res models.Result9001
  11453. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11454. // utils.ErrorLog("解析失败:%v", err)
  11455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11456. // return
  11457. // }
  11458. //
  11459. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11460. // var dat2 map[string]interface{}
  11461. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11462. // fmt.Println(dat)
  11463. // } else {
  11464. // fmt.Println(err)
  11465. // }
  11466. // userJSONBytes2, _ := json.Marshal(dat2)
  11467. // var res2 models.Result3260
  11468. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11469. // utils.ErrorLog("解析失败:%v", err)
  11470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11471. // return
  11472. // }
  11473. //
  11474. // if res2.Infcode == 0 {
  11475. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11476. // var dat map[string]interface{}
  11477. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11478. // fmt.Println(dat)
  11479. // } else {
  11480. // fmt.Println(err)
  11481. // }
  11482. // userJSONBytes, _ := json.Marshal(dat)
  11483. // var res3 models.Result3261
  11484. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11485. // utils.ErrorLog("解析失败:%v", err)
  11486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11487. // return
  11488. // }
  11489. //
  11490. // if res3.Infcode == 0 {
  11491. // record := &models.HisYidiClearRecord{
  11492. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11493. // Ctime: time.Now().Unix(),
  11494. // Mtime: time.Now().Unix(),
  11495. // Status: 1,
  11496. // MsgId: msgId,
  11497. // }
  11498. // service.SaveClearRecord(record)
  11499. // c.ServeSuccessJSON(map[string]interface{}{
  11500. // "msg": "提取成功",
  11501. // })
  11502. // }
  11503. // }
  11504. //}
  11505. func (c *HisApiController) RefundAllopatry() {
  11506. year := c.GetString("year")
  11507. month := c.GetString("month")
  11508. id, _ := c.GetInt64("id")
  11509. admin_user_id, _ := c.GetInt64("admin_user_id")
  11510. adminUser := c.GetAdminUserInfo()
  11511. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11512. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11513. record, _ := service.GetClearRecordById(id)
  11514. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11515. var dat map[string]interface{}
  11516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11517. fmt.Println(dat)
  11518. } else {
  11519. fmt.Println(err)
  11520. }
  11521. userJSONBytes, _ := json.Marshal(dat)
  11522. var empty ResultFourteen
  11523. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11524. utils.ErrorLog("解析失败:%v", err)
  11525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11526. return
  11527. }
  11528. if empty.Infcode == 0 {
  11529. c.ServeSuccessJSON(map[string]interface{}{
  11530. "msg": "撤销成功",
  11531. })
  11532. return
  11533. }
  11534. }
  11535. func (c *HisApiController) ReversalOtherData() {
  11536. var customData []*CustomData
  11537. custom := &CustomData{
  11538. MsgId: "H44022900158202103301714472004",
  11539. PsnNo: "44020000001101329945",
  11540. Info: "2208",
  11541. }
  11542. customData = append(customData, custom)
  11543. custom1 := &CustomData{
  11544. MsgId: "H4402290015820210330172057803",
  11545. PsnNo: "44020000001101161813",
  11546. Info: "2208",
  11547. }
  11548. customData = append(customData, custom1)
  11549. custom2 := &CustomData{
  11550. MsgId: "H44022900158202103301705198813",
  11551. PsnNo: "44190000133097375417",
  11552. Info: "2208",
  11553. }
  11554. customData = append(customData, custom2)
  11555. custom3 := &CustomData{
  11556. MsgId: "H44022900158202103301715524756",
  11557. PsnNo: "44020000001100187221",
  11558. Info: "2208",
  11559. }
  11560. customData = append(customData, custom3)
  11561. custom4 := &CustomData{
  11562. MsgId: "H44022900158202103301730376224",
  11563. PsnNo: "44020000001101959155",
  11564. Info: "2208",
  11565. }
  11566. customData = append(customData, custom4)
  11567. custom5 := &CustomData{
  11568. MsgId: "H44022900158202103301748008725",
  11569. PsnNo: "44020000001104246641",
  11570. Info: "2208",
  11571. }
  11572. customData = append(customData, custom5)
  11573. custom6 := &CustomData{
  11574. MsgId: "H44022900158202103301718096755",
  11575. PsnNo: "44020000001102211860",
  11576. Info: "2208",
  11577. }
  11578. customData = append(customData, custom6)
  11579. custom7 := &CustomData{
  11580. MsgId: "H44022900158202103301736551640",
  11581. PsnNo: "44020000001102687718",
  11582. Info: "2208",
  11583. }
  11584. customData = append(customData, custom7)
  11585. custom8 := &CustomData{
  11586. MsgId: "H44022900158202103301743097676",
  11587. PsnNo: "44020000001102127785",
  11588. Info: "2208",
  11589. }
  11590. customData = append(customData, custom8)
  11591. custom9 := &CustomData{
  11592. MsgId: "H44022900158202103301712304203",
  11593. PsnNo: "44020000001101518097",
  11594. Info: "2208",
  11595. }
  11596. customData = append(customData, custom9)
  11597. custom10 := &CustomData{
  11598. MsgId: "H44022900158202103301738448785",
  11599. PsnNo: "44020000001100500813",
  11600. Info: "2208",
  11601. }
  11602. customData = append(customData, custom10)
  11603. custom11 := &CustomData{
  11604. MsgId: "H44022900158202103301732455843",
  11605. PsnNo: "44020000001102690557",
  11606. Info: "2208",
  11607. }
  11608. customData = append(customData, custom11)
  11609. custom12 := &CustomData{
  11610. MsgId: "H44022900158202103301745421708",
  11611. PsnNo: "44020000001102211928",
  11612. Info: "2208",
  11613. }
  11614. customData = append(customData, custom12)
  11615. custom1212 := &CustomData{
  11616. MsgId: "H440229001582021033017351627",
  11617. PsnNo: "44020000001102481733",
  11618. Info: "2208",
  11619. }
  11620. customData = append(customData, custom1212)
  11621. custom13 := &CustomData{
  11622. MsgId: "H44022900158202103301740327951",
  11623. PsnNo: "44020000001103174866",
  11624. Info: "2208",
  11625. }
  11626. customData = append(customData, custom13)
  11627. custom14 := &CustomData{
  11628. MsgId: "H4402290015820210330174922668",
  11629. PsnNo: "44020000001102927272",
  11630. Info: "2208",
  11631. }
  11632. customData = append(customData, custom14)
  11633. custom15 := &CustomData{
  11634. MsgId: "H44022900158202103301752362273",
  11635. PsnNo: "44020000001102942890",
  11636. Info: "2208",
  11637. }
  11638. customData = append(customData, custom15)
  11639. custom16 := &CustomData{
  11640. MsgId: "H44022900158202103301751082917",
  11641. PsnNo: "44020000001101662162",
  11642. Info: "2208",
  11643. }
  11644. customData = append(customData, custom16)
  11645. custom17 := &CustomData{
  11646. MsgId: "H44022900158202103301754147728",
  11647. PsnNo: "44020000000229014511",
  11648. Info: "2208",
  11649. }
  11650. customData = append(customData, custom17)
  11651. adminUser := c.GetAdminUserInfo()
  11652. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11653. for _, item := range customData {
  11654. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11655. fmt.Println(result)
  11656. }
  11657. }
  11658. func PathExists(path string) (bool, error) {
  11659. _, err := os.Stat(path)
  11660. if err == nil {
  11661. return true, nil
  11662. }
  11663. if os.IsNotExist(err) {
  11664. return false, nil
  11665. }
  11666. return false, err
  11667. }
  11668. //创建文件夹
  11669. func Mkdir(dir string) {
  11670. // 创建文件夹
  11671. exist, err := PathExists(dir)
  11672. if err != nil {
  11673. fmt.Println(err.Error())
  11674. } else {
  11675. if exist {
  11676. fmt.Println(dir + "文件夹已存在!")
  11677. } else {
  11678. // 文件夹名称,权限
  11679. err := os.Mkdir(dir, os.ModePerm)
  11680. if err != nil {
  11681. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11682. } else {
  11683. fmt.Println(dir + "文件夹创建成功!")
  11684. }
  11685. }
  11686. }
  11687. }
  11688. //压缩文件
  11689. func Zip(srcFile string, destZip string) error {
  11690. zipfile, err := os.Create(destZip)
  11691. if err != nil {
  11692. return err
  11693. }
  11694. defer zipfile.Close()
  11695. archive := zip.NewWriter(zipfile)
  11696. defer archive.Close()
  11697. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11698. if err != nil {
  11699. return err
  11700. }
  11701. header, err := zip.FileInfoHeader(info)
  11702. if err != nil {
  11703. return err
  11704. }
  11705. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11706. // header.Name = path
  11707. if info.IsDir() {
  11708. header.Name += "/"
  11709. } else {
  11710. header.Method = zip.Deflate
  11711. }
  11712. writer, err := archive.CreateHeader(header)
  11713. if err != nil {
  11714. return err
  11715. }
  11716. if !info.IsDir() {
  11717. file, err := os.Open(path)
  11718. if err != nil {
  11719. return err
  11720. }
  11721. defer file.Close()
  11722. _, err = io.Copy(writer, file)
  11723. }
  11724. return err
  11725. })
  11726. return err
  11727. }
  11728. func ReadFile(filePath string) []byte {
  11729. f, err := os.Open(filePath)
  11730. if err != nil {
  11731. fmt.Println("read file fail", err)
  11732. return nil
  11733. }
  11734. defer f.Close()
  11735. fd, err := ioutil.ReadAll(f)
  11736. if err != nil {
  11737. fmt.Println("read to fd fail", err)
  11738. return nil
  11739. }
  11740. return fd
  11741. }
  11742. func saveLog(result string, request string, infno string, desc string) {
  11743. org_id, _ := beego.AppConfig.Int64("org_id")
  11744. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11745. dir := miConfig.OrgName + "日志"
  11746. utils.Mkdir(dir)
  11747. month := time.Unix(1557042972, 0).Format("1")
  11748. year := time.Now().Format("2006")
  11749. month = time.Now().Format("01")
  11750. day := time.Now().Format("02")
  11751. hour := time.Now().Format("15")
  11752. min := time.Now().Format("04")
  11753. sec := time.Now().Format("05")
  11754. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11755. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11756. file_name := file + ".txt"
  11757. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11758. exist, _ := utils.PathExists(file_path)
  11759. if exist { //存在
  11760. fmt.Println("存在")
  11761. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11762. if err != nil {
  11763. fmt.Println("read fail")
  11764. }
  11765. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11766. n, _ := f.Seek(0, 2)
  11767. _, err = f.WriteAt([]byte(content), n)
  11768. } else { //不存在
  11769. fmt.Println("文件不存在,创建文件")
  11770. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11771. defer f.Close()
  11772. if err != nil {
  11773. } else {
  11774. _, err = f.Write([]byte("记录日志"))
  11775. }
  11776. }
  11777. }
  11778. type Charset string
  11779. const (
  11780. UTF8 = Charset("UTF-8")
  11781. GB18030 = Charset("GB18030")
  11782. )
  11783. func ConvertToString(src string, srcCode string, tagCode string) string {
  11784. srcCoder := mahonia.NewDecoder(srcCode)
  11785. srcResult := srcCoder.ConvertString(src)
  11786. tagCoder := mahonia.NewDecoder(tagCode)
  11787. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11788. result := string(cdata)
  11789. return result
  11790. }
  11791. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  11792. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  11793. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11794. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11795. var api string
  11796. if miConfig.MdtrtareaAdmvs == "320921" {
  11797. 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 +
  11798. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  11799. fmt.Println(api)
  11800. } else {
  11801. 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 +
  11802. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  11803. }
  11804. resp, requestErr := http.Get(api)
  11805. if requestErr != nil {
  11806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11807. return ""
  11808. }
  11809. body, ioErr := ioutil.ReadAll(resp.Body)
  11810. if ioErr != nil {
  11811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11813. return ""
  11814. }
  11815. var respJSON map[string]interface{}
  11816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11819. return ""
  11820. }
  11821. var status string
  11822. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11823. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11824. var token string
  11825. var res ResultTwo //1101结果
  11826. var res10265 ResultTwo10265 //1101结果
  11827. if status == "0" { //读卡成功
  11828. var card_info string //卡信息
  11829. var busi_card_info string
  11830. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11831. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11832. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11833. fmt.Println(card_info)
  11834. fmt.Println(busi_card_info)
  11835. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11836. result, _ := json.Marshal(respJSON)
  11837. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11838. utils.ErrorLog("解析失败:%v", err)
  11839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11840. return ""
  11841. }
  11842. res.ErrMsg = res10265.ErrMsg
  11843. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11844. res.Infcode = infocode
  11845. res.Output = res10265.Output
  11846. res.InfRefmsgid = res10265.InfRefmsgid
  11847. if res.Infcode == 0 {
  11848. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11849. if err == gorm.ErrRecordNotFound {
  11850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11851. return ""
  11852. } else if err != nil {
  11853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11854. return ""
  11855. } else {
  11856. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11857. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11858. infoStr := string(Iinfos)
  11859. idetinfoStr := string(Idetinfos)
  11860. psn := &models.HisPsn{
  11861. PsnNo: res.Output.Baseinfo.PsnNo,
  11862. Age: res.Output.Baseinfo.Age,
  11863. PatientId: patient.ID,
  11864. Certno: res.Output.Baseinfo.Certno,
  11865. Brdy: res.Output.Baseinfo.Brdy,
  11866. Gend: res.Output.Baseinfo.Gend,
  11867. Naty: res.Output.Baseinfo.Naty,
  11868. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11869. PsnName: res.Output.Baseinfo.PsnName,
  11870. Idetinfo: idetinfoStr,
  11871. Insuinfo: infoStr,
  11872. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11873. CardInfo: card_info,
  11874. VerifyNumber: token,
  11875. }
  11876. service.CreateHisPsn(psn)
  11877. return token
  11878. }
  11879. }
  11880. } else {
  11881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11882. return ""
  11883. }
  11884. } else { //读卡失败
  11885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11886. return ""
  11887. }
  11888. }
  11889. func DeleteExtraSpaceTwo(s string) string {
  11890. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11891. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11892. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11893. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11894. s2 := make([]byte, len(s1)) //定义字符数组切片
  11895. copy(s2, s1) //将字符串复制到切片
  11896. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11897. for len(spc_index) > 0 { //找到适配项
  11898. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11899. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11900. }
  11901. return string(s2)
  11902. }
  11903. func Remove0000(s string) string {
  11904. str := make([]rune, 0, len(s))
  11905. for _, v := range []rune(s) {
  11906. if v == 0 {
  11907. continue
  11908. }
  11909. str = append(str, v)
  11910. }
  11911. return string(str)
  11912. }
  11913. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11914. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11915. readCard := DllDef.MustFindProc("EcQuery")
  11916. pCardInfo := make([]byte, 8192)
  11917. pBusiCardInfo := make([]byte, 8192)
  11918. data := make(map[string]interface{})
  11919. //pData := make(map[string]interface{})
  11920. inputData := make(map[string]interface{})
  11921. inputData["orgId"] = code
  11922. inputData["businessType"] = "01101"
  11923. inputData["operatorId"] = operator_id
  11924. inputData["operatorName"] = operator_name
  11925. inputData["officeId"] = "001"
  11926. inputData["officeName"] = "血透室"
  11927. //
  11928. data["data"] = inputData
  11929. data["transType"] = "ec.query"
  11930. data["orgId"] = code
  11931. bytesData, _ := json.Marshal(data)
  11932. pCardInfo = bytesData
  11933. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11934. fmt.Println(ret2)
  11935. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11936. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11937. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11938. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11939. if ret2 != 0 {
  11940. return "", ""
  11941. }
  11942. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11943. }
  11944. func DeleteExtraSpace(s string) string {
  11945. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11946. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11947. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11948. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11949. s2 := make([]byte, len(s1)) //定义字符数组切片
  11950. copy(s2, s1) //将字符串复制到切片
  11951. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11952. for len(spc_index) > 0 { //找到适配项
  11953. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11954. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11955. }
  11956. return string(s2)
  11957. }
  11958. //对账
  11959. func (c *HisApiController) Post3202() {
  11960. start_time := c.GetString("start_time")
  11961. end_time := c.GetString("end_time")
  11962. //insutype := c.GetString("insutype")
  11963. clr_type := c.GetString("clr_type")
  11964. clr_org := c.GetString("clr_optins")
  11965. admin_user_id, _ := c.GetInt64("admin_user_id")
  11966. adminUser := c.GetAdminUserInfo()
  11967. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11968. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11969. if len(clr_org) == 0 {
  11970. clr_org = miConfig.MdtrtareaAdmvs
  11971. }
  11972. timeLayout := "2006-01-02"
  11973. loc, _ := time.LoadLocation("Local")
  11974. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11975. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11976. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "390", "", clr_type)
  11977. orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  11978. //fixmedins_setl_cnt := int64(len(orders))
  11979. var medfee_sumamt float64
  11980. var acct_pay float64
  11981. var fund_pay_sumamt float64
  11982. var medfee_sumamt_str string
  11983. var acct_pay_str string
  11984. var fund_pay_sumamt_str string
  11985. for _, item := range orders {
  11986. medfee_sumamt_str = fmt.Sprintf("%.4f", medfee_sumamt+item.MedfeeSumamt)
  11987. acct_pay_str = fmt.Sprintf("%.4f", acct_pay+item.AcctPay)
  11988. fund_pay_sumamt_str = fmt.Sprintf("%.4f", fund_pay_sumamt+item.FundPaySumamt)
  11989. }
  11990. var medfee_sumamt_two float64
  11991. var acct_pay_two float64
  11992. var fund_pay_sumamt_two float64
  11993. var medfee_sumamt_two_str string
  11994. var acct_pay_two_str string
  11995. var fund_pay_sumamt_two_str string
  11996. for _, item := range orders_two {
  11997. medfee_sumamt_two_str = fmt.Sprintf("%.4f", medfee_sumamt_two+item.MedfeeSumamt)
  11998. acct_pay_two_str = fmt.Sprintf("%.4f", acct_pay_two+item.AcctPay)
  11999. fund_pay_sumamt_two_str = fmt.Sprintf("%.4f", fund_pay_sumamt_two+item.FundPaySumamt)
  12000. }
  12001. //var user_name string
  12002. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12003. //if role.ID == 0 {
  12004. // user_name = "xxx"
  12005. //} else {
  12006. // user_name = role.UserName
  12007. //}
  12008. var res ResultSix
  12009. if config.IsOpen == 1 {
  12010. var bps []models.BusinessParams
  12011. var bp models.BusinessParams
  12012. ms, _ := strconv.ParseFloat(medfee_sumamt_str, 64)
  12013. ap, _ := strconv.ParseFloat(acct_pay_str, 64)
  12014. fp, _ := strconv.ParseFloat(fund_pay_sumamt_str, 64)
  12015. bp.MedfeeSumamt = ms
  12016. bp.AcctPay = ap
  12017. bp.FundPaySumamt = fp
  12018. bp.Insutype = "390"
  12019. bp.StmtBegndate = start_time
  12020. bp.ClrType = clr_type
  12021. bp.SetlOptins = clr_org
  12022. bp.StmtEnddate = end_time
  12023. bps = append(bps, bp)
  12024. mst, _ := strconv.ParseFloat(medfee_sumamt_two_str, 64)
  12025. apt, _ := strconv.ParseFloat(acct_pay_two_str, 64)
  12026. fpt, _ := strconv.ParseFloat(fund_pay_sumamt_two_str, 64)
  12027. var bp2 models.BusinessParams
  12028. bp2.MedfeeSumamt = mst
  12029. bp2.AcctPay = apt
  12030. bp2.FundPaySumamt = fpt
  12031. bp2.Insutype = "310"
  12032. bp2.StmtBegndate = start_time
  12033. bp2.StmtEnddate = end_time
  12034. bp2.ClrType = clr_type
  12035. bp2.SetlOptins = clr_org
  12036. bps = append(bps, bp2)
  12037. data := make(map[string]interface{})
  12038. data["bps"] = bps
  12039. data["org_name"] = miConfig.OrgName
  12040. data["doctor"] = role.UserName
  12041. data["fixmedins_code"] = miConfig.Code
  12042. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  12043. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  12044. if miConfig.MdtrtareaAdmvs == "421300" {
  12045. client := &http.Client{}
  12046. bytesData, _ := json.Marshal(data)
  12047. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  12048. resp, _ := client.Do(req)
  12049. defer resp.Body.Close()
  12050. body, ioErr := ioutil.ReadAll(resp.Body)
  12051. if ioErr != nil {
  12052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12054. return
  12055. }
  12056. var respJSON map[string]interface{}
  12057. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12060. return
  12061. }
  12062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12063. userJSONBytes, _ := json.Marshal(respJSON)
  12064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12065. utils.ErrorLog("解析失败:%v", err)
  12066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12067. return
  12068. }
  12069. }
  12070. if res.Infcode == 0 {
  12071. c.ServeSuccessJSON(map[string]interface{}{
  12072. "msg": "发起成功",
  12073. })
  12074. } else {
  12075. c.ServeSuccessJSON(map[string]interface{}{
  12076. "code": -10,
  12077. "msg": res.ErrMsg,
  12078. })
  12079. }
  12080. }
  12081. }
  12082. func (c *HisApiController) Post3501() {
  12083. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12084. data := make(map[string]interface{})
  12085. var struct3501s []models.Struct3501
  12086. var struct3501 models.Struct3501
  12087. struct3501.OrgName = miConfig.OrgName
  12088. struct3501.AccessKey = miConfig.AccessKey
  12089. struct3501.RequestUrl = miConfig.Url
  12090. struct3501.SecretKey = miConfig.SecretKey
  12091. struct3501.ManuDate = "2022-08-17"
  12092. struct3501.FixmedinsBchno = ""
  12093. struct3501.ManuLotnum = ""
  12094. struct3501.RxFlag = "0"
  12095. struct3501.ExpyEnd = "2022-08-17"
  12096. struct3501.Invdate = "2022-08-17"
  12097. struct3501.InvCnt = "20.25"
  12098. struct3501.Memo = ""
  12099. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12100. struct3501.FixmedinsHilistId = miConfig.Code
  12101. struct3501.FixmedinsHilistName = miConfig.OrgName
  12102. struct3501s = append(struct3501s, struct3501)
  12103. data["struct_3501s"] = struct3501s
  12104. client := &http.Client{}
  12105. bytesData, _ := json.Marshal(data)
  12106. var req *http.Request
  12107. if miConfig.MdtrtareaAdmvs == "320921" {
  12108. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12109. } else {
  12110. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12111. }
  12112. resp, _ := client.Do(req)
  12113. defer resp.Body.Close()
  12114. body, ioErr := ioutil.ReadAll(resp.Body)
  12115. if ioErr != nil {
  12116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12118. return
  12119. }
  12120. var respJSON map[string]interface{}
  12121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12124. return
  12125. }
  12126. var res ResultSix
  12127. var resSix10265 ResultSix10265 //1101结果
  12128. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12129. result, _ := json.Marshal(respJSON)
  12130. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12131. utils.ErrorLog("解析失败:%v", err)
  12132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12133. return
  12134. }
  12135. res.InfRefmsgid = resSix10265.InfRefmsgid
  12136. res.Output = resSix10265.Output
  12137. res.ErrMsg = resSix10265.ErrMsg
  12138. res.Cainfo = resSix10265.Cainfo
  12139. res.WarnMsg = resSix10265.WarnMsg
  12140. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12141. res.Infcode = infocode
  12142. if infocode == 0 {
  12143. c.ServeSuccessJSON(map[string]interface{}{
  12144. "msg": "上传成功",
  12145. })
  12146. return
  12147. } else {
  12148. c.ServeSuccessJSON(map[string]interface{}{
  12149. "failed_code": -10,
  12150. "msg": res.ErrMsg,
  12151. })
  12152. return
  12153. }
  12154. }
  12155. func (c *HisApiController) Post3502() {
  12156. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12157. data := make(map[string]interface{})
  12158. var struct3502s []models.Struct3502
  12159. var struct3502 models.Struct3502
  12160. struct3502.OrgName = miConfig.OrgName
  12161. struct3502.AccessKey = miConfig.AccessKey
  12162. struct3502.RequestUrl = miConfig.Url
  12163. struct3502.SecretKey = miConfig.SecretKey
  12164. struct3502.ManuDate = "2022-08-15"
  12165. struct3502.FixmedinsBchno = ""
  12166. struct3502.ManuLotnum = ""
  12167. struct3502.RxFlag = "0"
  12168. struct3502.ExpyEnd = "2022-08-15"
  12169. struct3502.Invdate = "2022-08-15"
  12170. struct3502.InvCnt = "20.25"
  12171. struct3502.Memo = ""
  12172. struct3502.MedListCodg = "XB01ABD056B002020200517"
  12173. struct3502.FixmedinsHilistId = miConfig.Code
  12174. struct3502.FixmedinsHilistName = miConfig.OrgName
  12175. struct3502s = append(struct3502s, struct3502)
  12176. data["struct_3502s"] = struct3502s
  12177. client := &http.Client{}
  12178. bytesData, _ := json.Marshal(data)
  12179. var req *http.Request
  12180. if miConfig.MdtrtareaAdmvs == "320921" {
  12181. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12182. } else {
  12183. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12184. }
  12185. resp, _ := client.Do(req)
  12186. defer resp.Body.Close()
  12187. body, ioErr := ioutil.ReadAll(resp.Body)
  12188. if ioErr != nil {
  12189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12191. return
  12192. }
  12193. var respJSON map[string]interface{}
  12194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12197. return
  12198. }
  12199. var res ResultSix
  12200. var resSix10265 ResultSix10265 //1101结果
  12201. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12202. result, _ := json.Marshal(respJSON)
  12203. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12204. utils.ErrorLog("解析失败:%v", err)
  12205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12206. return
  12207. }
  12208. res.InfRefmsgid = resSix10265.InfRefmsgid
  12209. res.Output = resSix10265.Output
  12210. res.ErrMsg = resSix10265.ErrMsg
  12211. res.Cainfo = resSix10265.Cainfo
  12212. res.WarnMsg = resSix10265.WarnMsg
  12213. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12214. res.Infcode = infocode
  12215. if infocode == 0 {
  12216. c.ServeSuccessJSON(map[string]interface{}{
  12217. "msg": "上传成功",
  12218. })
  12219. return
  12220. } else {
  12221. c.ServeSuccessJSON(map[string]interface{}{
  12222. "failed_code": -10,
  12223. "msg": res.ErrMsg,
  12224. })
  12225. return
  12226. }
  12227. }
  12228. func (c *HisApiController) Post3503() {
  12229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12230. data := make(map[string]interface{})
  12231. var struct3501s []models.Struct3501
  12232. var struct3501 models.Struct3501
  12233. struct3501.OrgName = miConfig.OrgName
  12234. struct3501.AccessKey = miConfig.AccessKey
  12235. struct3501.RequestUrl = miConfig.Url
  12236. struct3501.SecretKey = miConfig.SecretKey
  12237. struct3501.ManuDate = "2022-08-15"
  12238. struct3501.FixmedinsBchno = ""
  12239. struct3501.ManuLotnum = ""
  12240. struct3501.RxFlag = "0"
  12241. struct3501.ExpyEnd = "2022-08-15"
  12242. struct3501.Invdate = "2022-08-15"
  12243. struct3501.InvCnt = "20.25"
  12244. struct3501.Memo = ""
  12245. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12246. struct3501.FixmedinsHilistId = miConfig.Code
  12247. struct3501.FixmedinsHilistName = miConfig.OrgName
  12248. struct3501s = append(struct3501s, struct3501)
  12249. data["struct_3501s"] = struct3501s
  12250. client := &http.Client{}
  12251. bytesData, _ := json.Marshal(data)
  12252. var req *http.Request
  12253. if miConfig.MdtrtareaAdmvs == "320921" {
  12254. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12255. } else {
  12256. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12257. }
  12258. resp, _ := client.Do(req)
  12259. defer resp.Body.Close()
  12260. body, ioErr := ioutil.ReadAll(resp.Body)
  12261. if ioErr != nil {
  12262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12264. return
  12265. }
  12266. var respJSON map[string]interface{}
  12267. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12270. return
  12271. }
  12272. var res ResultSix
  12273. var resSix10265 ResultSix10265 //1101结果
  12274. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12275. result, _ := json.Marshal(respJSON)
  12276. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12277. utils.ErrorLog("解析失败:%v", err)
  12278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12279. return
  12280. }
  12281. res.InfRefmsgid = resSix10265.InfRefmsgid
  12282. res.Output = resSix10265.Output
  12283. res.ErrMsg = resSix10265.ErrMsg
  12284. res.Cainfo = resSix10265.Cainfo
  12285. res.WarnMsg = resSix10265.WarnMsg
  12286. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12287. res.Infcode = infocode
  12288. if infocode == 0 {
  12289. c.ServeSuccessJSON(map[string]interface{}{
  12290. "msg": "上传成功",
  12291. })
  12292. return
  12293. } else {
  12294. c.ServeSuccessJSON(map[string]interface{}{
  12295. "failed_code": -10,
  12296. "msg": res.ErrMsg,
  12297. })
  12298. return
  12299. }
  12300. }
  12301. func (c *HisApiController) Post3504() {
  12302. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12303. data := make(map[string]interface{})
  12304. var struct3501s []models.Struct3501
  12305. var struct3501 models.Struct3501
  12306. struct3501.OrgName = miConfig.OrgName
  12307. struct3501.AccessKey = miConfig.AccessKey
  12308. struct3501.RequestUrl = miConfig.Url
  12309. struct3501.SecretKey = miConfig.SecretKey
  12310. struct3501.ManuDate = "2022-08-15"
  12311. struct3501.FixmedinsBchno = ""
  12312. struct3501.ManuLotnum = ""
  12313. struct3501.RxFlag = "0"
  12314. struct3501.ExpyEnd = "2022-08-15"
  12315. struct3501.Invdate = "2022-08-15"
  12316. struct3501.InvCnt = "20.25"
  12317. struct3501.Memo = ""
  12318. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12319. struct3501.FixmedinsHilistId = miConfig.Code
  12320. struct3501.FixmedinsHilistName = miConfig.OrgName
  12321. struct3501s = append(struct3501s, struct3501)
  12322. data["struct_3501s"] = struct3501s
  12323. client := &http.Client{}
  12324. bytesData, _ := json.Marshal(data)
  12325. var req *http.Request
  12326. if miConfig.MdtrtareaAdmvs == "320921" {
  12327. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12328. } else {
  12329. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12330. }
  12331. resp, _ := client.Do(req)
  12332. defer resp.Body.Close()
  12333. body, ioErr := ioutil.ReadAll(resp.Body)
  12334. if ioErr != nil {
  12335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12337. return
  12338. }
  12339. var respJSON map[string]interface{}
  12340. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12343. return
  12344. }
  12345. var res ResultSix
  12346. var resSix10265 ResultSix10265 //1101结果
  12347. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12348. result, _ := json.Marshal(respJSON)
  12349. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12350. utils.ErrorLog("解析失败:%v", err)
  12351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12352. return
  12353. }
  12354. res.InfRefmsgid = resSix10265.InfRefmsgid
  12355. res.Output = resSix10265.Output
  12356. res.ErrMsg = resSix10265.ErrMsg
  12357. res.Cainfo = resSix10265.Cainfo
  12358. res.WarnMsg = resSix10265.WarnMsg
  12359. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12360. res.Infcode = infocode
  12361. if infocode == 0 {
  12362. c.ServeSuccessJSON(map[string]interface{}{
  12363. "msg": "上传成功",
  12364. })
  12365. return
  12366. } else {
  12367. c.ServeSuccessJSON(map[string]interface{}{
  12368. "failed_code": -10,
  12369. "msg": res.ErrMsg,
  12370. })
  12371. return
  12372. }
  12373. }
  12374. func (c *HisApiController) Post3505() {
  12375. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12376. data := make(map[string]interface{})
  12377. var struct3501s []models.Struct3501
  12378. var struct3501 models.Struct3501
  12379. struct3501.OrgName = miConfig.OrgName
  12380. struct3501.AccessKey = miConfig.AccessKey
  12381. struct3501.RequestUrl = miConfig.Url
  12382. struct3501.SecretKey = miConfig.SecretKey
  12383. struct3501.ManuDate = "2022-08-15"
  12384. struct3501.FixmedinsBchno = ""
  12385. struct3501.ManuLotnum = ""
  12386. struct3501.RxFlag = "0"
  12387. struct3501.ExpyEnd = "2022-08-15"
  12388. struct3501.Invdate = "2022-08-15"
  12389. struct3501.InvCnt = "20.25"
  12390. struct3501.Memo = ""
  12391. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12392. struct3501.FixmedinsHilistId = miConfig.Code
  12393. struct3501.FixmedinsHilistName = miConfig.OrgName
  12394. struct3501s = append(struct3501s, struct3501)
  12395. data["struct_3501s"] = struct3501s
  12396. client := &http.Client{}
  12397. bytesData, _ := json.Marshal(data)
  12398. var req *http.Request
  12399. if miConfig.MdtrtareaAdmvs == "320921" {
  12400. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12401. } else {
  12402. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12403. }
  12404. resp, _ := client.Do(req)
  12405. defer resp.Body.Close()
  12406. body, ioErr := ioutil.ReadAll(resp.Body)
  12407. if ioErr != nil {
  12408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12410. return
  12411. }
  12412. var respJSON map[string]interface{}
  12413. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12416. return
  12417. }
  12418. var res ResultSix
  12419. var resSix10265 ResultSix10265 //1101结果
  12420. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12421. result, _ := json.Marshal(respJSON)
  12422. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12423. utils.ErrorLog("解析失败:%v", err)
  12424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12425. return
  12426. }
  12427. res.InfRefmsgid = resSix10265.InfRefmsgid
  12428. res.Output = resSix10265.Output
  12429. res.ErrMsg = resSix10265.ErrMsg
  12430. res.Cainfo = resSix10265.Cainfo
  12431. res.WarnMsg = resSix10265.WarnMsg
  12432. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12433. res.Infcode = infocode
  12434. if infocode == 0 {
  12435. c.ServeSuccessJSON(map[string]interface{}{
  12436. "msg": "上传成功",
  12437. })
  12438. return
  12439. } else {
  12440. c.ServeSuccessJSON(map[string]interface{}{
  12441. "failed_code": -10,
  12442. "msg": res.ErrMsg,
  12443. })
  12444. return
  12445. }
  12446. }
  12447. func (c *HisApiController) Post3506() {
  12448. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12449. data := make(map[string]interface{})
  12450. var struct3501s []models.Struct3501
  12451. var struct3501 models.Struct3501
  12452. struct3501.OrgName = miConfig.OrgName
  12453. struct3501.AccessKey = miConfig.AccessKey
  12454. struct3501.RequestUrl = miConfig.Url
  12455. struct3501.SecretKey = miConfig.SecretKey
  12456. struct3501.ManuDate = "2022-08-15"
  12457. struct3501.FixmedinsBchno = ""
  12458. struct3501.ManuLotnum = ""
  12459. struct3501.RxFlag = "0"
  12460. struct3501.ExpyEnd = "2022-08-15"
  12461. struct3501.Invdate = "2022-08-15"
  12462. struct3501.InvCnt = "20.25"
  12463. struct3501.Memo = ""
  12464. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12465. struct3501.FixmedinsHilistId = miConfig.Code
  12466. struct3501.FixmedinsHilistName = miConfig.OrgName
  12467. struct3501s = append(struct3501s, struct3501)
  12468. data["struct_3501s"] = struct3501s
  12469. client := &http.Client{}
  12470. bytesData, _ := json.Marshal(data)
  12471. var req *http.Request
  12472. if miConfig.MdtrtareaAdmvs == "320921" {
  12473. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12474. } else {
  12475. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12476. }
  12477. resp, _ := client.Do(req)
  12478. defer resp.Body.Close()
  12479. body, ioErr := ioutil.ReadAll(resp.Body)
  12480. if ioErr != nil {
  12481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12483. return
  12484. }
  12485. var respJSON map[string]interface{}
  12486. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12489. return
  12490. }
  12491. var res ResultSix
  12492. var resSix10265 ResultSix10265 //1101结果
  12493. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12494. result, _ := json.Marshal(respJSON)
  12495. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12496. utils.ErrorLog("解析失败:%v", err)
  12497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12498. return
  12499. }
  12500. res.InfRefmsgid = resSix10265.InfRefmsgid
  12501. res.Output = resSix10265.Output
  12502. res.ErrMsg = resSix10265.ErrMsg
  12503. res.Cainfo = resSix10265.Cainfo
  12504. res.WarnMsg = resSix10265.WarnMsg
  12505. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12506. res.Infcode = infocode
  12507. if infocode == 0 {
  12508. c.ServeSuccessJSON(map[string]interface{}{
  12509. "msg": "上传成功",
  12510. })
  12511. return
  12512. } else {
  12513. c.ServeSuccessJSON(map[string]interface{}{
  12514. "failed_code": -10,
  12515. "msg": res.ErrMsg,
  12516. })
  12517. return
  12518. }
  12519. }
  12520. func (c *HisApiController) Post3507() {
  12521. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12522. data := make(map[string]interface{})
  12523. var struct3501s []models.Struct3501
  12524. var struct3501 models.Struct3501
  12525. struct3501.OrgName = miConfig.OrgName
  12526. struct3501.AccessKey = miConfig.AccessKey
  12527. struct3501.RequestUrl = miConfig.Url
  12528. struct3501.SecretKey = miConfig.SecretKey
  12529. struct3501.ManuDate = "2022-08-15"
  12530. struct3501.FixmedinsBchno = ""
  12531. struct3501.ManuLotnum = ""
  12532. struct3501.RxFlag = "0"
  12533. struct3501.ExpyEnd = "2022-08-15"
  12534. struct3501.Invdate = "2022-08-15"
  12535. struct3501.InvCnt = "20.25"
  12536. struct3501.Memo = ""
  12537. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12538. struct3501.FixmedinsHilistId = miConfig.Code
  12539. struct3501.FixmedinsHilistName = miConfig.OrgName
  12540. struct3501s = append(struct3501s, struct3501)
  12541. data["struct_3501s"] = struct3501s
  12542. client := &http.Client{}
  12543. bytesData, _ := json.Marshal(data)
  12544. var req *http.Request
  12545. if miConfig.MdtrtareaAdmvs == "320921" {
  12546. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12547. } else {
  12548. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12549. }
  12550. resp, _ := client.Do(req)
  12551. defer resp.Body.Close()
  12552. body, ioErr := ioutil.ReadAll(resp.Body)
  12553. if ioErr != nil {
  12554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12556. return
  12557. }
  12558. var respJSON map[string]interface{}
  12559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12562. return
  12563. }
  12564. var res ResultSix
  12565. var resSix10265 ResultSix10265 //1101结果
  12566. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12567. result, _ := json.Marshal(respJSON)
  12568. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12569. utils.ErrorLog("解析失败:%v", err)
  12570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12571. return
  12572. }
  12573. res.InfRefmsgid = resSix10265.InfRefmsgid
  12574. res.Output = resSix10265.Output
  12575. res.ErrMsg = resSix10265.ErrMsg
  12576. res.Cainfo = resSix10265.Cainfo
  12577. res.WarnMsg = resSix10265.WarnMsg
  12578. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12579. res.Infcode = infocode
  12580. if infocode == 0 {
  12581. c.ServeSuccessJSON(map[string]interface{}{
  12582. "msg": "上传成功",
  12583. })
  12584. return
  12585. } else {
  12586. c.ServeSuccessJSON(map[string]interface{}{
  12587. "failed_code": -10,
  12588. "msg": res.ErrMsg,
  12589. })
  12590. return
  12591. }
  12592. }