his_api_controller.go 502KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817
  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. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2077. saveLog(result, requestLog, "6101", "电子凭证")
  2078. var ele ELeCertData
  2079. err := json.Unmarshal([]byte(result), &ele)
  2080. if err != nil {
  2081. utils.ErrorLog("解析失败:%v", err)
  2082. }
  2083. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  2084. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2085. var res ResultTwo
  2086. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2087. utils.ErrorLog("解析失败:%v", err)
  2088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2089. return
  2090. }
  2091. if res.Infcode == 0 {
  2092. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2093. if err == gorm.ErrRecordNotFound {
  2094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2095. return
  2096. } else if err != nil {
  2097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2098. return
  2099. } else {
  2100. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2101. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2102. infoStr := string(Iinfos)
  2103. idetinfoStr := string(Idetinfos)
  2104. psn := &models.HisPsn{
  2105. PsnNo: res.Output.Baseinfo.PsnNo,
  2106. Age: res.Output.Baseinfo.Age,
  2107. PatientId: patient.ID,
  2108. Certno: res.Output.Baseinfo.Certno,
  2109. Brdy: res.Output.Baseinfo.Brdy,
  2110. Gend: res.Output.Baseinfo.Gend,
  2111. Naty: res.Output.Baseinfo.Naty,
  2112. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2113. PsnName: res.Output.Baseinfo.PsnName,
  2114. Idetinfo: idetinfoStr,
  2115. Insuinfo: infoStr,
  2116. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2117. CardInfo: "",
  2118. VerifyNumber: ele.Data.EcToken,
  2119. }
  2120. service.CreateHisPsn(psn)
  2121. c.ServeSuccessJSON(map[string]interface{}{
  2122. "patient": patient,
  2123. "number": ele.Data.EcToken,
  2124. })
  2125. }
  2126. } else {
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2128. return
  2129. }
  2130. }
  2131. break
  2132. }
  2133. }
  2134. var initFlag int64 = 0
  2135. func (c *HisApiController) TestGetBasBaseInit() {
  2136. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2137. Iinit := DllDef.MustFindProc("Init")
  2138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2139. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  2140. if ret != 0 {
  2141. fmt.Println("SSCard的报错原因:", err)
  2142. fmt.Println("SSCard的运算结果为:", ret)
  2143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2144. return
  2145. }
  2146. result := int(ret)
  2147. fmt.Println("SSCard的运算结果为1:", result)
  2148. initFlag = 1
  2149. return
  2150. }
  2151. func (c *HisApiController) GetSFZBaseInfo() string {
  2152. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2153. readCard := DllDef.MustFindProc("ReadSFZ")
  2154. if readCard == nil {
  2155. fmt.Println("readcard is nil")
  2156. readCard = DllDef.MustFindProc("ReadSFZ")
  2157. }
  2158. str := make([]byte, 256)
  2159. str1 := make([]byte, 256)
  2160. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2161. fmt.Println(r)
  2162. return string(str)
  2163. }
  2164. func (c *HisApiController) GetBasBaseInfo() string {
  2165. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2166. readCard := DllDef.MustFindProc("ReadCardBas")
  2167. if readCard == nil {
  2168. fmt.Println("readcard is nil")
  2169. readCard = DllDef.MustFindProc("ReadCardBas")
  2170. }
  2171. str := make([]byte, 1024)
  2172. str1 := make([]byte, 1024)
  2173. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2174. fmt.Println(string(str1))
  2175. fmt.Println(string(str))
  2176. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2177. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2178. if ret2 != 0 {
  2179. return ""
  2180. }
  2181. return string(str)
  2182. }
  2183. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  2184. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2185. readCard := DllDef.MustFindProc("read_cardinfo")
  2186. if readCard == nil {
  2187. fmt.Println("readcard is nil")
  2188. readCard = DllDef.MustFindProc("read_cardinfo")
  2189. }
  2190. str := make([]byte, 1024) //卡号
  2191. str1 := make([]byte, 1024) //卡识别码
  2192. str2 := make([]byte, 1024) //身份证号
  2193. str3 := make([]byte, 1024) //姓名
  2194. str4 := make([]byte, 1024) //错误信息
  2195. 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])))
  2196. fmt.Println(string(str1))
  2197. fmt.Println(string(str))
  2198. fmt.Println(string(str2))
  2199. fmt.Println(string(str3))
  2200. fmt.Println(string(str4))
  2201. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2202. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2203. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  2204. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  2205. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  2206. if ret2 != 0 {
  2207. return "", "", "", "", ""
  2208. }
  2209. return string(str), string(str1), string(str2), string(str3), string(str4)
  2210. }
  2211. type CustomFundPay struct {
  2212. FundPayType string `json:"fund_pay_type"`
  2213. FundPayamt float64 `json:"fund_payamt"`
  2214. }
  2215. func (c *HisApiController) GetSettleList() {
  2216. order_id, _ := c.GetInt64("order_id")
  2217. admin_user_id, _ := c.GetInt64("admin_user_id")
  2218. order, _ := service.GetHisOrderByIDTwo(order_id)
  2219. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2220. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2221. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2222. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2223. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2224. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2225. if order.ID == 0 {
  2226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2227. return
  2228. }
  2229. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2230. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2231. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2232. fmt.Println(count)
  2233. var zero string
  2234. number := count + 1
  2235. if number >= 1000 {
  2236. zero = "0000" + strconv.FormatInt(number, 10)
  2237. } else if number >= 10000 {
  2238. zero = "000" + strconv.FormatInt(number, 10)
  2239. } else if number >= 100000 {
  2240. zero = "00" + strconv.FormatInt(number, 10)
  2241. } else if number >= 1000000 {
  2242. zero = "0" + strconv.FormatInt(number, 10)
  2243. } else {
  2244. zero = strconv.FormatInt(number, 10)
  2245. }
  2246. fmt.Println(zero)
  2247. struct4101 := service.Struct4101{
  2248. PsnNo: order.PsnNo,
  2249. MdtrtId: order.MdtrtId,
  2250. SetlId: order.SetlId,
  2251. PsnName: order.PsnName,
  2252. Gend: order.Gend,
  2253. Brdy: his.Brdy,
  2254. Age: his.Age,
  2255. Naty: order.Naty,
  2256. PatnCertType: "01",
  2257. Certno: order.Certno,
  2258. Prfs: "90",
  2259. ConerName: roles[0].UserName,
  2260. PatnRlts: "99",
  2261. ConerAddr: miConfig.OrgName,
  2262. ConerTel: admin.Mobile,
  2263. HiType: order.Insutype,
  2264. Insuplc: miConfig.InsuplcAdmdvs,
  2265. MaindiagFlag: "1",
  2266. BillCode: last_order.FaPiaoCode,
  2267. BillNo: zero,
  2268. BizSn: order.Number,
  2269. PsnSelfPay: order.PsnPartAmt,
  2270. PsnOwnPay: order.PsnPartAmt,
  2271. AcctPay: order.AcctPay,
  2272. PsnCashpay: order.PsnCashPay,
  2273. HiPaymtd: "1",
  2274. Hsorg: miConfig.InsuplcAdmdvs,
  2275. HsorgOpter: miConfig.InsuplcAdmdvs,
  2276. MedinsFillPsn: curRoles.UserName,
  2277. MedinsFillDept: depart.Name,
  2278. IptMedType: "2",
  2279. }
  2280. struct4101.SetlBegnDate = order.SetlTime
  2281. struct4101.SetlEndDate = order.SetlTime
  2282. time_arr := strings.Split(order.SetlTime, " ")
  2283. struct4101.AdmTime = time_arr[0]
  2284. struct4101.AdmEndTime = time_arr[0]
  2285. var rf []CustomFundPay
  2286. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2287. var tempFunPays []service.CustomStruct
  2288. for _, item := range rf {
  2289. var tempFunPay service.CustomStruct
  2290. tempFunPay.FundPayamt = item.FundPayamt
  2291. tempFunPay.FundPayType = item.FundPayType
  2292. tempFunPays = append(tempFunPays, tempFunPay)
  2293. }
  2294. struct4101.CustomStruct = tempFunPays
  2295. var tempDiaginfos []service.DiaginfoStructTwo
  2296. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2297. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2298. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2299. var config []*models.HisXtDiagnoseConfig
  2300. for _, item := range diagnosis_ids {
  2301. id, _ := strconv.ParseInt(item, 10, 64)
  2302. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2303. config = append(config, &diagnosisConfig)
  2304. }
  2305. for index, item := range config {
  2306. if index == 0 {
  2307. var tempDiaginfo service.DiaginfoStructTwo
  2308. tempDiaginfo.DiagCode = item.CountryCode
  2309. tempDiaginfo.DiagName = item.CountryContentName
  2310. tempDiaginfo.DiagType = "1"
  2311. tempDiaginfo.MaindiagFlag = "1"
  2312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2313. } else {
  2314. var tempDiaginfo service.DiaginfoStructTwo
  2315. tempDiaginfo.DiagCode = item.CountryCode
  2316. tempDiaginfo.DiagName = item.CountryContentName
  2317. tempDiaginfo.DiagType = "2"
  2318. tempDiaginfo.MaindiagFlag = "0"
  2319. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2320. }
  2321. }
  2322. struct4101.Diseinfo = tempDiaginfos
  2323. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2324. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2325. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2326. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2327. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2328. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2329. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2330. var iteminfo service.IteminfoStruct
  2331. var bedCostTotal float64 = 0 //床位总费
  2332. var bedCostSelfTotal float64 = 0 //床位自费
  2333. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2334. var operationCostTotal float64 = 0 //手术费
  2335. var operationCostSelfTotal float64 = 0 //手术费
  2336. var operationCostPartSelfTotal float64 = 0 //手术费
  2337. var otherCostTotal float64 = 0 //其他费用
  2338. var otherCostSelfTotal float64 = 0 //其他费用
  2339. var otherCostPartSelfTotal float64 = 0 //其他费用
  2340. var materialCostTotal float64 = 0 //材料费
  2341. var materialCostSelfTotal float64 = 0 //材料费
  2342. var materialCostPartSelfTotal float64 = 0 //材料费
  2343. var westernMedicineCostTotal float64 = 0 //西药费
  2344. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2345. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2346. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2347. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2348. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2349. var checkCostTotal float64 = 0 //检查费
  2350. var checkCostSelfTotal float64 = 0 //检查费
  2351. var checkCostPartSelfTotal float64 = 0 //检查费
  2352. var laboratoryCostTotal float64 = 0 //化验费
  2353. var laboratoryCostSelfTotal float64 = 0 //化验费
  2354. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2355. var treatCostTotal float64 = 0 //治疗费用
  2356. var treatCostSelfTotal float64 = 0 //治疗费用
  2357. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2358. decimal.DivisionPrecision = 2
  2359. var bed_fulamt_ownpay_amt float64 = 0
  2360. var operation_fulamt_ownpay_amt float64 = 0
  2361. var other_fulamt_ownpay_amt float64 = 0
  2362. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2363. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2364. var check_fulamt_ownpay_amt float64 = 0
  2365. var material_fulamt_ownpay_amt float64 = 0
  2366. var laboratory_fulamt_ownpay_amt float64 = 0
  2367. var treat_fulamt_ownpay_amt float64 = 0
  2368. var bed_claa_sunmfee float64 = 0
  2369. var bed_clab_amt float64 = 0
  2370. var bed_other_amt float64 = 0
  2371. var operation_claa_sunmfee float64 = 0
  2372. var operation_clab_amt float64 = 0
  2373. var operation_other_amt float64 = 0
  2374. var other_claa_sunmfee float64 = 0
  2375. var other_clab_amt float64 = 0
  2376. var other_other_amt float64 = 0
  2377. var westernMedicine_claa_sunmfee float64 = 0
  2378. var westernMedicine_clab_amt float64 = 0
  2379. var westernMedicine_other_amt float64 = 0
  2380. var chineseTraditional_claa_sunmfee float64 = 0
  2381. var chineseTraditional_clab_amt float64 = 0
  2382. var chineseTraditional_other_amt float64 = 0
  2383. var check_claa_sunmfee float64 = 0
  2384. var check_clab_amt float64 = 0
  2385. var check_other_amt float64 = 0
  2386. var material_claa_sunmfee float64 = 0
  2387. var material_clab_amt float64 = 0
  2388. var material_other_amt float64 = 0
  2389. var laboratory_claa_sunmfee float64 = 0
  2390. var laboratory_clab_amt float64 = 0
  2391. var laboratory_other_amt float64 = 0
  2392. var treat_claa_sunmfee float64 = 0
  2393. var treat_clab_amt float64 = 0
  2394. var treat_other_amt float64 = 0
  2395. for _, item := range order.HisOrderInfo {
  2396. if item.MedChrgitmType == "01" { //床位费
  2397. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2398. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2399. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2400. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2401. if item.ChrgitmLv == "1" {
  2402. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2403. }
  2404. if item.ChrgitmLv == "2" {
  2405. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2406. }
  2407. if item.ChrgitmLv == "3" {
  2408. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2409. }
  2410. }
  2411. if item.MedChrgitmType == "03" { //检查费
  2412. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2413. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2414. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2415. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2416. if item.ChrgitmLv == "1" {
  2417. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2418. }
  2419. if item.ChrgitmLv == "2" {
  2420. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2421. }
  2422. if item.ChrgitmLv == "3" {
  2423. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2424. }
  2425. }
  2426. if item.MedChrgitmType == "04" { //化验费
  2427. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2428. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2429. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2430. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2431. if item.ChrgitmLv == "1" {
  2432. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2433. }
  2434. if item.ChrgitmLv == "2" {
  2435. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2436. }
  2437. if item.ChrgitmLv == "3" {
  2438. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2439. }
  2440. }
  2441. if item.MedChrgitmType == "05" { //治疗费
  2442. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2443. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2444. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2445. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2446. if item.ChrgitmLv == "1" {
  2447. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2448. }
  2449. if item.ChrgitmLv == "2" {
  2450. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2451. }
  2452. if item.ChrgitmLv == "3" {
  2453. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2454. }
  2455. }
  2456. if item.MedChrgitmType == "06" { //手术费
  2457. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2458. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2459. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2460. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2461. if item.ChrgitmLv == "1" {
  2462. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2463. }
  2464. if item.ChrgitmLv == "2" {
  2465. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2466. }
  2467. if item.ChrgitmLv == "3" {
  2468. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2469. }
  2470. }
  2471. if item.MedChrgitmType == "08" { //材料费
  2472. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2473. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2474. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2475. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2476. if item.ChrgitmLv == "1" {
  2477. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2478. }
  2479. if item.ChrgitmLv == "2" {
  2480. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2481. }
  2482. if item.ChrgitmLv == "3" {
  2483. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2484. }
  2485. }
  2486. if item.MedChrgitmType == "09" { //西药费
  2487. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2488. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2489. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2490. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2491. if item.ChrgitmLv == "1" {
  2492. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2493. }
  2494. if item.ChrgitmLv == "2" {
  2495. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2496. }
  2497. if item.ChrgitmLv == "3" {
  2498. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2499. }
  2500. }
  2501. if item.MedChrgitmType == "11" { //中成费
  2502. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2503. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2504. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2505. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2506. if item.ChrgitmLv == "1" {
  2507. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2508. }
  2509. if item.ChrgitmLv == "2" {
  2510. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2511. }
  2512. if item.ChrgitmLv == "3" {
  2513. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2514. }
  2515. }
  2516. if item.MedChrgitmType == "14" { //其他费
  2517. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2518. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2519. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2520. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2521. if item.ChrgitmLv == "1" {
  2522. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2523. }
  2524. if item.ChrgitmLv == "2" {
  2525. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2526. }
  2527. if item.ChrgitmLv == "3" {
  2528. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2529. }
  2530. }
  2531. }
  2532. var iteminfoStructs []service.IteminfoStruct
  2533. if bedCostTotal != 0 {
  2534. iteminfo.MedChrgitm = "01"
  2535. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2536. iteminfo.Amt = bedCostTotal
  2537. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2538. iteminfo.ClabAmt = bed_clab_amt
  2539. iteminfo.OthAmt = bed_other_amt
  2540. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2541. }
  2542. if checkCostTotal != 0 {
  2543. iteminfo.MedChrgitm = "03"
  2544. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2545. iteminfo.Amt = checkCostTotal
  2546. iteminfo.ClaaSumfee = check_claa_sunmfee
  2547. iteminfo.ClabAmt = check_clab_amt
  2548. iteminfo.OthAmt = check_other_amt
  2549. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2550. }
  2551. if laboratoryCostTotal != 0 {
  2552. iteminfo.MedChrgitm = "04"
  2553. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2554. iteminfo.Amt = laboratoryCostTotal
  2555. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2556. iteminfo.ClabAmt = laboratory_clab_amt
  2557. iteminfo.OthAmt = laboratory_other_amt
  2558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2559. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2560. }
  2561. if treatCostTotal != 0 {
  2562. iteminfo.MedChrgitm = "05"
  2563. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2564. iteminfo.Amt = treatCostTotal
  2565. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2566. iteminfo.ClabAmt = treat_clab_amt
  2567. iteminfo.OthAmt = treat_other_amt
  2568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2569. //(struct4101.IteminfoStruct, iteminfo)
  2570. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2571. }
  2572. if operationCostTotal != 0 {
  2573. iteminfo.MedChrgitm = "06"
  2574. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2575. iteminfo.Amt = operationCostTotal
  2576. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2577. iteminfo.ClabAmt = operation_clab_amt
  2578. iteminfo.OthAmt = operation_other_amt
  2579. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2580. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2581. }
  2582. if materialCostTotal != 0 {
  2583. iteminfo.MedChrgitm = "08"
  2584. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2585. iteminfo.Amt = materialCostTotal
  2586. iteminfo.ClaaSumfee = material_claa_sunmfee
  2587. iteminfo.ClabAmt = material_clab_amt
  2588. iteminfo.OthAmt = material_other_amt
  2589. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2590. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2591. }
  2592. if westernMedicineCostTotal != 0 {
  2593. iteminfo.MedChrgitm = "09"
  2594. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2595. iteminfo.Amt = westernMedicineCostTotal
  2596. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2597. iteminfo.ClabAmt = westernMedicine_clab_amt
  2598. iteminfo.OthAmt = westernMedicine_other_amt
  2599. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2600. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2601. }
  2602. if chineseTraditionalMedicineCostTotal != 0 {
  2603. iteminfo.MedChrgitm = "11"
  2604. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2605. iteminfo.Amt = westernMedicineCostTotal
  2606. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2607. iteminfo.ClabAmt = westernMedicine_clab_amt
  2608. iteminfo.OthAmt = westernMedicine_other_amt
  2609. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2610. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2611. }
  2612. if otherCostTotal != 0 {
  2613. iteminfo.MedChrgitm = "14"
  2614. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2615. iteminfo.Amt = otherCostTotal
  2616. iteminfo.ClaaSumfee = other_claa_sunmfee
  2617. iteminfo.ClabAmt = other_clab_amt
  2618. iteminfo.OthAmt = other_other_amt
  2619. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2620. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2621. }
  2622. struct4101.IteminfoStruct = iteminfoStructs
  2623. struct4101.Ntly = "中国"
  2624. struct4101.AdmCaty = "A03.06"
  2625. var res ResultSeventeen
  2626. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2627. struct4101.BillCode = order.Number
  2628. struct4101.BillNo = order.SetlId
  2629. var resOther ResultSeventeenOther
  2630. var pp models.PublicParams
  2631. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2632. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2633. pp.FixmedinsName = miConfig.OrgName
  2634. pp.FixmedinsCode = miConfig.Code
  2635. pp.RequestUrl = miConfig.Url
  2636. pp.Cainfo = miConfig.Cainfo
  2637. pp.SecretKey = miConfig.SecretKey
  2638. pp.AccessKey = miConfig.AccessKey
  2639. pp.OpterName = curRoles.UserName
  2640. client := &http.Client{}
  2641. var req *http.Request
  2642. data := make(map[string]interface{})
  2643. data["struct4101"] = struct4101
  2644. data["pp"] = pp
  2645. bytesData, _ := json.Marshal(data)
  2646. if miConfig.MdtrtareaAdmvs == "320921" {
  2647. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2648. } else {
  2649. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2650. }
  2651. resp, _ := client.Do(req)
  2652. defer resp.Body.Close()
  2653. body, ioErr := ioutil.ReadAll(resp.Body)
  2654. if ioErr != nil {
  2655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2657. return
  2658. }
  2659. var respJSON map[string]interface{}
  2660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2663. return
  2664. }
  2665. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2666. userJSONBytes, _ := json.Marshal(respJSON)
  2667. fmt.Println("log")
  2668. fmt.Println(string(userJSONBytes))
  2669. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2670. utils.ErrorLog("解析失败:%v", err)
  2671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2672. return
  2673. }
  2674. res.InfRefmsgid = resOther.InfRefmsgid
  2675. res.Output = resOther.Output
  2676. res.ErrMsg = resOther.ErrMsg
  2677. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2678. res.Infcode = infocode
  2679. } else {
  2680. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2681. var dat map[string]interface{}
  2682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2683. fmt.Println(dat)
  2684. } else {
  2685. fmt.Println(err)
  2686. }
  2687. userJSONBytes, _ := json.Marshal(dat)
  2688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2689. utils.ErrorLog("解析失败:%v", err)
  2690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2691. return
  2692. }
  2693. }
  2694. if res.Infcode != 0 {
  2695. c.ServeSuccessJSON(map[string]interface{}{
  2696. "failed_code": -10,
  2697. "msg": res.ErrMsg,
  2698. })
  2699. return
  2700. } else {
  2701. order.FaPiaoNumber = zero
  2702. order.FaPiaoCode = last_order.FaPiaoCode
  2703. service.UpdateOrder(order)
  2704. hisFundSettleListResult := &models.HisFundSettleListResult{
  2705. Number: res.Output.SetlListId,
  2706. Status: 1,
  2707. Ctime: time.Now().Unix(),
  2708. Mtime: time.Now().Unix(),
  2709. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2710. IsUpload: 1,
  2711. OrderId: order_id,
  2712. }
  2713. service.CreateUploadRecord(hisFundSettleListResult)
  2714. c.ServeSuccessJSON(map[string]interface{}{
  2715. "msg": "上传成功",
  2716. "result": hisFundSettleListResult,
  2717. })
  2718. return
  2719. }
  2720. }
  2721. func (c *HisApiController) GetSettleListHospital() {
  2722. order_id, _ := c.GetInt64("order_id")
  2723. admin_user_id, _ := c.GetInt64("admin_user_id")
  2724. order, _ := service.GetHisOrderByIDTwo(order_id)
  2725. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2726. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2727. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2728. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2729. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2730. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2731. if order.ID == 0 {
  2732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2733. return
  2734. }
  2735. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2736. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2737. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2738. fmt.Println(count)
  2739. var zero string
  2740. number := count + 1
  2741. if number >= 1000 {
  2742. zero = "0000" + strconv.FormatInt(number, 10)
  2743. } else if number >= 10000 {
  2744. zero = "000" + strconv.FormatInt(number, 10)
  2745. } else if number >= 100000 {
  2746. zero = "00" + strconv.FormatInt(number, 10)
  2747. } else if number >= 1000000 {
  2748. zero = "0" + strconv.FormatInt(number, 10)
  2749. } else {
  2750. zero = strconv.FormatInt(number, 10)
  2751. }
  2752. fmt.Println(zero)
  2753. struct4101 := service.Struct4101{
  2754. PsnNo: order.PsnNo,
  2755. MdtrtId: order.MdtrtId,
  2756. SetlId: order.SetlId,
  2757. PsnName: order.PsnName,
  2758. Gend: order.Gend,
  2759. Brdy: his.Brdy,
  2760. Age: int64(order.Age),
  2761. Naty: order.Naty,
  2762. PatnCertType: "01",
  2763. Certno: order.Certno,
  2764. Prfs: "90",
  2765. ConerName: roles[0].UserName,
  2766. PatnRlts: "99",
  2767. ConerAddr: miConfig.OrgName,
  2768. ConerTel: admin.Mobile,
  2769. HiType: order.Insutype,
  2770. Insuplc: miConfig.InsuplcAdmdvs,
  2771. MaindiagFlag: "1",
  2772. BillCode: order.FaPiaoNumber,
  2773. BillNo: order.FaPiaoNumber,
  2774. BizSn: order.Number,
  2775. PsnSelfPay: order.PsnPartAmt,
  2776. PsnOwnPay: order.PsnPartAmt,
  2777. AcctPay: order.AcctPay,
  2778. PsnCashpay: order.PsnCashPay,
  2779. HiPaymtd: "1",
  2780. Hsorg: miConfig.InsuplcAdmdvs,
  2781. HsorgOpter: miConfig.InsuplcAdmdvs,
  2782. MedinsFillPsn: curRoles.UserName,
  2783. MedinsFillDept: depart.Name,
  2784. IptMedType: "2",
  2785. AdmTime: his.InHosptialTime,
  2786. AdmEndTime: his.OutHosptialTime,
  2787. }
  2788. struct4101.SetlBegnDate = order.SetlTime
  2789. struct4101.SetlEndDate = order.SetlTime
  2790. var rf []CustomFundPay
  2791. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2792. var tempFunPays []service.CustomStruct
  2793. for _, item := range rf {
  2794. var tempFunPay service.CustomStruct
  2795. tempFunPay.FundPayamt = item.FundPayamt
  2796. tempFunPay.FundPayType = item.FundPayType
  2797. tempFunPays = append(tempFunPays, tempFunPay)
  2798. }
  2799. struct4101.CustomStruct = tempFunPays
  2800. var tempDiaginfos []service.DiaginfoStructTwo
  2801. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2802. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2803. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2804. var config []*models.HisXtDiagnoseConfig
  2805. for _, item := range diagnosis_ids {
  2806. id, _ := strconv.ParseInt(item, 10, 64)
  2807. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2808. config = append(config, &diagnosisConfig)
  2809. }
  2810. for index, item := range config {
  2811. if index == 0 {
  2812. var tempDiaginfo service.DiaginfoStructTwo
  2813. tempDiaginfo.DiagCode = item.CountryCode
  2814. tempDiaginfo.DiagName = item.CountryContentName
  2815. tempDiaginfo.DiagType = "1"
  2816. tempDiaginfo.MaindiagFlag = "1"
  2817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2818. } else {
  2819. var tempDiaginfo service.DiaginfoStructTwo
  2820. tempDiaginfo.DiagCode = item.CountryCode
  2821. tempDiaginfo.DiagName = item.CountryContentName
  2822. tempDiaginfo.DiagType = "2"
  2823. tempDiaginfo.MaindiagFlag = "0"
  2824. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2825. }
  2826. }
  2827. struct4101.Diseinfo = tempDiaginfos
  2828. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2829. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2830. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2831. tempOpspdiseinfo2.OprnOprtCode = ""
  2832. tempOpspdiseinfo2.OprnOprtName = ""
  2833. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2834. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2835. var iteminfo service.IteminfoStruct
  2836. var bedCostTotal float64 = 0 //床位总费
  2837. var bedCostSelfTotal float64 = 0 //床位自费
  2838. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2839. var operationCostTotal float64 = 0 //手术费
  2840. var operationCostSelfTotal float64 = 0 //手术费
  2841. var operationCostPartSelfTotal float64 = 0 //手术费
  2842. var otherCostTotal float64 = 0 //其他费用
  2843. var otherCostSelfTotal float64 = 0 //其他费用
  2844. var otherCostPartSelfTotal float64 = 0 //其他费用
  2845. var materialCostTotal float64 = 0 //材料费
  2846. var materialCostSelfTotal float64 = 0 //材料费
  2847. var materialCostPartSelfTotal float64 = 0 //材料费
  2848. var westernMedicineCostTotal float64 = 0 //西药费
  2849. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2850. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2851. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2852. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2853. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2854. var checkCostTotal float64 = 0 //检查费
  2855. var checkCostSelfTotal float64 = 0 //检查费
  2856. var checkCostPartSelfTotal float64 = 0 //检查费
  2857. var laboratoryCostTotal float64 = 0 //化验费
  2858. var laboratoryCostSelfTotal float64 = 0 //化验费
  2859. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2860. var treatCostTotal float64 = 0 //治疗费用
  2861. var treatCostSelfTotal float64 = 0 //治疗费用
  2862. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2863. decimal.DivisionPrecision = 2
  2864. var bed_fulamt_ownpay_amt float64 = 0
  2865. var operation_fulamt_ownpay_amt float64 = 0
  2866. var other_fulamt_ownpay_amt float64 = 0
  2867. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2868. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2869. var check_fulamt_ownpay_amt float64 = 0
  2870. var material_fulamt_ownpay_amt float64 = 0
  2871. var laboratory_fulamt_ownpay_amt float64 = 0
  2872. var treat_fulamt_ownpay_amt float64 = 0
  2873. var bed_claa_sunmfee float64 = 0
  2874. var bed_clab_amt float64 = 0
  2875. var bed_other_amt float64 = 0
  2876. var operation_claa_sunmfee float64 = 0
  2877. var operation_clab_amt float64 = 0
  2878. var operation_other_amt float64 = 0
  2879. var other_claa_sunmfee float64 = 0
  2880. var other_clab_amt float64 = 0
  2881. var other_other_amt float64 = 0
  2882. var westernMedicine_claa_sunmfee float64 = 0
  2883. var westernMedicine_clab_amt float64 = 0
  2884. var westernMedicine_other_amt float64 = 0
  2885. var chineseTraditional_claa_sunmfee float64 = 0
  2886. var chineseTraditional_clab_amt float64 = 0
  2887. var chineseTraditional_other_amt float64 = 0
  2888. var check_claa_sunmfee float64 = 0
  2889. var check_clab_amt float64 = 0
  2890. var check_other_amt float64 = 0
  2891. var material_claa_sunmfee float64 = 0
  2892. var material_clab_amt float64 = 0
  2893. var material_other_amt float64 = 0
  2894. var laboratory_claa_sunmfee float64 = 0
  2895. var laboratory_clab_amt float64 = 0
  2896. var laboratory_other_amt float64 = 0
  2897. var treat_claa_sunmfee float64 = 0
  2898. var treat_clab_amt float64 = 0
  2899. var treat_other_amt float64 = 0
  2900. for _, item := range order.HisOrderInfo {
  2901. if item.MedChrgitmType == "01" { //床位费
  2902. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2903. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2904. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2905. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2906. if item.ChrgitmLv == "1" {
  2907. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2908. }
  2909. if item.ChrgitmLv == "2" {
  2910. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2911. }
  2912. if item.ChrgitmLv == "3" {
  2913. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2914. }
  2915. }
  2916. if item.MedChrgitmType == "03" { //检查费
  2917. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2918. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2919. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2920. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2921. if item.ChrgitmLv == "1" {
  2922. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2923. }
  2924. if item.ChrgitmLv == "2" {
  2925. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2926. }
  2927. if item.ChrgitmLv == "3" {
  2928. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2929. }
  2930. }
  2931. if item.MedChrgitmType == "04" { //化验费
  2932. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2933. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2934. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2935. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2936. if item.ChrgitmLv == "1" {
  2937. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2938. }
  2939. if item.ChrgitmLv == "2" {
  2940. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2941. }
  2942. if item.ChrgitmLv == "3" {
  2943. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2944. }
  2945. }
  2946. if item.MedChrgitmType == "05" { //治疗费
  2947. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2948. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2949. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2950. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2951. if item.ChrgitmLv == "1" {
  2952. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2953. }
  2954. if item.ChrgitmLv == "2" {
  2955. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2956. }
  2957. if item.ChrgitmLv == "3" {
  2958. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2959. }
  2960. }
  2961. if item.MedChrgitmType == "06" { //手术费
  2962. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2963. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2964. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2965. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2966. if item.ChrgitmLv == "1" {
  2967. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2968. }
  2969. if item.ChrgitmLv == "2" {
  2970. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2971. }
  2972. if item.ChrgitmLv == "3" {
  2973. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2974. }
  2975. }
  2976. if item.MedChrgitmType == "08" { //材料费
  2977. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2978. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2979. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2980. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2981. if item.ChrgitmLv == "1" {
  2982. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2983. }
  2984. if item.ChrgitmLv == "2" {
  2985. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2986. }
  2987. if item.ChrgitmLv == "3" {
  2988. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2989. }
  2990. }
  2991. if item.MedChrgitmType == "09" { //西药费
  2992. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2993. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2994. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2995. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2996. if item.ChrgitmLv == "1" {
  2997. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2998. }
  2999. if item.ChrgitmLv == "2" {
  3000. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3001. }
  3002. if item.ChrgitmLv == "3" {
  3003. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3004. }
  3005. }
  3006. if item.MedChrgitmType == "11" { //中成费
  3007. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3008. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3009. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3010. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3011. if item.ChrgitmLv == "1" {
  3012. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3013. }
  3014. if item.ChrgitmLv == "2" {
  3015. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3016. }
  3017. if item.ChrgitmLv == "3" {
  3018. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3019. }
  3020. }
  3021. if item.MedChrgitmType == "14" { //其他费
  3022. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3023. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3024. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3025. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3026. if item.ChrgitmLv == "1" {
  3027. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3028. }
  3029. if item.ChrgitmLv == "2" {
  3030. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3031. }
  3032. if item.ChrgitmLv == "3" {
  3033. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3034. }
  3035. }
  3036. }
  3037. var iteminfoStructs []service.IteminfoStruct
  3038. if bedCostTotal != 0 {
  3039. iteminfo.MedChrgitm = "01"
  3040. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3041. iteminfo.Amt = bedCostTotal
  3042. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3043. iteminfo.ClabAmt = bed_clab_amt
  3044. iteminfo.OthAmt = bed_other_amt
  3045. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3046. }
  3047. if checkCostTotal != 0 {
  3048. iteminfo.MedChrgitm = "03"
  3049. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3050. iteminfo.Amt = checkCostTotal
  3051. iteminfo.ClaaSumfee = check_claa_sunmfee
  3052. iteminfo.ClabAmt = check_clab_amt
  3053. iteminfo.OthAmt = check_other_amt
  3054. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3055. }
  3056. if laboratoryCostTotal != 0 {
  3057. iteminfo.MedChrgitm = "04"
  3058. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3059. iteminfo.Amt = laboratoryCostTotal
  3060. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3061. iteminfo.ClabAmt = laboratory_clab_amt
  3062. iteminfo.OthAmt = laboratory_other_amt
  3063. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3064. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3065. }
  3066. if treatCostTotal != 0 {
  3067. iteminfo.MedChrgitm = "05"
  3068. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3069. iteminfo.Amt = treatCostTotal
  3070. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3071. iteminfo.ClabAmt = treat_clab_amt
  3072. iteminfo.OthAmt = treat_other_amt
  3073. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3074. //(struct4101.IteminfoStruct, iteminfo)
  3075. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3076. }
  3077. if operationCostTotal != 0 {
  3078. iteminfo.MedChrgitm = "06"
  3079. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3080. iteminfo.Amt = operationCostTotal
  3081. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3082. iteminfo.ClabAmt = operation_clab_amt
  3083. iteminfo.OthAmt = operation_other_amt
  3084. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3085. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3086. }
  3087. if materialCostTotal != 0 {
  3088. iteminfo.MedChrgitm = "08"
  3089. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3090. iteminfo.Amt = materialCostTotal
  3091. iteminfo.ClaaSumfee = material_claa_sunmfee
  3092. iteminfo.ClabAmt = material_clab_amt
  3093. iteminfo.OthAmt = material_other_amt
  3094. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3095. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3096. }
  3097. if westernMedicineCostTotal != 0 {
  3098. iteminfo.MedChrgitm = "09"
  3099. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3100. iteminfo.Amt = westernMedicineCostTotal
  3101. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3102. iteminfo.ClabAmt = westernMedicine_clab_amt
  3103. iteminfo.OthAmt = westernMedicine_other_amt
  3104. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3105. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3106. }
  3107. if chineseTraditionalMedicineCostTotal != 0 {
  3108. iteminfo.MedChrgitm = "11"
  3109. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3110. iteminfo.Amt = westernMedicineCostTotal
  3111. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3112. iteminfo.ClabAmt = westernMedicine_clab_amt
  3113. iteminfo.OthAmt = westernMedicine_other_amt
  3114. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3115. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3116. }
  3117. if otherCostTotal != 0 {
  3118. iteminfo.MedChrgitm = "14"
  3119. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3120. iteminfo.Amt = otherCostTotal
  3121. iteminfo.ClaaSumfee = other_claa_sunmfee
  3122. iteminfo.ClabAmt = other_clab_amt
  3123. iteminfo.OthAmt = other_other_amt
  3124. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3125. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3126. }
  3127. struct4101.IteminfoStruct = iteminfoStructs
  3128. struct4101.Ntly = "中国"
  3129. struct4101.AdmCaty = "A03.06"
  3130. var resOther ResultSeventeenOther
  3131. var res ResultSeventeen
  3132. if miConfig.MdtrtareaAdmvs == "150499" {
  3133. var pp models.PublicParams
  3134. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3135. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3136. pp.FixmedinsName = miConfig.OrgName
  3137. pp.FixmedinsCode = miConfig.Code
  3138. pp.RequestUrl = miConfig.Url
  3139. pp.Cainfo = miConfig.Cainfo
  3140. pp.SecretKey = miConfig.SecretKey
  3141. pp.AccessKey = miConfig.AccessKey
  3142. pp.OpterName = curRoles.UserName
  3143. client := &http.Client{}
  3144. var req *http.Request
  3145. data := make(map[string]interface{})
  3146. data["struct4101"] = struct4101
  3147. data["pp"] = pp
  3148. bytesData, _ := json.Marshal(data)
  3149. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  3150. resp, _ := client.Do(req)
  3151. defer resp.Body.Close()
  3152. body, ioErr := ioutil.ReadAll(resp.Body)
  3153. if ioErr != nil {
  3154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3156. return
  3157. }
  3158. var respJSON map[string]interface{}
  3159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3162. return
  3163. }
  3164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3165. userJSONBytes, _ := json.Marshal(respJSON)
  3166. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  3167. utils.ErrorLog("解析失败:%v", err)
  3168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3169. return
  3170. }
  3171. res.InfRefmsgid = resOther.InfRefmsgid
  3172. res.Output = resOther.Output
  3173. res.ErrMsg = resOther.ErrMsg
  3174. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  3175. res.Infcode = infocode
  3176. } else {
  3177. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3178. var dat map[string]interface{}
  3179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3180. fmt.Println(dat)
  3181. } else {
  3182. fmt.Println(err)
  3183. }
  3184. userJSONBytes, _ := json.Marshal(dat)
  3185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3186. utils.ErrorLog("解析失败:%v", err)
  3187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3188. return
  3189. }
  3190. }
  3191. if res.Infcode != 0 {
  3192. c.ServeSuccessJSON(map[string]interface{}{
  3193. "failed_code": -10,
  3194. "msg": res.ErrMsg,
  3195. })
  3196. return
  3197. } else {
  3198. if miConfig.MdtrtareaAdmvs != "150499" {
  3199. order.FaPiaoNumber = zero
  3200. order.FaPiaoCode = last_order.FaPiaoCode
  3201. service.UpdateOrder(order)
  3202. }
  3203. hisFundSettleListResult := &models.HisFundSettleListResult{
  3204. Number: res.Output.SetlListId,
  3205. Status: 1,
  3206. Ctime: time.Now().Unix(),
  3207. Mtime: time.Now().Unix(),
  3208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3209. IsUpload: 1,
  3210. OrderId: order_id,
  3211. }
  3212. service.CreateUploadRecord(hisFundSettleListResult)
  3213. c.ServeSuccessJSON(map[string]interface{}{
  3214. "msg": "上传成功",
  3215. "result": hisFundSettleListResult,
  3216. })
  3217. return
  3218. }
  3219. }
  3220. func (c *HisApiController) GetBatchSettleList() {
  3221. orders, _ := service.GetAllHisOrder(10106)
  3222. for _, item := range orders {
  3223. order_id := item.ID
  3224. order, _ := service.GetHisOrderByIDTwo(order_id)
  3225. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3226. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3227. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  3229. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3230. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3231. if order.ID == 0 {
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3233. return
  3234. }
  3235. if his.BalanceAccountsType == 2 {
  3236. continue
  3237. }
  3238. struct4101 := service.Struct4101{
  3239. PsnNo: order.PsnNo,
  3240. MdtrtId: order.MdtrtId,
  3241. SetlId: order.SetlId,
  3242. PsnName: order.PsnName,
  3243. Gend: order.Gend,
  3244. Brdy: his.Brdy,
  3245. Age: his.Age,
  3246. Naty: order.Naty,
  3247. PatnCertType: "01",
  3248. Certno: order.Certno,
  3249. Prfs: "90",
  3250. ConerName: roles[0].UserName,
  3251. PatnRlts: "99",
  3252. ConerAddr: miConfig.OrgName,
  3253. ConerTel: admin.Mobile,
  3254. HiType: order.Insutype,
  3255. Insuplc: his.InsuplcAdmdvs,
  3256. MaindiagFlag: "1",
  3257. BillCode: order.SetlId,
  3258. BillNo: order.SetlId,
  3259. BizSn: order.Number,
  3260. PsnSelfPay: order.PsnPartAmt,
  3261. PsnOwnPay: order.PsnPartAmt,
  3262. AcctPay: order.AcctPay,
  3263. PsnCashpay: order.PsnCashPay,
  3264. HiPaymtd: "1",
  3265. Hsorg: his.InsuplcAdmdvs,
  3266. HsorgOpter: his.InsuplcAdmdvs,
  3267. MedinsFillPsn: curRoles.UserName,
  3268. MedinsFillDept: depart.Name,
  3269. IptMedType: "2",
  3270. }
  3271. struct4101.SetlBegnDate = order.SetlTime
  3272. struct4101.SetlEndDate = order.SetlTime
  3273. //if order.SettleType == 1 {
  3274. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3275. // dateStr := t.Format("2006-01-02")
  3276. // struct4101.SetlBegnDate = dateStr
  3277. // struct4101.SetlEndDate = dateStr
  3278. //} else {
  3279. // t := time.Unix(int64(order.SettleStartTime), 0)
  3280. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3281. // dateStartStr := t.Format("2006-01-02")
  3282. // dateEndStr := t2.Format("2006-01-02")
  3283. // struct4101.SetlBegnDate = dateStartStr
  3284. // struct4101.SetlEndDate = dateEndStr
  3285. //}
  3286. var rf []CustomFundPay
  3287. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3288. var tempFunPays []service.CustomStruct
  3289. var tempFunPay610100 service.CustomStruct
  3290. for _, item := range rf {
  3291. if item.FundPayType == "610100" {
  3292. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3293. tempFunPay610100.FundPayType = item.FundPayType
  3294. } else {
  3295. var tempFunPay service.CustomStruct
  3296. tempFunPay.FundPayamt = item.FundPayamt
  3297. tempFunPay.FundPayType = item.FundPayType
  3298. tempFunPays = append(tempFunPays, tempFunPay)
  3299. }
  3300. }
  3301. tempFunPays = append(tempFunPays, tempFunPay610100)
  3302. struct4101.CustomStruct = tempFunPays
  3303. var tempDiaginfos []service.DiaginfoStructTwo
  3304. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3305. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3306. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3307. var config []*models.HisXtDiagnoseConfig
  3308. for _, item := range diagnosis_ids {
  3309. id, _ := strconv.ParseInt(item, 10, 64)
  3310. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3311. config = append(config, &diagnosisConfig)
  3312. }
  3313. for index, item := range config {
  3314. if index == 0 {
  3315. var tempDiaginfo service.DiaginfoStructTwo
  3316. tempDiaginfo.DiagCode = item.CountryCode
  3317. tempDiaginfo.DiagName = item.CountryContentName
  3318. tempDiaginfo.DiagType = "1"
  3319. tempDiaginfo.MaindiagFlag = "1"
  3320. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3321. } else {
  3322. var tempDiaginfo service.DiaginfoStructTwo
  3323. tempDiaginfo.DiagCode = item.CountryCode
  3324. tempDiaginfo.DiagName = item.CountryContentName
  3325. tempDiaginfo.DiagType = "2"
  3326. tempDiaginfo.MaindiagFlag = "0"
  3327. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3328. }
  3329. }
  3330. struct4101.Diseinfo = tempDiaginfos
  3331. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3332. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3333. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3334. tempOpspdiseinfo2.OprnOprtCode = ""
  3335. tempOpspdiseinfo2.OprnOprtName = ""
  3336. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3337. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3338. var iteminfo service.IteminfoStruct
  3339. var bedCostTotal float64 = 0 //床位总费
  3340. var bedCostSelfTotal float64 = 0 //床位自费
  3341. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3342. var examineCostTotal float64 = 0 //诊查总费
  3343. var examineCostSelfTotal float64 = 0 //诊查自费
  3344. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3345. var nursingCostTotal float64 = 0 //护理总费
  3346. var nursingCostSelfTotal float64 = 0 //护理自费
  3347. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3348. var chineseMedicineCostTotal float64 = 0 //中成药
  3349. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3350. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3351. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3352. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3353. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3354. var registerCostTotal float64 = 0 //一般诊疗费
  3355. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3356. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3357. var operationCostTotal float64 = 0 //手术费
  3358. var operationCostSelfTotal float64 = 0 //手术费
  3359. var operationCostPartSelfTotal float64 = 0 //手术费
  3360. var otherCostTotal float64 = 0 //其他费用
  3361. var otherCostSelfTotal float64 = 0 //其他费用
  3362. var otherCostPartSelfTotal float64 = 0 //其他费用
  3363. var materialCostTotal float64 = 0 //材料费
  3364. var materialCostSelfTotal float64 = 0 //材料费
  3365. var materialCostPartSelfTotal float64 = 0 //材料费
  3366. var westernMedicineCostTotal float64 = 0 //西药费
  3367. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3368. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3369. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3370. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3371. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3372. var checkCostTotal float64 = 0 //检查费
  3373. var checkCostSelfTotal float64 = 0 //检查费
  3374. var checkCostPartSelfTotal float64 = 0 //检查费
  3375. var laboratoryCostTotal float64 = 0 //化验费
  3376. var laboratoryCostSelfTotal float64 = 0 //化验费
  3377. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3378. var treatCostTotal float64 = 0 //治疗费用
  3379. var treatCostSelfTotal float64 = 0 //治疗费用
  3380. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3381. decimal.DivisionPrecision = 2
  3382. var bed_fulamt_ownpay_amt float64 = 0
  3383. var examine_fulamt_ownpay_amt float64 = 0
  3384. var nursing_fulamt_ownpay_amt float64 = 0
  3385. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3386. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3387. var register_fulamt_ownpay_amt float64 = 0
  3388. var operation_fulamt_ownpay_amt float64 = 0
  3389. var other_fulamt_ownpay_amt float64 = 0
  3390. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3391. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3392. var check_fulamt_ownpay_amt float64 = 0
  3393. var material_fulamt_ownpay_amt float64 = 0
  3394. var laboratory_fulamt_ownpay_amt float64 = 0
  3395. var treat_fulamt_ownpay_amt float64 = 0
  3396. var bed_claa_sunmfee float64 = 0
  3397. var bed_clab_amt float64 = 0
  3398. var bed_other_amt float64 = 0
  3399. var examine_claa_sunmfee float64 = 0
  3400. var examine_clab_amt float64 = 0
  3401. var examine_other_amt float64 = 0
  3402. var nursing_claa_sunmfee float64 = 0
  3403. var nursing_clab_amt float64 = 0
  3404. var nursing_other_amt float64 = 0
  3405. var chinese_medicine_claa_sunmfee float64 = 0
  3406. var chinese_medicine_clab_amt float64 = 0
  3407. var chinese_medicine_other_amt float64 = 0
  3408. var commonly_treatment_claa_sunmfee float64 = 0
  3409. var commonly_treatment_clab_amt float64 = 0
  3410. var commonly_treatment_other_amt float64 = 0
  3411. var operation_claa_sunmfee float64 = 0
  3412. var operation_clab_amt float64 = 0
  3413. var operation_other_amt float64 = 0
  3414. var other_claa_sunmfee float64 = 0
  3415. var other_clab_amt float64 = 0
  3416. var other_other_amt float64 = 0
  3417. var westernMedicine_claa_sunmfee float64 = 0
  3418. var westernMedicine_clab_amt float64 = 0
  3419. var westernMedicine_other_amt float64 = 0
  3420. var chineseTraditional_claa_sunmfee float64 = 0
  3421. var chineseTraditional_clab_amt float64 = 0
  3422. var chineseTraditional_other_amt float64 = 0
  3423. var check_claa_sunmfee float64 = 0
  3424. var check_clab_amt float64 = 0
  3425. var check_other_amt float64 = 0
  3426. var material_claa_sunmfee float64 = 0
  3427. var material_clab_amt float64 = 0
  3428. var material_other_amt float64 = 0
  3429. var laboratory_claa_sunmfee float64 = 0
  3430. var laboratory_clab_amt float64 = 0
  3431. var laboratory_other_amt float64 = 0
  3432. var treat_claa_sunmfee float64 = 0
  3433. var treat_clab_amt float64 = 0
  3434. var treat_other_amt float64 = 0
  3435. var register_claa_sunmfee float64 = 0
  3436. var register_clab_amt float64 = 0
  3437. var register_other_amt float64 = 0
  3438. for _, item := range order.HisOrderInfo {
  3439. if item.MedChrgitmType == "01" { //床位费
  3440. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3441. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3442. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3443. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3444. if item.ChrgitmLv == "1" {
  3445. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3446. }
  3447. if item.ChrgitmLv == "2" {
  3448. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3449. }
  3450. if item.ChrgitmLv == "3" {
  3451. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3452. }
  3453. }
  3454. if item.MedChrgitmType == "02" { //诊查
  3455. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3456. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3457. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3458. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3459. if item.ChrgitmLv == "1" {
  3460. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3461. }
  3462. if item.ChrgitmLv == "2" {
  3463. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3464. }
  3465. if item.ChrgitmLv == "3" {
  3466. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3467. }
  3468. }
  3469. if item.MedChrgitmType == "03" { //检查费
  3470. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3471. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3472. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3473. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3474. if item.ChrgitmLv == "1" {
  3475. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3476. }
  3477. if item.ChrgitmLv == "2" {
  3478. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3479. }
  3480. if item.ChrgitmLv == "3" {
  3481. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3482. }
  3483. }
  3484. if item.MedChrgitmType == "04" { //化验费
  3485. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3486. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3487. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3488. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3489. if item.ChrgitmLv == "1" {
  3490. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3491. }
  3492. if item.ChrgitmLv == "2" {
  3493. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3494. }
  3495. if item.ChrgitmLv == "3" {
  3496. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3497. }
  3498. }
  3499. if item.MedChrgitmType == "05" { //治疗费
  3500. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3501. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3502. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3503. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3504. if item.ChrgitmLv == "1" {
  3505. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3506. }
  3507. if item.ChrgitmLv == "2" {
  3508. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3509. }
  3510. if item.ChrgitmLv == "3" {
  3511. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3512. }
  3513. }
  3514. if item.MedChrgitmType == "06" { //手术费
  3515. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3516. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3517. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3518. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3519. if item.ChrgitmLv == "1" {
  3520. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3521. }
  3522. if item.ChrgitmLv == "2" {
  3523. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3524. }
  3525. if item.ChrgitmLv == "3" {
  3526. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3527. }
  3528. }
  3529. if item.MedChrgitmType == "07" { //手术费
  3530. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3531. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3532. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3533. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3534. if item.ChrgitmLv == "1" {
  3535. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3536. }
  3537. if item.ChrgitmLv == "2" {
  3538. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3539. }
  3540. if item.ChrgitmLv == "3" {
  3541. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3542. }
  3543. }
  3544. if item.MedChrgitmType == "08" { //材料费
  3545. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3546. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3547. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3548. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3549. if item.ChrgitmLv == "1" {
  3550. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3551. }
  3552. if item.ChrgitmLv == "2" {
  3553. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3554. }
  3555. if item.ChrgitmLv == "3" {
  3556. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3557. }
  3558. }
  3559. if item.MedChrgitmType == "09" { //西药费
  3560. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3561. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3562. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3563. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3564. if item.ChrgitmLv == "1" {
  3565. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3566. }
  3567. if item.ChrgitmLv == "2" {
  3568. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3569. }
  3570. if item.ChrgitmLv == "3" {
  3571. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3572. }
  3573. }
  3574. if item.MedChrgitmType == "10" { //中药饮片
  3575. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3576. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3577. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3578. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3579. if item.ChrgitmLv == "1" {
  3580. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3581. }
  3582. if item.ChrgitmLv == "2" {
  3583. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3584. }
  3585. if item.ChrgitmLv == "3" {
  3586. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3587. }
  3588. }
  3589. if item.MedChrgitmType == "11" { //中成费
  3590. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3591. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3592. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3593. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3594. if item.ChrgitmLv == "1" {
  3595. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3596. }
  3597. if item.ChrgitmLv == "2" {
  3598. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3599. }
  3600. if item.ChrgitmLv == "3" {
  3601. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3602. }
  3603. }
  3604. if item.MedChrgitmType == "12" { //中成费
  3605. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3606. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3607. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3608. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3609. if item.ChrgitmLv == "1" {
  3610. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3611. }
  3612. if item.ChrgitmLv == "2" {
  3613. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3614. }
  3615. if item.ChrgitmLv == "3" {
  3616. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3617. }
  3618. }
  3619. if item.MedChrgitmType == "13" { //中成费
  3620. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3621. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3622. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3623. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3624. if item.ChrgitmLv == "1" {
  3625. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3626. }
  3627. if item.ChrgitmLv == "2" {
  3628. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3629. }
  3630. if item.ChrgitmLv == "3" {
  3631. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3632. }
  3633. }
  3634. if item.MedChrgitmType == "14" { //其他费
  3635. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3636. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3637. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3638. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3639. if item.ChrgitmLv == "1" {
  3640. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3641. }
  3642. if item.ChrgitmLv == "2" {
  3643. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3644. }
  3645. if item.ChrgitmLv == "3" {
  3646. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3647. }
  3648. }
  3649. }
  3650. var iteminfoStructs []service.IteminfoStruct
  3651. if bedCostTotal != 0 {
  3652. iteminfo.MedChrgitm = "01"
  3653. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3654. iteminfo.Amt = bedCostTotal
  3655. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3656. iteminfo.ClabAmt = bed_clab_amt
  3657. iteminfo.OthAmt = bed_other_amt
  3658. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3659. }
  3660. if examineCostTotal != 0 {
  3661. iteminfo.MedChrgitm = "02"
  3662. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3663. iteminfo.Amt = examineCostTotal
  3664. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3665. iteminfo.ClabAmt = examine_clab_amt
  3666. iteminfo.OthAmt = examine_other_amt
  3667. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3669. }
  3670. if checkCostTotal != 0 {
  3671. iteminfo.MedChrgitm = "03"
  3672. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3673. iteminfo.Amt = checkCostTotal
  3674. iteminfo.ClaaSumfee = check_claa_sunmfee
  3675. iteminfo.ClabAmt = check_clab_amt
  3676. iteminfo.OthAmt = check_other_amt
  3677. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3678. }
  3679. if laboratoryCostTotal != 0 {
  3680. iteminfo.MedChrgitm = "04"
  3681. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3682. iteminfo.Amt = laboratoryCostTotal
  3683. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3684. iteminfo.ClabAmt = laboratory_clab_amt
  3685. iteminfo.OthAmt = laboratory_other_amt
  3686. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3687. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3688. }
  3689. if treatCostTotal != 0 {
  3690. iteminfo.MedChrgitm = "05"
  3691. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3692. iteminfo.Amt = treatCostTotal
  3693. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3694. iteminfo.ClabAmt = treat_clab_amt
  3695. iteminfo.OthAmt = treat_other_amt
  3696. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3697. //(struct4101.IteminfoStruct, iteminfo)
  3698. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3699. }
  3700. if operationCostTotal != 0 {
  3701. iteminfo.MedChrgitm = "06"
  3702. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3703. iteminfo.Amt = operationCostTotal
  3704. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3705. iteminfo.ClabAmt = operation_clab_amt
  3706. iteminfo.OthAmt = operation_other_amt
  3707. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3708. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3709. }
  3710. if nursingCostTotal != 0 {
  3711. iteminfo.MedChrgitm = "07"
  3712. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3713. iteminfo.Amt = nursingCostTotal
  3714. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3715. iteminfo.ClabAmt = nursing_clab_amt
  3716. iteminfo.OthAmt = nursing_other_amt
  3717. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3718. }
  3719. if materialCostTotal != 0 {
  3720. iteminfo.MedChrgitm = "08"
  3721. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3722. iteminfo.Amt = materialCostTotal
  3723. iteminfo.ClaaSumfee = material_claa_sunmfee
  3724. iteminfo.ClabAmt = material_clab_amt
  3725. iteminfo.OthAmt = material_other_amt
  3726. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3727. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3728. }
  3729. if westernMedicineCostTotal != 0 {
  3730. iteminfo.MedChrgitm = "09"
  3731. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3732. iteminfo.Amt = westernMedicineCostTotal
  3733. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3734. iteminfo.ClabAmt = westernMedicine_clab_amt
  3735. iteminfo.OthAmt = westernMedicine_other_amt
  3736. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3737. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3738. }
  3739. if chineseMedicineCostTotal != 0 {
  3740. iteminfo.MedChrgitm = "10"
  3741. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3742. iteminfo.Amt = chineseMedicineCostTotal
  3743. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3744. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3745. iteminfo.OthAmt = chinese_medicine_other_amt
  3746. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3747. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3748. }
  3749. if chineseTraditionalMedicineCostTotal != 0 {
  3750. iteminfo.MedChrgitm = "11"
  3751. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3752. iteminfo.Amt = westernMedicineCostTotal
  3753. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3754. iteminfo.ClabAmt = westernMedicine_clab_amt
  3755. iteminfo.OthAmt = westernMedicine_other_amt
  3756. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3757. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3758. }
  3759. if commonlyTreatmentCostTotal != 0 {
  3760. iteminfo.MedChrgitm = "12"
  3761. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3762. iteminfo.Amt = commonlyTreatmentCostTotal
  3763. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3764. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3765. iteminfo.OthAmt = commonly_treatment_other_amt
  3766. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3767. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3768. }
  3769. if registerCostTotal != 0 {
  3770. iteminfo.MedChrgitm = "13"
  3771. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3772. iteminfo.Amt = registerCostTotal
  3773. iteminfo.ClaaSumfee = register_claa_sunmfee
  3774. iteminfo.ClabAmt = register_clab_amt
  3775. iteminfo.OthAmt = register_other_amt
  3776. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3778. }
  3779. if otherCostTotal != 0 {
  3780. iteminfo.MedChrgitm = "14"
  3781. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3782. iteminfo.Amt = otherCostTotal
  3783. iteminfo.ClaaSumfee = other_claa_sunmfee
  3784. iteminfo.ClabAmt = other_clab_amt
  3785. iteminfo.OthAmt = other_other_amt
  3786. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3787. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3788. }
  3789. struct4101.IteminfoStruct = iteminfoStructs
  3790. struct4101.Ntly = "中国"
  3791. struct4101.AdmCaty = "A03.06"
  3792. var res ResultSeventeen
  3793. if miConfig.MdtrtareaAdmvs == "421300" {
  3794. data := make(map[string]interface{})
  3795. data["struct4101"] = struct4101
  3796. data["secret_key"] = miConfig.SecretKey
  3797. data["org_name"] = miConfig.OrgName
  3798. data["opera"] = curRoles.UserName
  3799. data["code"] = miConfig.Code
  3800. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3801. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3802. client := &http.Client{}
  3803. bytesData, _ := json.Marshal(data)
  3804. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3805. resp, _ := client.Do(req)
  3806. defer resp.Body.Close()
  3807. body, ioErr := ioutil.ReadAll(resp.Body)
  3808. if ioErr != nil {
  3809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. var respJSON map[string]interface{}
  3814. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3817. return
  3818. }
  3819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3820. userJSONBytes, _ := json.Marshal(respJSON)
  3821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3822. utils.ErrorLog("解析失败:%v", err)
  3823. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3824. adminUser := c.GetAdminUserInfo()
  3825. errlog := &models.HisOrderError{
  3826. UserOrgId: adminUser.CurrentOrgId,
  3827. Ctime: time.Now().Unix(),
  3828. Mtime: time.Now().Unix(),
  3829. ErrMsg: res.ErrMsg + "解析失败",
  3830. Status: 1,
  3831. PatientId: order_id,
  3832. Stage: 10088,
  3833. }
  3834. service.CreateErrMsgLog(errlog)
  3835. continue
  3836. }
  3837. } else {
  3838. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3839. fmt.Println(result)
  3840. var dat map[string]interface{}
  3841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3842. fmt.Println(dat)
  3843. } else {
  3844. fmt.Println(err)
  3845. }
  3846. userJSONBytes, _ := json.Marshal(dat)
  3847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3848. utils.ErrorLog("解析失败:%v", err)
  3849. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. adminUser := c.GetAdminUserInfo()
  3851. errlog := &models.HisOrderError{
  3852. UserOrgId: adminUser.CurrentOrgId,
  3853. Ctime: time.Now().Unix(),
  3854. Mtime: time.Now().Unix(),
  3855. ErrMsg: res.ErrMsg + "解析失败",
  3856. Status: 1,
  3857. PatientId: order_id,
  3858. Stage: 10106,
  3859. }
  3860. service.CreateErrMsgLog(errlog)
  3861. continue
  3862. }
  3863. }
  3864. if res.Infcode != 0 {
  3865. adminUser := c.GetAdminUserInfo()
  3866. errlog := &models.HisOrderError{
  3867. UserOrgId: adminUser.CurrentOrgId,
  3868. Ctime: time.Now().Unix(),
  3869. Mtime: time.Now().Unix(),
  3870. ErrMsg: res.ErrMsg,
  3871. Status: 1,
  3872. PatientId: order_id,
  3873. Stage: 10106,
  3874. }
  3875. service.CreateErrMsgLog(errlog)
  3876. continue
  3877. } else {
  3878. hisFundSettleListResult := &models.HisFundSettleListResult{
  3879. Number: res.Output.SetlListId,
  3880. Status: 1,
  3881. Ctime: time.Now().Unix(),
  3882. Mtime: time.Now().Unix(),
  3883. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3884. IsUpload: 1,
  3885. OrderId: order_id,
  3886. }
  3887. service.CreateUploadRecord(hisFundSettleListResult)
  3888. continue
  3889. }
  3890. }
  3891. }
  3892. func (c *HisApiController) GetOrgInfo() {
  3893. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3894. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3895. }
  3896. func (c *HisApiController) GetHisPatientInfo() {
  3897. medical_insurance_card := c.GetString("medical_insurance_card")
  3898. id_card_type, _ := c.GetInt64("id_card_type")
  3899. id_card := c.GetString("id_card")
  3900. adminInfo := c.GetAdminUserInfo()
  3901. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3902. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3903. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3904. IdCardNo := ""
  3905. if id_card_type == 1 {
  3906. IdCardNo = medical_insurance_card
  3907. } else if id_card_type == 2 {
  3908. IdCardNo = id_card
  3909. }
  3910. if config.IsOpen == 1 {
  3911. 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
  3912. resp, requestErr := http.Get(api)
  3913. if requestErr != nil {
  3914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. return
  3916. }
  3917. defer resp.Body.Close()
  3918. body, ioErr := ioutil.ReadAll(resp.Body)
  3919. if ioErr != nil {
  3920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3922. return
  3923. }
  3924. var respJSON map[string]interface{}
  3925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. return
  3929. }
  3930. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3931. userJSONBytes, _ := json.Marshal(userJSON)
  3932. var res ResultTwo
  3933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3934. utils.ErrorLog("解析失败:%v", err)
  3935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3936. return
  3937. }
  3938. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3939. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3940. infoStr := string(Iinfos)
  3941. idetinfoStr := string(Idetinfos)
  3942. if res.Infcode == 0 {
  3943. his := models.VMHisPatient{
  3944. Status: 1,
  3945. Ctime: time.Now().Unix(),
  3946. Mtime: time.Now().Unix(),
  3947. PsnNo: res.Output.Baseinfo.PsnNo,
  3948. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3949. Certno: res.Output.Baseinfo.Certno,
  3950. PsnName: res.Output.Baseinfo.PsnName,
  3951. Gend: res.Output.Baseinfo.Gend,
  3952. Naty: res.Output.Baseinfo.Naty,
  3953. Brdy: res.Output.Baseinfo.Brdy,
  3954. Age: res.Output.Baseinfo.Age,
  3955. Iinfo: infoStr,
  3956. Idetinfo: idetinfoStr,
  3957. UserOrgId: adminInfo.CurrentOrgId,
  3958. IsReturn: 1,
  3959. IdCardType: id_card_type,
  3960. }
  3961. c.ServeSuccessJSON(map[string]interface{}{
  3962. "info": his,
  3963. })
  3964. } else {
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3966. return
  3967. }
  3968. }
  3969. }
  3970. //func GetBasBaseInfo() (jsonStr string, err error) {
  3971. //
  3972. // handle := syscall.NewLazyDLL("SSCard.dll")
  3973. // add := handle.NewProc("ReadCardBas")
  3974. // str := make([]byte, 1024)
  3975. // str1 := make([]byte, 1024)
  3976. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3977. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3978. //
  3979. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3980. //
  3981. // fmt.Println("> Add(4,5)的结果为:", ret)
  3982. // handle.Release()
  3983. //
  3984. // return "", nil
  3985. //
  3986. //}
  3987. //func GetQRBaseInfo() (jsonStr string, err error) {
  3988. // handle := syscall.LoadDLL("SSCard.dll")
  3989. // ReadCardBas := handle.FindProc("GetQRBase")
  3990. //
  3991. // str := make([]byte, 256)
  3992. // str1 := make([]byte, 256)
  3993. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3994. //
  3995. // fmt.Println(string(str))
  3996. // fmt.Println(r)
  3997. // return string(str), nil
  3998. //}
  3999. //func CardInit() int {
  4000. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  4001. // add := DllTestDef.MustFindProc("Init")
  4002. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4003. // if err != nil {
  4004. // fmt.Println("SSCard的运算结果为:", ret)
  4005. // }
  4006. // result := int(ret)
  4007. // return result
  4008. //}
  4009. //func CardInit() int {
  4010. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  4011. // if err != nil {
  4012. // fmt.Println("SSCard的运算结果为:", ret)
  4013. // }
  4014. // fmt.Println(err)
  4015. // result := int(ret)
  4016. // return result
  4017. //}
  4018. func IntPtr(n int) uintptr {
  4019. return uintptr(n)
  4020. }
  4021. func StrPtr(s string) uintptr {
  4022. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  4023. }
  4024. type Result2001 struct {
  4025. Cainfo interface{} `json:"cainfo"`
  4026. ErrMsg string `json:"err_msg"`
  4027. InfRefmsgid string `json:"inf_refmsgid"`
  4028. Infcode int64 `json:"infcode"`
  4029. Output struct {
  4030. Trtinfo struct {
  4031. PsnNo string `json:"psn_no"`
  4032. TrtChkType string `json:"trt_chk_type"`
  4033. FundPayType string `json:"fund_pay_type"`
  4034. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4035. Begndate string `json:"begndate"`
  4036. Enddate string `json:"enddate"`
  4037. TrtChkRslt string `json:"trt_chk_rslt"`
  4038. } `json:"trtinfo"`
  4039. } `json:"output"`
  4040. RefmsgTime string `json:"refmsg_time"`
  4041. RespondTime string `json:"respond_time"`
  4042. Signtype interface{} `json:"signtype"`
  4043. WarnMsg interface{} `json:"warn_msg"`
  4044. }
  4045. type Result2001Org10265 struct {
  4046. Cainfo interface{} `json:"cainfo"`
  4047. ErrMsg string `json:"err_msg"`
  4048. InfRefmsgid string `json:"inf_refmsgid"`
  4049. Infcode string `json:"infcode"`
  4050. Output struct {
  4051. Trtinfo struct {
  4052. PsnNo string `json:"psn_no"`
  4053. TrtChkType string `json:"trt_chk_type"`
  4054. FundPayType string `json:"fund_pay_type"`
  4055. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4056. Begndate string `json:"begndate"`
  4057. Enddate string `json:"enddate"`
  4058. TrtChkRslt string `json:"trt_chk_rslt"`
  4059. } `json:"trtinfo"`
  4060. } `json:"output"`
  4061. RefmsgTime string `json:"refmsg_time"`
  4062. RespondTime string `json:"respond_time"`
  4063. Signtype interface{} `json:"signtype"`
  4064. WarnMsg interface{} `json:"warn_msg"`
  4065. }
  4066. type ResultTwo struct {
  4067. ErrMsg string `json:"err_msg"`
  4068. InfRefmsgid string `json:"inf_refmsgid"`
  4069. Infcode int64 `json:"infcode"`
  4070. Output struct {
  4071. Baseinfo struct {
  4072. Age float64 `json:"age"`
  4073. Brdy string `json:"brdy"`
  4074. Certno string `json:"certno"`
  4075. Gend string `json:"gend"`
  4076. Naty string `json:"naty"`
  4077. PsnCertType string `json:"psn_cert_type"`
  4078. PsnName string `json:"psn_name"`
  4079. PsnNo string `json:"psn_no"`
  4080. } `json:"baseinfo"`
  4081. Idetinfo []interface{} `json:"idetinfo"`
  4082. Iinfo []struct {
  4083. Balc float64 `json:"balc"`
  4084. CvlservFlag string `json:"cvlserv_flag"`
  4085. EmpName string `json:"emp_name"`
  4086. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4087. Insutype string `json:"insutype"`
  4088. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4089. PausInsuDate string `json:"paus_insu_date"`
  4090. PsnInsuDate string `json:"psn_insu_date"`
  4091. PsnInsuStas string `json:"psn_insu_stas"`
  4092. PsnType string `json:"psn_type"`
  4093. } `json:"insuinfo"`
  4094. } `json:"output"`
  4095. RefmsgTime string `json:"refmsg_time"`
  4096. RespondTime string `json:"respond_time"`
  4097. Signtype interface{} `json:"signtype"`
  4098. WarnInfo interface{} `json:"warn_info"`
  4099. }
  4100. type ResultTwo10265 struct {
  4101. ErrMsg string `json:"err_msg"`
  4102. InfRefmsgid string `json:"inf_refmsgid"`
  4103. Infcode string `json:"infcode"`
  4104. Output struct {
  4105. Baseinfo struct {
  4106. Age float64 `json:"age"`
  4107. Brdy string `json:"brdy"`
  4108. Certno string `json:"certno"`
  4109. Gend string `json:"gend"`
  4110. Naty string `json:"naty"`
  4111. PsnCertType string `json:"psn_cert_type"`
  4112. PsnName string `json:"psn_name"`
  4113. PsnNo string `json:"psn_no"`
  4114. } `json:"baseinfo"`
  4115. Idetinfo []interface{} `json:"idetinfo"`
  4116. Iinfo []struct {
  4117. Balc float64 `json:"balc"`
  4118. CvlservFlag string `json:"cvlserv_flag"`
  4119. EmpName string `json:"emp_name"`
  4120. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4121. Insutype string `json:"insutype"`
  4122. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4123. PausInsuDate string `json:"paus_insu_date"`
  4124. PsnInsuDate string `json:"psn_insu_date"`
  4125. PsnInsuStas string `json:"psn_insu_stas"`
  4126. PsnType string `json:"psn_type"`
  4127. } `json:"insuinfo"`
  4128. } `json:"output"`
  4129. RefmsgTime string `json:"refmsg_time"`
  4130. RespondTime string `json:"respond_time"`
  4131. Signtype interface{} `json:"signtype"`
  4132. WarnInfo interface{} `json:"warn_info"`
  4133. }
  4134. type ResultThree struct {
  4135. Cainfo interface{} `json:"cainfo"`
  4136. ErrMsg string `json:"err_msg"`
  4137. InfRefmsgid string `json:"inf_refmsgid"`
  4138. Infcode int64 `json:"infcode"`
  4139. Output struct {
  4140. Data struct {
  4141. IptOtpNo string `json:"ipt_otp_no"`
  4142. MdtrtID string `json:"mdtrt_id"`
  4143. PsnNo string `json:"psn_no"`
  4144. } `json:"data"`
  4145. } `json:"output"`
  4146. RefmsgTime string `json:"refmsg_time"`
  4147. RespondTime string `json:"respond_time"`
  4148. Signtype interface{} `json:"signtype"`
  4149. WarnMsg interface{} `json:"warn_msg"`
  4150. }
  4151. type ResultThree10265 struct {
  4152. Cainfo interface{} `json:"cainfo"`
  4153. ErrMsg string `json:"err_msg"`
  4154. InfRefmsgid string `json:"inf_refmsgid"`
  4155. Infcode string `json:"infcode"`
  4156. Output struct {
  4157. Data struct {
  4158. IptOtpNo string `json:"ipt_otp_no"`
  4159. MdtrtID string `json:"mdtrt_id"`
  4160. PsnNo string `json:"psn_no"`
  4161. } `json:"data"`
  4162. } `json:"output"`
  4163. RefmsgTime string `json:"refmsg_time"`
  4164. RespondTime string `json:"respond_time"`
  4165. Signtype interface{} `json:"signtype"`
  4166. WarnMsg interface{} `json:"warn_msg"`
  4167. }
  4168. type ResultFour struct {
  4169. Cainfo string `json:"cainfo"`
  4170. ErrMsg string `json:"err_msg"`
  4171. InfRefmsgid string `json:"inf_refmsgid"`
  4172. Infcode int64 `json:"infcode"`
  4173. Output struct {
  4174. Result []struct {
  4175. BasMednFlag string `json:"bas_medn_flag"`
  4176. ChldMedcFlag string `json:"chld_medc_flag"`
  4177. ChrgitmLv string `json:"chrgitm_lv"`
  4178. Cnt float64 `json:"cnt"`
  4179. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4180. DrtReimFlag string `json:"drt_reim_flag"`
  4181. FeedetlSn string `json:"feedetl_sn"`
  4182. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4183. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4184. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4185. ListSpItemFlag string `json:"list_sp_item_flag"`
  4186. LmtUsedFlag string `json:"lmt_used_flag"`
  4187. MedChrgitmType string `json:"med_chrgitm_type"`
  4188. Memo string `json:"memo"`
  4189. OverlmtAmt float64 `json:"overlmt_amt"`
  4190. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4191. Pric float64 `json:"pric"`
  4192. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4193. SelfpayProp float64 `json:"selfpay_prop"`
  4194. } `json:"result"`
  4195. } `json:"output"`
  4196. RefmsgTime string `json:"refmsg_time"`
  4197. RespondTime string `json:"respond_time"`
  4198. Signtype string `json:"signtype"`
  4199. WarnMsg string `json:"warn_msg"`
  4200. }
  4201. type ResultFour10265 struct {
  4202. Cainfo string `json:"cainfo"`
  4203. ErrMsg string `json:"err_msg"`
  4204. InfRefmsgid string `json:"inf_refmsgid"`
  4205. Infcode string `json:"infcode"`
  4206. Output struct {
  4207. Result []struct {
  4208. BasMednFlag string `json:"bas_medn_flag"`
  4209. ChldMedcFlag string `json:"chld_medc_flag"`
  4210. ChrgitmLv string `json:"chrgitm_lv"`
  4211. Cnt float64 `json:"cnt"`
  4212. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4213. DrtReimFlag string `json:"drt_reim_flag"`
  4214. FeedetlSn string `json:"feedetl_sn"`
  4215. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4216. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4217. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4218. ListSpItemFlag string `json:"list_sp_item_flag"`
  4219. LmtUsedFlag string `json:"lmt_used_flag"`
  4220. MedChrgitmType string `json:"med_chrgitm_type"`
  4221. Memo string `json:"memo"`
  4222. OverlmtAmt float64 `json:"overlmt_amt"`
  4223. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4224. Pric float64 `json:"pric"`
  4225. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4226. SelfpayProp float64 `json:"selfpay_prop"`
  4227. } `json:"result"`
  4228. } `json:"output"`
  4229. RefmsgTime string `json:"refmsg_time"`
  4230. RespondTime string `json:"respond_time"`
  4231. Signtype string `json:"signtype"`
  4232. WarnMsg string `json:"warn_msg"`
  4233. }
  4234. type ResultFive struct {
  4235. Balc float64 `json:"balc"`
  4236. CvlservFlag string `json:"cvlserv_flag"`
  4237. EmpName string `json:"emp_name"`
  4238. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4239. Insutype string `json:"insutype"`
  4240. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4241. PausInsuDate string `json:"paus_insu_date"`
  4242. PsnInsuDate string `json:"psn_insu_date"`
  4243. PsnInsuStas string `json:"psn_insu_stas"`
  4244. PsnType string `json:"psn_type"`
  4245. }
  4246. type ResultSix struct {
  4247. Cainfo interface{} `json:"cainfo"`
  4248. ErrMsg string `json:"err_msg"`
  4249. InfRefmsgid string `json:"inf_refmsgid"`
  4250. Infcode int64 `json:"infcode"`
  4251. Output struct {
  4252. } `json:"output"`
  4253. RefmsgTime string `json:"refmsg_time"`
  4254. RespondTime string `json:"respond_time"`
  4255. Signtype interface{} `json:"signtype"`
  4256. WarnMsg interface{} `json:"warn_msg"`
  4257. }
  4258. type ResultSix10265 struct {
  4259. Cainfo interface{} `json:"cainfo"`
  4260. ErrMsg string `json:"err_msg"`
  4261. InfRefmsgid string `json:"inf_refmsgid"`
  4262. Infcode string `json:"infcode"`
  4263. Output struct {
  4264. } `json:"output"`
  4265. RefmsgTime string `json:"refmsg_time"`
  4266. RespondTime string `json:"respond_time"`
  4267. Signtype interface{} `json:"signtype"`
  4268. WarnMsg interface{} `json:"warn_msg"`
  4269. }
  4270. type ResultSeven struct {
  4271. Cainfo string `json:"cainfo"`
  4272. ErrMsg string `json:"err_msg"`
  4273. InfRefmsgid string `json:"inf_refmsgid"`
  4274. Infcode int64 `json:"infcode"`
  4275. Output struct {
  4276. Setldetail []interface{} `json:"setldetail"`
  4277. Setlinfo struct {
  4278. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4279. AcctPay float64 `json:"acct_pay"`
  4280. ActPayDedc float64 `json:"act_pay_dedc"`
  4281. Age float64 `json:"age"`
  4282. Balc float64 `json:"balc"`
  4283. Brdy string `json:"brdy"`
  4284. Certno string `json:"certno"`
  4285. ClrOptins string `json:"clr_optins"`
  4286. ClrType string `json:"clr_type"`
  4287. ClrWay string `json:"clr_way"`
  4288. CvlservFlag string `json:"cvlserv_flag"`
  4289. CvlservPay float64 `json:"cvlserv_pay"`
  4290. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4291. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4292. Gend string `json:"gend"`
  4293. HifesPay float64 `json:"hifes_pay"`
  4294. HifmiPay float64 `json:"hifmi_pay"`
  4295. HifpPay float64 `json:"hifp_pay"`
  4296. HospPartAmt float64 `json:"hosp_part_amt"`
  4297. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4298. Insutype string `json:"insutype"`
  4299. MafPay float64 `json:"maf_pay"`
  4300. MdtrtCertType string `json:"mdtrt_cert_type"`
  4301. HifobPay float64 `json:"hifob_pay"`
  4302. MdtrtID string `json:"mdtrt_id"`
  4303. MedType string `json:"med_type"`
  4304. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4305. MedinsSetlID string `json:"medins_setl_id"`
  4306. Naty string `json:"naty"`
  4307. OthPay float64 `json:"oth_pay"`
  4308. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4309. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4310. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4311. PsnCashPay float64 `json:"psn_cash_pay"`
  4312. PsnCertType string `json:"psn_cert_type"`
  4313. PsnName string `json:"psn_name"`
  4314. PsnNo string `json:"psn_no"`
  4315. PsnPartAmt float64 `json:"psn_part_amt"`
  4316. PsnType string `json:"psn_type"`
  4317. SetlID string `json:"setl_id"`
  4318. SetlTime string `json:"setl_time"`
  4319. } `json:"setlinfo"`
  4320. } `json:"output"`
  4321. RefmsgTime string `json:"refmsg_time"`
  4322. RespondTime string `json:"respond_time"`
  4323. Signtype interface{} `json:"signtype"`
  4324. WarnMsg interface{} `json:"warn_msg"`
  4325. }
  4326. type ResultSeven10265 struct {
  4327. Cainfo string `json:"cainfo"`
  4328. ErrMsg string `json:"err_msg"`
  4329. InfRefmsgid string `json:"inf_refmsgid"`
  4330. Infcode string `json:"infcode"`
  4331. Output struct {
  4332. Setldetail []interface{} `json:"setldetail"`
  4333. Setlinfo struct {
  4334. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4335. AcctPay float64 `json:"acct_pay"`
  4336. ActPayDedc float64 `json:"act_pay_dedc"`
  4337. Age float64 `json:"age"`
  4338. Balc float64 `json:"balc"`
  4339. Brdy string `json:"brdy"`
  4340. Certno string `json:"certno"`
  4341. ClrOptins string `json:"clr_optins"`
  4342. ClrType string `json:"clr_type"`
  4343. ClrWay string `json:"clr_way"`
  4344. CvlservFlag string `json:"cvlserv_flag"`
  4345. CvlservPay float64 `json:"cvlserv_pay"`
  4346. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4347. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4348. Gend string `json:"gend"`
  4349. HifesPay float64 `json:"hifes_pay"`
  4350. HifmiPay float64 `json:"hifmi_pay"`
  4351. HifpPay float64 `json:"hifp_pay"`
  4352. HospPartAmt float64 `json:"hosp_part_amt"`
  4353. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4354. Insutype string `json:"insutype"`
  4355. MafPay float64 `json:"maf_pay"`
  4356. MdtrtCertType string `json:"mdtrt_cert_type"`
  4357. HifobPay float64 `json:"hifob_pay"`
  4358. MdtrtID string `json:"mdtrt_id"`
  4359. MedType string `json:"med_type"`
  4360. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4361. MedinsSetlID string `json:"medins_setl_id"`
  4362. Naty string `json:"naty"`
  4363. OthPay float64 `json:"oth_pay"`
  4364. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4365. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4366. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4367. PsnCashPay float64 `json:"psn_cash_pay"`
  4368. PsnCertType string `json:"psn_cert_type"`
  4369. PsnName string `json:"psn_name"`
  4370. PsnNo string `json:"psn_no"`
  4371. PsnPartAmt float64 `json:"psn_part_amt"`
  4372. PsnType string `json:"psn_type"`
  4373. SetlID string `json:"setl_id"`
  4374. SetlTime string `json:"setl_time"`
  4375. } `json:"setlinfo"`
  4376. } `json:"output"`
  4377. RefmsgTime string `json:"refmsg_time"`
  4378. RespondTime string `json:"respond_time"`
  4379. Signtype interface{} `json:"signtype"`
  4380. WarnMsg interface{} `json:"warn_msg"`
  4381. }
  4382. type ResultEight struct {
  4383. Cainfo string `json:"cainfo"`
  4384. ErrMsg string `json:"err_msg"`
  4385. InfRefmsgid string `json:"inf_refmsgid"`
  4386. Infcode int64 `json:"infcode"`
  4387. Output struct {
  4388. Stmtinfo struct {
  4389. SetlOptins string `json:"setl_optins"`
  4390. StmtRslt string `json:"stmt_rslt"`
  4391. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4392. } `json:"stmtinfo"`
  4393. } `json:"output"`
  4394. RefmsgTime string `json:"refmsg_time"`
  4395. RespondTime string `json:"respond_time"`
  4396. Signtype interface{} `json:"signtype"`
  4397. WarnMsg interface{} `json:"warn_msg"`
  4398. }
  4399. type ResultEightFor10188 struct {
  4400. Cainfo string `json:"cainfo"`
  4401. ErrMsg string `json:"err_msg"`
  4402. InfRefmsgid string `json:"inf_refmsgid"`
  4403. Infcode string `json:"infcode"`
  4404. Output struct {
  4405. Stmtinfo struct {
  4406. SetlOptins string `json:"setl_optins"`
  4407. StmtRslt string `json:"stmt_rslt"`
  4408. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4409. } `json:"stmtinfo"`
  4410. } `json:"output"`
  4411. RefmsgTime string `json:"refmsg_time"`
  4412. RespondTime string `json:"respond_time"`
  4413. Signtype interface{} `json:"signtype"`
  4414. WarnMsg interface{} `json:"warn_msg"`
  4415. }
  4416. type ResultNine struct {
  4417. Cainfo string `json:"cainfo"`
  4418. ErrMsg string `json:"err_msg"`
  4419. InfRefmsgid string `json:"inf_refmsgid"`
  4420. Infcode int64 `json:"infcode"`
  4421. Output struct {
  4422. FileQuryNo string `json:"file_qury_no"`
  4423. } `json:"output"`
  4424. RefmsgTime string `json:"refmsg_time"`
  4425. RespondTime string `json:"respond_time"`
  4426. Signtype interface{} `json:"signtype"`
  4427. WarnMsg interface{} `json:"warn_msg"`
  4428. }
  4429. type ResultTen struct {
  4430. Cainfo string `json:"cainfo"`
  4431. ErrMsg string `json:"err_msg"`
  4432. InfRefmsgid string `json:"inf_refmsgid"`
  4433. Infcode int64 `json:"infcode"`
  4434. Output struct {
  4435. DldEndtime string `json:"dld_endtime"`
  4436. FileQuryNo string `json:"file_qury_no"`
  4437. Filename string `json:"filename"`
  4438. } `json:"output"`
  4439. RefmsgTime string `json:"refmsg_time"`
  4440. RespondTime string `json:"respond_time"`
  4441. Signtype interface{} `json:"signtype"`
  4442. WarnMsg interface{} `json:"warn_msg"`
  4443. }
  4444. //type Autogenerated struct {
  4445. // Output struct {
  4446. // Setlinfo struct {
  4447. // SetlTime string `json:"setl_time"`
  4448. // CvlservPay float64 `json:"cvlserv_pay"`
  4449. // Year string `json:"year"`
  4450. // MedType string `json:"med_type"`
  4451. // PsnPay float64 `json:"psn_pay"`
  4452. // OpterID string `json:"opter_id"`
  4453. // Begndate string `json:"begndate"`
  4454. // FlxempeFlag string `json:"flxempe_flag"`
  4455. // HifmiPay float64 `json:"hifmi_pay"`
  4456. // PsnNo string `json:"psn_no"`
  4457. // ActPayDedc float64 `json:"act_pay_dedc"`
  4458. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4459. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4460. // ClrWay string `json:"clr_way"`
  4461. // OthPay float64 `json:"oth_pay"`
  4462. // Gend string `json:"gend"`
  4463. // MdtrtID string `json:"mdtrt_id"`
  4464. // AcctPay float64 `json:"acct_pay"`
  4465. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4466. // Insutype string `json:"insutype"`
  4467. // Invono interface{} `json:"invono"`
  4468. // Enddate string `json:"enddate"`
  4469. // CashPayamt float64 `json:"cash_payamt"`
  4470. // PsnType string `json:"psn_type"`
  4471. // FixmedinsName string `json:"fixmedins_name"`
  4472. // HifpPay float64 `json:"hifp_pay"`
  4473. // NewFlag interface{} `json:"new_flag"`
  4474. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4475. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4476. // PayLoc string `json:"pay_loc"`
  4477. // ClrType string `json:"clr_type"`
  4478. // RefdSetlFlag string `json:"refd_setl_flag"`
  4479. // CvlservFlag string `json:"cvlserv_flag"`
  4480. // EmpName string `json:"emp_name"`
  4481. // Brdy string `json:"brdy"`
  4482. // Naty string `json:"naty"`
  4483. // Certno string `json:"certno"`
  4484. // DiseCode string `json:"dise_code"`
  4485. // FixmedinsCode string `json:"fixmedins_code"`
  4486. // DedcHospLv string `json:"dedc_hosp_lv"`
  4487. // OpterName string `json:"opter_name"`
  4488. // Balc float64 `json:"balc"`
  4489. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4490. // PsnCertType string `json:"psn_cert_type"`
  4491. // HifobPay float64 `json:"hifob_pay"`
  4492. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4493. // HifesPay float64 `json:"hifes_pay"`
  4494. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4495. // OptTime string `json:"opt_time"`
  4496. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4497. // SetlID string `json:"setl_id"`
  4498. // MafPay float64 `json:"maf_pay"`
  4499. // PsnName string `json:"psn_name"`
  4500. // InsuOptins interface{} `json:"insu_optins"`
  4501. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4502. // ClrOptins string `json:"clr_optins"`
  4503. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4504. // DiseName string `json:"dise_name"`
  4505. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4506. // Age float64 `json:"age"`
  4507. // DtrtCertType string `json:"dtrt_cert_type"`
  4508. // HospLv string `json:"hosp_lv"`
  4509. // } `json:"setlinfo"`
  4510. // Setldetail []struct {
  4511. // FundPayType string `json:"fund_pay_type"`
  4512. // FundPayamt float64 `json:"fund_payamt"`
  4513. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4514. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4515. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4516. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4517. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4518. // } `json:"setldetail"`
  4519. // } `json:"output"`
  4520. // Infcode int `json:"infcode"`
  4521. // WarnMsg interface{} `json:"warn_msg"`
  4522. // Cainfo interface{} `json:"cainfo"`
  4523. // ErrMsg interface{} `json:"err_msg"`
  4524. // RefmsgTime string `json:"refmsg_time"`
  4525. // Signtype interface{} `json:"signtype"`
  4526. // RespondTime string `json:"respond_time"`
  4527. // InfRefmsgid string `json:"inf_refmsgid"`
  4528. //}
  4529. type ResultEleven 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. Setlinfo struct {
  4536. SetlTime string `json:"setl_time"`
  4537. CvlservPay float64 `json:"cvlserv_pay"`
  4538. Year string `json:"year"`
  4539. MedType string `json:"med_type"`
  4540. PsnPay float64 `json:"psn_pay"`
  4541. OpterID string `json:"opter_id"`
  4542. Begndate string `json:"begndate"`
  4543. FlxempeFlag string `json:"flxempe_flag"`
  4544. HifmiPay float64 `json:"hifmi_pay"`
  4545. PsnNo string `json:"psn_no"`
  4546. ActPayDedc float64 `json:"act_pay_dedc"`
  4547. MedinsSetlID interface{} `json:"medins_setl_id"`
  4548. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4549. ClrWay string `json:"clr_way"`
  4550. OthPay float64 `json:"oth_pay"`
  4551. Gend string `json:"gend"`
  4552. MdtrtID string `json:"mdtrt_id"`
  4553. AcctPay float64 `json:"acct_pay"`
  4554. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4555. Insutype string `json:"insutype"`
  4556. Invono interface{} `json:"invono"`
  4557. Enddate string `json:"enddate"`
  4558. CashPayamt float64 `json:"cash_payamt"`
  4559. PsnType string `json:"psn_type"`
  4560. FixmedinsName string `json:"fixmedins_name"`
  4561. HifpPay float64 `json:"hifp_pay"`
  4562. NewFlag interface{} `json:"new_flag"`
  4563. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4564. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4565. PayLoc string `json:"pay_loc"`
  4566. ClrType string `json:"clr_type"`
  4567. RefdSetlFlag string `json:"refd_setl_flag"`
  4568. CvlservFlag string `json:"cvlserv_flag"`
  4569. EmpName string `json:"emp_name"`
  4570. Brdy string `json:"brdy"`
  4571. Naty string `json:"naty"`
  4572. Certno string `json:"certno"`
  4573. DiseCode string `json:"dise_code"`
  4574. FixmedinsCode string `json:"fixmedins_code"`
  4575. DedcHospLv string `json:"dedc_hosp_lv"`
  4576. OpterName string `json:"opter_name"`
  4577. Balc float64 `json:"balc"`
  4578. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4579. PsnCertType string `json:"psn_cert_type"`
  4580. HifobPay float64 `json:"hifob_pay"`
  4581. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4582. HifesPay float64 `json:"hifes_pay"`
  4583. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4584. OptTime string `json:"opt_time"`
  4585. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4586. SetlID string `json:"setl_id"`
  4587. MafPay float64 `json:"maf_pay"`
  4588. PsnName string `json:"psn_name"`
  4589. InsuOptins interface{} `json:"insu_optins"`
  4590. PrefFundPay interface{} `json:"pref_fund_pay"`
  4591. ClrOptins string `json:"clr_optins"`
  4592. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4593. DiseName string `json:"dise_name"`
  4594. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4595. Age float64 `json:"age"`
  4596. DtrtCertType string `json:"dtrt_cert_type"`
  4597. HospLv string `json:"hosp_lv"`
  4598. } `json:"setlinfo"`
  4599. } `json:"output"`
  4600. RefmsgTime string `json:"refmsg_time"`
  4601. RespondTime string `json:"respond_time"`
  4602. Signtype interface{} `json:"signtype"`
  4603. WarnMsg interface{} `json:"warn_msg"`
  4604. }
  4605. type ResultEleven10265 struct {
  4606. Cainfo string `json:"cainfo"`
  4607. ErrMsg string `json:"err_msg"`
  4608. InfRefmsgid string `json:"inf_refmsgid"`
  4609. Infcode string `json:"infcode"`
  4610. Output struct {
  4611. Setlinfo struct {
  4612. SetlTime string `json:"setl_time"`
  4613. CvlservPay float64 `json:"cvlserv_pay"`
  4614. Year string `json:"year"`
  4615. MedType string `json:"med_type"`
  4616. PsnPay float64 `json:"psn_pay"`
  4617. OpterID string `json:"opter_id"`
  4618. Begndate string `json:"begndate"`
  4619. FlxempeFlag string `json:"flxempe_flag"`
  4620. HifmiPay float64 `json:"hifmi_pay"`
  4621. PsnNo string `json:"psn_no"`
  4622. ActPayDedc float64 `json:"act_pay_dedc"`
  4623. MedinsSetlID interface{} `json:"medins_setl_id"`
  4624. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4625. ClrWay string `json:"clr_way"`
  4626. OthPay float64 `json:"oth_pay"`
  4627. Gend string `json:"gend"`
  4628. MdtrtID string `json:"mdtrt_id"`
  4629. AcctPay float64 `json:"acct_pay"`
  4630. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4631. Insutype string `json:"insutype"`
  4632. Invono interface{} `json:"invono"`
  4633. Enddate string `json:"enddate"`
  4634. CashPayamt float64 `json:"cash_payamt"`
  4635. PsnType string `json:"psn_type"`
  4636. FixmedinsName string `json:"fixmedins_name"`
  4637. HifpPay float64 `json:"hifp_pay"`
  4638. NewFlag interface{} `json:"new_flag"`
  4639. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4640. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4641. PayLoc string `json:"pay_loc"`
  4642. ClrType string `json:"clr_type"`
  4643. RefdSetlFlag string `json:"refd_setl_flag"`
  4644. CvlservFlag string `json:"cvlserv_flag"`
  4645. EmpName string `json:"emp_name"`
  4646. Brdy string `json:"brdy"`
  4647. Naty string `json:"naty"`
  4648. Certno string `json:"certno"`
  4649. DiseCode string `json:"dise_code"`
  4650. FixmedinsCode string `json:"fixmedins_code"`
  4651. DedcHospLv string `json:"dedc_hosp_lv"`
  4652. OpterName string `json:"opter_name"`
  4653. Balc float64 `json:"balc"`
  4654. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4655. PsnCertType string `json:"psn_cert_type"`
  4656. HifobPay float64 `json:"hifob_pay"`
  4657. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4658. HifesPay float64 `json:"hifes_pay"`
  4659. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4660. OptTime string `json:"opt_time"`
  4661. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4662. SetlID string `json:"setl_id"`
  4663. MafPay float64 `json:"maf_pay"`
  4664. PsnName string `json:"psn_name"`
  4665. InsuOptins interface{} `json:"insu_optins"`
  4666. PrefFundPay interface{} `json:"pref_fund_pay"`
  4667. ClrOptins string `json:"clr_optins"`
  4668. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4669. DiseName string `json:"dise_name"`
  4670. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4671. Age float64 `json:"age"`
  4672. DtrtCertType string `json:"dtrt_cert_type"`
  4673. HospLv string `json:"hosp_lv"`
  4674. } `json:"setlinfo"`
  4675. } `json:"output"`
  4676. RefmsgTime string `json:"refmsg_time"`
  4677. RespondTime string `json:"respond_time"`
  4678. Signtype interface{} `json:"signtype"`
  4679. WarnMsg interface{} `json:"warn_msg"`
  4680. }
  4681. type ResultTwelve struct {
  4682. Cainfo string `json:"cainfo"`
  4683. ErrMsg string `json:"err_msg"`
  4684. InfRefmsgid string `json:"inf_refmsgid"`
  4685. Infcode int64 `json:"infcode"`
  4686. Output struct {
  4687. MdtrtId string `json:"mdtrt_id"`
  4688. ChrgBchno string `json:"chrg_bchno"`
  4689. PsnNo string `json:"psn_no"`
  4690. } `json:"output"`
  4691. RefmsgTime string `json:"refmsg_time"`
  4692. RespondTime string `json:"respond_time"`
  4693. Signtype interface{} `json:"signtype"`
  4694. WarnMsg interface{} `json:"warn_msg"`
  4695. }
  4696. type ResultThirteen struct {
  4697. ErrMsg string `json:"err_msg"`
  4698. InfRefmsgid string `json:"inf_refmsgid"`
  4699. Infcode int64 `json:"infcode"`
  4700. Output struct {
  4701. Result struct {
  4702. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4703. } `json:"result"`
  4704. } `json:"output"`
  4705. RefmsgTime string `json:"refmsg_time"`
  4706. RespondTime string `json:"respond_time"`
  4707. Signtype interface{} `json:"signtype"`
  4708. WarnInfo interface{} `json:"warn_info"`
  4709. }
  4710. type ResultThirteen10265 struct {
  4711. ErrMsg string `json:"err_msg"`
  4712. InfRefmsgid string `json:"inf_refmsgid"`
  4713. Infcode string `json:"infcode"`
  4714. Output struct {
  4715. Result struct {
  4716. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4717. } `json:"result"`
  4718. } `json:"output"`
  4719. RefmsgTime string `json:"refmsg_time"`
  4720. RespondTime string `json:"respond_time"`
  4721. Signtype interface{} `json:"signtype"`
  4722. WarnInfo interface{} `json:"warn_info"`
  4723. }
  4724. type ResultFourteen struct {
  4725. ErrMsg string `json:"err_msg"`
  4726. InfRefmsgid string `json:"inf_refmsgid"`
  4727. Infcode int64 `json:"infcode"`
  4728. Output struct {
  4729. } `json:"output"`
  4730. RefmsgTime string `json:"refmsg_time"`
  4731. RespondTime string `json:"respond_time"`
  4732. Signtype interface{} `json:"signtype"`
  4733. WarnInfo interface{} `json:"warn_info"`
  4734. }
  4735. type ResultFourteen10265 struct {
  4736. ErrMsg string `json:"err_msg"`
  4737. InfRefmsgid string `json:"inf_refmsgid"`
  4738. Infcode string `json:"infcode"`
  4739. Output struct {
  4740. } `json:"output"`
  4741. RefmsgTime string `json:"refmsg_time"`
  4742. RespondTime string `json:"respond_time"`
  4743. Signtype interface{} `json:"signtype"`
  4744. WarnInfo interface{} `json:"warn_info"`
  4745. }
  4746. type ResultSixteen struct {
  4747. Cainfo string `json:"cainfo"`
  4748. ErrMsg string `json:"err_msg"`
  4749. InfRefmsgid string `json:"inf_refmsgid"`
  4750. Infcode int64 `json:"infcode"`
  4751. Output struct {
  4752. Setldetail []interface{} `json:"setldetail"`
  4753. Setlinfo struct {
  4754. MdtrtID string `json:"mdtrt_id"`
  4755. SetlID string `json:"setl_id"`
  4756. ClrOptins string `json:"clr_optins"`
  4757. SetlTime string `json:"setl_time"`
  4758. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4759. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4760. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4761. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4762. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4763. ActPayDedc float64 `json:"act_pay_dedc"`
  4764. HifpPay float64 `json:"hifp_pay"`
  4765. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4766. Lfpay float64 `json:"selfpay"`
  4767. CvlservPay float64 `json:"cvlserv_pay"`
  4768. HifesPay float64 `json:"hifes_pay"`
  4769. HifmiPay float64 `json:"hifmi_pay"`
  4770. HifobPay float64 `json:"hifob_pay"`
  4771. MafPay float64 `json:"maf_pay"`
  4772. OthPay float64 `json:"oth_pay"`
  4773. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4774. PsnPartAmt float64 `json:"psn_part_amt"`
  4775. AcctPay float64 `json:"acct_pay"`
  4776. Balc float64 `json:"balc"`
  4777. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4778. HospPartAmt float64 `json:"hosp_part_amt"`
  4779. MedinsSetlID string `json:"medins_setl_id"`
  4780. PdnCashPay string `json:"pdn_cash_pay"`
  4781. } `json:"setlinfo"`
  4782. } `json:"output"`
  4783. RefmsgTime string `json:"refmsg_time"`
  4784. RespondTime string `json:"respond_time"`
  4785. Signtype interface{} `json:"signtype"`
  4786. WarnMsg interface{} `json:"warn_msg"`
  4787. }
  4788. type ResultSixteen10265 struct {
  4789. Cainfo string `json:"cainfo"`
  4790. ErrMsg string `json:"err_msg"`
  4791. InfRefmsgid string `json:"inf_refmsgid"`
  4792. Infcode string `json:"infcode"`
  4793. Output struct {
  4794. Setldetail []interface{} `json:"setldetail"`
  4795. Setlinfo struct {
  4796. MdtrtID string `json:"mdtrt_id"`
  4797. SetlID string `json:"setl_id"`
  4798. ClrOptins string `json:"clr_optins"`
  4799. SetlTime string `json:"setl_time"`
  4800. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4801. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4802. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4803. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4804. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4805. ActPayDedc float64 `json:"act_pay_dedc"`
  4806. HifpPay float64 `json:"hifp_pay"`
  4807. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4808. Lfpay float64 `json:"selfpay"`
  4809. CvlservPay float64 `json:"cvlserv_pay"`
  4810. HifesPay float64 `json:"hifes_pay"`
  4811. HifmiPay float64 `json:"hifmi_pay"`
  4812. HifobPay float64 `json:"hifob_pay"`
  4813. MafPay float64 `json:"maf_pay"`
  4814. OthPay float64 `json:"oth_pay"`
  4815. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4816. PsnPartAmt float64 `json:"psn_part_amt"`
  4817. AcctPay float64 `json:"acct_pay"`
  4818. Balc float64 `json:"balc"`
  4819. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4820. HospPartAmt float64 `json:"hosp_part_amt"`
  4821. MedinsSetlID string `json:"medins_setl_id"`
  4822. PdnCashPay string `json:"pdn_cash_pay"`
  4823. } `json:"setlinfo"`
  4824. } `json:"output"`
  4825. RefmsgTime string `json:"refmsg_time"`
  4826. RespondTime string `json:"respond_time"`
  4827. Signtype interface{} `json:"signtype"`
  4828. WarnMsg interface{} `json:"warn_msg"`
  4829. }
  4830. type ResultSeventeen struct {
  4831. ErrMsg string `json:"err_msg"`
  4832. InfRefmsgid string `json:"inf_refmsgid"`
  4833. Infcode int64 `json:"infcode"`
  4834. Output struct {
  4835. SetlListId string `json:"setl_list_id"`
  4836. } `json:"output"`
  4837. RefmsgTime string `json:"refmsg_time"`
  4838. RespondTime string `json:"respond_time"`
  4839. Signtype string `json:"signtype"`
  4840. WarnInfo string `json:"warn_info"`
  4841. }
  4842. type ResultSeventeenOther struct {
  4843. ErrMsg string `json:"err_msg"`
  4844. InfRefmsgid string `json:"inf_refmsgid"`
  4845. Infcode string `json:"infcode"`
  4846. Output struct {
  4847. SetlListId string `json:"setl_list_id"`
  4848. } `json:"output"`
  4849. RefmsgTime string `json:"refmsg_time"`
  4850. RespondTime string `json:"respond_time"`
  4851. Signtype string `json:"signtype"`
  4852. WarnInfo string `json:"warn_info"`
  4853. }
  4854. type Result90991 struct {
  4855. ErrMsg string `json:"err_msg"`
  4856. InfRefmsgid string `json:"inf_refmsgid"`
  4857. Infcode int64 `json:"infcode"`
  4858. Output struct {
  4859. Result struct {
  4860. PsnNo string `json:"psn_no"`
  4861. CardStat string `json:"card_stat"`
  4862. Certno string `json:"certno"`
  4863. PsnName string `json:"psn_name"`
  4864. CheckStat string `json:"check_stat"`
  4865. SscnoCheckStat string `json:"sscno_check_stat"`
  4866. } `json:"result"`
  4867. } `json:"output"`
  4868. RefmsgTime string `json:"refmsg_time"`
  4869. RespondTime string `json:"respond_time"`
  4870. Signtype interface{} `json:"signtype"`
  4871. WarnInfo interface{} `json:"warn_info"`
  4872. }
  4873. type Result90100 struct {
  4874. ErrMsg string `json:"err_msg"`
  4875. InfRefmsgid string `json:"inf_refmsgid"`
  4876. Infcode int64 `json:"infcode"`
  4877. Output struct {
  4878. PoolareaNo string `json:"poolarea_no"`
  4879. PoolareaNoName string `json:"poolarea_no_name"`
  4880. Insutype string `json:"insutype"`
  4881. InsutypeName string `json:"insutype_name"`
  4882. ClctType string `json:"clct_type"`
  4883. ClctTypeName string `json:"clct_type_name"`
  4884. ClctFlag string `json:"clct_flag"`
  4885. ClctFlagName string `json:"clct_flag_name"`
  4886. AccrymBegn string `json:"accrym_begn"`
  4887. AccrymEnd string `json:"accrym_end"`
  4888. ClctTime string `json:"clct_time"`
  4889. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4890. } `json:"output"`
  4891. RefmsgTime string `json:"refmsg_time"`
  4892. RespondTime string `json:"respond_time"`
  4893. Signtype interface{} `json:"signtype"`
  4894. WarnInfo interface{} `json:"warn_info"`
  4895. }
  4896. type Custom struct {
  4897. DetItemFeeSumamt string
  4898. Cut string
  4899. FeedetlSn string
  4900. Price string
  4901. MedListCodg string
  4902. Type int64
  4903. AdviceId int64
  4904. ProjectId int64
  4905. ItemId int64
  4906. }
  4907. type Result5301 struct {
  4908. ErrMsg string `json:"err_msg"`
  4909. InfRefmsgid string `json:"inf_refmsgid"`
  4910. Infcode int64 `json:"infcode"`
  4911. Output struct {
  4912. Result []struct {
  4913. OpspDiseCode string `json:"opsp_dise_code"`
  4914. OpspDiseName string `json:"opsp_dise_name"`
  4915. Begndate string `json:"begndate"`
  4916. Enddate string `json:"enddate"`
  4917. } `json:"feedetail"`
  4918. } `json:"output"`
  4919. RefmsgTime string `json:"refmsg_time"`
  4920. RespondTime string `json:"respond_time"`
  4921. Signtype interface{} `json:"signtype"`
  4922. WarnInfo interface{} `json:"warn_info"`
  4923. }
  4924. type Result5301For10265 struct {
  4925. ErrMsg string `json:"err_msg"`
  4926. InfRefmsgid string `json:"inf_refmsgid"`
  4927. Infcode string `json:"infcode"`
  4928. Output struct {
  4929. Result []struct {
  4930. OpspDiseCode string `json:"opsp_dise_code"`
  4931. OpspDiseName string `json:"opsp_dise_name"`
  4932. Begndate string `json:"begndate"`
  4933. Enddate string `json:"enddate"`
  4934. } `json:"feedetail"`
  4935. } `json:"output"`
  4936. RefmsgTime string `json:"refmsg_time"`
  4937. RespondTime string `json:"respond_time"`
  4938. Signtype interface{} `json:"signtype"`
  4939. WarnInfo interface{} `json:"warn_info"`
  4940. }
  4941. //获取个人信息----挂号-----上传就诊信息
  4942. func (c *HisApiController) GetRegisterInfo() {
  4943. id, _ := c.GetInt64("id")
  4944. record_time := c.GetString("record_time")
  4945. settlementValue, _ := c.GetInt64("settlement_value")
  4946. medical_insurance_card := c.GetString("medical_insurance_card")
  4947. name := c.GetString("name")
  4948. id_card_type, _ := c.GetInt64("id_card_type")
  4949. certificates, _ := c.GetInt64("certificates")
  4950. medical_care, _ := c.GetInt64("medical_care")
  4951. birthday := c.GetString("birthday")
  4952. id_card := c.GetString("id_card")
  4953. register_type, _ := c.GetInt64("register")
  4954. doctor, _ := c.GetInt64("doctor")
  4955. department, _ := c.GetInt64("department")
  4956. gender, _ := c.GetInt64("sex")
  4957. registration_fee, _ := c.GetFloat("registration_fee")
  4958. medical_expenses, _ := c.GetFloat("medical_expenses")
  4959. social_type, _ := c.GetInt64("social_type")
  4960. med_type := c.GetString("social_type")
  4961. admin_user_id, _ := c.GetInt64("admin_user_id")
  4962. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4963. timeLayout := "2006-01-02"
  4964. loc, _ := time.LoadLocation("Local")
  4965. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4966. birthUnix := birthdays.Unix()
  4967. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4968. if err != nil {
  4969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4970. return
  4971. }
  4972. recordDateTime := theTime.Unix()
  4973. adminInfo := c.GetAdminUserInfo()
  4974. var patient service.Patients
  4975. if id == 0 {
  4976. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4977. } else {
  4978. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4979. }
  4980. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4981. if patientPrescription.ID == 0 {
  4982. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4983. }
  4984. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4985. if patient.ID == 0 {
  4986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4987. return
  4988. }
  4989. if len(patient.IdCardNo) == 0 {
  4990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4991. return
  4992. }
  4993. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4994. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4995. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4996. //就诊结算未完成,不能进行二次挂号
  4997. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4998. if len(his) >= 1 {
  4999. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  5000. if len(his) >= 1 && order.ID == 0 {
  5001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  5002. return
  5003. }
  5004. }
  5005. //var register_log string
  5006. if config.IsOpen == 1 {
  5007. var res ResultTwo
  5008. var res10265 ResultTwo10265
  5009. var PsnNo string
  5010. var PsnCertType string
  5011. var Certno string
  5012. var PsnName string
  5013. var Gend string
  5014. var Naty string
  5015. var Brdy string
  5016. var Age float64
  5017. var infoStr string
  5018. var idetinfoStr string
  5019. var infocode int64
  5020. var verify_number string
  5021. fmt.Println(verify_number)
  5022. if miConfig.MdtrtareaAdmvs == "421300" {
  5023. psn_info, _ := service.GetPsnByPatientId(id)
  5024. PsnNo = psn_info.PsnNo
  5025. PsnCertType = psn_info.PsnCertType
  5026. Certno = psn_info.Certno
  5027. PsnName = psn_info.PsnName
  5028. Gend = psn_info.Gend
  5029. Naty = psn_info.Naty
  5030. Brdy = psn_info.Brdy
  5031. Age = psn_info.Age
  5032. infoStr = psn_info.Insuinfo
  5033. idetinfoStr = psn_info.Idetinfo
  5034. infocode = 0
  5035. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5036. psn_info, _ := service.GetPsnByPatientId(id)
  5037. PsnNo = psn_info.PsnNo
  5038. PsnCertType = psn_info.PsnCertType
  5039. Certno = psn_info.Certno
  5040. PsnName = psn_info.PsnName
  5041. Gend = psn_info.Gend
  5042. Naty = psn_info.Naty
  5043. Brdy = psn_info.Brdy
  5044. Age = psn_info.Age
  5045. infoStr = psn_info.Insuinfo
  5046. idetinfoStr = psn_info.Idetinfo
  5047. infocode = 0
  5048. verify_number = psn_info.VerifyNumber
  5049. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5050. if id_card_type == 1 {
  5051. psn_info, _ := service.GetPsnByPatientId(id)
  5052. PsnNo = psn_info.PsnNo
  5053. PsnCertType = psn_info.PsnCertType
  5054. Certno = psn_info.Certno
  5055. PsnName = psn_info.PsnName
  5056. Gend = psn_info.Gend
  5057. Naty = psn_info.Naty
  5058. Brdy = psn_info.Brdy
  5059. Age = psn_info.Age
  5060. infoStr = psn_info.Insuinfo
  5061. idetinfoStr = psn_info.Idetinfo
  5062. infocode = 0
  5063. verify_number = psn_info.VerifyNumber
  5064. } else if id_card_type == 2 {
  5065. 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)
  5066. fmt.Println(errMsgLog)
  5067. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5069. utils.ErrorLog("解析失败:%v", err)
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5071. return
  5072. }
  5073. PsnNo = res.Output.Baseinfo.PsnNo
  5074. PsnCertType = res.Output.Baseinfo.PsnCertType
  5075. Certno = res.Output.Baseinfo.Certno
  5076. PsnName = res.Output.Baseinfo.PsnName
  5077. Gend = res.Output.Baseinfo.Gend
  5078. Naty = res.Output.Baseinfo.Naty
  5079. Brdy = res.Output.Baseinfo.Brdy
  5080. Age = res.Output.Baseinfo.Age
  5081. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5082. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5083. infoStr = string(Iinfos)
  5084. idetinfoStr = string(Idetinfos)
  5085. infocode = res.Infcode
  5086. }
  5087. } else {
  5088. var result string
  5089. var requestLog string
  5090. if miConfig.UserOrgId == 10138 {
  5091. if id_card_type == 4 {
  5092. psn_info, _ := service.GetPsnByPatientId(id)
  5093. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5094. } else {
  5095. 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)
  5096. }
  5097. } else {
  5098. 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)
  5099. }
  5100. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5101. if miConfig.Code == "H15049901371" {
  5102. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5103. utils.ErrorLog("解析失败:%v", err)
  5104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5105. return
  5106. }
  5107. res.ErrMsg = res10265.ErrMsg
  5108. res.Output = res10265.Output
  5109. res.InfRefmsgid = res10265.InfRefmsgid
  5110. } else {
  5111. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5112. utils.ErrorLog("解析失败:%v", err)
  5113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5114. return
  5115. }
  5116. }
  5117. PsnNo = res.Output.Baseinfo.PsnNo
  5118. PsnCertType = res.Output.Baseinfo.PsnCertType
  5119. Certno = res.Output.Baseinfo.Certno
  5120. PsnName = res.Output.Baseinfo.PsnName
  5121. Gend = res.Output.Baseinfo.Gend
  5122. Naty = res.Output.Baseinfo.Naty
  5123. Brdy = res.Output.Baseinfo.Brdy
  5124. Age = res.Output.Baseinfo.Age
  5125. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5126. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5127. infoStr = string(Iinfos)
  5128. idetinfoStr = string(Idetinfos)
  5129. if miConfig.Code == "H15049901371" {
  5130. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5131. } else {
  5132. infocode = res.Infcode
  5133. }
  5134. }
  5135. if infocode == 0 {
  5136. his := models.VMHisPatient{
  5137. Name: name,
  5138. Gender: gender,
  5139. Birthday: birthUnix,
  5140. MedicalTreatmentType: medical_care,
  5141. IdType: certificates,
  5142. IdCardNo: id_card,
  5143. BalanceAccountsType: settlementValue,
  5144. SocialType: social_type,
  5145. MedicalInsuranceNumber: medical_insurance_card,
  5146. RegisterType: register_type,
  5147. RegisterCost: registration_fee,
  5148. TreatmentCost: medical_expenses,
  5149. Status: 1,
  5150. Ctime: time.Now().Unix(),
  5151. Mtime: time.Now().Unix(),
  5152. PsnNo: PsnNo,
  5153. PsnCertType: PsnCertType,
  5154. Certno: Certno,
  5155. PsnName: PsnName,
  5156. Gend: Gend,
  5157. Naty: Naty,
  5158. Brdy: Brdy,
  5159. Age: Age,
  5160. Iinfo: infoStr,
  5161. Idetinfo: idetinfoStr,
  5162. PatientId: patient.ID,
  5163. RecordDate: theTime.Unix(),
  5164. UserOrgId: adminInfo.CurrentOrgId,
  5165. AdminUserId: admin_user_id,
  5166. IsReturn: 1,
  5167. IdCardType: id_card_type,
  5168. Doctor: doctor,
  5169. Departments: department,
  5170. }
  5171. timestamp := time.Now().Unix()
  5172. tempTime := time.Unix(timestamp, 0)
  5173. timeFormat := tempTime.Format("20060102150405")
  5174. chrgBchno := rand.Intn(100000) + 10000
  5175. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5176. his.Number = ipt_otp_no
  5177. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5178. department, _ := service.GetDepartMentDetail(department)
  5179. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5180. IdCardNo := ""
  5181. if id_card_type == 1 {
  5182. // IdCardNo = medical_insurance_card
  5183. IdCardNo = patient.IdCardNo
  5184. } else {
  5185. IdCardNo = patient.IdCardNo
  5186. }
  5187. var rf []*ResultFive
  5188. json.Unmarshal([]byte(his.Iinfo), &rf)
  5189. var insutypes []*ResultFive
  5190. var insutype string
  5191. var insuplc_admdvs_temp string
  5192. var is390 int = 0
  5193. var is310 int = 0
  5194. for _, item := range rf {
  5195. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5196. insutypes = append(insutypes, item)
  5197. }
  5198. }
  5199. if len(insutypes) == 1 {
  5200. insutype = insutypes[0].Insutype
  5201. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5202. } else {
  5203. for _, i := range insutypes {
  5204. if i.Insutype == "390" {
  5205. is390 = 1
  5206. }
  5207. if i.Insutype == "310" {
  5208. is310 = 1
  5209. }
  5210. }
  5211. }
  5212. if is390 == 1 {
  5213. insutype = "390"
  5214. }
  5215. if is310 == 1 {
  5216. insutype = "310"
  5217. }
  5218. if len(insutypes) == 0 {
  5219. insutype = "310"
  5220. }
  5221. if len(insutypes) == 2 {
  5222. insutype = med_type
  5223. }
  5224. if len(med_type) > 0 {
  5225. insutype = med_type
  5226. }
  5227. var infocode int64
  5228. var resThree ResultThree
  5229. var resThree10265 ResultThree10265
  5230. if len(insuplc_admdvs) == 0 {
  5231. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5232. } else {
  5233. insuplc_admdvs_temp = insuplc_admdvs
  5234. }
  5235. if miConfig.MdtrtareaAdmvs == "421300" {
  5236. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5237. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5238. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5239. "&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
  5240. resp, requestErr := http.Get(api)
  5241. if requestErr != nil {
  5242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5243. return
  5244. }
  5245. body, ioErr := ioutil.ReadAll(resp.Body)
  5246. if ioErr != nil {
  5247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5249. return
  5250. }
  5251. var respJSON map[string]interface{}
  5252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5255. return
  5256. }
  5257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5258. result, _ := json.Marshal(respJSON)
  5259. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5260. utils.ErrorLog("解析失败:%v", err)
  5261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5262. return
  5263. }
  5264. infocode = resThree.Infcode
  5265. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5266. psn_info, _ := service.GetPsnByPatientId(id)
  5267. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5268. var cert_no string
  5269. if id_card_type == 3 {
  5270. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5271. cert_no = IdCardNo
  5272. } else if id_card_type == 4 {
  5273. cert_no = IdCardNo
  5274. psn_info.VerifyNumber = psn_info.VerifyNumber
  5275. } else {
  5276. bas := strings.Split(psn_info.CardInfo, "|")
  5277. cert_no = bas[2]
  5278. }
  5279. var hisPrescription []*models.HisPrescription
  5280. for _, item := range rf {
  5281. if item.Insutype == insutype {
  5282. //insuplc_admdvs = item.InsuplcAdmdvs
  5283. his.InsuplcAdmdvs = insuplc_admdvs
  5284. }
  5285. }
  5286. his.Insutype = insutype
  5287. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5288. fmt.Println(res3101)
  5289. fmt.Println(res3101.Infcode)
  5290. if res3101.Infcode == "0" {
  5291. fmt.Println("33333333")
  5292. if len(res3101.Output.Result) > 0 {
  5293. fmt.Println("222222")
  5294. for _, item := range res3101.Output.Result {
  5295. if len(res3101.ErrMsg) == 0 {
  5296. res3101.ErrMsg = item.VolaCont
  5297. } else {
  5298. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5299. }
  5300. }
  5301. c.ServeSuccessJSON(map[string]interface{}{
  5302. "failed_code": -10,
  5303. "msg": res3101.ErrMsg,
  5304. })
  5305. return
  5306. } else {
  5307. fmt.Println("11111")
  5308. var api string
  5309. if miConfig.MdtrtareaAdmvs == "320921" {
  5310. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5311. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5312. "&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
  5313. } else {
  5314. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5315. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5316. "&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
  5317. }
  5318. resp, requestErr := http.Get(api)
  5319. if requestErr != nil {
  5320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5321. return
  5322. }
  5323. body, ioErr := ioutil.ReadAll(resp.Body)
  5324. if ioErr != nil {
  5325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5327. return
  5328. }
  5329. var respJSON map[string]interface{}
  5330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5333. return
  5334. }
  5335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5336. result, _ := json.Marshal(respJSON)
  5337. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5338. utils.ErrorLog("解析失败:%v", err)
  5339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5340. return
  5341. }
  5342. resThree.ErrMsg = resThree10265.ErrMsg
  5343. resThree.Output = resThree10265.Output
  5344. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5345. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5346. }
  5347. } else if res3101.Infcode != "0" {
  5348. c.ServeSuccessJSON(map[string]interface{}{
  5349. "failed_code": -10,
  5350. "msg": res3101.ErrMsg,
  5351. })
  5352. return
  5353. }
  5354. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5355. psn_info, _ := service.GetPsnByPatientId(id)
  5356. var cert_no string
  5357. if id_card_type == 1 {
  5358. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5359. } else {
  5360. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5361. }
  5362. fmt.Println(cert_no)
  5363. 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)
  5364. saveLog(result, requestLog, "2201", "挂号")
  5365. if miConfig.Code == "H15049901371" {
  5366. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5367. utils.ErrorLog("解析失败:%v", err)
  5368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5369. return
  5370. }
  5371. resThree.ErrMsg = resThree10265.ErrMsg
  5372. resThree.Output = resThree10265.Output
  5373. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5374. } else {
  5375. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5376. utils.ErrorLog("解析失败:%v", err)
  5377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5378. return
  5379. }
  5380. }
  5381. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5382. } else {
  5383. psn_info, _ := service.GetPsnByPatientId(id)
  5384. 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)
  5385. saveLog(result, requestLog, "2201A", "挂号")
  5386. if miConfig.Code == "H15049901371" {
  5387. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5388. utils.ErrorLog("解析失败:%v", err)
  5389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5390. return
  5391. }
  5392. resThree.ErrMsg = resThree10265.ErrMsg
  5393. resThree.Output = resThree10265.Output
  5394. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5395. } else {
  5396. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5397. utils.ErrorLog("解析失败:%v", err)
  5398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5399. return
  5400. }
  5401. }
  5402. if miConfig.Code == "H15049901371" {
  5403. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5404. } else {
  5405. infocode = resThree.Infcode
  5406. }
  5407. }
  5408. if infocode != 0 {
  5409. adminUser := c.GetAdminUserInfo()
  5410. errlog := &models.HisOrderError{
  5411. UserOrgId: adminUser.CurrentOrgId,
  5412. Ctime: time.Now().Unix(),
  5413. Mtime: time.Now().Unix(),
  5414. ErrMsg: resThree.ErrMsg,
  5415. Status: 1,
  5416. PatientId: id,
  5417. RecordTime: recordDateTime,
  5418. Stage: 2,
  5419. }
  5420. service.CreateErrMsgLog(errlog)
  5421. c.ServeSuccessJSON(map[string]interface{}{
  5422. "failed_code": -10,
  5423. "msg": resThree.ErrMsg,
  5424. })
  5425. return
  5426. }
  5427. his.Number = resThree.Output.Data.MdtrtID
  5428. his.PsnNo = resThree.Output.Data.PsnNo
  5429. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5430. his.IdCardNo = patient.IdCardNo
  5431. his.PhoneNumber = patient.Phone
  5432. his.UserOrgId = adminInfo.CurrentOrgId
  5433. his.Insutype = insutype
  5434. his.Ctime = time.Now().Unix()
  5435. his.Mtime = time.Now().Unix()
  5436. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5437. his.Status = 1
  5438. service.UpdateHisPatientStatus(&his)
  5439. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5440. c.ServeSuccessJSON(map[string]interface{}{
  5441. "his_info": his,
  5442. })
  5443. } else {
  5444. adminUser := c.GetAdminUserInfo()
  5445. errlog := &models.HisOrderError{
  5446. UserOrgId: adminUser.CurrentOrgId,
  5447. Ctime: time.Now().Unix(),
  5448. Mtime: time.Now().Unix(),
  5449. ErrMsg: res.ErrMsg,
  5450. Status: 1,
  5451. PatientId: id,
  5452. RecordTime: recordDateTime,
  5453. Stage: 1,
  5454. }
  5455. service.CreateErrMsgLog(errlog)
  5456. c.ServeSuccessJSON(map[string]interface{}{
  5457. "failed_code": -10,
  5458. "msg": res.ErrMsg,
  5459. })
  5460. return
  5461. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5462. }
  5463. }
  5464. }
  5465. //上传明细----预结算----确认订单
  5466. func (c *HisApiController) GetUploadInfo() {
  5467. id, _ := c.GetInt64("id")
  5468. record_time := c.GetString("record_time")
  5469. his_patient_id, _ := c.GetInt64("his_patient_id")
  5470. order_id, _ := c.GetInt64("order_id")
  5471. pay_way, _ := c.GetInt64("pay_way")
  5472. pay_price, _ := c.GetFloat("pay_price")
  5473. pay_card_no := c.GetString("pay_card_no")
  5474. discount_price, _ := c.GetFloat("discount_price")
  5475. preferential_price, _ := c.GetFloat("preferential_price")
  5476. reality_price, _ := c.GetFloat("reality_price")
  5477. found_price, _ := c.GetFloat("found_price")
  5478. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5479. private_price, _ := c.GetFloat("private_price")
  5480. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5481. admin_user_id, _ := c.GetInt64("admin_user_id")
  5482. fapiao_code := c.GetString("fapiao_code")
  5483. fapiao_number := c.GetString("fapiao_number")
  5484. diagnosis_id := c.GetString("diagnosis")
  5485. sick_type, _ := c.GetInt64("sick_type")
  5486. reg_type, _ := c.GetInt64("p_type")
  5487. begin_time := c.GetString("begin_time")
  5488. id_str := c.GetString("ids")
  5489. ids_arr := strings.Split(id_str, ",")
  5490. timeLayout := "2006-01-02"
  5491. loc, _ := time.LoadLocation("Local")
  5492. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5493. if err != nil {
  5494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5495. return
  5496. }
  5497. recordDateTime := theTime.Unix()
  5498. adminUser := c.GetAdminUserInfo()
  5499. var tempOrder models.HisOrder
  5500. tempOrder, _ = service.GetHisOrderByID(order_id)
  5501. var prescriptions []*models.HisPrescription
  5502. var start_time int64
  5503. var end_time int64
  5504. //押金模块
  5505. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5506. tmp_decimal := c.GetString("tmp_decimal")
  5507. var decimal float64 //本次使用的押金
  5508. var errmsg error
  5509. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5510. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5511. return
  5512. }
  5513. if len(tmp_decimal) > 0 {
  5514. if tmp_decimal[0] == 45 {
  5515. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5516. return
  5517. }
  5518. }
  5519. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5520. fmt.Println(errs)
  5521. decimal = tt
  5522. //if adminUser.CurrentOrgId == 10106{
  5523. // if len(fapiao_code) == 0{
  5524. // fapiao_code = "144072080589"
  5525. // }
  5526. // if len(fapiao_number) == 0{
  5527. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5528. // if order.ID == 0{
  5529. // fapiao_number = "00001520"
  5530. // }else{
  5531. // //fapiao_code = "00001520"
  5532. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5533. // var zero string
  5534. // if fpNumber >= 1000{
  5535. // zero = "0000" + strconv.Itoa(fpNumber)
  5536. // }else if fpNumber >= 10000{
  5537. // zero = "000" + strconv.Itoa(fpNumber)
  5538. // } else if fpNumber >= 100000{
  5539. // zero = "00" + strconv.Itoa(fpNumber)
  5540. // } else if fpNumber >= 1000000{
  5541. // zero = "0" + strconv.Itoa(fpNumber)
  5542. // }else {
  5543. // zero = strconv.Itoa(fpNumber)
  5544. // }
  5545. // fapiao_number = zero
  5546. // }
  5547. // }
  5548. //}
  5549. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5550. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5551. var patientPrescription models.HisPrescriptionInfo
  5552. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5553. if patientPrescription.ID == 0 {
  5554. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5555. }
  5556. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5557. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5558. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5559. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5560. var config []*models.HisXtDiagnoseConfig
  5561. for _, item := range diagnosis_ids {
  5562. id, _ := strconv.ParseInt(item, 10, 64)
  5563. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5564. config = append(config, &diagnosisConfig)
  5565. }
  5566. sickConfig, _ := service.FindSickById(sick_type)
  5567. //if tempOrder.ID == 0 {
  5568. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5569. //}
  5570. if tempOrder.ID == 0 {
  5571. var result string
  5572. var requestLog string
  5573. var res2 ResultSix
  5574. var ressix10265 ResultSix10265
  5575. if miConfig.MdtrtareaAdmvs == "421300" {
  5576. data := make(map[string]interface{})
  5577. client := &http.Client{}
  5578. data["psn_no"] = his.PsnNo
  5579. data["mdtrt_id"] = his.Number
  5580. data["opter"] = roles.UserName
  5581. data["org_name"] = miConfig.OrgName
  5582. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5583. data["doctor_id"] = doctor_info.DoctorNumber
  5584. data["doctor_name"] = doctor_info.UserName
  5585. data["department"] = department.Name
  5586. data["fixmedins_code"] = miConfig.Code
  5587. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5588. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5589. data["secret_key"] = miConfig.SecretKey
  5590. data["sick_code"] = sickConfig.CountryCode
  5591. data["sick_name"] = sickConfig.ClassName
  5592. data["dept"] = strconv.FormatInt(department.ID, 10)
  5593. data["config"] = config
  5594. data["begin_time"] = begin_time
  5595. bytesData, _ := json.Marshal(data)
  5596. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5597. resp, _ := client.Do(req)
  5598. defer resp.Body.Close()
  5599. body, ioErr := ioutil.ReadAll(resp.Body)
  5600. if ioErr != nil {
  5601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5603. return
  5604. }
  5605. var respJSON map[string]interface{}
  5606. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5609. return
  5610. }
  5611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5612. userJSONBytes, _ := json.Marshal(respJSON)
  5613. fmt.Println("log")
  5614. fmt.Println(string(userJSONBytes))
  5615. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5616. utils.ErrorLog("解析失败:%v", err)
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5618. return
  5619. }
  5620. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5621. data := make(map[string]interface{})
  5622. client := &http.Client{}
  5623. data["psn_no"] = his.PsnNo
  5624. data["mdtrt_id"] = his.Number
  5625. data["doctor"] = roles.UserName
  5626. data["department"] = department.Name
  5627. data["org_name"] = miConfig.OrgName
  5628. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5629. data["doctor_id"] = doctor_info.DoctorNumber
  5630. data["new_doctor_name"] = doctor_info.UserName
  5631. data["fixmedins_code"] = miConfig.Code
  5632. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5633. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5634. data["secret_key"] = miConfig.SecretKey
  5635. data["sick_code"] = sickConfig.CountryCode
  5636. data["sick_name"] = sickConfig.ClassName
  5637. data["url"] = miConfig.Url
  5638. data["ak"] = miConfig.AccessKey
  5639. data["begin_time"] = begin_time
  5640. data["cainfo"] = miConfig.Cainfo
  5641. data["dept"] = strconv.FormatInt(department.ID, 10)
  5642. data["config"] = config
  5643. bytesData, _ := json.Marshal(data)
  5644. var req *http.Request
  5645. if miConfig.MdtrtareaAdmvs == "320921" {
  5646. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5647. //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 +
  5648. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5649. } else {
  5650. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5651. }
  5652. resp, _ := client.Do(req)
  5653. defer resp.Body.Close()
  5654. body, ioErr := ioutil.ReadAll(resp.Body)
  5655. if ioErr != nil {
  5656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5658. return
  5659. }
  5660. var respJSON map[string]interface{}
  5661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5664. return
  5665. }
  5666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5667. userJSONBytes, _ := json.Marshal(respJSON)
  5668. fmt.Println("log")
  5669. fmt.Println(string(userJSONBytes))
  5670. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5671. utils.ErrorLog("解析失败:%v", err)
  5672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5673. return
  5674. }
  5675. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5676. res2.Output = ressix10265.Output
  5677. res2.ErrMsg = ressix10265.ErrMsg
  5678. res2.Cainfo = ressix10265.Cainfo
  5679. res2.WarnMsg = ressix10265.WarnMsg
  5680. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5681. res2.Infcode = infocode
  5682. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5683. 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)
  5684. saveLog(result, requestLog, "2203", "上传就诊信息")
  5685. var respJSON2 map[string]interface{}
  5686. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5689. return
  5690. }
  5691. userJSONBytes2, _ := json.Marshal(respJSON2)
  5692. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5693. utils.ErrorLog("解析失败:%v", err)
  5694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5695. return
  5696. }
  5697. } else {
  5698. if miConfig.MdtrtareaAdmvs == "440781" { //
  5699. 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)
  5700. } else {
  5701. if miConfig.Code == "H15049901371" {
  5702. //赤峰地区国家医保医疗类别
  5703. //职工透析:医疗类别选特殊情况门诊990502
  5704. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5705. var med_type string
  5706. if his.Insutype == "390" {
  5707. if reg_type == 14 {
  5708. med_type = "9933"
  5709. } else if reg_type == 11 {
  5710. med_type = "11"
  5711. }
  5712. } else if his.Insutype == "310" {
  5713. if reg_type == 14 {
  5714. med_type = "990502"
  5715. } else if reg_type == 11 {
  5716. med_type = "11"
  5717. }
  5718. }
  5719. 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)
  5720. } else {
  5721. 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)
  5722. }
  5723. }
  5724. saveLog(result, requestLog, "2203", "上传就诊信息")
  5725. var respJSON2 map[string]interface{}
  5726. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5729. return
  5730. }
  5731. userJSONBytes2, _ := json.Marshal(respJSON2)
  5732. if miConfig.Code == "H15049901371" {
  5733. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5734. utils.ErrorLog("解析失败:%v", err)
  5735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5736. return
  5737. }
  5738. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5739. res2.Output = ressix10265.Output
  5740. res2.ErrMsg = ressix10265.ErrMsg
  5741. res2.Cainfo = ressix10265.Cainfo
  5742. res2.WarnMsg = ressix10265.WarnMsg
  5743. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5744. res2.Infcode = infocode
  5745. } else {
  5746. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5747. utils.ErrorLog("解析失败:%v", err)
  5748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5749. return
  5750. }
  5751. }
  5752. }
  5753. if res2.Infcode != 0 {
  5754. adminUser := c.GetAdminUserInfo()
  5755. errlog := &models.HisOrderError{
  5756. UserOrgId: adminUser.CurrentOrgId,
  5757. Ctime: time.Now().Unix(),
  5758. Mtime: time.Now().Unix(),
  5759. ErrMsg: res2.ErrMsg,
  5760. Status: 1,
  5761. PatientId: id,
  5762. RecordTime: recordDateTime,
  5763. Stage: 3,
  5764. }
  5765. service.CreateErrMsgLog(errlog)
  5766. c.ServeSuccessJSON(map[string]interface{}{
  5767. "failed_code": -10,
  5768. "msg": res2.ErrMsg,
  5769. })
  5770. return
  5771. } else {
  5772. his.Diagnosis = diagnosis_id
  5773. his.SickType = sickConfig.ID
  5774. //var p_type int64
  5775. //if reg_type == 1111 || reg_type == 1112 {
  5776. // p_type = 11
  5777. //
  5778. //}
  5779. his.PType = fmt.Sprintf("%d", reg_type)
  5780. service.UpdateHisPatientThree(&his)
  5781. data := make(map[string]interface{})
  5782. if settle_accounts_type == 1 { //日结
  5783. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5784. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5785. } else {
  5786. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5787. }
  5788. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5789. data["pre"] = prescriptions
  5790. } else { //月结
  5791. start_time_str := c.GetString("start_time")
  5792. end_time_str := c.GetString("end_time")
  5793. timeLayout := "2006-01-02"
  5794. loc, _ := time.LoadLocation("Local")
  5795. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5796. if err != nil {
  5797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5798. return
  5799. }
  5800. recordStartTime := theStartTime.Unix()
  5801. start_time = recordStartTime
  5802. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5803. if err != nil {
  5804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5805. return
  5806. }
  5807. recordEndTime := theEndTime.Unix()
  5808. end_time = recordEndTime
  5809. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5810. data["pre"] = prescriptions
  5811. }
  5812. timestamp := time.Now().Unix()
  5813. tempTime := time.Unix(timestamp, 0)
  5814. timeFormat := tempTime.Format("20060102150405")
  5815. chrgBchno := rand.Intn(100000) + 10000
  5816. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5817. strconv.FormatInt(his.PatientId, 10)
  5818. client := &http.Client{}
  5819. data["psn_no"] = his.PsnNo
  5820. data["mdtrt_id"] = his.Number
  5821. data["chrg_bchno"] = chrg_bchno
  5822. data["org_name"] = miConfig.OrgName
  5823. data["doctor"] = doctor_info.UserName
  5824. data["doctor_id"] = doctor_info.DoctorNumber
  5825. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5826. data["fixmedins_code"] = miConfig.Code
  5827. data["opter"] = roles.UserName
  5828. data["dept_code"] = department.Number
  5829. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5830. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5831. data["secret_key"] = miConfig.SecretKey
  5832. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5833. data["url"] = miConfig.Url
  5834. data["ak"] = miConfig.AccessKey
  5835. data["new_doctor_name"] = patientPrescription.Doctor
  5836. data["diag_code"] = sickConfig.CountryCode
  5837. data["cainfo"] = miConfig.Cainfo
  5838. var ids []int64
  5839. for _, item := range prescriptions {
  5840. ids = append(ids, item.ID)
  5841. }
  5842. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5843. if config.IsOpen == 1 { //对接了医保,走医保流程
  5844. var res ResultFour
  5845. var resFour10265 ResultFour10265
  5846. if miConfig.MdtrtareaAdmvs == "421300" {
  5847. bytesData, _ := json.Marshal(data)
  5848. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5849. resp, _ := client.Do(req)
  5850. defer resp.Body.Close()
  5851. body, ioErr := ioutil.ReadAll(resp.Body)
  5852. if ioErr != nil {
  5853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5855. return
  5856. }
  5857. var respJSON map[string]interface{}
  5858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5861. return
  5862. }
  5863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5864. userJSONBytes, _ := json.Marshal(respJSON)
  5865. fmt.Println("log")
  5866. fmt.Println(string(userJSONBytes))
  5867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5868. utils.ErrorLog("解析失败:%v", err)
  5869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5870. return
  5871. }
  5872. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5873. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5874. if result3101.Infcode == "0" {
  5875. if len(result3101.Output.Result) > 0 {
  5876. var errMsgs []string
  5877. for _, item := range result3101.Output.Result {
  5878. errMsgs = append(errMsgs, item.VolaCont)
  5879. }
  5880. c.ServeSuccessJSON(map[string]interface{}{
  5881. "failed_code": -10,
  5882. "msg": errMsgs,
  5883. })
  5884. return
  5885. }
  5886. }
  5887. bytesData, _ := json.Marshal(data)
  5888. var req *http.Request
  5889. if miConfig.MdtrtareaAdmvs == "320921" {
  5890. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5891. } else {
  5892. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5893. }
  5894. resp, _ := client.Do(req)
  5895. defer resp.Body.Close()
  5896. body, ioErr := ioutil.ReadAll(resp.Body)
  5897. if ioErr != nil {
  5898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. return
  5901. }
  5902. var respJSON map[string]interface{}
  5903. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5906. return
  5907. }
  5908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5909. userJSONBytes, _ := json.Marshal(respJSON)
  5910. fmt.Println("log")
  5911. fmt.Println(string(userJSONBytes))
  5912. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5913. utils.ErrorLog("解析失败:%v", err)
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. res.InfRefmsgid = resFour10265.InfRefmsgid
  5918. res.Output = resFour10265.Output
  5919. res.ErrMsg = resFour10265.ErrMsg
  5920. res.Cainfo = resFour10265.Cainfo
  5921. res.WarnMsg = resFour10265.WarnMsg
  5922. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5923. res.Infcode = infocode
  5924. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5925. 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)
  5926. var dat map[string]interface{}
  5927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5928. fmt.Println(dat)
  5929. } else {
  5930. fmt.Println(err)
  5931. }
  5932. saveLog(result, request_log, "2204", "上传费用明细")
  5933. userJSONBytes, _ := json.Marshal(dat)
  5934. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5935. utils.ErrorLog("解析失败:%v", err)
  5936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5937. return
  5938. }
  5939. res.InfRefmsgid = resFour10265.InfRefmsgid
  5940. res.Output = resFour10265.Output
  5941. res.ErrMsg = resFour10265.ErrMsg
  5942. res.Cainfo = resFour10265.Cainfo
  5943. res.WarnMsg = resFour10265.WarnMsg
  5944. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5945. res.Infcode = infocode
  5946. } else {
  5947. if miConfig.Code == "H15049901371" {
  5948. 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)
  5949. var dat map[string]interface{}
  5950. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5951. fmt.Println(dat)
  5952. } else {
  5953. fmt.Println(err)
  5954. }
  5955. saveLog(result, request_log, "2204", "上传费用明细")
  5956. userJSONBytes, _ := json.Marshal(dat)
  5957. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5958. utils.ErrorLog("解析失败:%v", err)
  5959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5960. return
  5961. }
  5962. res.InfRefmsgid = resFour10265.InfRefmsgid
  5963. res.Output = resFour10265.Output
  5964. res.ErrMsg = resFour10265.ErrMsg
  5965. res.Cainfo = resFour10265.Cainfo
  5966. res.WarnMsg = resFour10265.WarnMsg
  5967. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5968. res.Infcode = infocode
  5969. } else {
  5970. 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)
  5971. var dat map[string]interface{}
  5972. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5973. fmt.Println(dat)
  5974. } else {
  5975. fmt.Println(err)
  5976. }
  5977. saveLog(result, request_log, "2204", "上传费用明细")
  5978. userJSONBytes, _ := json.Marshal(dat)
  5979. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5980. utils.ErrorLog("解析失败:%v", err)
  5981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5982. return
  5983. }
  5984. }
  5985. }
  5986. if res.Infcode == 0 {
  5987. order := &models.HisOrder{
  5988. UserOrgId: adminUser.CurrentOrgId,
  5989. HisPatientId: his.ID,
  5990. PatientId: his.PatientId,
  5991. SettleAccountsDate: recordDateTime,
  5992. MdtrtId: his.Number,
  5993. PsnNo: his.PsnNo,
  5994. MedType: strconv.FormatInt(reg_type, 10),
  5995. Ctime: time.Now().Unix(),
  5996. Mtime: time.Now().Unix(),
  5997. Status: 1,
  5998. Number: chrg_bchno,
  5999. Infcode: res.Infcode,
  6000. WarnMsg: res.WarnMsg,
  6001. Cainfo: res.Cainfo,
  6002. ErrMsg: res.ErrMsg,
  6003. RespondTime: res.RefmsgTime,
  6004. InfRefmsgid: res.InfRefmsgid,
  6005. OrderStatus: 1,
  6006. PayWay: pay_way,
  6007. PayPrice: pay_price,
  6008. PayCardNo: pay_card_no,
  6009. DiscountPrice: discount_price,
  6010. PreferentialPrice: preferential_price,
  6011. RealityPrice: reality_price,
  6012. FoundPrice: found_price,
  6013. MedicalInsurancePrice: medical_insurance_price,
  6014. PrivatePrice: private_price,
  6015. IsMedicineInsurance: 1,
  6016. SettleType: settle_accounts_type,
  6017. SettleStartTime: start_time,
  6018. SettleEndTime: end_time,
  6019. Creator: roles.AdminUserId,
  6020. Modify: roles.AdminUserId,
  6021. FaPiaoNumber: fapiao_number,
  6022. FaPiaoCode: fapiao_code,
  6023. PType: 2,
  6024. Diagnosis: diagnosis_id,
  6025. }
  6026. err = service.CreateOrder(order)
  6027. if err != nil {
  6028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6029. return
  6030. }
  6031. for _, item := range res.Output.Result {
  6032. temp := strings.Split(item.FeedetlSn, "-")
  6033. var advice_id int64 = 0
  6034. var project_id int64 = 0
  6035. var types int64 = 0
  6036. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6037. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6038. if temp[1] == "1" {
  6039. advice_id = id
  6040. project_id = 0
  6041. } else if temp[1] == "2" {
  6042. advice_id = 0
  6043. project_id = id
  6044. }
  6045. info := &models.HisOrderInfo{
  6046. OrderNumber: order.Number,
  6047. FeedetlSn: item.FeedetlSn,
  6048. UploadDate: time.Now().Unix(),
  6049. AdviceId: advice_id,
  6050. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6051. Cnt: item.Cnt,
  6052. Pric: float64(item.Pric),
  6053. PatientId: his.PatientId,
  6054. PricUplmtAmt: item.PricUplmtAmt,
  6055. SelfpayProp: item.SelfpayProp,
  6056. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6057. OverlmtAmt: item.OverlmtAmt,
  6058. PreselfpayAmt: item.PreselfpayAmt,
  6059. BasMednFlag: item.BasMednFlag,
  6060. MedChrgitmType: item.MedChrgitmType,
  6061. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6062. Status: 1,
  6063. Memo: item.Memo,
  6064. Mtime: time.Now().Unix(),
  6065. InscpScpAmt: item.InscpScpAmt,
  6066. DrtReimFlag: item.DrtReimFlag,
  6067. Ctime: time.Now().Unix(),
  6068. ListSpItemFlag: item.ListSpItemFlag,
  6069. ChldMedcFlag: item.ChldMedcFlag,
  6070. LmtUsedFlag: item.LmtUsedFlag,
  6071. ChrgitmLv: item.ChrgitmLv,
  6072. UserOrgId: adminUser.CurrentOrgId,
  6073. HisPatientId: his.ID,
  6074. OrderId: order.ID,
  6075. ProjectId: project_id,
  6076. Type: types,
  6077. }
  6078. service.CreateOrderInfo(info)
  6079. }
  6080. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6081. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6082. var total float64
  6083. for _, item := range prescriptions {
  6084. if item.Type == 1 { //药品
  6085. for _, subItem := range item.HisDoctorAdviceInfo {
  6086. total = total + (subItem.Price * subItem.PrescribingNumber)
  6087. }
  6088. }
  6089. if item.Type == 2 { //项目
  6090. for _, subItem := range item.HisPrescriptionProject {
  6091. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6092. total = total + (subItem.Price * cnt)
  6093. }
  6094. }
  6095. }
  6096. for _, item := range prescriptions {
  6097. for _, subItem := range item.HisAdditionalCharge {
  6098. total = total + (subItem.Price * float64(subItem.Count))
  6099. }
  6100. }
  6101. var allTotal string
  6102. if adminUser.CurrentOrgId == 9919 {
  6103. allTotal = fmt.Sprintf("%.4f", total)
  6104. } else {
  6105. allTotal = fmt.Sprintf("%.4f", total)
  6106. }
  6107. if res.Infcode == 0 {
  6108. var rf []*ResultFive
  6109. json.Unmarshal([]byte(his.Iinfo), &rf)
  6110. chrg_bchno := chrg_bchno
  6111. cert_no := his.Certno
  6112. var insutypes []string
  6113. var insutype string
  6114. var is390 int = 0
  6115. var is310 int = 0
  6116. for _, item := range rf {
  6117. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6118. insutypes = append(insutypes, item.Insutype)
  6119. }
  6120. }
  6121. if len(insutypes) == 1 {
  6122. insutype = insutypes[0]
  6123. } else {
  6124. for _, i := range insutypes {
  6125. if i == "390" {
  6126. is390 = 1
  6127. }
  6128. if i == "310" {
  6129. is310 = 1
  6130. }
  6131. }
  6132. }
  6133. if is390 == 1 {
  6134. insutype = "390"
  6135. }
  6136. if is310 == 1 {
  6137. insutype = "310"
  6138. }
  6139. if len(insutypes) == 0 {
  6140. insutype = "310"
  6141. }
  6142. if len(insutypes) == 2 {
  6143. insutype = strconv.FormatInt(his.SocialType, 10)
  6144. }
  6145. insutype = strconv.FormatInt(his.SocialType, 10)
  6146. //insutype = "390"
  6147. if his.IdCardType == 1 {
  6148. // cert_no = his.MedicalInsuranceNumber
  6149. cert_no = his.Certno
  6150. } else {
  6151. cert_no = his.Certno
  6152. }
  6153. var res ResultSeven
  6154. var resSeven10265 ResultSeven10265
  6155. var src_resquest string
  6156. var result2 string
  6157. var acct_used_flag string
  6158. fmt.Println("pay_way")
  6159. fmt.Println(pay_way)
  6160. fmt.Println("pay_way")
  6161. if pay_way == 4 {
  6162. acct_used_flag = "1"
  6163. } else {
  6164. acct_used_flag = "0"
  6165. }
  6166. if miConfig.MdtrtareaAdmvs == "421300" {
  6167. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6168. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6169. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6170. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6171. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6172. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6173. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6174. resp, requestErr := http.Get(api)
  6175. if requestErr != nil {
  6176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6177. return
  6178. }
  6179. body, ioErr := ioutil.ReadAll(resp.Body)
  6180. if ioErr != nil {
  6181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6183. return
  6184. }
  6185. var respJSON map[string]interface{}
  6186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6189. return
  6190. }
  6191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6192. result, _ := json.Marshal(respJSON)
  6193. if miConfig.Code == "H15049901371" {
  6194. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6195. utils.ErrorLog("解析失败:%v", err)
  6196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6197. return
  6198. }
  6199. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6200. res.Output = resSeven10265.Output
  6201. res.ErrMsg = resSeven10265.ErrMsg
  6202. res.Cainfo = resSeven10265.Cainfo
  6203. res.WarnMsg = resSeven10265.WarnMsg
  6204. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6205. res.Infcode = infocode
  6206. } else {
  6207. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6208. utils.ErrorLog("解析失败:%v", err)
  6209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6210. return
  6211. }
  6212. }
  6213. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6214. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  6215. if result3101.Infcode == "0" {
  6216. if len(result3101.Output.Result) > 0 {
  6217. var errMsgs []string
  6218. for _, item := range result3101.Output.Result {
  6219. errMsgs = append(errMsgs, item.VolaCont)
  6220. }
  6221. c.ServeSuccessJSON(map[string]interface{}{
  6222. "failed_code": -10,
  6223. "msg": errMsgs,
  6224. })
  6225. return
  6226. } else {
  6227. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6228. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6229. bas := strings.Split(psn_info.CardInfo, "|")
  6230. if his.IdCardType == 1 {
  6231. cert_no = bas[2]
  6232. } else if his.IdCardType == 3 {
  6233. cert_no = his.Certno
  6234. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6235. } else if his.IdCardType == 4 {
  6236. cert_no = his.Certno
  6237. psn_info.VerifyNumber = psn_info.VerifyNumber
  6238. }
  6239. var api string
  6240. if miConfig.MdtrtareaAdmvs == "320921" {
  6241. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6242. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6243. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6244. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6245. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6246. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6247. "&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
  6248. } else {
  6249. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6250. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6251. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6252. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6253. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6254. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6255. "&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
  6256. }
  6257. resp, requestErr := http.Get(api)
  6258. if requestErr != nil {
  6259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6260. return
  6261. }
  6262. body, ioErr := ioutil.ReadAll(resp.Body)
  6263. if ioErr != nil {
  6264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6266. return
  6267. }
  6268. var respJSON map[string]interface{}
  6269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6272. return
  6273. }
  6274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6275. result, _ := json.Marshal(respJSON)
  6276. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6277. utils.ErrorLog("解析失败:%v", err)
  6278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6279. return
  6280. }
  6281. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6282. res.Output = resSeven10265.Output
  6283. res.ErrMsg = resSeven10265.ErrMsg
  6284. res.Cainfo = resSeven10265.Cainfo
  6285. res.WarnMsg = resSeven10265.WarnMsg
  6286. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6287. res.Infcode = infocode
  6288. }
  6289. }
  6290. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6291. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6292. var cert_no string
  6293. if his.IdCardType == 1 {
  6294. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6295. }
  6296. fmt.Println(cert_no)
  6297. 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)
  6298. //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)
  6299. var dat map[string]interface{}
  6300. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6301. fmt.Println(dat)
  6302. } else {
  6303. fmt.Println(err)
  6304. }
  6305. saveLog(result2, src_resquest, "2207", "结算")
  6306. userJSONBytes, _ := json.Marshal(dat)
  6307. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6308. utils.ErrorLog("解析失败:%v", err)
  6309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6310. return
  6311. }
  6312. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6313. res.Output = resSeven10265.Output
  6314. res.ErrMsg = resSeven10265.ErrMsg
  6315. res.Cainfo = resSeven10265.Cainfo
  6316. res.WarnMsg = resSeven10265.WarnMsg
  6317. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6318. res.Infcode = infocode
  6319. } else {
  6320. if miConfig.Code == "H15049901371" {
  6321. //赤峰地区国家医保医疗类别
  6322. //职工透析:医疗类别选特殊情况门诊990502
  6323. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6324. var med_type string
  6325. if his.Insutype == "390" {
  6326. if reg_type == 14 {
  6327. med_type = "9933"
  6328. } else if reg_type == 11 {
  6329. med_type = "11"
  6330. }
  6331. } else if his.Insutype == "310" {
  6332. if reg_type == 14 {
  6333. med_type = "990502"
  6334. } else if reg_type == 11 {
  6335. med_type = "11"
  6336. }
  6337. }
  6338. 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)
  6339. } else {
  6340. 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)
  6341. }
  6342. //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)
  6343. var dat map[string]interface{}
  6344. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6345. fmt.Println(dat)
  6346. } else {
  6347. fmt.Println(err)
  6348. }
  6349. saveLog(result2, src_resquest, "2207", "结算")
  6350. userJSONBytes, _ := json.Marshal(dat)
  6351. if miConfig.Code == "H15049901371" {
  6352. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6353. utils.ErrorLog("解析失败:%v", err)
  6354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6355. return
  6356. }
  6357. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6358. res.Output = resSeven10265.Output
  6359. res.ErrMsg = resSeven10265.ErrMsg
  6360. res.Cainfo = resSeven10265.Cainfo
  6361. res.WarnMsg = resSeven10265.WarnMsg
  6362. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6363. res.Infcode = infocode
  6364. } else {
  6365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6366. utils.ErrorLog("解析失败:%v", err)
  6367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6368. return
  6369. }
  6370. }
  6371. }
  6372. if res.Infcode != 0 {
  6373. errlog := &models.HisOrderError{
  6374. UserOrgId: adminUser.CurrentOrgId,
  6375. Ctime: time.Now().Unix(),
  6376. Mtime: time.Now().Unix(),
  6377. Number: chrg_bchno,
  6378. ErrMsg: res.ErrMsg,
  6379. Status: 1,
  6380. PatientId: id,
  6381. RecordTime: recordDateTime,
  6382. Stage: 6,
  6383. }
  6384. service.CreateErrMsgLog(errlog)
  6385. c.ServeSuccessJSON(map[string]interface{}{
  6386. "failed_code": -10,
  6387. "msg": res.ErrMsg,
  6388. })
  6389. return
  6390. } else {
  6391. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6392. order.OrderStatus = 2
  6393. order.Status = 1
  6394. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6395. order.SetlId = res.Output.Setlinfo.SetlID
  6396. order.PsnNo = res.Output.Setlinfo.PsnNo
  6397. order.PsnName = res.Output.Setlinfo.PsnName
  6398. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6399. order.Certno = res.Output.Setlinfo.Certno
  6400. order.Gend = res.Output.Setlinfo.Gend
  6401. order.Naty = res.Output.Setlinfo.Naty
  6402. order.Age = res.Output.Setlinfo.Age
  6403. order.Insutype = res.Output.Setlinfo.Insutype
  6404. order.PsnType = res.Output.Setlinfo.PsnType
  6405. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6406. order.SetlTime = res.Output.Setlinfo.SetlTime
  6407. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6408. if res.Output.Setlinfo.MedType == "140101" {
  6409. order.MedType = "14"
  6410. } else {
  6411. order.MedType = res.Output.Setlinfo.MedType
  6412. }
  6413. if reg_type == 1112 {
  6414. order.MedType = "1112"
  6415. }
  6416. if reg_type == 1111 {
  6417. order.MedType = "1111"
  6418. }
  6419. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6420. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6421. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6422. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6423. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6424. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6425. order.HifpPay = res.Output.Setlinfo.HifpPay
  6426. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6427. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6428. order.HifesPay = res.Output.Setlinfo.HifesPay
  6429. order.HifobPay = res.Output.Setlinfo.HifobPay
  6430. order.MafPay = res.Output.Setlinfo.MafPay
  6431. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6432. order.OthPay = res.Output.Setlinfo.OthPay
  6433. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6434. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6435. order.AcctPay = res.Output.Setlinfo.AcctPay
  6436. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6437. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6438. order.Balc = res.Output.Setlinfo.Balc
  6439. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6440. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6441. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6442. order.ClrType = res.Output.Setlinfo.ClrType
  6443. order.ClrWay = res.Output.Setlinfo.ClrWay
  6444. order.Creator = order.Creator
  6445. order.Modify = roles.AdminUserId
  6446. order.RequestLog = src_resquest
  6447. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6448. detailStr := string(setlDetail)
  6449. order.SetlDetail = detailStr
  6450. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6451. err = service.UpDateOrder(order)
  6452. if err == nil {
  6453. //判断是否使用了押金
  6454. if dec_way == "true" {
  6455. tmpstring := strconv.FormatInt(order.ID, 10)
  6456. order.Decimal = decimal
  6457. service.UpDateOrder(order)
  6458. //扣押金
  6459. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6460. if errmsg != nil {
  6461. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6462. return
  6463. }
  6464. }
  6465. c.ServeSuccessJSON(map[string]interface{}{
  6466. "msg": "结算成功",
  6467. })
  6468. } else {
  6469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6470. return
  6471. }
  6472. }
  6473. } else {
  6474. adminUser := c.GetAdminUserInfo()
  6475. errlog := &models.HisOrderError{
  6476. UserOrgId: adminUser.CurrentOrgId,
  6477. Ctime: time.Now().Unix(),
  6478. Mtime: time.Now().Unix(),
  6479. ErrMsg: res.ErrMsg,
  6480. Status: 1,
  6481. PatientId: id,
  6482. RecordTime: recordDateTime,
  6483. Stage: 4,
  6484. }
  6485. service.CreateErrMsgLog(errlog)
  6486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6487. return
  6488. }
  6489. } else {
  6490. adminUser := c.GetAdminUserInfo()
  6491. errlog := &models.HisOrderError{
  6492. UserOrgId: adminUser.CurrentOrgId,
  6493. Ctime: time.Now().Unix(),
  6494. Mtime: time.Now().Unix(),
  6495. ErrMsg: res.ErrMsg,
  6496. Status: 1,
  6497. PatientId: id,
  6498. RecordTime: recordDateTime,
  6499. Stage: 4,
  6500. }
  6501. service.CreateErrMsgLog(errlog)
  6502. c.ServeSuccessJSON(map[string]interface{}{
  6503. "failed_code": -10,
  6504. "msg": res.ErrMsg,
  6505. })
  6506. return
  6507. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6508. //return
  6509. }
  6510. }
  6511. }
  6512. } else if tempOrder.ID > 0 {
  6513. if tempOrder.IsPre == 1 {
  6514. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6515. var rf []*ResultFive
  6516. json.Unmarshal([]byte(his.Iinfo), &rf)
  6517. chrg_bchno := tempOrder.Number
  6518. cert_no := his.Certno
  6519. var insutypes []string
  6520. var insutype string
  6521. var is390 int = 0
  6522. var is310 int = 0
  6523. for _, item := range rf {
  6524. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6525. insutypes = append(insutypes, item.Insutype)
  6526. }
  6527. }
  6528. if len(insutypes) == 1 {
  6529. insutype = insutypes[0]
  6530. } else {
  6531. for _, i := range insutypes {
  6532. if i == "390" {
  6533. is390 = 1
  6534. }
  6535. if i == "310" {
  6536. is310 = 1
  6537. }
  6538. }
  6539. }
  6540. if is390 == 1 {
  6541. insutype = "390"
  6542. }
  6543. if is310 == 1 {
  6544. insutype = "310"
  6545. }
  6546. if len(insutypes) == 0 {
  6547. insutype = "310"
  6548. }
  6549. if len(insutypes) == 2 {
  6550. insutype = strconv.FormatInt(his.SocialType, 64)
  6551. }
  6552. //insutype = "390"
  6553. if his.IdCardType == 1 {
  6554. // cert_no = his.MedicalInsuranceNumber
  6555. cert_no = his.Certno
  6556. } else {
  6557. cert_no = his.Certno
  6558. }
  6559. var res ResultSeven
  6560. var resSeven10265 ResultSeven10265
  6561. var src_resquest string
  6562. var result2 string
  6563. var acct_used_flag string
  6564. fmt.Println("pay_way")
  6565. fmt.Println(pay_way)
  6566. fmt.Println("pay_way")
  6567. if pay_way == 4 {
  6568. acct_used_flag = "1"
  6569. } else {
  6570. acct_used_flag = "0"
  6571. }
  6572. if miConfig.MdtrtareaAdmvs == "421300" {
  6573. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6574. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6575. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6576. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6577. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6578. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6579. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6580. resp, requestErr := http.Get(api)
  6581. if requestErr != nil {
  6582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6583. return
  6584. }
  6585. body, ioErr := ioutil.ReadAll(resp.Body)
  6586. if ioErr != nil {
  6587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6589. return
  6590. }
  6591. var respJSON map[string]interface{}
  6592. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6595. return
  6596. }
  6597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6598. result, _ := json.Marshal(respJSON)
  6599. fmt.Println("log")
  6600. fmt.Println(string(result))
  6601. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6602. utils.ErrorLog("解析失败:%v", err)
  6603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6604. return
  6605. }
  6606. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6607. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  6608. if result3101.Infcode == "0" {
  6609. if len(result3101.Output.Result) > 0 {
  6610. var errMsgs []string
  6611. for _, item := range result3101.Output.Result {
  6612. errMsgs = append(errMsgs, item.VolaCont)
  6613. }
  6614. c.ServeSuccessJSON(map[string]interface{}{
  6615. "failed_code": -10,
  6616. "msg": errMsgs,
  6617. })
  6618. return
  6619. } else {
  6620. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6621. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6622. //psn_info, _ := service.GetPsnByPatientId(id)
  6623. bas := strings.Split(psn_info.CardInfo, "|")
  6624. if his.IdCardType == 1 {
  6625. cert_no = bas[2]
  6626. } else {
  6627. cert_no = bas[1]
  6628. }
  6629. //江苏地区国家医保医疗类别
  6630. //职工透析:医疗类别选特殊情况门诊9933
  6631. //居民血透门慢: 医疗类别选门诊慢病1402
  6632. //var med_type string
  6633. //if his.Insutype == "310" {
  6634. // if reg_type == 14 {
  6635. // med_type = "9933"
  6636. // } else if reg_type == 11 {
  6637. // med_type = "11"
  6638. //
  6639. // }
  6640. //} else if his.Insutype == "390" {
  6641. // if reg_type == 14 {
  6642. // med_type = "1402"
  6643. // } else if reg_type == 11 {
  6644. // med_type = "11"
  6645. // }
  6646. //}
  6647. var api string
  6648. if miConfig.MdtrtareaAdmvs == "320921" {
  6649. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6650. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6651. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6652. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6653. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6654. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6655. "&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
  6656. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6657. } else {
  6658. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6659. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6660. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6661. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6662. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6663. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6664. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6665. "&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
  6666. }
  6667. resp, requestErr := http.Get(api)
  6668. if requestErr != nil {
  6669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6670. return
  6671. }
  6672. body, ioErr := ioutil.ReadAll(resp.Body)
  6673. if ioErr != nil {
  6674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6676. return
  6677. }
  6678. var respJSON map[string]interface{}
  6679. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. return
  6683. }
  6684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6685. result, _ := json.Marshal(respJSON)
  6686. fmt.Println("log")
  6687. fmt.Println(string(result))
  6688. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6689. utils.ErrorLog("解析失败:%v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. return
  6692. }
  6693. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6694. res.Output = resSeven10265.Output
  6695. res.ErrMsg = resSeven10265.ErrMsg
  6696. res.Cainfo = resSeven10265.Cainfo
  6697. res.WarnMsg = resSeven10265.WarnMsg
  6698. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6699. res.Infcode = infocode
  6700. }
  6701. }
  6702. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6703. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6704. var cert_no string
  6705. if his.IdCardType == 1 {
  6706. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6707. }
  6708. fmt.Println(cert_no)
  6709. 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)
  6710. var dat map[string]interface{}
  6711. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6712. fmt.Println(dat)
  6713. } else {
  6714. fmt.Println(err)
  6715. }
  6716. saveLog(result2, src_resquest, "2207", "结算")
  6717. userJSONBytes, _ := json.Marshal(dat)
  6718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6719. utils.ErrorLog("解析失败:%v", err)
  6720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6721. return
  6722. }
  6723. } else {
  6724. var src_resquest string
  6725. if miConfig.Code == "H15049901371" {
  6726. //赤峰地区国家医保医疗类别
  6727. //职工透析:医疗类别选特殊情况门诊990502
  6728. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6729. var med_type string
  6730. if his.Insutype == "390" {
  6731. if reg_type == 14 {
  6732. med_type = "9933"
  6733. } else if reg_type == 11 {
  6734. med_type = "11"
  6735. }
  6736. } else if his.Insutype == "310" {
  6737. if reg_type == 14 {
  6738. med_type = "990502"
  6739. } else if reg_type == 11 {
  6740. med_type = "11"
  6741. }
  6742. }
  6743. 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)
  6744. } else {
  6745. 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)
  6746. }
  6747. var dat map[string]interface{}
  6748. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6749. fmt.Println(dat)
  6750. } else {
  6751. fmt.Println(err)
  6752. }
  6753. saveLog(result2, src_resquest, "2207", "结算")
  6754. userJSONBytes, _ := json.Marshal(dat)
  6755. if miConfig.Code == "H15049901371" {
  6756. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6757. utils.ErrorLog("解析失败:%v", err)
  6758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6759. return
  6760. }
  6761. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6762. res.Output = resSeven10265.Output
  6763. res.ErrMsg = resSeven10265.ErrMsg
  6764. res.Cainfo = resSeven10265.Cainfo
  6765. res.WarnMsg = resSeven10265.WarnMsg
  6766. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6767. res.Infcode = infocode
  6768. } else {
  6769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6770. utils.ErrorLog("解析失败:%v", err)
  6771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6772. return
  6773. }
  6774. }
  6775. }
  6776. if res.Infcode != 0 {
  6777. errlog := &models.HisOrderError{
  6778. UserOrgId: adminUser.CurrentOrgId,
  6779. Ctime: time.Now().Unix(),
  6780. Mtime: time.Now().Unix(),
  6781. Number: chrg_bchno,
  6782. ErrMsg: res.ErrMsg,
  6783. Status: 1,
  6784. PatientId: id,
  6785. RecordTime: recordDateTime,
  6786. Stage: 6,
  6787. }
  6788. service.CreateErrMsgLog(errlog)
  6789. c.ServeSuccessJSON(map[string]interface{}{
  6790. "failed_code": -10,
  6791. "msg": res.ErrMsg,
  6792. })
  6793. return
  6794. } else {
  6795. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6796. order.OrderStatus = 2
  6797. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6798. order.SetlId = res.Output.Setlinfo.SetlID
  6799. order.PsnNo = res.Output.Setlinfo.PsnNo
  6800. order.PsnName = res.Output.Setlinfo.PsnName
  6801. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6802. order.Certno = res.Output.Setlinfo.Certno
  6803. order.Gend = res.Output.Setlinfo.Gend
  6804. order.Naty = res.Output.Setlinfo.Naty
  6805. order.Age = res.Output.Setlinfo.Age
  6806. order.Insutype = res.Output.Setlinfo.Insutype
  6807. order.PsnType = res.Output.Setlinfo.PsnType
  6808. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6809. order.SetlTime = res.Output.Setlinfo.SetlTime
  6810. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6811. //order.MedType = res.Output.Setlinfo.MedType
  6812. if reg_type == 1112 {
  6813. order.MedType = "1112"
  6814. }
  6815. if reg_type == 1111 {
  6816. order.MedType = "1111"
  6817. }
  6818. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6819. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6820. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6821. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6822. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6823. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6824. order.HifpPay = res.Output.Setlinfo.HifpPay
  6825. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6826. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6827. order.HifesPay = res.Output.Setlinfo.HifesPay
  6828. order.HifobPay = res.Output.Setlinfo.HifobPay
  6829. order.MafPay = res.Output.Setlinfo.MafPay
  6830. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6831. order.OthPay = res.Output.Setlinfo.OthPay
  6832. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6833. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6834. order.AcctPay = res.Output.Setlinfo.AcctPay
  6835. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6836. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6837. order.Balc = res.Output.Setlinfo.Balc
  6838. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6839. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6840. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6841. order.ClrWay = res.Output.Setlinfo.ClrWay
  6842. order.Creator = order.Creator
  6843. order.Modify = roles.AdminUserId
  6844. order.RequestLog = src_resquest
  6845. order.Diagnosis = diagnosis_id
  6846. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6847. detailStr := string(setlDetail)
  6848. order.SetlDetail = detailStr
  6849. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6850. err = service.UpDateOrder(order)
  6851. if err == nil {
  6852. //判断是否使用了押金
  6853. if dec_way == "true" {
  6854. tmpstring := strconv.FormatInt(order.ID, 10)
  6855. //扣押金
  6856. order.Decimal = decimal
  6857. service.UpDateOrder(order)
  6858. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6859. if errmsg != nil {
  6860. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6861. return
  6862. }
  6863. }
  6864. c.ServeSuccessJSON(map[string]interface{}{
  6865. "msg": "结算成功",
  6866. })
  6867. } else {
  6868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6869. return
  6870. }
  6871. }
  6872. }
  6873. }
  6874. }
  6875. //func (c *HisApiController) GetPreUploadInfo() {
  6876. // id, _ := c.GetInt64("id")
  6877. // record_time := c.GetString("record_time")
  6878. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6879. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6880. //
  6881. // timeLayout := "2006-01-02"
  6882. // loc, _ := time.LoadLocation("Local")
  6883. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6884. // if err != nil {
  6885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6886. // return
  6887. // }
  6888. // recordDateTime := theTime.Unix()
  6889. // adminUser := c.GetAdminUserInfo()
  6890. //
  6891. // var prescriptions []*models.HisPrescription
  6892. //
  6893. // var start_time int64
  6894. // var end_time int64
  6895. //
  6896. // data := make(map[string]interface{})
  6897. // if settle_accounts_type == 1 { //日结
  6898. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6899. // data["pre"] = prescriptions
  6900. //
  6901. // } else { //月结
  6902. // start_time_str := c.GetString("start_time")
  6903. // end_time_str := c.GetString("end_time")
  6904. // timeLayout := "2006-01-02"
  6905. // loc, _ := time.LoadLocation("Local")
  6906. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6907. // if err != nil {
  6908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6909. // return
  6910. // }
  6911. // recordStartTime := theStartTime.Unix()
  6912. // start_time = recordStartTime
  6913. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6914. // if err != nil {
  6915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6916. // return
  6917. // }
  6918. // recordEndTime := theEndTime.Unix()
  6919. // end_time = recordEndTime
  6920. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6921. // data["pre"] = prescriptions
  6922. //
  6923. // }
  6924. //
  6925. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6926. //
  6927. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6928. // timestamp := time.Now().Unix()
  6929. // tempTime := time.Unix(timestamp, 0)
  6930. // timeFormat := tempTime.Format("20060102150405")
  6931. // chrgBchno := rand.Intn(100000) + 10000
  6932. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6933. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6934. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6935. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6936. // strconv.FormatInt(his.PatientId, 10)
  6937. // client := &http.Client{}
  6938. // data["psn_no"] = his.PsnNo
  6939. // data["mdtrt_id"] = his.Number
  6940. // data["chrg_bchno"] = chrg_bchno
  6941. // data["org_name"] = miConfig.OrgName
  6942. // data["doctor"] = roles.UserName
  6943. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6944. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6945. // data["fixmedins_code"] = miConfig.Code
  6946. // data["dept_code"] = department.Number
  6947. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6948. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6949. // data["secret_key"] = miConfig.SecretKey
  6950. // var ids []int64
  6951. //
  6952. // for _, item := range prescriptions {
  6953. // ids = append(ids, item.ID)
  6954. // }
  6955. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6956. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6957. // bytesData, _ := json.Marshal(data)
  6958. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6959. // resp, _ := client.Do(req)
  6960. // defer resp.Body.Close()
  6961. // body, ioErr := ioutil.ReadAll(resp.Body)
  6962. // if ioErr != nil {
  6963. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. // return
  6966. // }
  6967. // var respJSON map[string]interface{}
  6968. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6969. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6970. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. // return
  6972. // }
  6973. //
  6974. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6975. // userJSONBytes, _ := json.Marshal(respJSON)
  6976. // var res ResultFour
  6977. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6978. // utils.ErrorLog("解析失败:%v", err)
  6979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. // return
  6981. // }
  6982. //
  6983. // if res.Infcode == 0 {
  6984. // order := &models.HisOrder{
  6985. // UserOrgId: adminUser.CurrentOrgId,
  6986. // HisPatientId: his.ID,
  6987. // PatientId: his.PatientId,
  6988. // SettleAccountsDate: recordDateTime,
  6989. // Ctime: time.Now().Unix(),
  6990. // Mtime: time.Now().Unix(),
  6991. // Status: 1,
  6992. // Number: chrg_bchno,
  6993. // Infcode: res.Infcode,
  6994. // WarnMsg: res.WarnMsg,
  6995. // Cainfo: res.Cainfo,
  6996. // ErrMsg: res.ErrMsg,
  6997. // RespondTime: res.RefmsgTime,
  6998. // InfRefmsgid: res.InfRefmsgid,
  6999. // OrderStatus: 1,
  7000. // IsMedicineInsurance: 1,
  7001. // SettleType: settle_accounts_type,
  7002. // SettleStartTime: start_time,
  7003. // SettleEndTime: end_time,
  7004. // Creator: roles.ID,
  7005. // Modify: roles.ID,
  7006. // PType: 2,
  7007. // }
  7008. // err = service.CreateOrder(order)
  7009. // if err != nil {
  7010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7011. // return
  7012. // }
  7013. //
  7014. // for _, item := range res.Output.Result {
  7015. // temp := strings.Split(item.FeedetlSn, "-")
  7016. // var advice_id int64 = 0
  7017. // var project_id int64 = 0
  7018. // var types int64 = 0
  7019. //
  7020. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  7021. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  7022. //
  7023. // if temp[1] == "1" {
  7024. // advice_id = id
  7025. // project_id = 0
  7026. // } else if temp[1] == "2" {
  7027. // advice_id = 0
  7028. // project_id = id
  7029. // }
  7030. //
  7031. // info := &models.HisOrderInfo{
  7032. // OrderNumber: order.Number,
  7033. // FeedetlSn: item.FeedetlSn,
  7034. // UploadDate: time.Now().Unix(),
  7035. // AdviceId: advice_id,
  7036. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  7037. // Cnt: item.Cnt,
  7038. // Pric: float64(item.Pric),
  7039. // PatientId: his.PatientId,
  7040. // PricUplmtAmt: item.PricUplmtAmt,
  7041. // SelfpayProp: item.SelfpayProp,
  7042. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7043. // OverlmtAmt: item.OverlmtAmt,
  7044. // PreselfpayAmt: item.PreselfpayAmt,
  7045. // BasMednFlag: item.BasMednFlag,
  7046. // MedChrgitmType: item.MedChrgitmType,
  7047. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  7048. // Status: 1,
  7049. // Memo: item.Memo,
  7050. // Mtime: time.Now().Unix(),
  7051. // InscpScpAmt: item.InscpScpAmt,
  7052. // DrtReimFlag: item.DrtReimFlag,
  7053. // Ctime: time.Now().Unix(),
  7054. // ListSpItemFlag: item.ListSpItemFlag,
  7055. // ChldMedcFlag: item.ChldMedcFlag,
  7056. // LmtUsedFlag: item.LmtUsedFlag,
  7057. // ChrgitmLv: item.ChrgitmLv,
  7058. // UserOrgId: adminUser.CurrentOrgId,
  7059. // HisPatientId: his.ID,
  7060. // OrderId: order.ID,
  7061. // ProjectId: project_id,
  7062. // Type: types,
  7063. // }
  7064. // service.CreateOrderInfo(info)
  7065. //
  7066. // }
  7067. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7068. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7069. //
  7070. // var total float64
  7071. // for _, item := range prescriptions {
  7072. // if item.Type == 1 { //药品
  7073. // for _, subItem := range item.HisDoctorAdviceInfo {
  7074. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7075. // }
  7076. // }
  7077. // if item.Type == 2 { //项目
  7078. // for _, subItem := range item.HisPrescriptionProject {
  7079. // total = total + (subItem.Price * float64(subItem.Count))
  7080. // }
  7081. // }
  7082. // }
  7083. //
  7084. // for _, item := range prescriptions {
  7085. // for _, subItem := range item.HisAdditionalCharge {
  7086. // total = total + (subItem.Price * float64(subItem.Count))
  7087. // }
  7088. // }
  7089. //
  7090. // allTotal := fmt.Sprintf("%.2f", total)
  7091. // if res.Infcode == 0 {
  7092. // var rf []*ResultFive
  7093. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7094. // psn_no := his.PsnNo
  7095. // mdtrt_id := his.Number
  7096. // chrg_bchno := chrg_bchno
  7097. // cert_no := his.Certno
  7098. // insutype := rf[0].Insutype
  7099. //
  7100. // if his.IdCardType == 1 {
  7101. // cert_no = his.MedicalInsuranceNumber
  7102. //
  7103. // } else {
  7104. //
  7105. // cert_no = his.Certno
  7106. //
  7107. // }
  7108. //
  7109. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7110. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7111. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7112. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7113. // resp, requestErr := http.Get(api)
  7114. // if requestErr != nil {
  7115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7116. // return
  7117. // }
  7118. // defer resp.Body.Close()
  7119. // body, ioErr := ioutil.ReadAll(resp.Body)
  7120. // if ioErr != nil {
  7121. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7122. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7123. // return
  7124. // }
  7125. // var respJSON map[string]interface{}
  7126. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7127. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7129. // return
  7130. // }
  7131. // fmt.Println(respJSON)
  7132. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7133. // userJSONBytes, _ := json.Marshal(respJSON)
  7134. // var res ResultSeven
  7135. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7136. // utils.ErrorLog("解析失败:%v", err)
  7137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7138. // return
  7139. // }
  7140. // if res.Infcode != 0 {
  7141. // errlog := &models.HisOrderError{
  7142. // UserOrgId: adminUser.CurrentOrgId,
  7143. // Ctime: time.Now().Unix(),
  7144. // Mtime: time.Now().Unix(),
  7145. // Number: chrg_bchno,
  7146. // ErrMsg: res.ErrMsg,
  7147. // Status: 1,
  7148. // PatientId: id,
  7149. // RecordTime: recordDateTime,
  7150. // Stage: 7,
  7151. // }
  7152. // service.CreateErrMsgLog(errlog)
  7153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7154. // return
  7155. // } else {
  7156. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7157. // order.OrderStatus = 1
  7158. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7159. // order.SetlId = res.Output.Setlinfo.SetlID
  7160. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7161. // order.PsnName = res.Output.Setlinfo.PsnName
  7162. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7163. // order.Certno = res.Output.Setlinfo.Certno
  7164. // order.Gend = res.Output.Setlinfo.Gend
  7165. // order.Naty = res.Output.Setlinfo.Naty
  7166. // order.Age = res.Output.Setlinfo.Age
  7167. // order.Insutype = res.Output.Setlinfo.Insutype
  7168. // order.PsnType = res.Output.Setlinfo.PsnType
  7169. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7170. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7171. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7172. // order.MedType = res.Output.Setlinfo.MedType
  7173. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7174. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7175. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7176. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7177. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7178. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7179. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7180. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7181. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7182. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7183. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7184. // order.MafPay = res.Output.Setlinfo.MafPay
  7185. // order.OthPay = res.Output.Setlinfo.OthPay
  7186. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7187. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7188. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7189. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7190. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7191. // order.Balc = res.Output.Setlinfo.Balc
  7192. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7193. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7194. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7195. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7196. // order.Creator = order.Creator
  7197. // order.Modify = roles.ID
  7198. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7199. // detailStr := string(setlDetail)
  7200. // order.SetlDetail = detailStr
  7201. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7202. // err = service.UpDateOrder(order)
  7203. // if err == nil {
  7204. // c.ServeSuccessJSON(map[string]interface{}{
  7205. // "msg": "预结算成功",
  7206. // })
  7207. // } else {
  7208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7209. // return
  7210. // }
  7211. // }
  7212. // } else {
  7213. // adminUser := c.GetAdminUserInfo()
  7214. // errlog := &models.HisOrderError{
  7215. // UserOrgId: adminUser.CurrentOrgId,
  7216. // Ctime: time.Now().Unix(),
  7217. // Mtime: time.Now().Unix(),
  7218. // ErrMsg: res.ErrMsg,
  7219. // Status: 1,
  7220. // PatientId: id,
  7221. // RecordTime: recordDateTime,
  7222. // Stage: 4,
  7223. // }
  7224. // service.CreateErrMsgLog(errlog)
  7225. //
  7226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7227. // return
  7228. // }
  7229. // } else {
  7230. // adminUser := c.GetAdminUserInfo()
  7231. // errlog := &models.HisOrderError{
  7232. // UserOrgId: adminUser.CurrentOrgId,
  7233. // Ctime: time.Now().Unix(),
  7234. // Mtime: time.Now().Unix(),
  7235. // ErrMsg: res.ErrMsg,
  7236. // Status: 1,
  7237. // PatientId: id,
  7238. // RecordTime: recordDateTime,
  7239. // Stage: 4,
  7240. // }
  7241. // service.CreateErrMsgLog(errlog)
  7242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7243. // return
  7244. // }
  7245. //
  7246. // } else {
  7247. // var total float64
  7248. // for _, item := range prescriptions {
  7249. // if item.Type == 1 { //药品
  7250. // for _, subItem := range item.HisDoctorAdviceInfo {
  7251. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7252. // }
  7253. // }
  7254. // if item.Type == 2 { //项目
  7255. // for _, subItem := range item.HisPrescriptionProject {
  7256. // total = total + (subItem.Price * float64(subItem.Count))
  7257. // }
  7258. // }
  7259. //
  7260. // for _, subItem := range item.HisAdditionalCharge {
  7261. // total = total + (subItem.Price * float64(subItem.Count))
  7262. // }
  7263. // }
  7264. //
  7265. // allTotal := fmt.Sprintf("%.2f", total)
  7266. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7267. // order := &models.HisOrder{
  7268. // UserOrgId: adminUser.CurrentOrgId,
  7269. // HisPatientId: his.ID,
  7270. // PatientId: id,
  7271. // SettleAccountsDate: recordDateTime,
  7272. // Ctime: time.Now().Unix(),
  7273. // Mtime: time.Now().Unix(),
  7274. // Status: 1,
  7275. // OrderStatus: 2,
  7276. // Number: chrg_bchno,
  7277. // MedfeeSumamt: totals,
  7278. // }
  7279. // err = service.CreateOrder(order)
  7280. // if err != nil {
  7281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7282. // return
  7283. // }
  7284. //
  7285. // var customs []*Custom
  7286. // for _, item := range prescriptions {
  7287. //
  7288. // if item.Type == 1 { //药品
  7289. // for _, subItem := range item.HisDoctorAdviceInfo {
  7290. // cus := &Custom{
  7291. // AdviceId: subItem.ID,
  7292. // ProjectId: 0,
  7293. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7294. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7295. // FeedetlSn: subItem.FeedetlSn,
  7296. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7297. // MedListCodg: subItem.MedListCodg,
  7298. // Type: 1,
  7299. // }
  7300. // customs = append(customs, cus)
  7301. // }
  7302. // }
  7303. //
  7304. // if item.Type == 2 { //项目
  7305. // for _, subItem := range item.HisPrescriptionProject {
  7306. //
  7307. // cus := &Custom{
  7308. // AdviceId: 0,
  7309. // ProjectId: subItem.ID,
  7310. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7311. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7312. // FeedetlSn: subItem.FeedetlSn,
  7313. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7314. // MedListCodg: subItem.MedListCodg,
  7315. // Type: 2,
  7316. // }
  7317. //
  7318. // customs = append(customs, cus)
  7319. // }
  7320. // }
  7321. //
  7322. // for _, item := range item.HisAdditionalCharge {
  7323. // cus := &Custom{
  7324. // ItemId: item.ID,
  7325. // AdviceId: 0,
  7326. // ProjectId: 0,
  7327. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7328. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7329. // FeedetlSn: item.FeedetlSn,
  7330. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7331. // MedListCodg: item.XtHisAddtionConfig.Code,
  7332. // Type: 3,
  7333. // }
  7334. //
  7335. // customs = append(customs, cus)
  7336. // }
  7337. //
  7338. // }
  7339. //
  7340. // for _, item := range customs {
  7341. // var advice_id int64 = 0
  7342. // var project_id int64 = 0
  7343. // var item_id int64 = 0
  7344. //
  7345. // var types int64 = 0
  7346. //
  7347. // if item.Type == 1 {
  7348. // advice_id = item.AdviceId
  7349. // project_id = 0
  7350. // item_id = 0
  7351. // } else if item.Type == 2 {
  7352. // advice_id = 0
  7353. // item_id = 0
  7354. //
  7355. // project_id = item.ProjectId
  7356. // } else if item.Type == 3 {
  7357. // advice_id = 0
  7358. // item_id = item.ItemId
  7359. // project_id = 0
  7360. // }
  7361. //
  7362. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7363. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7364. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7365. //
  7366. // info := &models.HisOrderInfo{
  7367. // OrderNumber: order.Number,
  7368. // UploadDate: time.Now().Unix(),
  7369. // AdviceId: advice_id,
  7370. // DetItemFeeSumamt: detItemFeeSumamt,
  7371. // Cnt: cut,
  7372. // Pric: pric,
  7373. // PatientId: id,
  7374. // Status: 1,
  7375. // Mtime: time.Now().Unix(),
  7376. // Ctime: time.Now().Unix(),
  7377. // UserOrgId: adminUser.CurrentOrgId,
  7378. // HisPatientId: his.ID,
  7379. // OrderId: order.ID,
  7380. // ProjectId: project_id,
  7381. // Type: types,
  7382. // ItemId: item_id,
  7383. // }
  7384. // service.CreateOrderInfo(info)
  7385. // }
  7386. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7387. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7388. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7389. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7390. // if err == nil {
  7391. // c.ServeSuccessJSON(map[string]interface{}{
  7392. // "msg": "结算成功",
  7393. // })
  7394. // } else {
  7395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7396. // return
  7397. // }
  7398. // }
  7399. //}
  7400. //上传明细-预结算-
  7401. func (c *HisApiController) GetPreUploadInfo() {
  7402. id, _ := c.GetInt64("id")
  7403. record_time := c.GetString("record_time")
  7404. his_patient_id, _ := c.GetInt64("his_patient_id")
  7405. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7406. admin_user_id, _ := c.GetInt64("admin_user_id")
  7407. diagnosis_id := c.GetString("diagnosis")
  7408. sick_type, _ := c.GetInt64("sick_type")
  7409. reg_type, _ := c.GetInt64("p_type")
  7410. begin_time := c.GetString("begin_time")
  7411. id_str := c.GetString("ids")
  7412. ids_arr := strings.Split(id_str, ",")
  7413. timeLayout := "2006-01-02"
  7414. loc, _ := time.LoadLocation("Local")
  7415. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7416. if err != nil {
  7417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7418. return
  7419. }
  7420. recordDateTime := theTime.Unix()
  7421. adminUser := c.GetAdminUserInfo()
  7422. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7423. var config []*models.HisXtDiagnoseConfig
  7424. for _, item := range diagnosis_ids {
  7425. id, _ := strconv.ParseInt(item, 10, 64)
  7426. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7427. config = append(config, &diagnosisConfig)
  7428. }
  7429. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7430. sickConfig, _ := service.FindSickById(sick_type)
  7431. var prescriptions []*models.HisPrescription
  7432. var start_time int64
  7433. var end_time int64
  7434. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7435. fmt.Println(his_patient_id)
  7436. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7437. timestamp := time.Now().Unix()
  7438. tempTime := time.Unix(timestamp, 0)
  7439. timeFormat := tempTime.Format("20060102150405")
  7440. chrgBchno := rand.Intn(100000) + 10000
  7441. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7442. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7443. var patientPrescription models.HisPrescriptionInfo
  7444. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7445. if patientPrescription.ID == 0 {
  7446. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7447. }
  7448. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7449. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7450. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7451. strconv.FormatInt(his.PatientId, 10)
  7452. var res2 ResultSix
  7453. var resSix10265 ResultSix10265
  7454. var time_stamp string
  7455. if miConfig.MdtrtareaAdmvs == "421300" {
  7456. data := make(map[string]interface{})
  7457. client := &http.Client{}
  7458. data["psn_no"] = his.PsnNo
  7459. data["mdtrt_id"] = his.Number
  7460. data["department"] = department.Name
  7461. data["org_name"] = miConfig.OrgName
  7462. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7463. data["doctor_id"] = doctor_info.DoctorNumber
  7464. data["doctor_name"] = roles.UserName
  7465. data["fixmedins_code"] = miConfig.Code
  7466. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7467. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7468. data["secret_key"] = miConfig.SecretKey
  7469. data["sick_code"] = sickConfig.CountryCode
  7470. data["sick_name"] = sickConfig.ClassName
  7471. data["begin_time"] = begin_time
  7472. data["dept"] = strconv.FormatInt(department.ID, 10)
  7473. data["config"] = config
  7474. data["opter"] = roles.UserName
  7475. fmt.Println(data)
  7476. bytesData, _ := json.Marshal(data)
  7477. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7478. resp, _ := client.Do(req)
  7479. defer resp.Body.Close()
  7480. body, ioErr := ioutil.ReadAll(resp.Body)
  7481. if ioErr != nil {
  7482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. return
  7485. }
  7486. var respJSON map[string]interface{}
  7487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7490. return
  7491. }
  7492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7493. userJSONBytes, _ := json.Marshal(respJSON)
  7494. fmt.Println("log")
  7495. fmt.Println(string(userJSONBytes))
  7496. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7497. utils.ErrorLog("解析失败:%v", err)
  7498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7499. return
  7500. }
  7501. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7502. data := make(map[string]interface{})
  7503. client := &http.Client{}
  7504. data["psn_no"] = his.PsnNo
  7505. data["mdtrt_id"] = his.Number
  7506. data["doctor"] = roles.UserName
  7507. data["department"] = department.Name
  7508. data["org_name"] = miConfig.OrgName
  7509. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7510. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7511. data["fixmedins_code"] = miConfig.Code
  7512. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7513. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7514. data["secret_key"] = miConfig.SecretKey
  7515. data["sick_code"] = sickConfig.CountryCode
  7516. data["sick_name"] = sickConfig.ClassName
  7517. data["begin_time"] = begin_time
  7518. data["dept"] = strconv.FormatInt(department.ID, 10)
  7519. data["config"] = config
  7520. data["url"] = miConfig.Url
  7521. data["ak"] = miConfig.AccessKey
  7522. data["cainfo"] = miConfig.Cainfo
  7523. bytesData, _ := json.Marshal(data)
  7524. var req *http.Request
  7525. if miConfig.MdtrtareaAdmvs == "320921" {
  7526. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7527. } else {
  7528. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  7529. if len(tokens) > 0 {
  7530. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7531. } else {
  7532. c.ServeSuccessJSON(map[string]interface{}{
  7533. "failed_code": -10,
  7534. "msg": "token无效",
  7535. })
  7536. }
  7537. }
  7538. resp, _ := client.Do(req)
  7539. defer resp.Body.Close()
  7540. body, ioErr := ioutil.ReadAll(resp.Body)
  7541. if ioErr != nil {
  7542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7544. return
  7545. }
  7546. var respJSON map[string]interface{}
  7547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7550. return
  7551. }
  7552. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7553. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7554. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7556. userJSONBytes, _ := json.Marshal(respJSON)
  7557. fmt.Println("log")
  7558. fmt.Println(string(userJSONBytes))
  7559. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7560. utils.ErrorLog("解析失败:%v", err)
  7561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7562. return
  7563. }
  7564. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7565. res2.Output = resSix10265.Output
  7566. res2.ErrMsg = resSix10265.ErrMsg
  7567. res2.Cainfo = resSix10265.Cainfo
  7568. res2.WarnMsg = resSix10265.WarnMsg
  7569. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7570. res2.Infcode = infocode
  7571. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7572. 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)
  7573. saveLog(result, requestLog, "2203", "上传就诊信息")
  7574. var respJSON2 map[string]interface{}
  7575. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7578. return
  7579. }
  7580. userJSONBytes2, _ := json.Marshal(respJSON2)
  7581. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7582. utils.ErrorLog("解析失败:%v", err)
  7583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7584. return
  7585. }
  7586. } else {
  7587. var result string
  7588. var requestLog string
  7589. if miConfig.MdtrtareaAdmvs == "440781" { //
  7590. 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)
  7591. } else {
  7592. if miConfig.Code == "H15049901371" {
  7593. //赤峰地区国家医保医疗类别
  7594. //职工透析:医疗类别选特殊情况门诊990502
  7595. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7596. var med_type string
  7597. if his.Insutype == "390" {
  7598. if reg_type == 14 {
  7599. med_type = "9933"
  7600. } else if reg_type == 11 {
  7601. med_type = "11"
  7602. }
  7603. } else if his.Insutype == "310" {
  7604. if reg_type == 14 {
  7605. med_type = "990502"
  7606. } else if reg_type == 11 {
  7607. med_type = "11"
  7608. }
  7609. }
  7610. 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)
  7611. } else {
  7612. 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)
  7613. }
  7614. saveLog(result, requestLog, "2203", "上传就诊信息")
  7615. var respJSON2 map[string]interface{}
  7616. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7619. return
  7620. }
  7621. userJSONBytes2, _ := json.Marshal(respJSON2)
  7622. if miConfig.Code == "H15049901371" {
  7623. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7624. utils.ErrorLog("解析失败:%v", err)
  7625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7626. return
  7627. }
  7628. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7629. res2.Output = resSix10265.Output
  7630. res2.ErrMsg = resSix10265.ErrMsg
  7631. res2.Cainfo = resSix10265.Cainfo
  7632. res2.WarnMsg = resSix10265.WarnMsg
  7633. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7634. res2.Infcode = infocode
  7635. } else {
  7636. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7637. utils.ErrorLog("解析失败:%v", err)
  7638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7639. return
  7640. }
  7641. }
  7642. }
  7643. }
  7644. if res2.Infcode != 0 {
  7645. adminUser := c.GetAdminUserInfo()
  7646. errlog := &models.HisOrderError{
  7647. UserOrgId: adminUser.CurrentOrgId,
  7648. Ctime: time.Now().Unix(),
  7649. Mtime: time.Now().Unix(),
  7650. ErrMsg: res2.ErrMsg,
  7651. Status: 1,
  7652. PatientId: id,
  7653. RecordTime: recordDateTime,
  7654. Stage: 3,
  7655. }
  7656. service.CreateErrMsgLog(errlog)
  7657. c.ServeSuccessJSON(map[string]interface{}{
  7658. "failed_code": -10,
  7659. "msg": res2.ErrMsg,
  7660. })
  7661. return
  7662. } else {
  7663. his.Diagnosis = diagnosis_id
  7664. his.SickType = sickConfig.ID
  7665. his.PType = fmt.Sprintf("%d", reg_type)
  7666. service.UpdateHisPatientThree(&his)
  7667. data := make(map[string]interface{})
  7668. if settle_accounts_type == 1 { //日结
  7669. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7670. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7671. } else {
  7672. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7673. }
  7674. data["pre"] = prescriptions
  7675. } else { //月结
  7676. start_time_str := c.GetString("start_time")
  7677. end_time_str := c.GetString("end_time")
  7678. timeLayout := "2006-01-02"
  7679. loc, _ := time.LoadLocation("Local")
  7680. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7681. if err != nil {
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7683. return
  7684. }
  7685. recordStartTime := theStartTime.Unix()
  7686. start_time = recordStartTime
  7687. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7688. if err != nil {
  7689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7690. return
  7691. }
  7692. recordEndTime := theEndTime.Unix()
  7693. end_time = recordEndTime
  7694. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7695. data["pre"] = prescriptions
  7696. }
  7697. client := &http.Client{}
  7698. data["psn_no"] = his.PsnNo
  7699. data["mdtrt_id"] = his.Number
  7700. data["chrg_bchno"] = chrg_bchno
  7701. data["org_name"] = miConfig.OrgName
  7702. data["doctor"] = roles.UserName
  7703. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7704. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7705. data["fixmedins_code"] = miConfig.Code
  7706. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7707. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7708. data["dept_code"] = "15"
  7709. } else {
  7710. data["dept_code"] = department.Number
  7711. }
  7712. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7713. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7714. data["secret_key"] = miConfig.SecretKey
  7715. data["url"] = miConfig.Url
  7716. data["ak"] = miConfig.AccessKey
  7717. data["new_doctor_name"] = patientPrescription.Doctor
  7718. data["diag_code"] = sickConfig.CountryCode
  7719. data["time_stamp"] = time_stamp
  7720. data["cainfo"] = miConfig.Cainfo
  7721. var ids []int64
  7722. for _, item := range prescriptions {
  7723. ids = append(ids, item.ID)
  7724. }
  7725. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7726. if config.IsOpen == 1 { //对接了医保,走医保流程
  7727. var res ResultFour
  7728. var resFour10265 ResultFour10265
  7729. if miConfig.MdtrtareaAdmvs == "421300" {
  7730. bytesData, _ := json.Marshal(data)
  7731. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7732. resp, _ := client.Do(req)
  7733. defer resp.Body.Close()
  7734. body, ioErr := ioutil.ReadAll(resp.Body)
  7735. if ioErr != nil {
  7736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7738. return
  7739. }
  7740. var respJSON map[string]interface{}
  7741. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. return
  7745. }
  7746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7747. userJSONBytes, _ := json.Marshal(respJSON)
  7748. fmt.Println("log")
  7749. fmt.Println(string(userJSONBytes))
  7750. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7751. utils.ErrorLog("解析失败:%v", err)
  7752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7753. return
  7754. }
  7755. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7756. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7757. if result3101.Infcode == "0" {
  7758. if len(result3101.Output.Result) > 0 {
  7759. var errMsgs []string
  7760. for _, item := range result3101.Output.Result {
  7761. errMsgs = append(errMsgs, item.VolaCont)
  7762. }
  7763. c.ServeSuccessJSON(map[string]interface{}{
  7764. "failed_code": -10,
  7765. "msg": errMsgs,
  7766. })
  7767. return
  7768. } else {
  7769. bytesData, _ := json.Marshal(data)
  7770. var req *http.Request
  7771. if miConfig.MdtrtareaAdmvs == "320921" {
  7772. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7773. } else {
  7774. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7775. }
  7776. resp, _ := client.Do(req)
  7777. defer resp.Body.Close()
  7778. body, ioErr := ioutil.ReadAll(resp.Body)
  7779. if ioErr != nil {
  7780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7782. return
  7783. }
  7784. var respJSON map[string]interface{}
  7785. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7788. return
  7789. }
  7790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7791. userJSONBytes, _ := json.Marshal(respJSON)
  7792. fmt.Println("log")
  7793. fmt.Println(string(userJSONBytes))
  7794. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7795. utils.ErrorLog("解析失败:%v", err)
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. res.InfRefmsgid = resFour10265.InfRefmsgid
  7800. res.Output = resFour10265.Output
  7801. res.ErrMsg = resFour10265.ErrMsg
  7802. res.Cainfo = resFour10265.Cainfo
  7803. res.WarnMsg = resFour10265.WarnMsg
  7804. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7805. res.Infcode = infocode
  7806. }
  7807. }
  7808. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7809. 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)
  7810. var dat map[string]interface{}
  7811. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7812. fmt.Println(dat)
  7813. } else {
  7814. fmt.Println(err)
  7815. }
  7816. saveLog(result, request_log, "2204", "上传费用明细")
  7817. userJSONBytes, _ := json.Marshal(dat)
  7818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7819. utils.ErrorLog("解析失败:%v", err)
  7820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7821. return
  7822. }
  7823. } else {
  7824. if miConfig.Code == "H15049901371" {
  7825. 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)
  7826. var dat map[string]interface{}
  7827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7828. fmt.Println(dat)
  7829. } else {
  7830. fmt.Println(err)
  7831. }
  7832. saveLog(result, request_log, "2204", "上传费用明细")
  7833. userJSONBytes, _ := json.Marshal(dat)
  7834. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7835. utils.ErrorLog("解析失败:%v", err)
  7836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7837. return
  7838. }
  7839. res.InfRefmsgid = resFour10265.InfRefmsgid
  7840. res.Output = resFour10265.Output
  7841. res.ErrMsg = resFour10265.ErrMsg
  7842. res.Cainfo = resFour10265.Cainfo
  7843. res.WarnMsg = resFour10265.WarnMsg
  7844. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7845. res.Infcode = infocode
  7846. } else {
  7847. 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)
  7848. var dat map[string]interface{}
  7849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7850. fmt.Println(dat)
  7851. } else {
  7852. fmt.Println(err)
  7853. }
  7854. saveLog(result, request_log, "2204", "上传费用明细")
  7855. userJSONBytes, _ := json.Marshal(dat)
  7856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7857. utils.ErrorLog("解析失败:%v", err)
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. }
  7862. }
  7863. if res.Infcode == 0 {
  7864. order := &models.HisOrder{
  7865. UserOrgId: adminUser.CurrentOrgId,
  7866. HisPatientId: his.ID,
  7867. PatientId: his.PatientId,
  7868. SettleAccountsDate: recordDateTime,
  7869. Ctime: time.Now().Unix(),
  7870. Mtime: time.Now().Unix(),
  7871. MdtrtId: his.Number,
  7872. PsnNo: his.PsnNo,
  7873. MedType: strconv.FormatInt(reg_type, 10),
  7874. Status: 1,
  7875. Number: chrg_bchno,
  7876. Infcode: res.Infcode,
  7877. WarnMsg: res.WarnMsg,
  7878. Cainfo: res.Cainfo,
  7879. ErrMsg: res.ErrMsg,
  7880. RespondTime: res.RefmsgTime,
  7881. InfRefmsgid: res.InfRefmsgid,
  7882. OrderStatus: 1,
  7883. IsMedicineInsurance: 1,
  7884. SettleType: settle_accounts_type,
  7885. SettleStartTime: start_time,
  7886. SettleEndTime: end_time,
  7887. Creator: roles.AdminUserId,
  7888. Modify: roles.AdminUserId,
  7889. PType: 2,
  7890. Diagnosis: diagnosis_id,
  7891. }
  7892. err = service.CreateOrder(order)
  7893. if err != nil {
  7894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7895. return
  7896. }
  7897. for _, item := range res.Output.Result {
  7898. temp := strings.Split(item.FeedetlSn, "-")
  7899. var advice_id int64 = 0
  7900. var project_id int64 = 0
  7901. var types int64 = 0
  7902. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7903. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7904. if temp[1] == "1" {
  7905. advice_id = id
  7906. project_id = 0
  7907. } else if temp[1] == "2" {
  7908. advice_id = 0
  7909. project_id = id
  7910. }
  7911. info := &models.HisOrderInfo{
  7912. OrderNumber: order.Number,
  7913. FeedetlSn: item.FeedetlSn,
  7914. UploadDate: time.Now().Unix(),
  7915. AdviceId: advice_id,
  7916. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7917. Cnt: item.Cnt,
  7918. Pric: float64(item.Pric),
  7919. PatientId: his.PatientId,
  7920. PricUplmtAmt: item.PricUplmtAmt,
  7921. SelfpayProp: item.SelfpayProp,
  7922. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7923. OverlmtAmt: item.OverlmtAmt,
  7924. PreselfpayAmt: item.PreselfpayAmt,
  7925. BasMednFlag: item.BasMednFlag,
  7926. MedChrgitmType: item.MedChrgitmType,
  7927. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7928. Status: 1,
  7929. Memo: item.Memo,
  7930. Mtime: time.Now().Unix(),
  7931. InscpScpAmt: item.InscpScpAmt,
  7932. DrtReimFlag: item.DrtReimFlag,
  7933. Ctime: time.Now().Unix(),
  7934. ListSpItemFlag: item.ListSpItemFlag,
  7935. ChldMedcFlag: item.ChldMedcFlag,
  7936. LmtUsedFlag: item.LmtUsedFlag,
  7937. ChrgitmLv: item.ChrgitmLv,
  7938. UserOrgId: adminUser.CurrentOrgId,
  7939. HisPatientId: his.ID,
  7940. OrderId: order.ID,
  7941. ProjectId: project_id,
  7942. Type: types,
  7943. }
  7944. service.CreateOrderInfo(info)
  7945. }
  7946. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7947. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7948. var total float64
  7949. for _, item := range prescriptions {
  7950. if item.Type == 1 { //药品
  7951. for _, subItem := range item.HisDoctorAdviceInfo {
  7952. total = total + (subItem.Price * subItem.PrescribingNumber)
  7953. }
  7954. }
  7955. if item.Type == 2 { //项目
  7956. for _, subItem := range item.HisPrescriptionProject {
  7957. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7958. total = total + (subItem.Price * cnt)
  7959. }
  7960. }
  7961. }
  7962. for _, item := range prescriptions {
  7963. for _, subItem := range item.HisAdditionalCharge {
  7964. total = total + (subItem.Price * float64(subItem.Count))
  7965. }
  7966. }
  7967. allTotal := fmt.Sprintf("%.4f", total)
  7968. if res.Infcode == 0 {
  7969. var rf []*ResultFive
  7970. json.Unmarshal([]byte(his.Iinfo), &rf)
  7971. chrg_bchno := chrg_bchno
  7972. cert_no := his.Certno
  7973. var insutypes []string
  7974. var insutype string
  7975. var is390 int = 0
  7976. var is310 int = 0
  7977. for _, item := range rf {
  7978. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7979. insutypes = append(insutypes, item.Insutype)
  7980. }
  7981. }
  7982. if len(insutypes) == 1 {
  7983. insutype = insutypes[0]
  7984. } else {
  7985. for _, i := range insutypes {
  7986. if i == "390" {
  7987. is390 = 1
  7988. }
  7989. if i == "310" {
  7990. is310 = 1
  7991. }
  7992. }
  7993. }
  7994. if is390 == 1 {
  7995. insutype = "390"
  7996. }
  7997. if is310 == 1 {
  7998. insutype = "310"
  7999. }
  8000. if len(insutypes) == 0 {
  8001. insutype = "310"
  8002. }
  8003. if len(insutypes) == 2 {
  8004. insutype = strconv.FormatInt(his.SocialType, 64)
  8005. }
  8006. //insutype = "390"
  8007. if his.IdCardType == 1 {
  8008. cert_no = his.MedicalInsuranceNumber
  8009. } else {
  8010. cert_no = his.Certno
  8011. }
  8012. var res ResultSeven
  8013. var resSeven10265 ResultSeven10265
  8014. if miConfig.MdtrtareaAdmvs == "421300" {
  8015. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8016. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8017. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8018. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8019. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8020. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8021. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  8022. resp, requestErr := http.Get(api)
  8023. if requestErr != nil {
  8024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8025. return
  8026. }
  8027. body, ioErr := ioutil.ReadAll(resp.Body)
  8028. if ioErr != nil {
  8029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8031. return
  8032. }
  8033. var respJSON map[string]interface{}
  8034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8037. return
  8038. }
  8039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8040. result, _ := json.Marshal(respJSON)
  8041. fmt.Println("log")
  8042. fmt.Println(string(result))
  8043. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8044. utils.ErrorLog("解析失败:%v", err)
  8045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8046. return
  8047. }
  8048. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8049. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  8050. if result3101.Infcode == "0" {
  8051. if len(result3101.Output.Result) > 0 {
  8052. var errMsgs []string
  8053. for _, item := range result3101.Output.Result {
  8054. errMsgs = append(errMsgs, item.VolaCont)
  8055. }
  8056. c.ServeSuccessJSON(map[string]interface{}{
  8057. "failed_code": -10,
  8058. "msg": errMsgs,
  8059. })
  8060. return
  8061. } else {
  8062. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8063. if his.IdCardType != 4 {
  8064. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8065. }
  8066. bas := strings.Split(psn_info.CardInfo, "|")
  8067. if his.IdCardType == 1 {
  8068. cert_no = bas[2]
  8069. } else {
  8070. cert_no = bas[1]
  8071. }
  8072. //江苏地区国家医保医疗类别
  8073. //职工透析:医疗类别选特殊情况门诊9933
  8074. //居民血透门慢: 医疗类别选门诊慢病1402
  8075. //var med_type string
  8076. //if his.Insutype == "310" {
  8077. // if reg_type == 14 {
  8078. // med_type = "9933"
  8079. // } else if reg_type == 11 {
  8080. // med_type = "11"
  8081. //
  8082. // }
  8083. //} else if his.Insutype == "390" {
  8084. // if reg_type == 14 {
  8085. // med_type = "1402"
  8086. // } else if reg_type == 11 {
  8087. // med_type = "11"
  8088. // }
  8089. //}
  8090. var api string
  8091. if miConfig.MdtrtareaAdmvs == "320921" {
  8092. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8093. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8094. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8095. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8096. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8097. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8098. "&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
  8099. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8100. } else {
  8101. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8102. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8103. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8104. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8106. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8107. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8108. "&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
  8109. }
  8110. resp, requestErr := http.Get(api)
  8111. if requestErr != nil {
  8112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8113. return
  8114. }
  8115. body, ioErr := ioutil.ReadAll(resp.Body)
  8116. if ioErr != nil {
  8117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8119. return
  8120. }
  8121. var respJSON map[string]interface{}
  8122. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8125. return
  8126. }
  8127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8128. result, _ := json.Marshal(respJSON)
  8129. fmt.Println("log")
  8130. fmt.Println(string(result))
  8131. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8132. utils.ErrorLog("解析失败:%v", err)
  8133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8134. return
  8135. }
  8136. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8137. res.Output = resSeven10265.Output
  8138. res.ErrMsg = resSeven10265.ErrMsg
  8139. res.Cainfo = resSeven10265.Cainfo
  8140. res.WarnMsg = resSeven10265.WarnMsg
  8141. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8142. res.Infcode = infocode
  8143. }
  8144. }
  8145. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8146. 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)
  8147. var dat map[string]interface{}
  8148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8149. fmt.Println(dat)
  8150. } else {
  8151. fmt.Println(err)
  8152. }
  8153. saveLog(result, request_log, "2206", "预结算")
  8154. userJSONBytes, _ := json.Marshal(dat)
  8155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8156. utils.ErrorLog("解析失败:%v", err)
  8157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8158. return
  8159. }
  8160. } else {
  8161. var result string
  8162. var request_log string
  8163. if miConfig.Code == "H15049901371" {
  8164. //赤峰地区国家医保医疗类别
  8165. //职工透析:医疗类别选特殊情况门诊990502
  8166. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8167. var med_type string
  8168. if his.Insutype == "390" {
  8169. if reg_type == 14 {
  8170. med_type = "9933"
  8171. } else if reg_type == 11 {
  8172. med_type = "11"
  8173. }
  8174. } else if his.Insutype == "310" {
  8175. if reg_type == 14 {
  8176. med_type = "990502"
  8177. } else if reg_type == 11 {
  8178. med_type = "11"
  8179. }
  8180. }
  8181. 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)
  8182. } else {
  8183. 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)
  8184. }
  8185. var dat map[string]interface{}
  8186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8187. fmt.Println(dat)
  8188. } else {
  8189. fmt.Println(err)
  8190. }
  8191. saveLog(result, request_log, "2206", "预结算")
  8192. //userJSONBytes, _ := json.Marshal(dat)
  8193. //
  8194. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8195. // utils.ErrorLog("解析失败:%v", err)
  8196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. // return
  8198. //}
  8199. userJSONBytes, _ := json.Marshal(dat)
  8200. if miConfig.Code == "H15049901371" {
  8201. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8202. utils.ErrorLog("解析失败:%v", err)
  8203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8204. return
  8205. }
  8206. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8207. res.Output = resSeven10265.Output
  8208. res.ErrMsg = resSeven10265.ErrMsg
  8209. res.Cainfo = resSeven10265.Cainfo
  8210. res.WarnMsg = resSeven10265.WarnMsg
  8211. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8212. res.Infcode = infocode
  8213. } else {
  8214. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8215. utils.ErrorLog("解析失败:%v", err)
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. return
  8218. }
  8219. }
  8220. }
  8221. if res.Infcode != 0 {
  8222. errlog := &models.HisOrderError{
  8223. UserOrgId: adminUser.CurrentOrgId,
  8224. Ctime: time.Now().Unix(),
  8225. Mtime: time.Now().Unix(),
  8226. Number: chrg_bchno,
  8227. ErrMsg: res.ErrMsg,
  8228. Status: 1,
  8229. PatientId: id,
  8230. RecordTime: recordDateTime,
  8231. Stage: 20,
  8232. }
  8233. service.CreateErrMsgLog(errlog)
  8234. c.ServeSuccessJSON(map[string]interface{}{
  8235. "failed_code": -10,
  8236. "msg": res.ErrMsg,
  8237. })
  8238. return
  8239. } else {
  8240. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8241. order.OrderStatus = 1
  8242. order.IsPre = 1
  8243. order.Status = 1
  8244. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8245. order.SetlId = res.Output.Setlinfo.SetlID
  8246. order.PsnNo = res.Output.Setlinfo.PsnNo
  8247. order.PsnName = res.Output.Setlinfo.PsnName
  8248. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8249. order.Certno = res.Output.Setlinfo.Certno
  8250. order.Gend = res.Output.Setlinfo.Gend
  8251. order.Naty = res.Output.Setlinfo.Naty
  8252. order.Age = res.Output.Setlinfo.Age
  8253. order.Insutype = res.Output.Setlinfo.Insutype
  8254. order.PsnType = res.Output.Setlinfo.PsnType
  8255. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8256. order.SetlTime = res.Output.Setlinfo.SetlTime
  8257. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8258. if res.Output.Setlinfo.MedType == "140101" {
  8259. order.MedType = "14"
  8260. } else {
  8261. order.MedType = res.Output.Setlinfo.MedType
  8262. }
  8263. if reg_type == 1112 {
  8264. order.MedType = "1112"
  8265. }
  8266. if reg_type == 1111 {
  8267. order.MedType = "1111"
  8268. }
  8269. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8270. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8271. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8272. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8273. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8274. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8275. order.HifpPay = res.Output.Setlinfo.HifpPay
  8276. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8277. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8278. order.HifesPay = res.Output.Setlinfo.HifesPay
  8279. order.HifobPay = res.Output.Setlinfo.HifobPay
  8280. order.MafPay = res.Output.Setlinfo.MafPay
  8281. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8282. order.OthPay = res.Output.Setlinfo.OthPay
  8283. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8284. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8285. order.AcctPay = res.Output.Setlinfo.AcctPay
  8286. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8287. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8288. order.Balc = res.Output.Setlinfo.Balc
  8289. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8290. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8291. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8292. order.ClrWay = res.Output.Setlinfo.ClrWay
  8293. order.Creator = order.Creator
  8294. order.Modify = roles.AdminUserId
  8295. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8296. detailStr := string(setlDetail)
  8297. order.SetlDetail = detailStr
  8298. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8299. err = service.UpDateOrder(order)
  8300. if err == nil {
  8301. c.ServeSuccessJSON(map[string]interface{}{
  8302. "msg": "预结算成功",
  8303. })
  8304. } else {
  8305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8306. return
  8307. }
  8308. }
  8309. } else {
  8310. adminUser := c.GetAdminUserInfo()
  8311. errlog := &models.HisOrderError{
  8312. UserOrgId: adminUser.CurrentOrgId,
  8313. Ctime: time.Now().Unix(),
  8314. Mtime: time.Now().Unix(),
  8315. ErrMsg: res.ErrMsg,
  8316. Status: 1,
  8317. PatientId: id,
  8318. RecordTime: recordDateTime,
  8319. Stage: 4,
  8320. }
  8321. service.CreateErrMsgLog(errlog)
  8322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8323. return
  8324. }
  8325. } else {
  8326. adminUser := c.GetAdminUserInfo()
  8327. errlog := &models.HisOrderError{
  8328. UserOrgId: adminUser.CurrentOrgId,
  8329. Ctime: time.Now().Unix(),
  8330. Mtime: time.Now().Unix(),
  8331. ErrMsg: res.ErrMsg,
  8332. Status: 1,
  8333. PatientId: id,
  8334. RecordTime: recordDateTime,
  8335. Stage: 4,
  8336. }
  8337. service.CreateErrMsgLog(errlog)
  8338. c.ServeSuccessJSON(map[string]interface{}{
  8339. "failed_code": -10,
  8340. "msg": res.ErrMsg,
  8341. })
  8342. return
  8343. }
  8344. }
  8345. }
  8346. }
  8347. //退款
  8348. func (c *HisApiController) Refund() {
  8349. order_id, _ := c.GetInt64("order_id")
  8350. admin_user_id, _ := c.GetInt64("admin_user_id")
  8351. adminUser := c.GetAdminUserInfo()
  8352. var order models.HisOrder
  8353. order, _ = service.GetHisOrderByID(order_id)
  8354. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8355. if order.ID == 0 {
  8356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8357. return
  8358. }
  8359. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8360. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8361. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8362. if config.IsOpen == 1 { //对接了医保,走医保流程
  8363. var res ResultSixteen
  8364. var resSixteen10265 ResultSixteen10265
  8365. var src_resquest string
  8366. var result string
  8367. if miConfig.MdtrtareaAdmvs == "421300" {
  8368. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8369. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8370. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8371. resp3, requestErr3 := http.Get(api3)
  8372. if requestErr3 != nil {
  8373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8374. return
  8375. }
  8376. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8377. if ioErr3 != nil {
  8378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8380. return
  8381. }
  8382. var respJSON3 map[string]interface{}
  8383. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8386. return
  8387. }
  8388. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8389. userJSONBytes3, _ := json.Marshal(respJSON3)
  8390. fmt.Println("log")
  8391. fmt.Println(string(userJSONBytes3))
  8392. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8393. utils.ErrorLog("解析失败:%v", err)
  8394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8395. return
  8396. }
  8397. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8398. var api3 string
  8399. if miConfig.MdtrtareaAdmvs == "320921" {
  8400. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8401. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8402. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8403. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8404. } else {
  8405. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8406. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8407. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8408. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8409. }
  8410. resp3, requestErr3 := http.Get(api3)
  8411. if requestErr3 != nil {
  8412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8413. return
  8414. }
  8415. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8416. if ioErr3 != nil {
  8417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8419. return
  8420. }
  8421. var respJSON3 map[string]interface{}
  8422. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8425. return
  8426. }
  8427. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8428. userJSONBytes3, _ := json.Marshal(respJSON3)
  8429. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8430. utils.ErrorLog("解析失败:%v", err)
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8435. res.Output = resSixteen10265.Output
  8436. res.ErrMsg = resSixteen10265.ErrMsg
  8437. res.Cainfo = resSixteen10265.Cainfo
  8438. res.WarnMsg = resSixteen10265.WarnMsg
  8439. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8440. res.Infcode = infocode
  8441. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8442. 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)
  8443. var dat map[string]interface{}
  8444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8445. fmt.Println(dat)
  8446. } else {
  8447. fmt.Println(err)
  8448. }
  8449. saveLog(result, src_resquest, "2208", "退费")
  8450. userJSONBytes, _ := json.Marshal(dat)
  8451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8452. utils.ErrorLog("解析失败:%v", err)
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8454. return
  8455. }
  8456. } else {
  8457. if miConfig.Code == "H15049901371" {
  8458. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8459. var dat map[string]interface{}
  8460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8461. fmt.Println(dat)
  8462. } else {
  8463. fmt.Println(err)
  8464. }
  8465. saveLog(result, src_resquest, "2208", "退费")
  8466. userJSONBytes, _ := json.Marshal(dat)
  8467. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8468. utils.ErrorLog("解析失败:%v", err)
  8469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8470. return
  8471. }
  8472. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8473. res.Output = resSixteen10265.Output
  8474. res.ErrMsg = resSixteen10265.ErrMsg
  8475. res.Cainfo = resSixteen10265.Cainfo
  8476. res.WarnMsg = resSixteen10265.WarnMsg
  8477. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8478. res.Infcode = infocode
  8479. } else {
  8480. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8481. var dat map[string]interface{}
  8482. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8483. fmt.Println(dat)
  8484. } else {
  8485. fmt.Println(err)
  8486. }
  8487. saveLog(result, src_resquest, "2208", "退费")
  8488. userJSONBytes, _ := json.Marshal(dat)
  8489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8490. utils.ErrorLog("解析失败:%v", err)
  8491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8492. return
  8493. }
  8494. }
  8495. }
  8496. if res.Infcode == 0 {
  8497. var res2 ResultSix
  8498. var resSix10265 ResultSix10265
  8499. if miConfig.MdtrtareaAdmvs == "421300" {
  8500. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8501. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8503. resp3, requestErr3 := http.Get(api3)
  8504. if requestErr3 != nil {
  8505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8506. return
  8507. }
  8508. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8509. if ioErr3 != nil {
  8510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8512. return
  8513. }
  8514. var respJSON3 map[string]interface{}
  8515. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8518. return
  8519. }
  8520. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8521. userJSONBytes3, _ := json.Marshal(respJSON3)
  8522. fmt.Println("log")
  8523. fmt.Println(string(userJSONBytes3))
  8524. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8525. utils.ErrorLog("解析失败:%v", err)
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8530. var api3 string
  8531. if miConfig.MdtrtareaAdmvs == "320921" {
  8532. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8533. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8535. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8536. } else {
  8537. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8538. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8539. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8540. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8541. }
  8542. resp3, requestErr3 := http.Get(api3)
  8543. if requestErr3 != nil {
  8544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8545. return
  8546. }
  8547. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8548. if ioErr3 != nil {
  8549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8551. return
  8552. }
  8553. var respJSON3 map[string]interface{}
  8554. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8557. return
  8558. }
  8559. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8560. userJSONBytes3, _ := json.Marshal(respJSON3)
  8561. fmt.Println("log")
  8562. fmt.Println(string(userJSONBytes3))
  8563. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8564. utils.ErrorLog("解析失败:%v", err)
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8569. res2.Output = resSix10265.Output
  8570. res2.ErrMsg = resSix10265.ErrMsg
  8571. res2.Cainfo = resSix10265.Cainfo
  8572. res2.WarnMsg = resSix10265.WarnMsg
  8573. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8574. res2.Infcode = infocode
  8575. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8576. 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)
  8577. var dat map[string]interface{}
  8578. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8579. fmt.Println(dat)
  8580. } else {
  8581. fmt.Println(err)
  8582. }
  8583. saveLog(result2, src_request, "2205", "撤销明细")
  8584. userJSONBytes, _ := json.Marshal(dat)
  8585. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8586. utils.ErrorLog("解析失败:%v", err)
  8587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8588. return
  8589. }
  8590. } else {
  8591. if miConfig.Code == "H15049901371" {
  8592. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8593. var dat map[string]interface{}
  8594. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8595. fmt.Println(dat)
  8596. } else {
  8597. fmt.Println(err)
  8598. }
  8599. saveLog(result2, src_request, "2205", "撤销明细")
  8600. userJSONBytes, _ := json.Marshal(dat)
  8601. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8602. utils.ErrorLog("解析失败:%v", err)
  8603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8604. return
  8605. }
  8606. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8607. res2.Output = resSix10265.Output
  8608. res2.ErrMsg = resSix10265.ErrMsg
  8609. res2.Cainfo = resSix10265.Cainfo
  8610. res2.WarnMsg = resSix10265.WarnMsg
  8611. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8612. res2.Infcode = infocode
  8613. } else {
  8614. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8615. var dat map[string]interface{}
  8616. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8617. fmt.Println(dat)
  8618. } else {
  8619. fmt.Println(err)
  8620. }
  8621. saveLog(result2, src_request, "2205", "撤销明细")
  8622. userJSONBytes, _ := json.Marshal(dat)
  8623. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8624. utils.ErrorLog("解析失败:%v", err)
  8625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8626. return
  8627. }
  8628. }
  8629. }
  8630. if res2.Infcode == 0 {
  8631. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8632. if err == nil {
  8633. //当押金不为零时产生退费记录
  8634. if order.Decimal != 0 {
  8635. tmp := strconv.FormatInt(order.ID, 10)
  8636. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8637. if err != nil {
  8638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8639. return
  8640. }
  8641. }
  8642. c.ServeSuccessJSON(map[string]interface{}{
  8643. "msg": "退费成功",
  8644. })
  8645. } else {
  8646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8647. return
  8648. }
  8649. } else {
  8650. c.ServeSuccessJSON(map[string]interface{}{
  8651. "code": -10,
  8652. "msg": res2.ErrMsg,
  8653. })
  8654. }
  8655. } else {
  8656. c.ServeSuccessJSON(map[string]interface{}{
  8657. "code": -10,
  8658. "msg": res.ErrMsg,
  8659. })
  8660. }
  8661. }
  8662. }
  8663. func (c *HisApiController) RefundNumber() {
  8664. record_time := c.GetString("record_time")
  8665. //patient_id, _ := c.GetInt64("patient_id")
  8666. admin_user_id, _ := c.GetInt64("admin_user_id")
  8667. his_patient_id, _ := c.GetInt64("id")
  8668. timeLayout := "2006-01-02"
  8669. loc, _ := time.LoadLocation("Local")
  8670. adminUser := c.GetAdminUserInfo()
  8671. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8672. fmt.Println(err)
  8673. if err != nil {
  8674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8675. return
  8676. }
  8677. recordDateTime := theTime.Unix()
  8678. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8679. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8680. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8681. //order, _ := service.GetHisOrderByID(order_id)
  8682. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8683. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8684. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8685. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8686. if count > 0 {
  8687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8688. return
  8689. }
  8690. if config.IsOpen == 1 { //对接了医保,走医保流程
  8691. var res2 ResultSix
  8692. var resSix10265 ResultSix10265
  8693. if miConfig.MdtrtareaAdmvs == "421300" {
  8694. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8695. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8697. resp3, requestErr3 := http.Get(api3)
  8698. if requestErr3 != nil {
  8699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8700. return
  8701. }
  8702. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8703. if ioErr3 != nil {
  8704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8706. return
  8707. }
  8708. var respJSON3 map[string]interface{}
  8709. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8712. return
  8713. }
  8714. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8715. userJSONBytes3, _ := json.Marshal(respJSON3)
  8716. fmt.Println("log")
  8717. fmt.Println(string(userJSONBytes3))
  8718. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8719. utils.ErrorLog("解析失败:%v", err)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8724. var api3 string
  8725. if miConfig.MdtrtareaAdmvs == "320921" {
  8726. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8727. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8728. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8729. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8730. } else {
  8731. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8732. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8733. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8734. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8735. }
  8736. resp3, requestErr3 := http.Get(api3)
  8737. if requestErr3 != nil {
  8738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8739. return
  8740. }
  8741. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8742. if ioErr3 != nil {
  8743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8745. return
  8746. }
  8747. var respJSON3 map[string]interface{}
  8748. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8751. return
  8752. }
  8753. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8754. userJSONBytes3, _ := json.Marshal(respJSON3)
  8755. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8756. utils.ErrorLog("解析失败:%v", err)
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8761. res2.Output = resSix10265.Output
  8762. res2.ErrMsg = resSix10265.ErrMsg
  8763. res2.Cainfo = resSix10265.Cainfo
  8764. res2.WarnMsg = resSix10265.WarnMsg
  8765. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8766. res2.Infcode = infocode
  8767. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8768. 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)
  8769. var dat map[string]interface{}
  8770. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8771. fmt.Println(dat)
  8772. } else {
  8773. fmt.Println(err)
  8774. }
  8775. saveLog(result, request, "2202", "退号")
  8776. userJSONBytes, _ := json.Marshal(dat)
  8777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8778. utils.ErrorLog("解析失败:%v", err)
  8779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8780. return
  8781. }
  8782. } else {
  8783. var api3 string
  8784. if miConfig.Code == "H15049901371" {
  8785. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8786. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8787. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8788. } else {
  8789. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8790. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8791. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8792. }
  8793. resp3, requestErr3 := http.Get(api3)
  8794. if requestErr3 != nil {
  8795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8796. return
  8797. }
  8798. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8799. if ioErr3 != nil {
  8800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8802. return
  8803. }
  8804. var respJSON3 map[string]interface{}
  8805. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8808. return
  8809. }
  8810. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8811. userJSONBytes3, _ := json.Marshal(respJSON3)
  8812. if miConfig.Code == "H15049901371" {
  8813. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8814. utils.ErrorLog("解析失败:%v", err)
  8815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8816. return
  8817. }
  8818. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8819. res2.Output = resSix10265.Output
  8820. res2.ErrMsg = resSix10265.ErrMsg
  8821. res2.Cainfo = resSix10265.Cainfo
  8822. res2.WarnMsg = resSix10265.WarnMsg
  8823. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8824. res2.Infcode = infocode
  8825. } else {
  8826. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8827. utils.ErrorLog("解析失败:%v", err)
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8829. return
  8830. }
  8831. }
  8832. }
  8833. if res2.Infcode == 0 {
  8834. if err == nil {
  8835. c.ServeSuccessJSON(map[string]interface{}{
  8836. "msg": "退号成功",
  8837. })
  8838. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8839. } else {
  8840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8841. return
  8842. }
  8843. } else {
  8844. c.ServeSuccessJSON(map[string]interface{}{
  8845. "code": -10,
  8846. "msg": res2.ErrMsg,
  8847. })
  8848. }
  8849. } else {
  8850. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8851. //if err == nil {
  8852. // c.ServeSuccessJSON(map[string]interface{}{
  8853. // "msg": "退费成功",
  8854. // })
  8855. //} else {
  8856. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8857. // return
  8858. //}
  8859. }
  8860. }
  8861. func (c *HisApiController) RefundDetail() {
  8862. order_id, _ := c.GetInt64("order_id")
  8863. admin_user_id, _ := c.GetInt64("admin_user_id")
  8864. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8865. number := c.GetString("number")
  8866. record_time := c.GetString("record_time")
  8867. patient_id, _ := c.GetInt64("patient_id")
  8868. //med_type, _ := c.GetInt64("med_type")
  8869. timeLayout := "2006-01-02"
  8870. loc, _ := time.LoadLocation("Local")
  8871. adminUser := c.GetAdminUserInfo()
  8872. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8873. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8874. fmt.Println(err)
  8875. if err != nil {
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8877. return
  8878. }
  8879. recordDateTime := theTime.Unix()
  8880. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8881. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8882. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8883. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8884. var order models.HisOrder
  8885. order, _ = service.GetHisOrderByID(order_id)
  8886. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8887. if config.IsOpen == 1 { //对接了医保,走医保流程
  8888. var res2 ResultSix
  8889. if miConfig.MdtrtareaAdmvs == "421300" {
  8890. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8891. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8892. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8893. resp3, requestErr3 := http.Get(api3)
  8894. if requestErr3 != nil {
  8895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8896. return
  8897. }
  8898. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8899. if ioErr3 != nil {
  8900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8902. return
  8903. }
  8904. var respJSON3 map[string]interface{}
  8905. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8908. return
  8909. }
  8910. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8911. userJSONBytes3, _ := json.Marshal(respJSON3)
  8912. fmt.Println("log")
  8913. fmt.Println(string(userJSONBytes3))
  8914. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8915. utils.ErrorLog("解析失败:%v", err)
  8916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8917. return
  8918. }
  8919. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8920. if err == nil {
  8921. c.ServeSuccessJSON(map[string]interface{}{
  8922. "msg": "撤销明细成功",
  8923. })
  8924. return
  8925. } else {
  8926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8927. return
  8928. }
  8929. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8930. var resSix10265 ResultSix10265
  8931. var api3 string
  8932. if miConfig.MdtrtareaAdmvs == "320921" {
  8933. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8934. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8935. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8936. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8937. } else {
  8938. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8939. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8940. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8941. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8942. }
  8943. resp3, requestErr3 := http.Get(api3)
  8944. if requestErr3 != nil {
  8945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8946. return
  8947. }
  8948. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8949. if ioErr3 != nil {
  8950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8952. return
  8953. }
  8954. var respJSON3 map[string]interface{}
  8955. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8958. return
  8959. }
  8960. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8961. userJSONBytes3, _ := json.Marshal(respJSON3)
  8962. fmt.Println("log")
  8963. fmt.Println(string(userJSONBytes3))
  8964. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8965. utils.ErrorLog("解析失败:%v", err)
  8966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8967. return
  8968. }
  8969. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8970. res2.Output = resSix10265.Output
  8971. res2.ErrMsg = resSix10265.ErrMsg
  8972. res2.Cainfo = resSix10265.Cainfo
  8973. res2.WarnMsg = resSix10265.WarnMsg
  8974. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8975. res2.Infcode = infocode
  8976. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8977. if err == nil {
  8978. c.ServeSuccessJSON(map[string]interface{}{
  8979. "msg": "撤销明细成功",
  8980. })
  8981. return
  8982. } else {
  8983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8984. return
  8985. }
  8986. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8987. 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)
  8988. var dat map[string]interface{}
  8989. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8990. fmt.Println(dat)
  8991. } else {
  8992. fmt.Println(err)
  8993. }
  8994. saveLog(result2, src_request, "2205", "撤销明细")
  8995. userJSONBytes, _ := json.Marshal(dat)
  8996. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8997. utils.ErrorLog("解析失败:%v", err)
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8999. return
  9000. }
  9001. if res2.Infcode == 0 {
  9002. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9003. if err == nil {
  9004. c.ServeSuccessJSON(map[string]interface{}{
  9005. "msg": "撤销明细成功",
  9006. })
  9007. return
  9008. } else {
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9010. return
  9011. }
  9012. } else {
  9013. c.ServeSuccessJSON(map[string]interface{}{
  9014. "code": -10,
  9015. "msg": res2.ErrMsg,
  9016. })
  9017. }
  9018. } else {
  9019. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  9020. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  9021. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9022. resp2, requestErr2 := http.Get(api2)
  9023. if requestErr2 != nil {
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9028. if ioErr2 != nil {
  9029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9031. return
  9032. }
  9033. var respJSON2 map[string]interface{}
  9034. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9037. return
  9038. }
  9039. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9040. if err == nil {
  9041. c.ServeSuccessJSON(map[string]interface{}{
  9042. "msg": "撤销明细成功",
  9043. })
  9044. return
  9045. } else {
  9046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9047. return
  9048. }
  9049. }
  9050. } else {
  9051. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9052. if err == nil {
  9053. c.ServeSuccessJSON(map[string]interface{}{
  9054. "msg": "退费成功",
  9055. })
  9056. } else {
  9057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9058. return
  9059. }
  9060. }
  9061. }
  9062. //对账
  9063. func (c *HisApiController) GetCheckAccount() {
  9064. start_time := c.GetString("start_time")
  9065. end_time := c.GetString("end_time")
  9066. insutype := c.GetString("insutype")
  9067. clr_type := c.GetString("clr_type")
  9068. clr_org := c.GetString("clr_optins")
  9069. admin_user_id, _ := c.GetInt64("admin_user_id")
  9070. adminUser := c.GetAdminUserInfo()
  9071. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9072. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9073. if len(clr_org) == 0 {
  9074. clr_org = miConfig.MdtrtareaAdmvs
  9075. }
  9076. timeLayout := "2006-01-02"
  9077. loc, _ := time.LoadLocation("Local")
  9078. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9079. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9080. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9081. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9082. fixmedins_setl_cnt := int64(len(orders))
  9083. var medfee_sumamt float64
  9084. var acct_pay float64
  9085. var fund_pay_sumamt float64
  9086. for _, item := range orders {
  9087. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9088. acct_pay = acct_pay + item.AcctPay
  9089. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9090. }
  9091. var user_name string
  9092. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9093. if role.ID == 0 {
  9094. user_name = "xxx"
  9095. } else {
  9096. user_name = role.UserName
  9097. }
  9098. var res ResultEight
  9099. var res10188 ResultEightFor10188
  9100. if config.IsOpen == 1 {
  9101. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9102. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9103. "insutype=" + insutype +
  9104. "&clr_type=" + clr_type +
  9105. "&setl_optins=" + clr_org +
  9106. "&stmt_begndate=" + start_time +
  9107. "&stm_enddate=" + end_time +
  9108. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9109. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9110. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9111. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9112. "&fixmedins_code=" + miConfig.Code +
  9113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9114. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9115. "&secret_key=" + miConfig.SecretKey +
  9116. "&org_name=" + miConfig.OrgName +
  9117. "&doctor=" + user_name +
  9118. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9119. fmt.Println(api)
  9120. resp, requestErr := http.Get(api)
  9121. if requestErr != nil {
  9122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9123. return
  9124. }
  9125. body, ioErr := ioutil.ReadAll(resp.Body)
  9126. fmt.Println(body)
  9127. if ioErr != nil {
  9128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9130. return
  9131. }
  9132. var respJSON map[string]interface{}
  9133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9136. return
  9137. }
  9138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9139. userJSONBytes, _ := json.Marshal(respJSON)
  9140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9141. utils.ErrorLog("解析失败:%v", err)
  9142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9143. return
  9144. }
  9145. res.InfRefmsgid = res10188.InfRefmsgid
  9146. res.Output = res10188.Output
  9147. res.ErrMsg = res10188.ErrMsg
  9148. res.Cainfo = res10188.Cainfo
  9149. res.WarnMsg = res10188.WarnMsg
  9150. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9151. res.Infcode = infocode
  9152. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9153. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9154. "insutype=" + insutype +
  9155. "&clr_type=" + "21" +
  9156. "&setl_optins=" + clr_org +
  9157. "&stmt_begndate=" + start_time +
  9158. "&stm_enddate=" + end_time +
  9159. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9160. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9161. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9162. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9163. "&fixmedins_code=" + miConfig.Code +
  9164. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9165. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9166. "&secret_key=" + miConfig.SecretKey +
  9167. "&org_name=" + miConfig.OrgName +
  9168. "&doctor=" + user_name
  9169. resp, requestErr := http.Get(api)
  9170. if requestErr != nil {
  9171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9172. return
  9173. }
  9174. body, ioErr := ioutil.ReadAll(resp.Body)
  9175. if ioErr != nil {
  9176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9178. return
  9179. }
  9180. var respJSON map[string]interface{}
  9181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9184. return
  9185. }
  9186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9187. result, _ := json.Marshal(respJSON)
  9188. fmt.Println("log")
  9189. fmt.Println(string(result))
  9190. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  9191. utils.ErrorLog("解析失败:%v", err)
  9192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9193. return
  9194. }
  9195. res.InfRefmsgid = res10188.InfRefmsgid
  9196. res.Output = res10188.Output
  9197. res.ErrMsg = res10188.ErrMsg
  9198. res.Cainfo = res10188.Cainfo
  9199. res.WarnMsg = res10188.WarnMsg
  9200. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9201. res.Infcode = infocode
  9202. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9203. var baseParams models.BaseParams
  9204. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9205. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9206. baseParams.SecretKey = miConfig.SecretKey
  9207. baseParams.OrgName = miConfig.OrgName
  9208. baseParams.FixmedinsCode = miConfig.Code
  9209. baseParams.EncKey = miConfig.EncKey
  9210. baseParams.AppSecret = miConfig.AppSecret
  9211. baseParams.SignKey = miConfig.SignKey
  9212. baseParams.AppID = miConfig.Code
  9213. baseParams.Doctor = role.UserName
  9214. baseParams.RequestUrl = miConfig.Url
  9215. businessParams := models.BusinessParams{
  9216. Insutype: insutype,
  9217. ClrType: clr_type,
  9218. SetlOptins: clr_org,
  9219. StmtBegndate: start_time,
  9220. StmtEnddate: end_time,
  9221. MedfeeSumamt: medfee_sumamt,
  9222. FundPaySumamt: fund_pay_sumamt,
  9223. AcctPay: acct_pay,
  9224. FixmedinsSetlCnt: fixmedins_setl_cnt + int64(len(orders_two)*2),
  9225. }
  9226. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams)
  9227. fmt.Println(requestLog)
  9228. fmt.Println(result)
  9229. fmt.Println(err_msg)
  9230. } else {
  9231. if len(clr_type) == 0 {
  9232. clr_type = "11"
  9233. }
  9234. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9235. "insutype=" + insutype +
  9236. "&clr_type=" + clr_type +
  9237. "&setl_optins=" + clr_org +
  9238. "&stmt_begndate=" + start_time +
  9239. "&stm_enddate=" + end_time +
  9240. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9241. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9242. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9243. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9244. "&fixmedins_code=" + miConfig.Code +
  9245. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9246. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9247. "&secret_key=" + miConfig.SecretKey +
  9248. "&org_name=" + miConfig.OrgName +
  9249. "&doctor=" + user_name
  9250. fmt.Println(api)
  9251. resp, requestErr := http.Get(api)
  9252. if requestErr != nil {
  9253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9254. return
  9255. }
  9256. body, ioErr := ioutil.ReadAll(resp.Body)
  9257. fmt.Println(body)
  9258. if ioErr != nil {
  9259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9261. return
  9262. }
  9263. var respJSON map[string]interface{}
  9264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9267. return
  9268. }
  9269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9270. userJSONBytes, _ := json.Marshal(respJSON)
  9271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9272. utils.ErrorLog("解析失败:%v", err)
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9274. return
  9275. }
  9276. }
  9277. if res.Infcode == 0 {
  9278. if res.Output.Stmtinfo.StmtRslt == "0" {
  9279. micc := &models.MedicalInsuranceCostCompare{
  9280. StartTime: startime.Unix(),
  9281. EndTime: endtime.Unix(),
  9282. Insutype: insutype,
  9283. CheckType: 1,
  9284. Num: fixmedins_setl_cnt,
  9285. Mtime: time.Now().Unix(),
  9286. Status: 1,
  9287. UserOrgId: adminUser.CurrentOrgId,
  9288. CostTotal: medfee_sumamt,
  9289. FuncTotal: fund_pay_sumamt,
  9290. PsnPay: acct_pay,
  9291. Creator: admin_user_id,
  9292. Ctime: time.Now().Unix(),
  9293. ClrType: clr_type,
  9294. }
  9295. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9296. if err == nil {
  9297. c.ServeSuccessJSON(map[string]interface{}{
  9298. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9299. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9300. })
  9301. } else {
  9302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9303. }
  9304. } else {
  9305. c.ServeSuccessJSON(map[string]interface{}{
  9306. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9307. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9308. })
  9309. }
  9310. } else {
  9311. c.ServeSuccessJSON(map[string]interface{}{
  9312. "code": -10,
  9313. "msg": res.ErrMsg,
  9314. })
  9315. }
  9316. }
  9317. }
  9318. func (c *HisApiController) Check310() {
  9319. adminUser := c.GetAdminUserInfo()
  9320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9321. var user_name string
  9322. user_name = "高慧裕"
  9323. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9324. "insutype=" + "310" +
  9325. "&clr_type=" + "" +
  9326. "&setl_optins=" + "441202" +
  9327. "&stmt_begndate=" + "2022-03-01" +
  9328. "&stm_enddate=" + "2022-03-31" +
  9329. "&medfee_sumamt=" + "194930.12" +
  9330. "&fund_pay_sumamt=" + "188741.46" +
  9331. "&acct_pay=" + "0" +
  9332. "&fixmedins_setl_cnt=" + "452" +
  9333. "&fixmedins_code=" + miConfig.Code +
  9334. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9335. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9336. "&secret_key=" + miConfig.SecretKey +
  9337. "&org_name=" + miConfig.OrgName +
  9338. "&doctor=" + user_name
  9339. fmt.Println(api)
  9340. resp, requestErr := http.Get(api)
  9341. if requestErr != nil {
  9342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9343. return
  9344. }
  9345. body, ioErr := ioutil.ReadAll(resp.Body)
  9346. fmt.Println(body)
  9347. if ioErr != nil {
  9348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. var respJSON map[string]interface{}
  9353. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9356. return
  9357. }
  9358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9359. userJSONBytes, _ := json.Marshal(respJSON)
  9360. var res ResultEight
  9361. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9362. utils.ErrorLog("解析失败:%v", err)
  9363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9364. return
  9365. }
  9366. }
  9367. func (c *HisApiController) Check390() {
  9368. adminUser := c.GetAdminUserInfo()
  9369. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9370. var user_name string
  9371. user_name = "高慧裕"
  9372. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9373. "insutype=" + "390" +
  9374. "&clr_type=" + "" +
  9375. "&setl_optins=" + "441202" +
  9376. "&stmt_begndate=" + "2022-03-01" +
  9377. "&stm_enddate=" + "2022-03-31" +
  9378. "&medfee_sumamt=" + "1068448.89" +
  9379. "&fund_pay_sumamt=" + "1014677.62" +
  9380. "&acct_pay=" + "0" +
  9381. "&fixmedins_setl_cnt=" + "1950" +
  9382. "&fixmedins_code=" + miConfig.Code +
  9383. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9384. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9385. "&secret_key=" + miConfig.SecretKey +
  9386. "&org_name=" + miConfig.OrgName +
  9387. "&doctor=" + user_name
  9388. fmt.Println(api)
  9389. resp, requestErr := http.Get(api)
  9390. if requestErr != nil {
  9391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9392. return
  9393. }
  9394. body, ioErr := ioutil.ReadAll(resp.Body)
  9395. fmt.Println(body)
  9396. if ioErr != nil {
  9397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9399. return
  9400. }
  9401. var respJSON map[string]interface{}
  9402. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9405. return
  9406. }
  9407. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9408. userJSONBytes, _ := json.Marshal(respJSON)
  9409. var res ResultEight
  9410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9411. utils.ErrorLog("解析失败:%v", err)
  9412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9413. return
  9414. }
  9415. }
  9416. //对账明细
  9417. func (c *HisApiController) GetCheckDetailAccount() {
  9418. start_time := c.GetString("start_time")
  9419. end_time := c.GetString("end_time")
  9420. admin_user_id, _ := c.GetInt64("admin_user_id")
  9421. adminUser := c.GetAdminUserInfo()
  9422. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9423. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9424. timeLayout := "2006-01-02"
  9425. loc, _ := time.LoadLocation("Local")
  9426. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9427. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9428. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9429. rand.Seed(time.Now().UnixNano())
  9430. num := rand.Intn(30000)
  9431. Mkdir(miConfig.OrgName)
  9432. file := strconv.FormatInt(int64(num), 10)
  9433. file_name := file + ".txt"
  9434. zip_name := file + ".zip"
  9435. zip_path := miConfig.OrgName + "/" + zip_name
  9436. file_path := miConfig.OrgName + "/" + file_name
  9437. decimal.DivisionPrecision = 2
  9438. var medfee_sumamt float64
  9439. var psn_cash_pay float64
  9440. var fund_pay_sumamt float64
  9441. fixmedins_setl_cnt := int64(len(orders))
  9442. for _, item := range orders {
  9443. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9444. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9445. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9446. }
  9447. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9448. defer f.Close()
  9449. if err != nil {
  9450. fmt.Println(err.Error())
  9451. } else {
  9452. for _, item := range orders {
  9453. var refd_setl_flag string
  9454. if item.OrderStatus == 2 {
  9455. refd_setl_flag = "0"
  9456. var str string
  9457. str = item.SetlId + " " +
  9458. item.MdtrtId + " " +
  9459. item.PsnNo + " " +
  9460. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9461. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9462. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9463. _, err = f.Write([]byte(str))
  9464. }
  9465. if item.OrderStatus == 3 {
  9466. var str string
  9467. str = item.SetlId + " " +
  9468. item.MdtrtId + " " +
  9469. item.PsnNo + " " +
  9470. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9471. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9472. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9473. _, err = f.Write([]byte(str))
  9474. var str2 string
  9475. str2 = item.SetlId + " " +
  9476. item.MdtrtId + " " +
  9477. item.PsnNo + " " +
  9478. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9479. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9480. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9481. _, err = f.Write([]byte(str2))
  9482. }
  9483. }
  9484. }
  9485. Zip(file_path, zip_path)
  9486. fmt.Println(ReadFile(zip_path))
  9487. fmt.Println(string(ReadFile(zip_path)))
  9488. if config.IsOpen == 1 {
  9489. var user_name string
  9490. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9491. if role.ID == 0 {
  9492. user_name = "管理员"
  9493. } else {
  9494. user_name = role.UserName
  9495. }
  9496. baseParams := models.BaseParams{
  9497. SecretKey: miConfig.SecretKey,
  9498. FixmedinsCode: miConfig.Code,
  9499. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9500. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9501. OrgName: miConfig.OrgName,
  9502. Doctor: user_name,
  9503. }
  9504. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9505. var dat map[string]interface{}
  9506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9507. fmt.Println(dat)
  9508. } else {
  9509. fmt.Println(err)
  9510. }
  9511. userJSONBytes, _ := json.Marshal(dat)
  9512. var res ResultNine
  9513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9514. utils.ErrorLog("解析失败:%v", err)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return
  9517. }
  9518. if res.Infcode == 0 {
  9519. fileNo := res.Output.FileQuryNo
  9520. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9521. "file_qury_no=" + fileNo +
  9522. "&setl_optins=" + "定点医保中心" +
  9523. "&stmt_begndate=" + start_time +
  9524. "&stm_enddate=" + end_time +
  9525. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9526. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9527. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9528. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  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. resp, requestErr := http.Get(api)
  9536. if requestErr != nil {
  9537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9538. return
  9539. }
  9540. body, ioErr := ioutil.ReadAll(resp.Body)
  9541. if ioErr != nil {
  9542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9544. return
  9545. }
  9546. var respJSON map[string]interface{}
  9547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9550. return
  9551. }
  9552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9553. userJSONBytes, _ := json.Marshal(respJSON)
  9554. var res ResultTen
  9555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9556. utils.ErrorLog("解析失败:%v", err)
  9557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9558. return
  9559. }
  9560. if res.Infcode == 0 {
  9561. service.Gdyb9102(baseParams, zip_name, fileNo)
  9562. micc := &models.MedicalInsuranceCostCompare{
  9563. StartTime: startime.Unix(),
  9564. EndTime: endtime.Unix(),
  9565. Insutype: "0",
  9566. CheckType: 2,
  9567. Num: fixmedins_setl_cnt,
  9568. Mtime: time.Now().Unix(),
  9569. Status: 1,
  9570. UserOrgId: adminUser.CurrentOrgId,
  9571. CostTotal: medfee_sumamt,
  9572. FuncTotal: fund_pay_sumamt,
  9573. PsnPay: psn_cash_pay,
  9574. Creator: admin_user_id,
  9575. Ctime: time.Now().Unix(),
  9576. }
  9577. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9578. c.ServeSuccessJSON(map[string]interface{}{
  9579. "msg": "明细对账成功",
  9580. })
  9581. }
  9582. } else {
  9583. }
  9584. }
  9585. }
  9586. type CustomOrderInfo struct {
  9587. Name string
  9588. Spec string
  9589. Unit string
  9590. Count float64
  9591. Price float64
  9592. Total float64
  9593. }
  9594. func (c *HisApiController) GetSettleAccounts() {
  9595. //id, _ := c.GetInt64("id")
  9596. //record_time := c.GetString("record_time")
  9597. order_id, _ := c.GetInt64("order_id")
  9598. admin_user_id, _ := c.GetInt64("admin_user_id")
  9599. //timeLayout := "2006-01-02"
  9600. //loc, _ := time.LoadLocation("Local")
  9601. //
  9602. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9603. //if err != nil {
  9604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9605. // return
  9606. //}
  9607. //recordDateTime := theTime.Unix()
  9608. adminUser := c.GetAdminUserInfo()
  9609. order, _ := service.GetHisOrderByID(order_id)
  9610. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9611. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9612. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9613. orderInfos = append(orderInfos, orderInfos_two...)
  9614. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9615. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9616. var diagnosis_ids []string
  9617. if his.ID > 0 {
  9618. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9619. } else {
  9620. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9621. }
  9622. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9623. var dia_config []*models.HisXtDiagnoseConfig
  9624. var name string
  9625. for _, item := range diagnosis_ids {
  9626. id, _ := strconv.ParseInt(item, 10, 64)
  9627. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9628. dia_config = append(dia_config, &diagnosisConfig)
  9629. if len(name) == 0 {
  9630. name = diagnosisConfig.ClassName
  9631. } else {
  9632. name = name + "," + diagnosisConfig.ClassName
  9633. }
  9634. }
  9635. var bedCostTotal float64 = 0 //床位总费
  9636. var bedCostSelfTotal float64 = 0 //床位自费
  9637. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9638. var operationCostTotal float64 = 0 //手术费
  9639. var operationCostSelfTotal float64 = 0 //手术费
  9640. var operationCostPartSelfTotal float64 = 0 //手术费
  9641. var otherCostTotal float64 = 0 //其他费用
  9642. var otherCostSelfTotal float64 = 0 //其他费用
  9643. var otherCostPartSelfTotal float64 = 0 //其他费用
  9644. var materialCostTotal float64 = 0 //材料费
  9645. var materialCostSelfTotal float64 = 0 //材料费
  9646. var materialCostPartSelfTotal float64 = 0 //材料费
  9647. var westernMedicineCostTotal float64 = 0 //西药费
  9648. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9649. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9650. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9651. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9652. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9653. var checkCostTotal float64 = 0 //检查费
  9654. var checkCostSelfTotal float64 = 0 //检查费
  9655. var checkCostPartSelfTotal float64 = 0 //检查费
  9656. var laboratoryCostTotal float64 = 0 //化验费
  9657. var laboratoryCostSelfTotal float64 = 0 //化验费
  9658. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9659. var treatCostTotal float64 = 0 //治疗费用
  9660. var treatCostSelfTotal float64 = 0 //治疗费用
  9661. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9662. decimal.DivisionPrecision = 2
  9663. for _, item := range orderInfos {
  9664. if item.MedChrgitmType == "01" { //床位费
  9665. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9666. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9667. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9668. }
  9669. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9670. if item.MedChrgitmType == "03" { //检查费
  9671. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9672. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9673. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9674. }
  9675. } else {
  9676. if item.MedChrgitmType == "03" { //检查费
  9677. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9678. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9679. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9680. }
  9681. }
  9682. if item.MedChrgitmType == "04" { //化验费
  9683. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9684. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9685. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9686. }
  9687. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9688. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9689. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9690. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9691. }
  9692. if item.MedChrgitmType == "06" { //手术费
  9693. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9694. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9695. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9696. }
  9697. if item.MedChrgitmType == "08" { //材料费
  9698. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9699. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9700. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9701. }
  9702. if item.MedChrgitmType == "09" { //西药费
  9703. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9704. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9705. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9706. }
  9707. if item.MedChrgitmType == "11" { //中成费
  9708. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9709. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9710. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9711. }
  9712. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9713. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9714. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9715. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9716. }
  9717. }
  9718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9719. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9720. var user_name string
  9721. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9722. if role.ID == 0 {
  9723. user_name = "管理员"
  9724. } else {
  9725. user_name = role.UserName
  9726. }
  9727. baseParams := models.BaseParams{
  9728. SecretKey: miConfig.SecretKey,
  9729. FixmedinsCode: miConfig.Code,
  9730. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9731. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9732. OrgName: miConfig.OrgName,
  9733. Doctor: user_name,
  9734. }
  9735. businessParams := models.BusinessParams{
  9736. PsnNo: order.PsnNo,
  9737. MdtrtId: order.MdtrtId,
  9738. SetlId: order.SetlId,
  9739. }
  9740. var res ResultEleven
  9741. var resEleven10265 ResultEleven10265
  9742. if config.IsOpen == 1 {
  9743. if miConfig.MdtrtareaAdmvs == "421300" {
  9744. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9745. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9747. resp, requestErr := http.Get(api)
  9748. if requestErr != nil {
  9749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9750. return
  9751. }
  9752. body, ioErr := ioutil.ReadAll(resp.Body)
  9753. if ioErr != nil {
  9754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9756. return
  9757. }
  9758. var respJSON map[string]interface{}
  9759. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9762. return
  9763. }
  9764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9765. result, _ := json.Marshal(respJSON)
  9766. fmt.Println("log")
  9767. fmt.Println(string(result))
  9768. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9769. utils.ErrorLog("解析失败:%v", err)
  9770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9771. return
  9772. }
  9773. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9774. var api string
  9775. if miConfig.MdtrtareaAdmvs == "320921" {
  9776. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9777. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9778. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9779. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9780. } else {
  9781. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9782. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9783. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9784. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9785. }
  9786. resp, requestErr := http.Get(api)
  9787. if requestErr != nil {
  9788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9789. return
  9790. }
  9791. body, ioErr := ioutil.ReadAll(resp.Body)
  9792. if ioErr != nil {
  9793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9795. return
  9796. }
  9797. var respJSON map[string]interface{}
  9798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9801. return
  9802. }
  9803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9804. result, _ := json.Marshal(respJSON)
  9805. fmt.Println("log")
  9806. fmt.Println(string(result))
  9807. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9808. utils.ErrorLog("解析失败:%v", err)
  9809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9810. return
  9811. }
  9812. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9813. res.Output = resEleven10265.Output
  9814. res.ErrMsg = resEleven10265.ErrMsg
  9815. res.Cainfo = resEleven10265.Cainfo
  9816. res.WarnMsg = resEleven10265.WarnMsg
  9817. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9818. res.Infcode = infocode
  9819. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9820. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9821. saveLog(result, requestLog, "5203", "结算单")
  9822. var dat map[string]interface{}
  9823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9824. fmt.Println(dat)
  9825. } else {
  9826. fmt.Println(err)
  9827. }
  9828. userJSONBytes, _ := json.Marshal(dat)
  9829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9830. utils.ErrorLog("解析失败:%v", err)
  9831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9832. return
  9833. }
  9834. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9835. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9836. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9837. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9838. resp, requestErr := http.Get(api)
  9839. if requestErr != nil {
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9841. return
  9842. }
  9843. body, ioErr := ioutil.ReadAll(resp.Body)
  9844. if ioErr != nil {
  9845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9847. return
  9848. }
  9849. var respJSON map[string]interface{}
  9850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9853. return
  9854. }
  9855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9856. result, _ := json.Marshal(respJSON)
  9857. fmt.Println("log")
  9858. fmt.Println(string(result))
  9859. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9860. utils.ErrorLog("解析失败:%v", err)
  9861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9862. return
  9863. }
  9864. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9865. res.Output = resEleven10265.Output
  9866. res.ErrMsg = resEleven10265.ErrMsg
  9867. res.Cainfo = resEleven10265.Cainfo
  9868. res.WarnMsg = resEleven10265.WarnMsg
  9869. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9870. res.Infcode = infocode
  9871. } else {
  9872. result := service.Gdyb5203(baseParams, businessParams)
  9873. //service.Gdyb5204(baseParams, businessParams)
  9874. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9875. var dat map[string]interface{}
  9876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9877. fmt.Println(dat)
  9878. } else {
  9879. fmt.Println(err)
  9880. }
  9881. userJSONBytes, _ := json.Marshal(dat)
  9882. if miConfig.Code == "H15049901371" {
  9883. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9884. utils.ErrorLog("解析失败:%v", err)
  9885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9886. return
  9887. }
  9888. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9889. res.Output = resEleven10265.Output
  9890. res.ErrMsg = resEleven10265.ErrMsg
  9891. res.Cainfo = resEleven10265.Cainfo
  9892. res.WarnMsg = resEleven10265.WarnMsg
  9893. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9894. res.Infcode = infocode
  9895. } else {
  9896. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9897. utils.ErrorLog("解析失败:%v", err)
  9898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9899. return
  9900. }
  9901. }
  9902. }
  9903. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9904. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9905. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9906. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9907. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9908. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9909. var doctor_name string
  9910. if roles.ID == 0 {
  9911. doctor_name = "管理员"
  9912. } else {
  9913. doctor_name = roles.UserName
  9914. }
  9915. yiliao_leibie := ""
  9916. switch order.MedType {
  9917. case "11":
  9918. yiliao_leibie = "普通门诊"
  9919. break
  9920. case "12":
  9921. yiliao_leibie = "门诊挂号"
  9922. break
  9923. case "13":
  9924. yiliao_leibie = "急诊"
  9925. break
  9926. case "14":
  9927. yiliao_leibie = "门诊特殊病"
  9928. break
  9929. case "15":
  9930. yiliao_leibie = "门诊统筹"
  9931. break
  9932. case "16":
  9933. yiliao_leibie = "门诊慢性病"
  9934. break
  9935. case "21":
  9936. yiliao_leibie = "普通住院"
  9937. break
  9938. }
  9939. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9940. if res.Infcode == 0 {
  9941. c.ServeSuccessJSON(map[string]interface{}{
  9942. "diagnosis": name,
  9943. "order_infos": orderInfos,
  9944. "number": order.MdtrtId,
  9945. "date": order.SettleAccountsDate,
  9946. "charge_admin": charge_admin,
  9947. "printor_admin": printor_admin,
  9948. "info": res.Output.Setlinfo,
  9949. "order": order,
  9950. "bedCostTotal": bedCostTotal,
  9951. "bedCostSelfTotal": bedCostSelfTotal,
  9952. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9953. "operationCostTotal": operationCostTotal,
  9954. "operationCostSelfTotal": operationCostSelfTotal,
  9955. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9956. "otherCostTotal": otherCostTotal,
  9957. "otherCostSelfTotal": otherCostSelfTotal,
  9958. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9959. "materialCostTotal": materialCostTotal,
  9960. "materialCostSelfTotal": materialCostSelfTotal,
  9961. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9962. "westernMedicineCostTotal": westernMedicineCostTotal,
  9963. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9964. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9965. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9966. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9967. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9968. "checkCostTotal": checkCostTotal,
  9969. "checkCostSelfTotal": checkCostSelfTotal,
  9970. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9971. "laboratoryCostTotal": laboratoryCostTotal,
  9972. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9973. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9974. "treatCostTotal": treatCostTotal,
  9975. "treatCostSelfTotal": treatCostSelfTotal,
  9976. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9977. "doctor_info": doctor_info,
  9978. "doctor_code": adminRole_two.DoctorCode,
  9979. "doctor_name": doctor_name,
  9980. "health_card_no": order.PsnNo,
  9981. "department": departments.Name,
  9982. "yiliao_leibie": yiliao_leibie,
  9983. "after_money": order.AccountPrice,
  9984. "patient": patient,
  9985. "org_name": miConfig.OrgName,
  9986. "org_code": miConfig.Code,
  9987. "order_number": order.Number,
  9988. "his_hospital": his_hospital,
  9989. "his": his,
  9990. "dia_config": dia_config,
  9991. //"check_order_info": cus_slice,
  9992. })
  9993. }
  9994. }
  9995. }
  9996. func (c *HisApiController) CheckTreatment() {
  9997. patient_id, _ := c.GetInt64("patient_id")
  9998. id_card_no := c.GetString("id_card_no")
  9999. insutype := c.GetString("insutype")
  10000. med_type := c.GetString("med_type")
  10001. admin_user_id, _ := c.GetInt64("admin_user_id")
  10002. adminUser := c.GetAdminUserInfo()
  10003. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10004. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10005. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10006. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10007. if miConfig.MdtrtareaAdmvs == "421300" {
  10008. var res ResultTwo
  10009. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  10010. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10011. "&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)
  10012. resp, requestErr := http.Get(api)
  10013. if requestErr != nil {
  10014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10015. return
  10016. }
  10017. body, ioErr := ioutil.ReadAll(resp.Body)
  10018. if ioErr != nil {
  10019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10021. return
  10022. }
  10023. var respJSON map[string]interface{}
  10024. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10027. return
  10028. }
  10029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10030. result, _ := json.Marshal(respJSON)
  10031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10032. utils.ErrorLog("解析失败:%v", err)
  10033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10034. return
  10035. }
  10036. if res.Infcode == 0 {
  10037. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  10038. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10039. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  10040. resp, requestErr := http.Get(api)
  10041. if requestErr != nil {
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10043. return
  10044. }
  10045. body, ioErr := ioutil.ReadAll(resp.Body)
  10046. if ioErr != nil {
  10047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10049. return
  10050. }
  10051. var respJSON map[string]interface{}
  10052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10055. return
  10056. }
  10057. var res Result2001
  10058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10059. result2, _ := json.Marshal(respJSON)
  10060. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10061. utils.ErrorLog("解析失败:%v", err)
  10062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10063. return
  10064. }
  10065. if res.Infcode == 0 {
  10066. c.ServeSuccessJSON(map[string]interface{}{
  10067. "msg": res.Output.Trtinfo,
  10068. })
  10069. }
  10070. } else {
  10071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10072. return
  10073. }
  10074. } else {
  10075. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10076. var dat map[string]interface{}
  10077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10078. fmt.Println(dat)
  10079. } else {
  10080. fmt.Println(err)
  10081. }
  10082. userJSONBytes, _ := json.Marshal(dat)
  10083. var res ResultTwo
  10084. var res10265 ResultTwo10265
  10085. if miConfig.Code == "H15049901371" {
  10086. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10087. utils.ErrorLog("解析失败:%v", err)
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10089. return
  10090. }
  10091. res.ErrMsg = res10265.ErrMsg
  10092. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10093. res.Infcode = infocode
  10094. res.Output = res10265.Output
  10095. res.InfRefmsgid = res10265.InfRefmsgid
  10096. } else {
  10097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10098. utils.ErrorLog("解析失败:%v", err)
  10099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10100. return
  10101. }
  10102. }
  10103. var user_name string
  10104. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10105. if role.ID == 0 {
  10106. user_name = "xxx"
  10107. } else {
  10108. user_name = role.UserName
  10109. }
  10110. baseParams := models.BaseParams{
  10111. SecretKey: miConfig.SecretKey,
  10112. FixmedinsCode: miConfig.Code,
  10113. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10114. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10115. OrgName: miConfig.OrgName,
  10116. Doctor: user_name,
  10117. }
  10118. if config.IsOpen == 1 {
  10119. if miConfig.Code == "H15049901371" {
  10120. if med_type == "14" {
  10121. if insutype == "390" {
  10122. med_type = "9933"
  10123. } else if insutype == "310" {
  10124. med_type = "990502"
  10125. }
  10126. } else if med_type == "11" {
  10127. med_type = "11"
  10128. }
  10129. }
  10130. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10131. var dat map[string]interface{}
  10132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10133. fmt.Println(dat)
  10134. } else {
  10135. fmt.Println(err)
  10136. }
  10137. var res Result2001
  10138. var res10265 Result2001Org10265
  10139. if miConfig.Code == "H15049901371" {
  10140. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10141. utils.ErrorLog("解析失败:%v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. res.ErrMsg = res10265.ErrMsg
  10146. res.Output = res10265.Output
  10147. res.InfRefmsgid = res10265.InfRefmsgid
  10148. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10149. res.Infcode = infocode
  10150. } else {
  10151. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10152. utils.ErrorLog("解析失败:%v", err)
  10153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10154. return
  10155. }
  10156. }
  10157. if res.Infcode == 0 {
  10158. c.ServeSuccessJSON(map[string]interface{}{
  10159. "msg": res.Output.Trtinfo,
  10160. })
  10161. }
  10162. }
  10163. }
  10164. }
  10165. //func (c *HisApiController) PutRecord() {
  10166. // id, _ := c.GetInt64("id")
  10167. // record_time := c.GetString("record_time")
  10168. // timeLayout := "2006-01-02"
  10169. // loc, _ := time.LoadLocation("Local")
  10170. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10171. // if err != nil {
  10172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10173. // return
  10174. // }
  10175. // recordDateTime := theTime.Unix()
  10176. //
  10177. // adminInfo := c.GetAdminUserInfo()
  10178. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10179. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10180. //
  10181. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10182. //
  10183. // fmt.Println(miConfig.SecretKey)
  10184. //
  10185. // if patient == nil {
  10186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10187. // return
  10188. // }
  10189. // if len(patient.IdCardNo) == 0 {
  10190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10191. // return
  10192. // }
  10193. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10194. // if config.IsOpen == 1 {
  10195. // 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
  10196. // resp, requestErr := http.Get(api)
  10197. // if requestErr != nil {
  10198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10199. // return
  10200. // }
  10201. // defer resp.Body.Close()
  10202. // body, ioErr := ioutil.ReadAll(resp.Body)
  10203. // if ioErr != nil {
  10204. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10206. // return
  10207. // }
  10208. // var respJSON map[string]interface{}
  10209. //
  10210. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10211. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10213. // return
  10214. // }
  10215. //
  10216. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10217. // userJSONBytes, _ := json.Marshal(userJSON)
  10218. // var res ResultTwo
  10219. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10220. // utils.ErrorLog("解析失败:%v", err)
  10221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10222. // return
  10223. // }
  10224. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10225. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10226. // infoStr := string(Iinfos)
  10227. // idetinfoStr := string(Idetinfos)
  10228. //
  10229. // if res.Infcode == 0 {
  10230. // his := models.VMHisPatient{
  10231. // Status: 1,
  10232. // Ctime: time.Now().Unix(),
  10233. // Mtime: time.Now().Unix(),
  10234. // PsnNo: res.Output.Baseinfo.PsnNo,
  10235. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10236. // Certno: res.Output.Baseinfo.Certno,
  10237. // PsnName: res.Output.Baseinfo.PsnName,
  10238. // Gend: res.Output.Baseinfo.Gend,
  10239. // Naty: res.Output.Baseinfo.Naty,
  10240. // Brdy: res.Output.Baseinfo.Brdy,
  10241. // Age: res.Output.Baseinfo.Age,
  10242. // Iinfo: infoStr,
  10243. // Idetinfo: idetinfoStr,
  10244. // PatientId: patient.ID,
  10245. // RecordDate: theTime.Unix(),
  10246. // UserOrgId: adminInfo.CurrentOrgId,
  10247. // AdminUserId: adminInfo.AdminUser.Id,
  10248. // IsReturn: 1,
  10249. // }
  10250. //
  10251. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10252. // //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")
  10253. // //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")
  10254. //
  10255. // //var dat map[string]interface{}
  10256. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10257. // // fmt.Println(dat)
  10258. // //} else {
  10259. // // fmt.Println(err)
  10260. // //}
  10261. //
  10262. // var dat2 map[string]interface{}
  10263. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10264. // fmt.Println(dat2)
  10265. // } else {
  10266. // fmt.Println(err)
  10267. // }
  10268. //
  10269. // } else {
  10270. // adminUser := c.GetAdminUserInfo()
  10271. // errlog := &models.HisOrderError{
  10272. // UserOrgId: adminUser.CurrentOrgId,
  10273. // Ctime: time.Now().Unix(),
  10274. // Mtime: time.Now().Unix(),
  10275. // ErrMsg: res.ErrMsg,
  10276. // Status: 1,
  10277. // PatientId: id,
  10278. // RecordTime: recordDateTime,
  10279. // Stage: 1,
  10280. // }
  10281. // service.CreateErrMsgLog(errlog)
  10282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10283. // return
  10284. // }
  10285. // }
  10286. //
  10287. //}
  10288. //func (c *HisApiController) GetUploadDiag() {
  10289. // id, _ := c.GetInt64("id")
  10290. // record_time := c.GetString("record_time")
  10291. //
  10292. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10293. // sick_type, _ := c.GetInt64("sick_type")
  10294. // reg_type, _ := c.GetInt64("reg_type")
  10295. //
  10296. // timeLayout := "2006-01-02"
  10297. // loc, _ := time.LoadLocation("Local")
  10298. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10299. // if err != nil {
  10300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10301. // return
  10302. // }
  10303. //
  10304. // var patientPrescription models.HisPrescriptionInfo
  10305. // recordDateTime := theTime.Unix()
  10306. // adminInfo := c.GetAdminUserInfo()
  10307. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10308. //
  10309. // if patientPrescription.ID == 0 {
  10310. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10311. // }
  10312. //
  10313. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10314. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10315. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10316. // sickConfig, _ := service.FindSickById(sick_type)
  10317. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10318. //
  10319. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10320. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10321. // "&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 +
  10322. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10323. // resp2, requestErr2 := http.Get(api2)
  10324. // if requestErr2 != nil {
  10325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10326. // return
  10327. // }
  10328. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10329. // if ioErr2 != nil {
  10330. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10332. // return
  10333. // }
  10334. // var respJSON2 map[string]interface{}
  10335. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10336. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10338. // return
  10339. // }
  10340. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10341. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10342. //
  10343. // var res2 ResultSix
  10344. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10345. // utils.ErrorLog("解析失败:%v", err)
  10346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10347. // return
  10348. // }
  10349. // if res2.Infcode != 0 {
  10350. // adminUser := c.GetAdminUserInfo()
  10351. // errlog := &models.HisOrderError{
  10352. // UserOrgId: adminUser.CurrentOrgId,
  10353. // Ctime: time.Now().Unix(),
  10354. // Mtime: time.Now().Unix(),
  10355. // ErrMsg: res2.ErrMsg,
  10356. // Status: 1,
  10357. // PatientId: id,
  10358. // RecordTime: recordDateTime,
  10359. // Stage: 3,
  10360. // }
  10361. // service.CreateErrMsgLog(errlog)
  10362. //
  10363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10364. // return
  10365. // }
  10366. //
  10367. // c.ServeSuccessJSON(map[string]interface{}{
  10368. // "msg": "上传成功",
  10369. // })
  10370. //
  10371. //}
  10372. type QueryResult struct {
  10373. ID int64
  10374. Name string
  10375. Code string
  10376. List_type_code string
  10377. }
  10378. func (c *HisApiController) GetCheckCode() {
  10379. ids_str := c.GetString("ids")
  10380. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10381. ids_arr := strings.Split(ids_str, ",")
  10382. var queryResult []QueryResult
  10383. ids := make([]int64, 0)
  10384. for _, item := range ids_arr {
  10385. id, _ := strconv.ParseInt(item, 10, 64)
  10386. ids = append(ids, id)
  10387. }
  10388. if record_type == 1 {
  10389. drugs, _ := service.GetBatchDrugList(ids)
  10390. for _, item := range drugs {
  10391. result := QueryResult{
  10392. ID: item.ID,
  10393. Name: item.DrugName,
  10394. Code: item.MedicalInsuranceNumber,
  10395. List_type_code: "101",
  10396. }
  10397. queryResult = append(queryResult, result)
  10398. }
  10399. } else if record_type == 2 {
  10400. goods, _ := service.GetBatchGoodInformationList(ids)
  10401. for _, item := range goods {
  10402. result := QueryResult{
  10403. ID: item.ID,
  10404. Name: item.GoodName,
  10405. Code: item.MedicalInsuranceNumber,
  10406. List_type_code: "301",
  10407. }
  10408. queryResult = append(queryResult, result)
  10409. }
  10410. } else if record_type == 3 {
  10411. projects, _ := service.GetBathchMyPorjecgList(ids)
  10412. for _, item := range projects {
  10413. result := QueryResult{
  10414. ID: item.ID,
  10415. Name: item.ProjectName,
  10416. Code: item.MedicalCode,
  10417. List_type_code: "201",
  10418. }
  10419. queryResult = append(queryResult, result)
  10420. }
  10421. }
  10422. admin_user_id, _ := c.GetInt64("admin_user_id")
  10423. adminUser := c.GetAdminUserInfo()
  10424. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10425. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10426. var user_name string
  10427. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10428. if role.ID == 0 {
  10429. user_name = "xxx"
  10430. } else {
  10431. user_name = role.UserName
  10432. }
  10433. baseParams := &models.BaseParams{
  10434. SecretKey: miConfig.SecretKey,
  10435. FixmedinsCode: miConfig.Code,
  10436. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10437. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10438. OrgName: miConfig.OrgName,
  10439. Doctor: user_name,
  10440. }
  10441. if config.IsOpen == 1 {
  10442. for _, item := range queryResult {
  10443. var result string
  10444. if record_type == 1 {
  10445. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10446. } else if record_type == 2 {
  10447. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10448. } else if record_type == 3 {
  10449. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10450. }
  10451. var dat map[string]interface{}
  10452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10453. fmt.Println(dat)
  10454. } else {
  10455. fmt.Println(err)
  10456. }
  10457. userJSONBytes, _ := json.Marshal(dat)
  10458. var res ResultSix
  10459. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10460. utils.ErrorLog("解析失败:%v", err)
  10461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10462. return
  10463. }
  10464. if res.Infcode == 0 {
  10465. if record_type == 1 {
  10466. service.UpdateBaseDrugById(item.ID)
  10467. } else if record_type == 2 {
  10468. service.UpdateGoodInformaitonByDetail(item.ID)
  10469. } else if record_type == 3 {
  10470. service.UpdateProjectById(item.ID)
  10471. }
  10472. c.ServeSuccessJSON(map[string]interface{}{
  10473. "failed_code": 0,
  10474. "msg": "目录对照成功",
  10475. })
  10476. } else {
  10477. c.ServeSuccessJSON(map[string]interface{}{
  10478. "failed_code": -10,
  10479. "msg": res.ErrMsg,
  10480. })
  10481. }
  10482. }
  10483. }
  10484. }
  10485. func (c *HisApiController) UnCheckCode() {
  10486. ids_str := c.GetString("ids")
  10487. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10488. admin_user_id, _ := c.GetInt64("admin_user_id")
  10489. ids_arr := strings.Split(ids_str, ",")
  10490. var queryResult []QueryResult
  10491. ids := make([]int64, 0)
  10492. for _, item := range ids_arr {
  10493. id, _ := strconv.ParseInt(item, 10, 64)
  10494. ids = append(ids, id)
  10495. }
  10496. if record_type == 1 {
  10497. drugs, _ := service.GetBatchDrugList(ids)
  10498. for _, item := range drugs {
  10499. result := QueryResult{
  10500. ID: item.ID,
  10501. Name: item.DrugName,
  10502. Code: item.MedicalInsuranceNumber,
  10503. List_type_code: "101",
  10504. }
  10505. queryResult = append(queryResult, result)
  10506. }
  10507. } else if record_type == 2 {
  10508. goods, _ := service.GetBatchGoodInformationList(ids)
  10509. for _, item := range goods {
  10510. result := QueryResult{
  10511. ID: item.ID,
  10512. Name: item.GoodName,
  10513. Code: item.MedicalInsuranceNumber,
  10514. List_type_code: "301",
  10515. }
  10516. queryResult = append(queryResult, result)
  10517. }
  10518. } else if record_type == 3 {
  10519. projects, _ := service.GetBathchMyPorjecgList(ids)
  10520. for _, item := range projects {
  10521. result := QueryResult{
  10522. ID: item.ID,
  10523. Name: item.ProjectName,
  10524. Code: item.MedicalCode,
  10525. List_type_code: "201",
  10526. }
  10527. queryResult = append(queryResult, result)
  10528. }
  10529. }
  10530. adminUser := c.GetAdminUserInfo()
  10531. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10532. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10533. var user_name string
  10534. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10535. if role.ID == 0 {
  10536. user_name = "xxx"
  10537. } else {
  10538. user_name = role.UserName
  10539. }
  10540. baseParams := &models.BaseParams{
  10541. SecretKey: miConfig.SecretKey,
  10542. FixmedinsCode: miConfig.Code,
  10543. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10544. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10545. OrgName: miConfig.OrgName,
  10546. Doctor: user_name,
  10547. }
  10548. if config.IsOpen == 1 {
  10549. for _, item := range queryResult {
  10550. var result string
  10551. if record_type == 1 {
  10552. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10553. } else if record_type == 2 {
  10554. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10555. } else if record_type == 3 {
  10556. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10557. }
  10558. var dat2 map[string]interface{}
  10559. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10560. fmt.Println(dat2)
  10561. } else {
  10562. fmt.Println(err)
  10563. }
  10564. userJSONBytes, _ := json.Marshal(dat2)
  10565. var res ResultSix
  10566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10567. utils.ErrorLog("解析失败:%v", err)
  10568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10569. return
  10570. }
  10571. if res.Infcode == 0 {
  10572. if record_type == 1 {
  10573. service.UpdateDrugByIdDetail(item.ID)
  10574. } else if record_type == 2 {
  10575. service.UpdateGoodInfoById(item.ID)
  10576. } else if record_type == 3 {
  10577. service.UpdateMyProjectById(item.ID)
  10578. }
  10579. c.ServeSuccessJSON(map[string]interface{}{
  10580. "failed_code": 0,
  10581. "msg": "撤销目录对照成功",
  10582. })
  10583. } else {
  10584. c.ServeSuccessJSON(map[string]interface{}{
  10585. "failed_code": -10,
  10586. "msg": res.ErrMsg,
  10587. })
  10588. }
  10589. }
  10590. }
  10591. }
  10592. func (c *HisApiController) GetPatientInfo() {
  10593. id_card_no := c.GetString("id_card_no")
  10594. admin_user_id, _ := c.GetInt64("admin_user_id")
  10595. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10596. if patient.ID == 0 {
  10597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10598. return
  10599. }
  10600. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10601. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10602. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10603. if config.IsOpen == 1 {
  10604. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10605. var dat map[string]interface{}
  10606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10607. fmt.Println(dat)
  10608. } else {
  10609. fmt.Println(err)
  10610. }
  10611. userJSONBytes, _ := json.Marshal(dat)
  10612. var res ResultTwo
  10613. var res10265 ResultTwo10265
  10614. if miConfig.Code == "H15049901371" {
  10615. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10616. utils.ErrorLog("解析失败:%v", err)
  10617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10618. return
  10619. }
  10620. res.ErrMsg = res10265.ErrMsg
  10621. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10622. res.Infcode = infocode
  10623. res.Output = res10265.Output
  10624. res.InfRefmsgid = res10265.InfRefmsgid
  10625. } else {
  10626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10627. utils.ErrorLog("解析失败:%v", err)
  10628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10629. return
  10630. }
  10631. }
  10632. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10633. // utils.ErrorLog("解析失败:%v", err)
  10634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10635. // return
  10636. //}
  10637. if res.Infcode != 0 {
  10638. c.ServeSuccessJSON(map[string]interface{}{
  10639. "failed_code": -10,
  10640. "msg": res.ErrMsg,
  10641. })
  10642. } else {
  10643. c.ServeSuccessJSON(map[string]interface{}{
  10644. "failed_code": 0,
  10645. "info": res,
  10646. })
  10647. }
  10648. }
  10649. }
  10650. func (c *HisApiController) PsnPutOnRecord() {
  10651. record_type, _ := c.GetInt64("type")
  10652. patient_id, _ := c.GetInt64("patient_id")
  10653. admin_user_id, _ := c.GetInt64("admin_user_id")
  10654. start_time := c.GetString("start_time")
  10655. end_time := c.GetString("end_time")
  10656. adminUser := c.GetAdminUserInfo()
  10657. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10658. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10659. var patients []*models.Patients
  10660. if record_type == 1 { //全部备案
  10661. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10662. patients = append(patients, patient...)
  10663. } else { //单个备案
  10664. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10665. patients = append(patients, patient)
  10666. }
  10667. var user_name string
  10668. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10669. if role.ID == 0 {
  10670. user_name = "xxx"
  10671. } else {
  10672. user_name = role.UserName
  10673. }
  10674. if config.IsOpen == 1 {
  10675. for _, item := range patients {
  10676. 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
  10677. resp, requestErr := http.Get(api)
  10678. if requestErr != nil {
  10679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10680. return
  10681. }
  10682. defer resp.Body.Close()
  10683. body, ioErr := ioutil.ReadAll(resp.Body)
  10684. if ioErr != nil {
  10685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10687. return
  10688. }
  10689. var respJSON map[string]interface{}
  10690. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10693. return
  10694. }
  10695. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10696. userJSONBytes, _ := json.Marshal(userJSON)
  10697. var res ResultTwo
  10698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10699. utils.ErrorLog("解析失败:%v", err)
  10700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10701. return
  10702. }
  10703. if res.Infcode == 0 {
  10704. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10705. var dat map[string]interface{}
  10706. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10707. fmt.Println(dat)
  10708. } else {
  10709. fmt.Println(err)
  10710. }
  10711. userJSONBytes, _ := json.Marshal(dat)
  10712. var res2 ResultThirteen
  10713. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10714. utils.ErrorLog("解析失败:%v", err)
  10715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10716. return
  10717. }
  10718. if res2.Infcode == 0 {
  10719. psnResult := &models.GdybPsnRecord{
  10720. UserOrgId: adminUser.CurrentOrgId,
  10721. PatientId: item.ID,
  10722. PsnNo: res.Output.Baseinfo.PsnNo,
  10723. Ctime: time.Now().Unix(),
  10724. Mtime: time.Now().Unix(),
  10725. Status: 1,
  10726. IsCancel: 1,
  10727. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10728. }
  10729. service.CreatePsnRecord(psnResult)
  10730. } else {
  10731. c.ServeSuccessJSON(map[string]interface{}{
  10732. "failed_code": -10,
  10733. "msg": res2.ErrMsg,
  10734. })
  10735. return
  10736. }
  10737. }
  10738. }
  10739. }
  10740. }
  10741. func (c *HisApiController) PsnUnPutOnRecord() {
  10742. id, _ := c.GetInt64("id")
  10743. //record_type, _ := c.GetInt64("type")
  10744. admin_user_id, _ := c.GetInt64("admin_user_id")
  10745. adminUser := c.GetAdminUserInfo()
  10746. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10747. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10748. var user_name string
  10749. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10750. if role.ID == 0 {
  10751. user_name = "xxx"
  10752. } else {
  10753. user_name = role.UserName
  10754. }
  10755. psn_record, _ := service.GetPsnRecordById(id)
  10756. if psn_record.ID == 0 {
  10757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10758. return
  10759. }
  10760. if config.IsOpen == 1 {
  10761. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10762. var dat map[string]interface{}
  10763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10764. fmt.Println(dat)
  10765. } else {
  10766. fmt.Println(err)
  10767. }
  10768. userJSONBytes, _ := json.Marshal(dat)
  10769. var res ResultFourteen
  10770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10771. utils.ErrorLog("解析失败:%v", err)
  10772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10773. return
  10774. }
  10775. if res.Infcode == 0 {
  10776. psn_record.IsCancel = 2
  10777. service.CreatePsnRecord(&psn_record)
  10778. } else {
  10779. c.ServeSuccessJSON(map[string]interface{}{
  10780. "failed_code": -10,
  10781. "msg": res.ErrMsg,
  10782. })
  10783. return
  10784. }
  10785. }
  10786. }
  10787. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10788. patient_id, _ := c.GetInt64("patient_id")
  10789. insutype_two := c.GetString("insutype")
  10790. psn_no := c.GetString("psn_no")
  10791. doctor_id, _ := c.GetInt64("doctor_id")
  10792. sick_id, _ := c.GetInt64("sick_id")
  10793. department_id, _ := c.GetInt64("department_id")
  10794. start_time := c.GetString("start_time")
  10795. end_time := c.GetString("end_time")
  10796. check_time := c.GetString("check_time")
  10797. adminUser := c.GetAdminUserInfo()
  10798. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10799. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10800. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10801. sick, _ := service.FindSickById(sick_id)
  10802. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10803. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10804. var res ResultTwo
  10805. var res10265 ResultTwo10265
  10806. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10807. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10808. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10809. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10810. "&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
  10811. resp, requestErr := http.Get(api)
  10812. if requestErr != nil {
  10813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10814. return
  10815. }
  10816. body, ioErr := ioutil.ReadAll(resp.Body)
  10817. if ioErr != nil {
  10818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10820. return
  10821. }
  10822. var respJSON map[string]interface{}
  10823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10826. return
  10827. }
  10828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10829. result, _ := json.Marshal(respJSON)
  10830. fmt.Println("log")
  10831. fmt.Println(string(result))
  10832. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10833. utils.ErrorLog("解析失败:%v", err)
  10834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10835. return
  10836. }
  10837. res.ErrMsg = res10265.ErrMsg
  10838. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10839. res.Infcode = infocode
  10840. res.Output = res10265.Output
  10841. res.InfRefmsgid = res10265.InfRefmsgid
  10842. } else {
  10843. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10844. if miConfig.Code == "H15049901371" {
  10845. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10846. utils.ErrorLog("解析失败:%v", err)
  10847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10848. return
  10849. }
  10850. res.ErrMsg = res10265.ErrMsg
  10851. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10852. res.Infcode = infocode
  10853. res.Output = res10265.Output
  10854. res.InfRefmsgid = res10265.InfRefmsgid
  10855. } else {
  10856. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10857. utils.ErrorLog("解析失败:%v", err)
  10858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10859. return
  10860. }
  10861. }
  10862. }
  10863. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10864. infoStr := string(Iinfos)
  10865. var rf []*ResultFive
  10866. json.Unmarshal([]byte(infoStr), &rf)
  10867. var insuplc_admdvs string
  10868. var insutype string
  10869. var is390 int = 0
  10870. var is310 int = 0
  10871. var insutypes []*ResultFive
  10872. for _, item := range rf {
  10873. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10874. insutypes = append(insutypes, item)
  10875. }
  10876. }
  10877. if len(insutypes) == 1 {
  10878. insutype = insutypes[0].Insutype
  10879. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10880. } else {
  10881. for _, i := range insutypes {
  10882. if i.Insutype == "390" {
  10883. is390 = 1
  10884. }
  10885. if i.Insutype == "310" {
  10886. is310 = 1
  10887. }
  10888. }
  10889. }
  10890. if is390 == 1 {
  10891. insutype = "390"
  10892. }
  10893. if is310 == 1 {
  10894. insutype = "310"
  10895. }
  10896. if len(insutypes) == 2 {
  10897. insutype = insutype_two
  10898. }
  10899. if len(insutypes) == 0 {
  10900. insutype = "310"
  10901. }
  10902. insutype = insutype_two
  10903. fmt.Println(insutype)
  10904. for _, item := range rf {
  10905. fmt.Println(item.Insutype)
  10906. fmt.Println(insutype)
  10907. if item.Insutype == insutype {
  10908. fmt.Println(item.Insutype)
  10909. fmt.Println(insutype)
  10910. insuplc_admdvs = item.InsuplcAdmdvs
  10911. }
  10912. }
  10913. fmt.Println(insuplc_admdvs)
  10914. var res2 ResultThirteen
  10915. var res10265_2 ResultThirteen10265
  10916. if config.IsOpen == 1 {
  10917. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10918. } else {
  10919. 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)
  10920. var dat map[string]interface{}
  10921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10922. fmt.Println(dat)
  10923. } else {
  10924. fmt.Println(err)
  10925. }
  10926. userJSONBytes, _ := json.Marshal(dat)
  10927. if miConfig.Code == "H15049901371" {
  10928. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10929. utils.ErrorLog("解析失败:%v", err)
  10930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10931. return
  10932. }
  10933. res2.ErrMsg = res10265_2.ErrMsg
  10934. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10935. res2.Infcode = infocode
  10936. res2.Output = res10265_2.Output
  10937. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10938. } else {
  10939. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10940. utils.ErrorLog("解析失败:%v", err)
  10941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10942. return
  10943. }
  10944. }
  10945. }
  10946. if res2.Infcode == 0 {
  10947. psnResult := &models.GdybPsnNcdsRecord{
  10948. UserOrgId: adminUser.CurrentOrgId,
  10949. PatientId: patient.ID,
  10950. PsnNo: psn_no,
  10951. DoctorId: doctor.AdminUserId,
  10952. DepartmentId: department_id,
  10953. SickType: sick_id,
  10954. Insutype: insutype,
  10955. Ctime: time.Now().Unix(),
  10956. Mtime: time.Now().Unix(),
  10957. Status: 1,
  10958. IsCancel: 1,
  10959. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10960. }
  10961. service.CreatePsnNCDSRecord(psnResult)
  10962. c.ServeSuccessJSON(map[string]interface{}{
  10963. "failed_code": 0,
  10964. "msg": "备案成功",
  10965. "result": psnResult,
  10966. })
  10967. } else {
  10968. c.ServeSuccessJSON(map[string]interface{}{
  10969. "failed_code": -10,
  10970. "msg": res2.ErrMsg,
  10971. })
  10972. return
  10973. }
  10974. }
  10975. }
  10976. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10977. id, _ := c.GetInt64("id")
  10978. admin_user_id, _ := c.GetInt64("admin_user_id")
  10979. adminUser := c.GetAdminUserInfo()
  10980. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10981. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10982. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10983. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10984. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10985. //var user_name string
  10986. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10987. //if role.ID == 0 {
  10988. // user_name = "xxx"
  10989. //} else {
  10990. // user_name = role.UserName
  10991. //}
  10992. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10993. if psn_record.ID == 0 {
  10994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10995. return
  10996. }
  10997. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10998. var res ResultTwo
  10999. var res10265 ResultTwo10265
  11000. if miConfig.Code == "H15049901371" {
  11001. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11002. utils.ErrorLog("解析失败:%v", err)
  11003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11004. return
  11005. }
  11006. res.ErrMsg = res10265.ErrMsg
  11007. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11008. res.Infcode = infocode
  11009. res.Output = res10265.Output
  11010. res.InfRefmsgid = res10265.InfRefmsgid
  11011. } else {
  11012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11013. utils.ErrorLog("解析失败:%v", err)
  11014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11015. return
  11016. }
  11017. }
  11018. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11019. infoStr := string(Iinfos)
  11020. var rf []*ResultFive
  11021. json.Unmarshal([]byte(infoStr), &rf)
  11022. var insuplc_admdvs string
  11023. var insutype string
  11024. var is390 int = 0
  11025. var is310 int = 0
  11026. var insutypes []*ResultFive
  11027. for _, item := range rf {
  11028. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11029. insutypes = append(insutypes, item)
  11030. }
  11031. }
  11032. if len(insutypes) == 1 {
  11033. insutype = insutypes[0].Insutype
  11034. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11035. } else {
  11036. for _, i := range insutypes {
  11037. if i.Insutype == "390" {
  11038. is390 = 1
  11039. }
  11040. if i.Insutype == "310" {
  11041. is310 = 1
  11042. }
  11043. }
  11044. }
  11045. if is390 == 1 {
  11046. insutype = "390"
  11047. }
  11048. if is310 == 1 {
  11049. insutype = "310"
  11050. }
  11051. if len(insutypes) == 0 {
  11052. insutype = "310"
  11053. }
  11054. insutype = psn_record.Insutype
  11055. for _, item := range rf {
  11056. if item.Insutype == insutype {
  11057. insuplc_admdvs = item.InsuplcAdmdvs
  11058. }
  11059. }
  11060. if config.IsOpen == 1 {
  11061. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11062. var dat map[string]interface{}
  11063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11064. fmt.Println(dat)
  11065. } else {
  11066. fmt.Println(err)
  11067. }
  11068. userJSONBytes, _ := json.Marshal(dat)
  11069. var res ResultFourteen
  11070. var res10265 ResultFourteen10265
  11071. if miConfig.Code == "H15049901371" {
  11072. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11073. utils.ErrorLog("解析失败:%v", err)
  11074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11075. return
  11076. }
  11077. res.ErrMsg = res10265.ErrMsg
  11078. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11079. res.Infcode = infocode
  11080. res.Output = res10265.Output
  11081. res.InfRefmsgid = res10265.InfRefmsgid
  11082. } else {
  11083. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11084. utils.ErrorLog("解析失败:%v", err)
  11085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11086. return
  11087. }
  11088. }
  11089. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11090. // utils.ErrorLog("解析失败:%v", err)
  11091. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11092. // return
  11093. //}
  11094. if res.Infcode == 0 {
  11095. psn_record.IsCancel = 2
  11096. service.CreatePsnNCDSRecord(&psn_record)
  11097. c.ServeSuccessJSON(map[string]interface{}{
  11098. "failed_code": 0,
  11099. "msg": "撤销备案成功",
  11100. })
  11101. } else {
  11102. c.ServeSuccessJSON(map[string]interface{}{
  11103. "failed_code": -10,
  11104. "msg": res.ErrMsg,
  11105. })
  11106. return
  11107. }
  11108. }
  11109. }
  11110. func (c *HisApiController) TestTest() {
  11111. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11112. fmt.Println(patient.Iinfo)
  11113. }
  11114. type CustomData struct {
  11115. MsgId string
  11116. PsnNo string
  11117. Info string
  11118. }
  11119. func (c *HisApiController) ReversalData() {
  11120. var customData []*CustomData
  11121. custom := &CustomData{
  11122. MsgId: "H44022900158202103301714472004",
  11123. PsnNo: "44020000001101329945",
  11124. Info: "2207",
  11125. }
  11126. customData = append(customData, custom)
  11127. custom1 := &CustomData{
  11128. MsgId: "H4402290015820210330172057803",
  11129. PsnNo: "44020000001101161813",
  11130. Info: "2207",
  11131. }
  11132. customData = append(customData, custom1)
  11133. custom2 := &CustomData{
  11134. MsgId: "H44022900158202103301705198813",
  11135. PsnNo: "44190000133097375417",
  11136. Info: "2207",
  11137. }
  11138. customData = append(customData, custom2)
  11139. custom3 := &CustomData{
  11140. MsgId: "H44022900158202103301715524756",
  11141. PsnNo: "44020000001100187221",
  11142. Info: "2207",
  11143. }
  11144. customData = append(customData, custom3)
  11145. custom4 := &CustomData{
  11146. MsgId: "H44022900158202103301730376224",
  11147. PsnNo: "44020000001101959155",
  11148. Info: "2207",
  11149. }
  11150. customData = append(customData, custom4)
  11151. custom5 := &CustomData{
  11152. MsgId: "H44022900158202103301748008725",
  11153. PsnNo: "44020000001104246641",
  11154. Info: "2207",
  11155. }
  11156. customData = append(customData, custom5)
  11157. custom6 := &CustomData{
  11158. MsgId: "H44022900158202103301718096755",
  11159. PsnNo: "44020000001102211860",
  11160. Info: "2207",
  11161. }
  11162. customData = append(customData, custom6)
  11163. custom7 := &CustomData{
  11164. MsgId: "H44022900158202103301736551640",
  11165. PsnNo: "44020000001102687718",
  11166. Info: "2207",
  11167. }
  11168. customData = append(customData, custom7)
  11169. custom8 := &CustomData{
  11170. MsgId: "H44022900158202103301743097676",
  11171. PsnNo: "44020000001102127785",
  11172. Info: "2207",
  11173. }
  11174. customData = append(customData, custom8)
  11175. custom9 := &CustomData{
  11176. MsgId: "H44022900158202103301712304203",
  11177. PsnNo: "44020000001101518097",
  11178. Info: "2207",
  11179. }
  11180. customData = append(customData, custom9)
  11181. custom10 := &CustomData{
  11182. MsgId: "H44022900158202103301738448785",
  11183. PsnNo: "44020000001100500813",
  11184. Info: "2207",
  11185. }
  11186. customData = append(customData, custom10)
  11187. custom11 := &CustomData{
  11188. MsgId: "H44022900158202103301732455843",
  11189. PsnNo: "44020000001102690557",
  11190. Info: "2207",
  11191. }
  11192. customData = append(customData, custom11)
  11193. custom12 := &CustomData{
  11194. MsgId: "H44022900158202103301745421708",
  11195. PsnNo: "44020000001102211928",
  11196. Info: "2207",
  11197. }
  11198. customData = append(customData, custom12)
  11199. custom1212 := &CustomData{
  11200. MsgId: "H440229001582021033017351627",
  11201. PsnNo: "44020000001102481733",
  11202. Info: "2207",
  11203. }
  11204. customData = append(customData, custom1212)
  11205. custom13 := &CustomData{
  11206. MsgId: "H44022900158202103301740327951",
  11207. PsnNo: "44020000001103174866",
  11208. Info: "2207",
  11209. }
  11210. customData = append(customData, custom13)
  11211. custom14 := &CustomData{
  11212. MsgId: "H4402290015820210330174922668",
  11213. PsnNo: "44020000001102927272",
  11214. Info: "2207",
  11215. }
  11216. customData = append(customData, custom14)
  11217. custom15 := &CustomData{
  11218. MsgId: "H44022900158202103301752362273",
  11219. PsnNo: "44020000001102942890",
  11220. Info: "2207",
  11221. }
  11222. customData = append(customData, custom15)
  11223. custom16 := &CustomData{
  11224. MsgId: "H44022900158202103301751082917",
  11225. PsnNo: "44020000001101662162",
  11226. Info: "2207",
  11227. }
  11228. customData = append(customData, custom16)
  11229. custom17 := &CustomData{
  11230. MsgId: "H44022900158202103301754147728",
  11231. PsnNo: "44020000000229014511",
  11232. Info: "2207",
  11233. }
  11234. customData = append(customData, custom17)
  11235. adminUser := c.GetAdminUserInfo()
  11236. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11237. for _, item := range customData {
  11238. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11239. fmt.Println(result)
  11240. }
  11241. }
  11242. //func (c *HisApiController) GetAllopatry() {
  11243. // year := c.GetString("year")
  11244. // month := c.GetString("month")
  11245. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11246. // adminUser := c.GetAdminUserInfo()
  11247. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11248. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11249. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11250. //
  11251. // var dat map[string]interface{}
  11252. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11253. // fmt.Println(dat)
  11254. // } else {
  11255. // fmt.Println(err)
  11256. // }
  11257. // userJSONBytes, _ := json.Marshal(dat)
  11258. // var res models.Result9001
  11259. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11260. // utils.ErrorLog("解析失败:%v", err)
  11261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11262. // return
  11263. // }
  11264. //
  11265. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11266. // var dat2 map[string]interface{}
  11267. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11268. // fmt.Println(dat)
  11269. // } else {
  11270. // fmt.Println(err)
  11271. // }
  11272. // userJSONBytes2, _ := json.Marshal(dat2)
  11273. // var res2 models.Result3260
  11274. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11275. // utils.ErrorLog("解析失败:%v", err)
  11276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11277. // return
  11278. // }
  11279. // if res2.Infcode == 0 {
  11280. // c.ServeSuccessJSON(map[string]interface{}{
  11281. // "list": res2.Output.Data,
  11282. // })
  11283. // return
  11284. // } else {
  11285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11286. // return
  11287. // }
  11288. //
  11289. //}
  11290. //func (c *HisApiController) ComfirmAllopatry() {
  11291. // year := c.GetString("year")
  11292. // month := c.GetString("month")
  11293. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11294. // adminUser := c.GetAdminUserInfo()
  11295. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11296. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11297. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11298. // var dat map[string]interface{}
  11299. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11300. // fmt.Println(dat)
  11301. // } else {
  11302. // fmt.Println(err)
  11303. // }
  11304. // userJSONBytes, _ := json.Marshal(dat)
  11305. // var res models.Result9001
  11306. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11307. // utils.ErrorLog("解析失败:%v", err)
  11308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11309. // return
  11310. // }
  11311. //
  11312. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11313. // var dat2 map[string]interface{}
  11314. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11315. // fmt.Println(dat)
  11316. // } else {
  11317. // fmt.Println(err)
  11318. // }
  11319. // userJSONBytes2, _ := json.Marshal(dat2)
  11320. // var res2 models.Result3260
  11321. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11322. // utils.ErrorLog("解析失败:%v", err)
  11323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11324. // return
  11325. // }
  11326. //
  11327. // if res2.Infcode == 0 {
  11328. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11329. // var dat map[string]interface{}
  11330. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11331. // fmt.Println(dat)
  11332. // } else {
  11333. // fmt.Println(err)
  11334. // }
  11335. // userJSONBytes, _ := json.Marshal(dat)
  11336. // var res3 models.Result3261
  11337. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11338. // utils.ErrorLog("解析失败:%v", err)
  11339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11340. // return
  11341. // }
  11342. //
  11343. // if res3.Infcode == 0 {
  11344. // record := &models.HisYidiClearRecord{
  11345. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11346. // Ctime: time.Now().Unix(),
  11347. // Mtime: time.Now().Unix(),
  11348. // Status: 1,
  11349. // MsgId: msgId,
  11350. // }
  11351. // service.SaveClearRecord(record)
  11352. // c.ServeSuccessJSON(map[string]interface{}{
  11353. // "msg": "提取成功",
  11354. // })
  11355. // }
  11356. // }
  11357. //}
  11358. func (c *HisApiController) RefundAllopatry() {
  11359. year := c.GetString("year")
  11360. month := c.GetString("month")
  11361. id, _ := c.GetInt64("id")
  11362. admin_user_id, _ := c.GetInt64("admin_user_id")
  11363. adminUser := c.GetAdminUserInfo()
  11364. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11365. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11366. record, _ := service.GetClearRecordById(id)
  11367. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11368. var dat map[string]interface{}
  11369. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11370. fmt.Println(dat)
  11371. } else {
  11372. fmt.Println(err)
  11373. }
  11374. userJSONBytes, _ := json.Marshal(dat)
  11375. var empty ResultFourteen
  11376. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11377. utils.ErrorLog("解析失败:%v", err)
  11378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11379. return
  11380. }
  11381. if empty.Infcode == 0 {
  11382. c.ServeSuccessJSON(map[string]interface{}{
  11383. "msg": "撤销成功",
  11384. })
  11385. return
  11386. }
  11387. }
  11388. func (c *HisApiController) ReversalOtherData() {
  11389. var customData []*CustomData
  11390. custom := &CustomData{
  11391. MsgId: "H44022900158202103301714472004",
  11392. PsnNo: "44020000001101329945",
  11393. Info: "2208",
  11394. }
  11395. customData = append(customData, custom)
  11396. custom1 := &CustomData{
  11397. MsgId: "H4402290015820210330172057803",
  11398. PsnNo: "44020000001101161813",
  11399. Info: "2208",
  11400. }
  11401. customData = append(customData, custom1)
  11402. custom2 := &CustomData{
  11403. MsgId: "H44022900158202103301705198813",
  11404. PsnNo: "44190000133097375417",
  11405. Info: "2208",
  11406. }
  11407. customData = append(customData, custom2)
  11408. custom3 := &CustomData{
  11409. MsgId: "H44022900158202103301715524756",
  11410. PsnNo: "44020000001100187221",
  11411. Info: "2208",
  11412. }
  11413. customData = append(customData, custom3)
  11414. custom4 := &CustomData{
  11415. MsgId: "H44022900158202103301730376224",
  11416. PsnNo: "44020000001101959155",
  11417. Info: "2208",
  11418. }
  11419. customData = append(customData, custom4)
  11420. custom5 := &CustomData{
  11421. MsgId: "H44022900158202103301748008725",
  11422. PsnNo: "44020000001104246641",
  11423. Info: "2208",
  11424. }
  11425. customData = append(customData, custom5)
  11426. custom6 := &CustomData{
  11427. MsgId: "H44022900158202103301718096755",
  11428. PsnNo: "44020000001102211860",
  11429. Info: "2208",
  11430. }
  11431. customData = append(customData, custom6)
  11432. custom7 := &CustomData{
  11433. MsgId: "H44022900158202103301736551640",
  11434. PsnNo: "44020000001102687718",
  11435. Info: "2208",
  11436. }
  11437. customData = append(customData, custom7)
  11438. custom8 := &CustomData{
  11439. MsgId: "H44022900158202103301743097676",
  11440. PsnNo: "44020000001102127785",
  11441. Info: "2208",
  11442. }
  11443. customData = append(customData, custom8)
  11444. custom9 := &CustomData{
  11445. MsgId: "H44022900158202103301712304203",
  11446. PsnNo: "44020000001101518097",
  11447. Info: "2208",
  11448. }
  11449. customData = append(customData, custom9)
  11450. custom10 := &CustomData{
  11451. MsgId: "H44022900158202103301738448785",
  11452. PsnNo: "44020000001100500813",
  11453. Info: "2208",
  11454. }
  11455. customData = append(customData, custom10)
  11456. custom11 := &CustomData{
  11457. MsgId: "H44022900158202103301732455843",
  11458. PsnNo: "44020000001102690557",
  11459. Info: "2208",
  11460. }
  11461. customData = append(customData, custom11)
  11462. custom12 := &CustomData{
  11463. MsgId: "H44022900158202103301745421708",
  11464. PsnNo: "44020000001102211928",
  11465. Info: "2208",
  11466. }
  11467. customData = append(customData, custom12)
  11468. custom1212 := &CustomData{
  11469. MsgId: "H440229001582021033017351627",
  11470. PsnNo: "44020000001102481733",
  11471. Info: "2208",
  11472. }
  11473. customData = append(customData, custom1212)
  11474. custom13 := &CustomData{
  11475. MsgId: "H44022900158202103301740327951",
  11476. PsnNo: "44020000001103174866",
  11477. Info: "2208",
  11478. }
  11479. customData = append(customData, custom13)
  11480. custom14 := &CustomData{
  11481. MsgId: "H4402290015820210330174922668",
  11482. PsnNo: "44020000001102927272",
  11483. Info: "2208",
  11484. }
  11485. customData = append(customData, custom14)
  11486. custom15 := &CustomData{
  11487. MsgId: "H44022900158202103301752362273",
  11488. PsnNo: "44020000001102942890",
  11489. Info: "2208",
  11490. }
  11491. customData = append(customData, custom15)
  11492. custom16 := &CustomData{
  11493. MsgId: "H44022900158202103301751082917",
  11494. PsnNo: "44020000001101662162",
  11495. Info: "2208",
  11496. }
  11497. customData = append(customData, custom16)
  11498. custom17 := &CustomData{
  11499. MsgId: "H44022900158202103301754147728",
  11500. PsnNo: "44020000000229014511",
  11501. Info: "2208",
  11502. }
  11503. customData = append(customData, custom17)
  11504. adminUser := c.GetAdminUserInfo()
  11505. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11506. for _, item := range customData {
  11507. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11508. fmt.Println(result)
  11509. }
  11510. }
  11511. func PathExists(path string) (bool, error) {
  11512. _, err := os.Stat(path)
  11513. if err == nil {
  11514. return true, nil
  11515. }
  11516. if os.IsNotExist(err) {
  11517. return false, nil
  11518. }
  11519. return false, err
  11520. }
  11521. //创建文件夹
  11522. func Mkdir(dir string) {
  11523. // 创建文件夹
  11524. exist, err := PathExists(dir)
  11525. if err != nil {
  11526. fmt.Println(err.Error())
  11527. } else {
  11528. if exist {
  11529. fmt.Println(dir + "文件夹已存在!")
  11530. } else {
  11531. // 文件夹名称,权限
  11532. err := os.Mkdir(dir, os.ModePerm)
  11533. if err != nil {
  11534. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11535. } else {
  11536. fmt.Println(dir + "文件夹创建成功!")
  11537. }
  11538. }
  11539. }
  11540. }
  11541. //压缩文件
  11542. func Zip(srcFile string, destZip string) error {
  11543. zipfile, err := os.Create(destZip)
  11544. if err != nil {
  11545. return err
  11546. }
  11547. defer zipfile.Close()
  11548. archive := zip.NewWriter(zipfile)
  11549. defer archive.Close()
  11550. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11551. if err != nil {
  11552. return err
  11553. }
  11554. header, err := zip.FileInfoHeader(info)
  11555. if err != nil {
  11556. return err
  11557. }
  11558. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11559. // header.Name = path
  11560. if info.IsDir() {
  11561. header.Name += "/"
  11562. } else {
  11563. header.Method = zip.Deflate
  11564. }
  11565. writer, err := archive.CreateHeader(header)
  11566. if err != nil {
  11567. return err
  11568. }
  11569. if !info.IsDir() {
  11570. file, err := os.Open(path)
  11571. if err != nil {
  11572. return err
  11573. }
  11574. defer file.Close()
  11575. _, err = io.Copy(writer, file)
  11576. }
  11577. return err
  11578. })
  11579. return err
  11580. }
  11581. func ReadFile(filePath string) []byte {
  11582. f, err := os.Open(filePath)
  11583. if err != nil {
  11584. fmt.Println("read file fail", err)
  11585. return nil
  11586. }
  11587. defer f.Close()
  11588. fd, err := ioutil.ReadAll(f)
  11589. if err != nil {
  11590. fmt.Println("read to fd fail", err)
  11591. return nil
  11592. }
  11593. return fd
  11594. }
  11595. func saveLog(result string, request string, infno string, desc string) {
  11596. org_id, _ := beego.AppConfig.Int64("org_id")
  11597. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11598. dir := miConfig.OrgName + "日志"
  11599. utils.Mkdir(dir)
  11600. month := time.Unix(1557042972, 0).Format("1")
  11601. year := time.Now().Format("2006")
  11602. month = time.Now().Format("01")
  11603. day := time.Now().Format("02")
  11604. hour := time.Now().Format("15")
  11605. min := time.Now().Format("04")
  11606. sec := time.Now().Format("05")
  11607. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11608. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11609. file_name := file + ".txt"
  11610. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11611. exist, _ := utils.PathExists(file_path)
  11612. if exist { //存在
  11613. fmt.Println("存在")
  11614. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11615. if err != nil {
  11616. fmt.Println("read fail")
  11617. }
  11618. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11619. n, _ := f.Seek(0, 2)
  11620. _, err = f.WriteAt([]byte(content), n)
  11621. } else { //不存在
  11622. fmt.Println("文件不存在,创建文件")
  11623. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11624. defer f.Close()
  11625. if err != nil {
  11626. } else {
  11627. _, err = f.Write([]byte("记录日志"))
  11628. }
  11629. }
  11630. }
  11631. type Charset string
  11632. const (
  11633. UTF8 = Charset("UTF-8")
  11634. GB18030 = Charset("GB18030")
  11635. )
  11636. func ConvertToString(src string, srcCode string, tagCode string) string {
  11637. srcCoder := mahonia.NewDecoder(srcCode)
  11638. srcResult := srcCoder.ConvertString(src)
  11639. tagCoder := mahonia.NewDecoder(tagCode)
  11640. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11641. result := string(cdata)
  11642. return result
  11643. }
  11644. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  11645. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  11646. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11647. var token string
  11648. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11649. var api string
  11650. if miConfig.MdtrtareaAdmvs == "320921" {
  11651. 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 +
  11652. "&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
  11653. fmt.Println(api)
  11654. } else {
  11655. 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 +
  11656. "&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
  11657. }
  11658. resp, requestErr := http.Get(api)
  11659. if requestErr != nil {
  11660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11661. return ""
  11662. }
  11663. body, ioErr := ioutil.ReadAll(resp.Body)
  11664. if ioErr != nil {
  11665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11667. return ""
  11668. }
  11669. var respJSON map[string]interface{}
  11670. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11673. return ""
  11674. }
  11675. var status string
  11676. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11677. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11678. var res ResultTwo //1101结果
  11679. var res10265 ResultTwo10265 //1101结果
  11680. if status == "0" { //读卡成功
  11681. var card_info string //卡信息
  11682. var busi_card_info string
  11683. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11684. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11685. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11686. fmt.Println(card_info)
  11687. fmt.Println(busi_card_info)
  11688. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11689. result, _ := json.Marshal(respJSON)
  11690. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11691. utils.ErrorLog("解析失败:%v", err)
  11692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11693. return ""
  11694. }
  11695. res.ErrMsg = res10265.ErrMsg
  11696. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11697. res.Infcode = infocode
  11698. res.Output = res10265.Output
  11699. res.InfRefmsgid = res10265.InfRefmsgid
  11700. if res.Infcode == 0 {
  11701. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11702. if err == gorm.ErrRecordNotFound {
  11703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11704. return ""
  11705. } else if err != nil {
  11706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11707. return ""
  11708. } else {
  11709. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11710. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11711. infoStr := string(Iinfos)
  11712. idetinfoStr := string(Idetinfos)
  11713. psn := &models.HisPsn{
  11714. PsnNo: res.Output.Baseinfo.PsnNo,
  11715. Age: res.Output.Baseinfo.Age,
  11716. PatientId: patient.ID,
  11717. Certno: res.Output.Baseinfo.Certno,
  11718. Brdy: res.Output.Baseinfo.Brdy,
  11719. Gend: res.Output.Baseinfo.Gend,
  11720. Naty: res.Output.Baseinfo.Naty,
  11721. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11722. PsnName: res.Output.Baseinfo.PsnName,
  11723. Idetinfo: idetinfoStr,
  11724. Insuinfo: infoStr,
  11725. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11726. CardInfo: card_info,
  11727. VerifyNumber: token,
  11728. }
  11729. service.CreateHisPsn(psn)
  11730. return token
  11731. }
  11732. }
  11733. } else {
  11734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11735. return ""
  11736. }
  11737. } else { //读卡失败
  11738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11739. return ""
  11740. }
  11741. return token
  11742. }
  11743. func DeleteExtraSpaceTwo(s string) string {
  11744. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11745. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11746. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11747. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11748. s2 := make([]byte, len(s1)) //定义字符数组切片
  11749. copy(s2, s1) //将字符串复制到切片
  11750. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11751. for len(spc_index) > 0 { //找到适配项
  11752. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11753. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11754. }
  11755. return string(s2)
  11756. }
  11757. func Remove0000(s string) string {
  11758. str := make([]rune, 0, len(s))
  11759. for _, v := range []rune(s) {
  11760. if v == 0 {
  11761. continue
  11762. }
  11763. str = append(str, v)
  11764. }
  11765. return string(str)
  11766. }
  11767. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11768. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11769. readCard := DllDef.MustFindProc("EcQuery")
  11770. pCardInfo := make([]byte, 8192)
  11771. pBusiCardInfo := make([]byte, 8192)
  11772. data := make(map[string]interface{})
  11773. //pData := make(map[string]interface{})
  11774. inputData := make(map[string]interface{})
  11775. inputData["orgId"] = code
  11776. inputData["businessType"] = "01101"
  11777. inputData["operatorId"] = operator_id
  11778. inputData["operatorName"] = operator_name
  11779. inputData["officeId"] = "001"
  11780. inputData["officeName"] = "血透室"
  11781. //
  11782. data["data"] = inputData
  11783. data["transType"] = "ec.query"
  11784. data["orgId"] = code
  11785. bytesData, _ := json.Marshal(data)
  11786. pCardInfo = bytesData
  11787. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11788. fmt.Println(ret2)
  11789. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11790. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11791. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11792. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11793. if ret2 != 0 {
  11794. return "", ""
  11795. }
  11796. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11797. }
  11798. func DeleteExtraSpace(s string) string {
  11799. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11800. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11801. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11802. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11803. s2 := make([]byte, len(s1)) //定义字符数组切片
  11804. copy(s2, s1) //将字符串复制到切片
  11805. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11806. for len(spc_index) > 0 { //找到适配项
  11807. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11808. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11809. }
  11810. return string(s2)
  11811. }
  11812. //对账
  11813. func (c *HisApiController) Post3202() {
  11814. start_time := c.GetString("start_time")
  11815. end_time := c.GetString("end_time")
  11816. //insutype := c.GetString("insutype")
  11817. clr_type := c.GetString("clr_type")
  11818. clr_org := c.GetString("clr_optins")
  11819. admin_user_id, _ := c.GetInt64("admin_user_id")
  11820. adminUser := c.GetAdminUserInfo()
  11821. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11822. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11823. if len(clr_org) == 0 {
  11824. clr_org = miConfig.MdtrtareaAdmvs
  11825. }
  11826. timeLayout := "2006-01-02"
  11827. loc, _ := time.LoadLocation("Local")
  11828. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11829. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11830. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11831. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  11832. //fixmedins_setl_cnt := int64(len(orders))
  11833. var medfee_sumamt float64
  11834. var acct_pay float64
  11835. var fund_pay_sumamt float64
  11836. for _, item := range orders {
  11837. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11838. acct_pay = acct_pay + item.AcctPay
  11839. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11840. }
  11841. //var medfee_sumamt_two float64
  11842. //var acct_pay_two float64
  11843. //var fund_pay_sumamt_two float64
  11844. //for _, item := range orders_two {
  11845. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  11846. // acct_pay_two = acct_pay_two + item.AcctPay
  11847. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  11848. //}
  11849. //var user_name string
  11850. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11851. //if role.ID == 0 {
  11852. // user_name = "xxx"
  11853. //} else {
  11854. // user_name = role.UserName
  11855. //}
  11856. var res ResultSix
  11857. if config.IsOpen == 1 {
  11858. var bps []*models.BusinessParamsTwo
  11859. var bp models.BusinessParamsTwo
  11860. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  11861. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  11862. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  11863. bp.MedfeeSumamt = medfee_sumamt_str
  11864. bp.AcctPay = acct_pay_str
  11865. bp.FundPaySumamt = fund_pay_sumamt_str
  11866. bp.Insutype = "390"
  11867. bp.StmtBegndate = start_time
  11868. bp.ClrType = clr_type
  11869. bp.SetlOptins = clr_org
  11870. bp.StmtEnddate = end_time
  11871. bps = append(bps, &bp)
  11872. data := make(map[string]interface{})
  11873. data["bps"] = bps
  11874. data["org_name"] = miConfig.OrgName
  11875. data["doctor"] = role.UserName
  11876. data["fixmedins_code"] = miConfig.Code
  11877. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11878. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11879. if miConfig.MdtrtareaAdmvs == "421300" {
  11880. client := &http.Client{}
  11881. bytesData, _ := json.Marshal(data)
  11882. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  11883. resp, _ := client.Do(req)
  11884. defer resp.Body.Close()
  11885. body, ioErr := ioutil.ReadAll(resp.Body)
  11886. if ioErr != nil {
  11887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11889. return
  11890. }
  11891. var respJSON map[string]interface{}
  11892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11895. return
  11896. }
  11897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11898. userJSONBytes, _ := json.Marshal(respJSON)
  11899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11900. utils.ErrorLog("解析失败:%v", err)
  11901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11902. return
  11903. }
  11904. }
  11905. if res.Infcode == 0 {
  11906. c.ServeSuccessJSON(map[string]interface{}{
  11907. "msg": "发起成功",
  11908. })
  11909. } else {
  11910. c.ServeSuccessJSON(map[string]interface{}{
  11911. "code": -10,
  11912. "msg": res.ErrMsg,
  11913. })
  11914. }
  11915. }
  11916. }
  11917. func (c *HisApiController) Post3501() {
  11918. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11919. data := make(map[string]interface{})
  11920. var struct3501s []models.Struct3501
  11921. var struct3501 models.Struct3501
  11922. struct3501.OrgName = miConfig.OrgName
  11923. struct3501.AccessKey = miConfig.AccessKey
  11924. struct3501.RequestUrl = miConfig.Url
  11925. struct3501.SecretKey = miConfig.SecretKey
  11926. struct3501.ManuDate = "2022-08-17"
  11927. struct3501.FixmedinsBchno = ""
  11928. struct3501.ManuLotnum = ""
  11929. struct3501.RxFlag = "0"
  11930. struct3501.ExpyEnd = "2022-08-17"
  11931. struct3501.Invdate = "2022-08-17"
  11932. struct3501.InvCnt = "20.25"
  11933. struct3501.Memo = ""
  11934. struct3501.MedListCodg = "XB01ABD056B002020200517"
  11935. struct3501.FixmedinsHilistId = miConfig.Code
  11936. struct3501.FixmedinsHilistName = miConfig.OrgName
  11937. struct3501s = append(struct3501s, struct3501)
  11938. data["struct_3501s"] = struct3501s
  11939. client := &http.Client{}
  11940. bytesData, _ := json.Marshal(data)
  11941. var req *http.Request
  11942. if miConfig.MdtrtareaAdmvs == "320921" {
  11943. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  11944. } else {
  11945. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  11946. }
  11947. resp, _ := client.Do(req)
  11948. defer resp.Body.Close()
  11949. body, ioErr := ioutil.ReadAll(resp.Body)
  11950. if ioErr != nil {
  11951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11953. return
  11954. }
  11955. var respJSON map[string]interface{}
  11956. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11959. return
  11960. }
  11961. var res ResultSix
  11962. var resSix10265 ResultSix10265 //1101结果
  11963. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11964. result, _ := json.Marshal(respJSON)
  11965. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  11966. utils.ErrorLog("解析失败:%v", err)
  11967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11968. return
  11969. }
  11970. res.InfRefmsgid = resSix10265.InfRefmsgid
  11971. res.Output = resSix10265.Output
  11972. res.ErrMsg = resSix10265.ErrMsg
  11973. res.Cainfo = resSix10265.Cainfo
  11974. res.WarnMsg = resSix10265.WarnMsg
  11975. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11976. res.Infcode = infocode
  11977. if infocode == 0 {
  11978. c.ServeSuccessJSON(map[string]interface{}{
  11979. "msg": "上传成功",
  11980. })
  11981. return
  11982. } else {
  11983. c.ServeSuccessJSON(map[string]interface{}{
  11984. "failed_code": -10,
  11985. "msg": res.ErrMsg,
  11986. })
  11987. return
  11988. }
  11989. }
  11990. func (c *HisApiController) Post3502() {
  11991. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11992. data := make(map[string]interface{})
  11993. var struct3502s []models.Struct3502
  11994. var struct3502 models.Struct3502
  11995. struct3502.OrgName = miConfig.OrgName
  11996. struct3502.AccessKey = miConfig.AccessKey
  11997. struct3502.RequestUrl = miConfig.Url
  11998. struct3502.SecretKey = miConfig.SecretKey
  11999. struct3502.ManuDate = "2022-08-15"
  12000. struct3502.FixmedinsBchno = ""
  12001. struct3502.ManuLotnum = ""
  12002. struct3502.RxFlag = "0"
  12003. struct3502.ExpyEnd = "2022-08-15"
  12004. struct3502.Invdate = "2022-08-15"
  12005. struct3502.InvCnt = "20.25"
  12006. struct3502.Memo = ""
  12007. struct3502.MedListCodg = "XB01ABD056B002020200517"
  12008. struct3502.FixmedinsHilistId = miConfig.Code
  12009. struct3502.FixmedinsHilistName = miConfig.OrgName
  12010. struct3502s = append(struct3502s, struct3502)
  12011. data["struct_3502s"] = struct3502s
  12012. client := &http.Client{}
  12013. bytesData, _ := json.Marshal(data)
  12014. var req *http.Request
  12015. if miConfig.MdtrtareaAdmvs == "320921" {
  12016. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12017. } else {
  12018. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12019. }
  12020. resp, _ := client.Do(req)
  12021. defer resp.Body.Close()
  12022. body, ioErr := ioutil.ReadAll(resp.Body)
  12023. if ioErr != nil {
  12024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12026. return
  12027. }
  12028. var respJSON map[string]interface{}
  12029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12032. return
  12033. }
  12034. var res ResultSix
  12035. var resSix10265 ResultSix10265 //1101结果
  12036. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12037. result, _ := json.Marshal(respJSON)
  12038. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12039. utils.ErrorLog("解析失败:%v", err)
  12040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12041. return
  12042. }
  12043. res.InfRefmsgid = resSix10265.InfRefmsgid
  12044. res.Output = resSix10265.Output
  12045. res.ErrMsg = resSix10265.ErrMsg
  12046. res.Cainfo = resSix10265.Cainfo
  12047. res.WarnMsg = resSix10265.WarnMsg
  12048. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12049. res.Infcode = infocode
  12050. if infocode == 0 {
  12051. c.ServeSuccessJSON(map[string]interface{}{
  12052. "msg": "上传成功",
  12053. })
  12054. return
  12055. } else {
  12056. c.ServeSuccessJSON(map[string]interface{}{
  12057. "failed_code": -10,
  12058. "msg": res.ErrMsg,
  12059. })
  12060. return
  12061. }
  12062. }
  12063. func (c *HisApiController) Post3503() {
  12064. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12065. data := make(map[string]interface{})
  12066. var struct3501s []models.Struct3501
  12067. var struct3501 models.Struct3501
  12068. struct3501.OrgName = miConfig.OrgName
  12069. struct3501.AccessKey = miConfig.AccessKey
  12070. struct3501.RequestUrl = miConfig.Url
  12071. struct3501.SecretKey = miConfig.SecretKey
  12072. struct3501.ManuDate = "2022-08-15"
  12073. struct3501.FixmedinsBchno = ""
  12074. struct3501.ManuLotnum = ""
  12075. struct3501.RxFlag = "0"
  12076. struct3501.ExpyEnd = "2022-08-15"
  12077. struct3501.Invdate = "2022-08-15"
  12078. struct3501.InvCnt = "20.25"
  12079. struct3501.Memo = ""
  12080. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12081. struct3501.FixmedinsHilistId = miConfig.Code
  12082. struct3501.FixmedinsHilistName = miConfig.OrgName
  12083. struct3501s = append(struct3501s, struct3501)
  12084. data["struct_3501s"] = struct3501s
  12085. client := &http.Client{}
  12086. bytesData, _ := json.Marshal(data)
  12087. var req *http.Request
  12088. if miConfig.MdtrtareaAdmvs == "320921" {
  12089. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12090. } else {
  12091. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12092. }
  12093. resp, _ := client.Do(req)
  12094. defer resp.Body.Close()
  12095. body, ioErr := ioutil.ReadAll(resp.Body)
  12096. if ioErr != nil {
  12097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12099. return
  12100. }
  12101. var respJSON map[string]interface{}
  12102. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12105. return
  12106. }
  12107. var res ResultSix
  12108. var resSix10265 ResultSix10265 //1101结果
  12109. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12110. result, _ := json.Marshal(respJSON)
  12111. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12112. utils.ErrorLog("解析失败:%v", err)
  12113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12114. return
  12115. }
  12116. res.InfRefmsgid = resSix10265.InfRefmsgid
  12117. res.Output = resSix10265.Output
  12118. res.ErrMsg = resSix10265.ErrMsg
  12119. res.Cainfo = resSix10265.Cainfo
  12120. res.WarnMsg = resSix10265.WarnMsg
  12121. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12122. res.Infcode = infocode
  12123. if infocode == 0 {
  12124. c.ServeSuccessJSON(map[string]interface{}{
  12125. "msg": "上传成功",
  12126. })
  12127. return
  12128. } else {
  12129. c.ServeSuccessJSON(map[string]interface{}{
  12130. "failed_code": -10,
  12131. "msg": res.ErrMsg,
  12132. })
  12133. return
  12134. }
  12135. }
  12136. func (c *HisApiController) Post3504() {
  12137. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12138. data := make(map[string]interface{})
  12139. var struct3501s []models.Struct3501
  12140. var struct3501 models.Struct3501
  12141. struct3501.OrgName = miConfig.OrgName
  12142. struct3501.AccessKey = miConfig.AccessKey
  12143. struct3501.RequestUrl = miConfig.Url
  12144. struct3501.SecretKey = miConfig.SecretKey
  12145. struct3501.ManuDate = "2022-08-15"
  12146. struct3501.FixmedinsBchno = ""
  12147. struct3501.ManuLotnum = ""
  12148. struct3501.RxFlag = "0"
  12149. struct3501.ExpyEnd = "2022-08-15"
  12150. struct3501.Invdate = "2022-08-15"
  12151. struct3501.InvCnt = "20.25"
  12152. struct3501.Memo = ""
  12153. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12154. struct3501.FixmedinsHilistId = miConfig.Code
  12155. struct3501.FixmedinsHilistName = miConfig.OrgName
  12156. struct3501s = append(struct3501s, struct3501)
  12157. data["struct_3501s"] = struct3501s
  12158. client := &http.Client{}
  12159. bytesData, _ := json.Marshal(data)
  12160. var req *http.Request
  12161. if miConfig.MdtrtareaAdmvs == "320921" {
  12162. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12163. } else {
  12164. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12165. }
  12166. resp, _ := client.Do(req)
  12167. defer resp.Body.Close()
  12168. body, ioErr := ioutil.ReadAll(resp.Body)
  12169. if ioErr != nil {
  12170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12172. return
  12173. }
  12174. var respJSON map[string]interface{}
  12175. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12178. return
  12179. }
  12180. var res ResultSix
  12181. var resSix10265 ResultSix10265 //1101结果
  12182. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12183. result, _ := json.Marshal(respJSON)
  12184. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12185. utils.ErrorLog("解析失败:%v", err)
  12186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12187. return
  12188. }
  12189. res.InfRefmsgid = resSix10265.InfRefmsgid
  12190. res.Output = resSix10265.Output
  12191. res.ErrMsg = resSix10265.ErrMsg
  12192. res.Cainfo = resSix10265.Cainfo
  12193. res.WarnMsg = resSix10265.WarnMsg
  12194. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12195. res.Infcode = infocode
  12196. if infocode == 0 {
  12197. c.ServeSuccessJSON(map[string]interface{}{
  12198. "msg": "上传成功",
  12199. })
  12200. return
  12201. } else {
  12202. c.ServeSuccessJSON(map[string]interface{}{
  12203. "failed_code": -10,
  12204. "msg": res.ErrMsg,
  12205. })
  12206. return
  12207. }
  12208. }
  12209. func (c *HisApiController) Post3505() {
  12210. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12211. data := make(map[string]interface{})
  12212. var struct3501s []models.Struct3501
  12213. var struct3501 models.Struct3501
  12214. struct3501.OrgName = miConfig.OrgName
  12215. struct3501.AccessKey = miConfig.AccessKey
  12216. struct3501.RequestUrl = miConfig.Url
  12217. struct3501.SecretKey = miConfig.SecretKey
  12218. struct3501.ManuDate = "2022-08-15"
  12219. struct3501.FixmedinsBchno = ""
  12220. struct3501.ManuLotnum = ""
  12221. struct3501.RxFlag = "0"
  12222. struct3501.ExpyEnd = "2022-08-15"
  12223. struct3501.Invdate = "2022-08-15"
  12224. struct3501.InvCnt = "20.25"
  12225. struct3501.Memo = ""
  12226. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12227. struct3501.FixmedinsHilistId = miConfig.Code
  12228. struct3501.FixmedinsHilistName = miConfig.OrgName
  12229. struct3501s = append(struct3501s, struct3501)
  12230. data["struct_3501s"] = struct3501s
  12231. client := &http.Client{}
  12232. bytesData, _ := json.Marshal(data)
  12233. var req *http.Request
  12234. if miConfig.MdtrtareaAdmvs == "320921" {
  12235. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12236. } else {
  12237. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12238. }
  12239. resp, _ := client.Do(req)
  12240. defer resp.Body.Close()
  12241. body, ioErr := ioutil.ReadAll(resp.Body)
  12242. if ioErr != nil {
  12243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12245. return
  12246. }
  12247. var respJSON map[string]interface{}
  12248. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12251. return
  12252. }
  12253. var res ResultSix
  12254. var resSix10265 ResultSix10265 //1101结果
  12255. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12256. result, _ := json.Marshal(respJSON)
  12257. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12258. utils.ErrorLog("解析失败:%v", err)
  12259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12260. return
  12261. }
  12262. res.InfRefmsgid = resSix10265.InfRefmsgid
  12263. res.Output = resSix10265.Output
  12264. res.ErrMsg = resSix10265.ErrMsg
  12265. res.Cainfo = resSix10265.Cainfo
  12266. res.WarnMsg = resSix10265.WarnMsg
  12267. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12268. res.Infcode = infocode
  12269. if infocode == 0 {
  12270. c.ServeSuccessJSON(map[string]interface{}{
  12271. "msg": "上传成功",
  12272. })
  12273. return
  12274. } else {
  12275. c.ServeSuccessJSON(map[string]interface{}{
  12276. "failed_code": -10,
  12277. "msg": res.ErrMsg,
  12278. })
  12279. return
  12280. }
  12281. }
  12282. func (c *HisApiController) Post3506() {
  12283. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12284. data := make(map[string]interface{})
  12285. var struct3501s []models.Struct3501
  12286. var struct3501 models.Struct3501
  12287. struct3501.OrgName = miConfig.OrgName
  12288. struct3501.AccessKey = miConfig.AccessKey
  12289. struct3501.RequestUrl = miConfig.Url
  12290. struct3501.SecretKey = miConfig.SecretKey
  12291. struct3501.ManuDate = "2022-08-15"
  12292. struct3501.FixmedinsBchno = ""
  12293. struct3501.ManuLotnum = ""
  12294. struct3501.RxFlag = "0"
  12295. struct3501.ExpyEnd = "2022-08-15"
  12296. struct3501.Invdate = "2022-08-15"
  12297. struct3501.InvCnt = "20.25"
  12298. struct3501.Memo = ""
  12299. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12300. struct3501.FixmedinsHilistId = miConfig.Code
  12301. struct3501.FixmedinsHilistName = miConfig.OrgName
  12302. struct3501s = append(struct3501s, struct3501)
  12303. data["struct_3501s"] = struct3501s
  12304. client := &http.Client{}
  12305. bytesData, _ := json.Marshal(data)
  12306. var req *http.Request
  12307. if miConfig.MdtrtareaAdmvs == "320921" {
  12308. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12309. } else {
  12310. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12311. }
  12312. resp, _ := client.Do(req)
  12313. defer resp.Body.Close()
  12314. body, ioErr := ioutil.ReadAll(resp.Body)
  12315. if ioErr != nil {
  12316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12318. return
  12319. }
  12320. var respJSON map[string]interface{}
  12321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12324. return
  12325. }
  12326. var res ResultSix
  12327. var resSix10265 ResultSix10265 //1101结果
  12328. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12329. result, _ := json.Marshal(respJSON)
  12330. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12331. utils.ErrorLog("解析失败:%v", err)
  12332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12333. return
  12334. }
  12335. res.InfRefmsgid = resSix10265.InfRefmsgid
  12336. res.Output = resSix10265.Output
  12337. res.ErrMsg = resSix10265.ErrMsg
  12338. res.Cainfo = resSix10265.Cainfo
  12339. res.WarnMsg = resSix10265.WarnMsg
  12340. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12341. res.Infcode = infocode
  12342. if infocode == 0 {
  12343. c.ServeSuccessJSON(map[string]interface{}{
  12344. "msg": "上传成功",
  12345. })
  12346. return
  12347. } else {
  12348. c.ServeSuccessJSON(map[string]interface{}{
  12349. "failed_code": -10,
  12350. "msg": res.ErrMsg,
  12351. })
  12352. return
  12353. }
  12354. }
  12355. func (c *HisApiController) Post3507() {
  12356. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12357. data := make(map[string]interface{})
  12358. var struct3501s []models.Struct3501
  12359. var struct3501 models.Struct3501
  12360. struct3501.OrgName = miConfig.OrgName
  12361. struct3501.AccessKey = miConfig.AccessKey
  12362. struct3501.RequestUrl = miConfig.Url
  12363. struct3501.SecretKey = miConfig.SecretKey
  12364. struct3501.ManuDate = "2022-08-15"
  12365. struct3501.FixmedinsBchno = ""
  12366. struct3501.ManuLotnum = ""
  12367. struct3501.RxFlag = "0"
  12368. struct3501.ExpyEnd = "2022-08-15"
  12369. struct3501.Invdate = "2022-08-15"
  12370. struct3501.InvCnt = "20.25"
  12371. struct3501.Memo = ""
  12372. struct3501.MedListCodg = "XB01ABD056B002020200517"
  12373. struct3501.FixmedinsHilistId = miConfig.Code
  12374. struct3501.FixmedinsHilistName = miConfig.OrgName
  12375. struct3501s = append(struct3501s, struct3501)
  12376. data["struct_3501s"] = struct3501s
  12377. client := &http.Client{}
  12378. bytesData, _ := json.Marshal(data)
  12379. var req *http.Request
  12380. if miConfig.MdtrtareaAdmvs == "320921" {
  12381. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12382. } else {
  12383. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  12384. }
  12385. resp, _ := client.Do(req)
  12386. defer resp.Body.Close()
  12387. body, ioErr := ioutil.ReadAll(resp.Body)
  12388. if ioErr != nil {
  12389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12391. return
  12392. }
  12393. var respJSON map[string]interface{}
  12394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12397. return
  12398. }
  12399. var res ResultSix
  12400. var resSix10265 ResultSix10265 //1101结果
  12401. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12402. result, _ := json.Marshal(respJSON)
  12403. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  12404. utils.ErrorLog("解析失败:%v", err)
  12405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12406. return
  12407. }
  12408. res.InfRefmsgid = resSix10265.InfRefmsgid
  12409. res.Output = resSix10265.Output
  12410. res.ErrMsg = resSix10265.ErrMsg
  12411. res.Cainfo = resSix10265.Cainfo
  12412. res.WarnMsg = resSix10265.WarnMsg
  12413. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12414. res.Infcode = infocode
  12415. if infocode == 0 {
  12416. c.ServeSuccessJSON(map[string]interface{}{
  12417. "msg": "上传成功",
  12418. })
  12419. return
  12420. } else {
  12421. c.ServeSuccessJSON(map[string]interface{}{
  12422. "failed_code": -10,
  12423. "msg": res.ErrMsg,
  12424. })
  12425. return
  12426. }
  12427. }