zh_his_api_controller.go 279KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038
  1. package zh
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/controllers"
  7. "gdyb/enums"
  8. "gdyb/models"
  9. "gdyb/service"
  10. "gdyb/utils"
  11. "github.com/astaxie/beego"
  12. "github.com/axgle/mahonia"
  13. "github.com/jinzhu/gorm"
  14. "io/ioutil"
  15. "math"
  16. "math/rand"
  17. "net/http"
  18. "os"
  19. "regexp"
  20. "strconv"
  21. "strings"
  22. "syscall"
  23. "time"
  24. "unsafe"
  25. "github.com/gorilla/websocket"
  26. "net/url"
  27. )
  28. type ZHHisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. type ResultSix struct {
  32. Cainfo interface{} `json:"cainfo"`
  33. ErrMsg string `json:"err_msg"`
  34. InfRefmsgid string `json:"inf_refmsgid"`
  35. Infcode int64 `json:"infcode"`
  36. Output struct {
  37. } `json:"output"`
  38. RefmsgTime string `json:"refmsg_time"`
  39. RespondTime string `json:"respond_time"`
  40. Signtype interface{} `json:"signtype"`
  41. WarnMsg interface{} `json:"warn_msg"`
  42. }
  43. type ResultTwo struct {
  44. ErrMsg string `json:"err_msg"`
  45. InfRefmsgid string `json:"inf_refmsgid"`
  46. Infcode int64 `json:"infcode"`
  47. Output struct {
  48. Baseinfo struct {
  49. Age float64 `json:"age"`
  50. Certno string `json:"certno"`
  51. Gend string `json:"gend"`
  52. //Brdy string `json:"brdy"`
  53. Naty string `json:"naty"`
  54. PsnCertType string `json:"psn_cert_type"`
  55. PsnName string `json:"psn_name"`
  56. PsnNo string `json:"psn_no"`
  57. } `json:"baseinfo"`
  58. Idetinfo []interface{} `json:"idetinfo"`
  59. Iinfo []struct {
  60. Balc float64 `json:"balc"`
  61. CvlservFlag string `json:"cvlserv_flag"`
  62. EmpName string `json:"emp_name"`
  63. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  64. Insutype string `json:"insutype"`
  65. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  66. //PausInsuDate string `json:"paus_insu_date"`
  67. //PsnInsuDate string `json:"psn_insu_date"`
  68. PsnInsuStas string `json:"psn_insu_stas"`
  69. PsnType string `json:"psn_type"`
  70. } `json:"insuinfo"`
  71. } `json:"output"`
  72. RefmsgTime string `json:"refmsg_time"`
  73. RespondTime string `json:"respond_time"`
  74. Signtype interface{} `json:"signtype"`
  75. WarnInfo interface{} `json:"warn_info"`
  76. }
  77. type ResultTwohb struct {
  78. ErrMsg string `json:"err_msg"`
  79. InfRefmsgid string `json:"inf_refmsgid"`
  80. Infcode int64 `json:"infcode"`
  81. Output struct {
  82. Baseinfo struct {
  83. Age float64 `json:"age"`
  84. Certno string `json:"certno"`
  85. Gend string `json:"gend"`
  86. //Brdy string `json:"brdy"`
  87. Naty string `json:"naty"`
  88. PsnCertType string `json:"psn_cert_type"`
  89. PsnName string `json:"psn_name"`
  90. PsnNo string `json:"psn_no"`
  91. ExpContent ExpContent `json:"exp_content"`
  92. } `json:"baseinfo"`
  93. Idetinfo []interface{} `json:"idetinfo"`
  94. Iinfo []struct {
  95. Balc float64 `json:"balc"`
  96. CvlservFlag string `json:"cvlserv_flag"`
  97. EmpName string `json:"emp_name"`
  98. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  99. Insutype string `json:"insutype"`
  100. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  101. //PausInsuDate string `json:"paus_insu_date"`
  102. //PsnInsuDate string `json:"psn_insu_date"`
  103. PsnInsuStas string `json:"psn_insu_stas"`
  104. PsnType string `json:"psn_type"`
  105. } `json:"insuinfo"`
  106. } `json:"output"`
  107. RefmsgTime string `json:"refmsg_time"`
  108. RespondTime string `json:"respond_time"`
  109. Signtype interface{} `json:"signtype"`
  110. WarnInfo interface{} `json:"warn_info"`
  111. }
  112. type ExpContent struct {
  113. MdtrtCertType string `json:"mdtrt_cert_type"`
  114. MdtrtCertNo string `json:"mdtrt_cert_no"`
  115. }
  116. type AHResultTwo struct {
  117. ErrMsg string `json:"err_msg"`
  118. InfRefmsgid string `json:"inf_refmsgid"`
  119. Infcode int64 `json:"infcode"`
  120. Output struct {
  121. Baseinfo struct {
  122. Age float64 `json:"age"`
  123. Certno string `json:"certno"`
  124. Gend string `json:"gend"`
  125. Naty string `json:"naty"`
  126. //Brdy string `json:"brdy"`
  127. PsnCertType string `json:"psn_cert_type"`
  128. PsnName string `json:"psn_name"`
  129. PsnNo string `json:"psn_no"`
  130. } `json:"baseinfo"`
  131. Idetinfo []interface{} `json:"idetinfo"`
  132. Iinfo []struct {
  133. Balc float64 `json:"balc"`
  134. CvlservFlag string `json:"cvlserv_flag"`
  135. EmpName string `json:"emp_name"`
  136. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  137. Insutype string `json:"insutype"`
  138. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  139. PsnInsuStas string `json:"psn_insu_stas"`
  140. PsnType string `json:"psn_type"`
  141. } `json:"insuinfo"`
  142. } `json:"output"`
  143. RefmsgTime string `json:"refmsg_time"`
  144. RespondTime string `json:"respond_time"`
  145. Signtype interface{} `json:"signtype"`
  146. WarnInfo interface{} `json:"warn_info"`
  147. }
  148. type ResultTwo10265 struct {
  149. ErrMsg string `json:"err_msg"`
  150. InfRefmsgid string `json:"inf_refmsgid"`
  151. Infcode string `json:"infcode"`
  152. Output struct {
  153. Baseinfo struct {
  154. Age float64 `json:"age"`
  155. Certno string `json:"certno"`
  156. Gend string `json:"gend"`
  157. //Brdy string `json:"brdy"`
  158. Naty string `json:"naty"`
  159. PsnCertType string `json:"psn_cert_type"`
  160. PsnName string `json:"psn_name"`
  161. PsnNo string `json:"psn_no"`
  162. } `json:"baseinfo"`
  163. Idetinfo []interface{} `json:"idetinfo"`
  164. Iinfo []struct {
  165. Balc float64 `json:"balc"`
  166. CvlservFlag string `json:"cvlserv_flag"`
  167. EmpName string `json:"emp_name"`
  168. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  169. Insutype string `json:"insutype"`
  170. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  171. PsnInsuStas string `json:"psn_insu_stas"`
  172. PsnType string `json:"psn_type"`
  173. } `json:"insuinfo"`
  174. } `json:"output"`
  175. RefmsgTime string `json:"refmsg_time"`
  176. RespondTime string `json:"respond_time"`
  177. Signtype interface{} `json:"signtype"`
  178. WarnInfo interface{} `json:"warn_info"`
  179. }
  180. type ResultThree struct {
  181. Cainfo interface{} `json:"cainfo"`
  182. ErrMsg string `json:"err_msg"`
  183. InfRefmsgid string `json:"inf_refmsgid"`
  184. Infcode int64 `json:"infcode"`
  185. Output struct {
  186. Result struct {
  187. MdtrtID string `json:"mdtrt_id"`
  188. } `json:"result"`
  189. } `json:"output"`
  190. RefmsgTime string `json:"refmsg_time"`
  191. RespondTime string `json:"respond_time"`
  192. Signtype interface{} `json:"signtype"`
  193. WarnMsg interface{} `json:"warn_msg"`
  194. }
  195. type ResultThree10265 struct {
  196. Cainfo interface{} `json:"cainfo"`
  197. ErrMsg string `json:"err_msg"`
  198. InfRefmsgid string `json:"inf_refmsgid"`
  199. Infcode string `json:"infcode"`
  200. Output struct {
  201. Result struct {
  202. MdtrtID string `json:"mdtrt_id"`
  203. } `json:"result"`
  204. } `json:"output"`
  205. RefmsgTime string `json:"refmsg_time"`
  206. RespondTime string `json:"respond_time"`
  207. Signtype interface{} `json:"signtype"`
  208. WarnMsg interface{} `json:"warn_msg"`
  209. }
  210. type ResultFour struct {
  211. Cainfo string `json:"cainfo"`
  212. ErrMsg string `json:"err_msg"`
  213. InfRefmsgid string `json:"inf_refmsgid"`
  214. Infcode int64 `json:"infcode"`
  215. Output struct {
  216. Result []struct {
  217. BasMednFlag string `json:"bas_medn_flag"`
  218. ChldMedcFlag string `json:"chld_medc_flag"`
  219. ChrgitmLv string `json:"chrgitm_lv"`
  220. Cnt float64 `json:"cnt"`
  221. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  222. DrtReimFlag string `json:"drt_reim_flag"`
  223. FeedetlSn string `json:"feedetl_sn"`
  224. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  225. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  226. InscpScpAmt float64 `json:"inscp_scp_amt"`
  227. ListSpItemFlag string `json:"list_sp_item_flag"`
  228. LmtUsedFlag string `json:"lmt_used_flag"`
  229. MedChrgitmType string `json:"med_chrgitm_type"`
  230. Memo string `json:"memo"`
  231. OverlmtAmt float64 `json:"overlmt_amt"`
  232. PreselfpayAmt float64 `json:"preselfpay_amt"`
  233. Pric float64 `json:"pric"`
  234. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  235. SelfpayProp float64 `json:"selfpay_prop"`
  236. } `json:"result"`
  237. } `json:"output"`
  238. RefmsgTime string `json:"refmsg_time"`
  239. RespondTime string `json:"respond_time"`
  240. Signtype string `json:"signtype"`
  241. WarnMsg string `json:"warn_msg"`
  242. }
  243. type ResultFour10265 struct {
  244. Cainfo string `json:"cainfo"`
  245. ErrMsg string `json:"err_msg"`
  246. InfRefmsgid string `json:"inf_refmsgid"`
  247. Infcode string `json:"infcode"`
  248. Output struct {
  249. Result []struct {
  250. BasMednFlag string `json:"bas_medn_flag"`
  251. ChldMedcFlag string `json:"chld_medc_flag"`
  252. ChrgitmLv string `json:"chrgitm_lv"`
  253. Cnt float64 `json:"cnt"`
  254. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  255. DrtReimFlag string `json:"drt_reim_flag"`
  256. FeedetlSn string `json:"feedetl_sn"`
  257. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  258. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  259. InscpScpAmt float64 `json:"inscp_scp_amt"`
  260. ListSpItemFlag string `json:"list_sp_item_flag"`
  261. LmtUsedFlag string `json:"lmt_used_flag"`
  262. MedChrgitmType string `json:"med_chrgitm_type"`
  263. Memo string `json:"memo"`
  264. OverlmtAmt float64 `json:"overlmt_amt"`
  265. PreselfpayAmt float64 `json:"preselfpay_amt"`
  266. Pric float64 `json:"pric"`
  267. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  268. SelfpayProp float64 `json:"selfpay_prop"`
  269. } `json:"result"`
  270. } `json:"output"`
  271. RefmsgTime string `json:"refmsg_time"`
  272. RespondTime string `json:"respond_time"`
  273. Signtype string `json:"signtype"`
  274. WarnMsg string `json:"warn_msg"`
  275. }
  276. type ResultFive struct {
  277. Balc float64 `json:"balc"`
  278. CvlservFlag string `json:"cvlserv_flag"`
  279. EmpName string `json:"emp_name"`
  280. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  281. Insutype string `json:"insutype"`
  282. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  283. PausInsuDate string `json:"paus_insu_date"`
  284. PsnInsuDate string `json:"psn_insu_date"`
  285. PsnInsuStas string `json:"psn_insu_stas"`
  286. PsnType string `json:"psn_type"`
  287. }
  288. type ResultSevenTwo struct {
  289. Cainfo string `json:"cainfo"`
  290. ErrMsg string `json:"err_msg"`
  291. InfRefmsgid string `json:"inf_refmsgid"`
  292. Infcode int64 `json:"infcode"`
  293. Output struct {
  294. Setldetail []interface{} `json:"setldetail"`
  295. Setlinfo struct {
  296. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  297. AcctPay float64 `json:"acct_pay"`
  298. ActPayDedc float64 `json:"act_pay_dedc"`
  299. Age string `json:"age"`
  300. Balc float64 `json:"balc"`
  301. //Brdy string `json:"brdy"`
  302. Certno string `json:"certno"`
  303. ClrOptins string `json:"clr_optins"`
  304. ClrType string `json:"clr_type"`
  305. ClrWay string `json:"clr_way"`
  306. CvlservFlag string `json:"cvlserv_flag"`
  307. CvlservPay float64 `json:"cvlserv_pay"`
  308. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  309. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  310. Gend string `json:"gend"`
  311. HifesPay float64 `json:"hifes_pay"`
  312. HifmiPay float64 `json:"hifmi_pay"`
  313. HifpPay float64 `json:"hifp_pay"`
  314. HospPartAmt float64 `json:"hosp_part_amt"`
  315. InscpScpAmt float64 `json:"inscp_scp_amt"`
  316. Insutype string `json:"insutype"`
  317. MafPay float64 `json:"maf_pay"`
  318. MdtrtCertType string `json:"mdtrt_cert_type"`
  319. HifobPay float64 `json:"hifob_pay"`
  320. MdtrtID string `json:"mdtrt_id"`
  321. MedType string `json:"med_type"`
  322. MedfeeSumamt float64 `json:"medfee_sumamt"`
  323. MedinsSetlID string `json:"medins_setl_id"`
  324. Naty string `json:"naty"`
  325. OthPay float64 `json:"oth_pay"`
  326. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  327. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  328. PreselfpayAmt float64 `json:"preselfpay_amt"`
  329. PsnCashPay float64 `json:"psn_cash_pay"`
  330. PsnCertType string `json:"psn_cert_type"`
  331. PsnName string `json:"psn_name"`
  332. PsnNo string `json:"psn_no"`
  333. PsnPartAmt float64 `json:"psn_part_amt"`
  334. PsnType string `json:"psn_type"`
  335. SetlID string `json:"setl_id"`
  336. SetlTime string `json:"setl_time"`
  337. } `json:"setlinfo"`
  338. } `json:"output"`
  339. RefmsgTime string `json:"refmsg_time"`
  340. RespondTime string `json:"respond_time"`
  341. Signtype interface{} `json:"signtype"`
  342. WarnMsg interface{} `json:"warn_msg"`
  343. }
  344. type ResultSeven struct {
  345. Cainfo string `json:"cainfo"`
  346. ErrMsg string `json:"err_msg"`
  347. InfRefmsgid string `json:"inf_refmsgid"`
  348. Infcode int64 `json:"infcode"`
  349. Output struct {
  350. Setldetail []interface{} `json:"setldetail"`
  351. Setlinfo struct {
  352. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  353. AcctPay float64 `json:"acct_pay"`
  354. ActPayDedc float64 `json:"act_pay_dedc"`
  355. Age float64 `json:"age"`
  356. Balc float64 `json:"balc"`
  357. //Brdy string `json:"brdy"`
  358. Certno string `json:"certno"`
  359. ClrOptins string `json:"clr_optins"`
  360. ClrType string `json:"clr_type"`
  361. ClrWay string `json:"clr_way"`
  362. CvlservFlag string `json:"cvlserv_flag"`
  363. CvlservPay float64 `json:"cvlserv_pay"`
  364. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  365. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  366. Gend string `json:"gend"`
  367. HifesPay float64 `json:"hifes_pay"`
  368. HifmiPay float64 `json:"hifmi_pay"`
  369. HifpPay float64 `json:"hifp_pay"`
  370. HospPartAmt float64 `json:"hosp_part_amt"`
  371. InscpScpAmt float64 `json:"inscp_scp_amt"`
  372. Insutype string `json:"insutype"`
  373. MafPay float64 `json:"maf_pay"`
  374. MdtrtCertType string `json:"mdtrt_cert_type"`
  375. HifobPay float64 `json:"hifob_pay"`
  376. MdtrtID string `json:"mdtrt_id"`
  377. MedType string `json:"med_type"`
  378. MedfeeSumamt float64 `json:"medfee_sumamt"`
  379. MedinsSetlID string `json:"medins_setl_id"`
  380. Naty string `json:"naty"`
  381. OthPay float64 `json:"oth_pay"`
  382. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  383. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  384. PreselfpayAmt float64 `json:"preselfpay_amt"`
  385. PsnCashPay float64 `json:"psn_cash_pay"`
  386. PsnCertType string `json:"psn_cert_type"`
  387. PsnName string `json:"psn_name"`
  388. PsnNo string `json:"psn_no"`
  389. PsnPartAmt float64 `json:"psn_part_amt"`
  390. PsnType string `json:"psn_type"`
  391. SetlID string `json:"setl_id"`
  392. SetlTime string `json:"setl_time"`
  393. } `json:"setlinfo"`
  394. } `json:"output"`
  395. RefmsgTime string `json:"refmsg_time"`
  396. RespondTime string `json:"respond_time"`
  397. Signtype interface{} `json:"signtype"`
  398. WarnMsg interface{} `json:"warn_msg"`
  399. }
  400. type ResultSeven10265 struct {
  401. Cainfo string `json:"cainfo"`
  402. ErrMsg string `json:"err_msg"`
  403. InfRefmsgid string `json:"inf_refmsgid"`
  404. Infcode string `json:"infcode"`
  405. Output struct {
  406. Setldetail []interface{} `json:"setldetail"`
  407. Setlinfo struct {
  408. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  409. AcctPay float64 `json:"acct_pay"`
  410. ActPayDedc float64 `json:"act_pay_dedc"`
  411. Age float64 `json:"age"`
  412. Balc float64 `json:"balc"`
  413. //Brdy string `json:"brdy"`
  414. Certno string `json:"certno"`
  415. ClrOptins string `json:"clr_optins"`
  416. ClrType string `json:"clr_type"`
  417. ClrWay string `json:"clr_way"`
  418. CvlservFlag string `json:"cvlserv_flag"`
  419. CvlservPay float64 `json:"cvlserv_pay"`
  420. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  421. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  422. Gend string `json:"gend"`
  423. HifesPay float64 `json:"hifes_pay"`
  424. HifmiPay float64 `json:"hifmi_pay"`
  425. HifpPay float64 `json:"hifp_pay"`
  426. HospPartAmt float64 `json:"hosp_part_amt"`
  427. InscpScpAmt float64 `json:"inscp_scp_amt"`
  428. Insutype string `json:"insutype"`
  429. MafPay float64 `json:"maf_pay"`
  430. MdtrtCertType string `json:"mdtrt_cert_type"`
  431. HifobPay float64 `json:"hifob_pay"`
  432. MdtrtID string `json:"mdtrt_id"`
  433. MedType string `json:"med_type"`
  434. MedfeeSumamt float64 `json:"medfee_sumamt"`
  435. MedinsSetlID string `json:"medins_setl_id"`
  436. Naty string `json:"naty"`
  437. OthPay float64 `json:"oth_pay"`
  438. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  439. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  440. PreselfpayAmt float64 `json:"preselfpay_amt"`
  441. PsnCashPay float64 `json:"psn_cash_pay"`
  442. PsnCertType string `json:"psn_cert_type"`
  443. PsnName string `json:"psn_name"`
  444. PsnNo string `json:"psn_no"`
  445. PsnPartAmt float64 `json:"psn_part_amt"`
  446. PsnType string `json:"psn_type"`
  447. SetlID string `json:"setl_id"`
  448. SetlTime string `json:"setl_time"`
  449. } `json:"setlinfo"`
  450. } `json:"output"`
  451. RefmsgTime string `json:"refmsg_time"`
  452. RespondTime string `json:"respond_time"`
  453. Signtype interface{} `json:"signtype"`
  454. WarnMsg interface{} `json:"warn_msg"`
  455. }
  456. type ResultSixteen struct {
  457. Cainfo string `json:"cainfo"`
  458. ErrMsg string `json:"err_msg"`
  459. InfRefmsgid string `json:"inf_refmsgid"`
  460. Infcode int64 `json:"infcode"`
  461. Output struct {
  462. Setldetail []interface{} `json:"setldetail"`
  463. Setlinfo struct {
  464. MdtrtID string `json:"mdtrt_id"`
  465. SetlID string `json:"setl_id"`
  466. ClrOptins string `json:"clr_optins"`
  467. SetlTime string `json:"setl_time"`
  468. MedfeeSumamt float64 `json:"medfee_sumamt"`
  469. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  470. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  471. PreselfpayAmt float64 `json:"preselfpay_amt"`
  472. InscpScpAmt float64 `json:"inscp_scp_amt"`
  473. ActPayDedc float64 `json:"act_pay_dedc"`
  474. HifpPay float64 `json:"hifp_pay"`
  475. PoolPropSe float64 `json:"pool_prop_selfpay"`
  476. Lfpay float64 `json:"selfpay"`
  477. CvlservPay float64 `json:"cvlserv_pay"`
  478. HifesPay float64 `json:"hifes_pay"`
  479. HifmiPay float64 `json:"hifmi_pay"`
  480. HifobPay float64 `json:"hifob_pay"`
  481. MafPay float64 `json:"maf_pay"`
  482. OthPay float64 `json:"oth_pay"`
  483. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  484. PsnPartAmt float64 `json:"psn_part_amt"`
  485. AcctPay float64 `json:"acct_pay"`
  486. Balc float64 `json:"balc"`
  487. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  488. HospPartAmt float64 `json:"hosp_part_amt"`
  489. MedinsSetlID string `json:"medins_setl_id"`
  490. PdnCashPay string `json:"pdn_cash_pay"`
  491. } `json:"setlinfo"`
  492. } `json:"output"`
  493. RefmsgTime string `json:"refmsg_time"`
  494. RespondTime string `json:"respond_time"`
  495. Signtype interface{} `json:"signtype"`
  496. WarnMsg interface{} `json:"warn_msg"`
  497. }
  498. type ResultSixteen10265 struct {
  499. Cainfo string `json:"cainfo"`
  500. ErrMsg string `json:"err_msg"`
  501. InfRefmsgid string `json:"inf_refmsgid"`
  502. Infcode string `json:"infcode"`
  503. Output struct {
  504. Setldetail []interface{} `json:"setldetail"`
  505. Setlinfo struct {
  506. MdtrtID string `json:"mdtrt_id"`
  507. SetlID string `json:"setl_id"`
  508. ClrOptins string `json:"clr_optins"`
  509. SetlTime string `json:"setl_time"`
  510. MedfeeSumamt float64 `json:"medfee_sumamt"`
  511. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  512. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  513. PreselfpayAmt float64 `json:"preselfpay_amt"`
  514. InscpScpAmt float64 `json:"inscp_scp_amt"`
  515. ActPayDedc float64 `json:"act_pay_dedc"`
  516. HifpPay float64 `json:"hifp_pay"`
  517. PoolPropSe float64 `json:"pool_prop_selfpay"`
  518. Lfpay float64 `json:"selfpay"`
  519. CvlservPay float64 `json:"cvlserv_pay"`
  520. HifesPay float64 `json:"hifes_pay"`
  521. HifmiPay float64 `json:"hifmi_pay"`
  522. HifobPay float64 `json:"hifob_pay"`
  523. MafPay float64 `json:"maf_pay"`
  524. OthPay float64 `json:"oth_pay"`
  525. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  526. PsnPartAmt float64 `json:"psn_part_amt"`
  527. AcctPay float64 `json:"acct_pay"`
  528. Balc float64 `json:"balc"`
  529. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  530. HospPartAmt float64 `json:"hosp_part_amt"`
  531. MedinsSetlID string `json:"medins_setl_id"`
  532. PdnCashPay string `json:"pdn_cash_pay"`
  533. } `json:"setlinfo"`
  534. } `json:"output"`
  535. RefmsgTime string `json:"refmsg_time"`
  536. RespondTime string `json:"respond_time"`
  537. Signtype interface{} `json:"signtype"`
  538. WarnMsg interface{} `json:"warn_msg"`
  539. }
  540. type Custom struct {
  541. DetItemFeeSumamt string
  542. Cut string
  543. FeedetlSn string
  544. Price string
  545. MedListCodg string
  546. Type int64
  547. AdviceId int64
  548. ProjectId int64
  549. ItemId int64
  550. }
  551. type ResultEmpty struct {
  552. Cainfo interface{} `json:"cainfo"`
  553. ErrMsg string `json:"err_msg"`
  554. InfRefmsgid string `json:"inf_refmsgid"`
  555. Infcode int64 `json:"infcode"`
  556. Output struct {
  557. } `json:"output"`
  558. RefmsgTime string `json:"refmsg_time"`
  559. RespondTime string `json:"respond_time"`
  560. Signtype interface{} `json:"signtype"`
  561. WarnMsg interface{} `json:"warn_msg"`
  562. }
  563. type ResultEmpty10265 struct {
  564. Cainfo interface{} `json:"cainfo"`
  565. ErrMsg string `json:"err_msg"`
  566. InfRefmsgid string `json:"inf_refmsgid"`
  567. Infcode string `json:"infcode"`
  568. Output struct {
  569. } `json:"output"`
  570. RefmsgTime string `json:"refmsg_time"`
  571. RespondTime string `json:"respond_time"`
  572. Signtype interface{} `json:"signtype"`
  573. WarnMsg interface{} `json:"warn_msg"`
  574. }
  575. type CustomResult struct {
  576. BasMednFlag string `json:"bas_medn_flag"`
  577. ChldMedcFlag string `json:"chld_medc_flag"`
  578. ChrgitmLv string `json:"chrgitm_lv"`
  579. Cnt float64 `json:"cnt"`
  580. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  581. DrtReimFlag string `json:"drt_reim_flag"`
  582. FeedetlSn string `json:"feedetl_sn"`
  583. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  584. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  585. InscpScpAmt float64 `json:"inscp_scp_amt"`
  586. ListSpItemFlag string `json:"list_sp_item_flag"`
  587. LmtUsedFlag string `json:"lmt_used_flag"`
  588. MedChrgitmType string `json:"med_chrgitm_type"`
  589. Memo string `json:"memo"`
  590. OverlmtAmt float64 `json:"overlmt_amt"`
  591. PreselfpayAmt float64 `json:"preselfpay_amt"`
  592. Pric float64 `json:"pric"`
  593. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  594. SelfpayProp float64 `json:"selfpay_prop"`
  595. }
  596. func ZHHisManagerApiRegistRouters() {
  597. beego.Router("/zh/api/inhopitalcheck/get", &ZHHisApiController{}, "get:GetZHInHospitalCheck")
  598. beego.Router("/zh/api/outhopitalcheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalCheck")
  599. beego.Router("/zh/api/uploadinfo/get", &ZHHisApiController{}, "get:GetUploadInfo")
  600. beego.Router("/zh/api/presettle/get", &ZHHisApiController{}, "get:GetPreSettleInfo")
  601. beego.Router("/zh/api/settle/get", &ZHHisApiController{}, "get:GetSettleInfo")
  602. beego.Router("/zh/api/inthopitaluncheck/get", &ZHHisApiController{}, "get:GetZHInHospitalUnCheck")
  603. beego.Router("/zh/api/outhopitaluncheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalUnCheck")
  604. beego.Router("/zh/api/refund", &ZHHisApiController{}, "get:ZHRefund")
  605. beego.Router("/zh/api/refunddetail", &ZHHisApiController{}, "get:ZHRefundDetail")
  606. beego.Router("/zh/api/patient/info", &ZHHisApiController{}, "get:GetZHPatientInfo")
  607. beego.Router("/zh/api/readcard", &ZHHisApiController{}, "get:ReadCard")
  608. beego.Router("/zh/api/clearsettle", &ZHHisApiController{}, "get:ClearSettle")
  609. beego.Router("/zh/api/readelecard", &ZHHisApiController{}, "get:ReadEleCard")
  610. beego.Router("/zh/api/deviceinit", &ZHHisApiController{}, "get:ReadEleCardfordevice")
  611. //beego.Router("/zh/api/readelecard", &ZHHisApiController{}, "get:ReadEleCard")
  612. beego.Router("/zh/api/lingbao/upload", &ZHHisApiController{}, "get:UploadLingBao")
  613. beego.Router("/zh/api/lingbao/refund", &ZHHisApiController{}, "get:RefundLingBao")
  614. beego.Router("/zh/api/lingbao/get", &ZHHisApiController{}, "get:GetLingBao")
  615. beego.Router("/api/token/get", &ZHHisApiController{}, "post:GetToken")
  616. beego.Router("/api/ele/info", &ZHHisApiController{}, "post:GetEleInfo")
  617. beego.Router("/api/4102", &ZHHisApiController{}, "get:Get4102")
  618. beego.Router("/api/4103", &ZHHisApiController{}, "get:Get4103")
  619. //beego.Router("/api/4104", &ZHHisApiController{}, "get:Get4104")
  620. beego.Router("/api/cardstatus", &ZHHisApiController{}, "get:GetCardStatus")
  621. //beego.Router("/api/2403", &ZHHisApiController{}, "get:Get2403")
  622. beego.Router("/api/5201", &ZHHisApiController{}, "get:Get5201")
  623. }
  624. func (c *ZHHisApiController) Get5201() {
  625. }
  626. // func (c *ZHHisApiController) Get2403(){
  627. // id, _ := c.GetInt64("order_id")
  628. // order,_ := service.GetHisOrderByID(id)
  629. // hosp,_ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  630. //
  631. //
  632. // med_type := "21"
  633. // id_card_type := hosp.IdCardType
  634. //
  635. //
  636. //
  637. // diagnosis_ids_arr := strings.Split(hosp.Diagnosis, "-")
  638. // adminInfo := c.GetAdminUserInfo()
  639. // var patient service.Patients
  640. // if id == 0 {
  641. // patient, _ = service.GetPatientByIDCard(order.Certno, adminInfo.CurrentOrgId)
  642. // } else {
  643. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  644. // }
  645. // diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  646. //
  647. // doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, hosp.Doctor)
  648. // //deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
  649. // departmentInfo, _ := service.GetDepartMentDetail(hosp.Departments)
  650. //
  651. //
  652. //
  653. //
  654. // var struct2401 service.Struct2401
  655. // struct2401.Insutype = "390"
  656. // psn_info, _ := service.GetPsnByPatientId(patient.ID)
  657. // if id_card_type == 1 {
  658. // struct2401.MdtrtCertType = "03"
  659. // bas := strings.Split(psn_info.CardInfo, "|")
  660. // cardNumber := bas[2]
  661. // struct2401.MdtrtCertNo = cardNumber
  662. // struct2401.PsnNo = order.PsnNo
  663. // } else if id_card_type == 4 {
  664. // struct2401.MdtrtCertType = "01"
  665. // struct2401.MdtrtCertNo = psn_info.VerifyNumber
  666. // struct2401.PsnNo = psn_info.PsnNo
  667. // } else {
  668. // struct2401.MdtrtCertType = "02"
  669. // struct2401.MdtrtCertNo = hosp.Certno
  670. // struct2401.PsnNo = hosp.PsnNo
  671. // }
  672. //
  673. // struct2401.IptNo = "2023061415103410808113442"
  674. // struct2401.AtddrNo = doctorInfo.DoctorNumber
  675. // struct2401.ChfpdrName = doctorInfo.UserName
  676. // struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
  677. // struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  678. // struct2401.AdmDeptName = departmentInfo.Name
  679. // struct2401.AdmBed = ""
  680. // struct2401.AdmBed = "待定"
  681. //
  682. // struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
  683. // struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
  684. // struct2401.Begntime = "2023"
  685. // struct2401.DiseCodg = sickConfig.CountryCode
  686. // struct2401.DiseName = sickConfig.ClassName
  687. //
  688. // }
  689. func (c *ZHHisApiController) GetCardStatus() {
  690. //patient_id, _ := c.GetInt64("patient_id")
  691. //record_date, _ := c.GetInt64("record_date")
  692. //psn, _ := service.GetPsnByPatientIdtWO(patient_id,record_date)
  693. //if len(psn.VerifyNumber) > 0{
  694. // c.ServeSuccessJSON(map[string]interface{}{
  695. // "msg": "读卡成功",
  696. // })
  697. //} else{
  698. // c.ServeSuccessJSON(map[string]interface{}{
  699. // "msg": "",
  700. // })
  701. //}
  702. }
  703. func (c *ZHHisApiController) GetEleInfo() {
  704. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  705. var respJSON map[string]interface{}
  706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  708. return
  709. }
  710. token := respJSON["token"].(string)
  711. respJSON = respJSON["result"].(map[string]interface{})
  712. result_byte, _ := json.Marshal(respJSON)
  713. result := string(result_byte)
  714. fmt.Println("token")
  715. fmt.Println(token)
  716. fmt.Println("result")
  717. fmt.Println(result)
  718. var res ResultTwo
  719. var res10265 ResultTwo10265 //1101结果
  720. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  721. utils.ErrorLog("解析失败:%v", err)
  722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  723. return
  724. }
  725. res.ErrMsg = res10265.ErrMsg
  726. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  727. res.Infcode = infocode
  728. res.Output = res10265.Output
  729. res.InfRefmsgid = res10265.InfRefmsgid
  730. if res.Infcode == 0 {
  731. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  732. if err == gorm.ErrRecordNotFound {
  733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  734. return
  735. } else if err != nil {
  736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  737. return
  738. } else {
  739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  741. infoStr := string(Iinfos)
  742. idetinfoStr := string(Idetinfos)
  743. psn := &models.HisPsn{
  744. PsnNo: res.Output.Baseinfo.PsnNo,
  745. Age: res.Output.Baseinfo.Age,
  746. PatientId: patient.ID,
  747. Certno: res.Output.Baseinfo.Certno,
  748. Gend: res.Output.Baseinfo.Gend,
  749. Naty: res.Output.Baseinfo.Naty,
  750. PsnCertType: res.Output.Baseinfo.PsnCertType,
  751. PsnName: res.Output.Baseinfo.PsnName,
  752. Idetinfo: idetinfoStr,
  753. Insuinfo: infoStr,
  754. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  755. CardInfo: "",
  756. VerifyNumber: token,
  757. }
  758. service.CreateHisPsn(psn)
  759. c.ServeSuccessJSON(map[string]interface{}{
  760. "patient": patient,
  761. "number": token,
  762. })
  763. }
  764. } else {
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  766. return
  767. }
  768. }
  769. func (c *ZHHisApiController) GetToken() {
  770. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  771. var respJSON map[string]interface{}
  772. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  774. return
  775. }
  776. token := respJSON["token"].(string)
  777. id_card_no := respJSON["id_card_no"].(string)
  778. fmt.Println("token")
  779. fmt.Println(token)
  780. fmt.Println("result")
  781. fmt.Println(id_card_no)
  782. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  783. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  784. var api string
  785. api = "http://172.16.13.254:9532/" + "api/eleinfo?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName +
  786. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&token=" + token + "&user_name=" + patient.Name + "&id_card_no=" + patient.IdCardNo
  787. resp, requestErr := http.Get(api)
  788. if requestErr != nil {
  789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  790. return
  791. }
  792. body, ioErr := ioutil.ReadAll(resp.Body)
  793. if ioErr != nil {
  794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  796. return
  797. }
  798. c.ServeSuccessJSON(map[string]interface{}{
  799. "msg": "读卡成功",
  800. })
  801. }
  802. func (c *ZHHisApiController) UploadLingBao() {
  803. id, _ := c.GetInt64("id")
  804. record_time := c.GetString("record_time")
  805. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  806. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  807. admin_user_id, _ := c.GetInt64("admin_user_id")
  808. timeLayout := "2006-01-02"
  809. loc, _ := time.LoadLocation("Local")
  810. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  811. if err != nil {
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  813. return
  814. }
  815. recordDateTime := theTime.Unix()
  816. adminUser := c.GetAdminUserInfo()
  817. var prescriptions []*models.HisPrescription
  818. data := make(map[string]interface{})
  819. if settle_accounts_type == 1 { //日结
  820. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  821. } else { //月结
  822. start_time_str := c.GetString("start_time")
  823. end_time_str := c.GetString("end_time")
  824. timeLayout := "2006-01-02"
  825. loc, _ := time.LoadLocation("Local")
  826. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  827. if err != nil {
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  829. return
  830. }
  831. recordStartTime := theStartTime.Unix()
  832. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  833. if err != nil {
  834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  835. return
  836. }
  837. recordEndTime := theEndTime.Unix()
  838. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  839. }
  840. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  841. record, _ := service.GetInHospitalRecord(in_hospital_id)
  842. if record.ID == 0 {
  843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  844. return
  845. }
  846. timestamp := time.Now().Unix()
  847. tempTime := time.Unix(timestamp, 0)
  848. timeFormat := tempTime.Format("20060102150405")
  849. chrgBchno := rand.Intn(100000) + 10000
  850. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
  851. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  852. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  853. department, _ := service.GetDepartMentDetail(record.Departments)
  854. strconv.FormatInt(record.PatientId, 10)
  855. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, record.Doctor)
  856. //client := &http.Client{}
  857. data["psn_no"] = record.PsnNo
  858. data["mdtrt_id"] = record.Number
  859. data["chrg_bchno"] = chrg_bchno
  860. data["org_name"] = miConfig.OrgName
  861. data["doctor"] = roles.UserName
  862. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  863. data["dept"] = strconv.FormatInt(department.ID, 10)
  864. data["fixmedins_code"] = miConfig.Code
  865. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  866. data["dept_code"] = "15"
  867. } else {
  868. data["dept_code"] = department.Number
  869. }
  870. if miConfig.Code == "H15049901371" {
  871. if record.MedType == 14 {
  872. if record.InsutypeType == "390" {
  873. data["med_type"] = "9933"
  874. } else if record.InsutypeType == "310" {
  875. data["med_type"] = "990502"
  876. }
  877. } else if record.MedType == 11 {
  878. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  879. }
  880. } else {
  881. if record.MedType == 1112 {
  882. data["med_type"] = strconv.FormatInt(11, 10)
  883. } else {
  884. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  885. }
  886. }
  887. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  888. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  889. data["secret_key"] = miConfig.SecretKey
  890. var ids []int64
  891. fmt.Println(data)
  892. for _, item := range prescriptions {
  893. ids = append(ids, item.ID)
  894. }
  895. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  896. if config.IsOpen == 1 { //对接了医保,走医保流程
  897. var pagesize int = 100
  898. var start int = 1
  899. var stop int
  900. var pagecount int
  901. var curpage int
  902. var isSuccess bool = true
  903. var customs []*models.NewCustom
  904. for _, item := range prescriptions {
  905. tm := time.Unix(item.PreTime, 0)
  906. if item.Type == 1 { //药品
  907. for _, subItem := range item.HisDoctorAdviceInfo {
  908. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  909. //var randNum int
  910. //randNum = rand.Intn(10000) + 1000
  911. cus := &models.NewCustom{
  912. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  913. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  914. FeedetlSn: subItem.FeedetlSn,
  915. Price: fmt.Sprintf("%.4f", subItem.Price),
  916. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  917. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  918. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  919. }
  920. customs = append(customs, cus)
  921. }
  922. }
  923. }
  924. if item.Type == 2 { //项目
  925. for _, subItem := range item.HisPrescriptionProject {
  926. //var randNum int
  927. //randNum = rand.Intn(10000) + 1000
  928. if subItem.Type == 2 {
  929. if len(subItem.HisProject.MedicalCode) > 0 {
  930. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  931. cus := &models.NewCustom{
  932. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  933. Cut: fmt.Sprintf("%.4f", cnt),
  934. FeedetlSn: subItem.FeedetlSn,
  935. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  936. MedListCodg: subItem.HisProject.MedicalCode,
  937. HospApprFlag: -1,
  938. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  939. }
  940. customs = append(customs, cus)
  941. }
  942. } else if subItem.Type == 3 {
  943. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
  944. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  945. cus := &models.NewCustom{
  946. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  947. Cut: fmt.Sprintf("%.4f", cnt),
  948. FeedetlSn: subItem.FeedetlSn,
  949. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  950. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  951. HospApprFlag: -1,
  952. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  953. }
  954. customs = append(customs, cus)
  955. }
  956. }
  957. }
  958. }
  959. }
  960. //总页数,向上取整,注意除之前要先转换类型为float64
  961. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  962. var ress []*ResultFour
  963. for curpage = 1; curpage <= pagecount; curpage++ {
  964. if curpage == 1 {
  965. start = 1
  966. } else {
  967. start = (curpage-1)*pagesize + 1
  968. }
  969. stop = curpage * pagesize
  970. if stop > len(customs) {
  971. stop = len(customs)
  972. }
  973. var result string
  974. var requestLog string
  975. if miConfig.MdtrtareaAdmvs == "150499" {
  976. data := make(map[string]interface{})
  977. if record.MedType == 14 {
  978. if record.InsutypeType == "390" {
  979. data["med_type"] = "9933"
  980. } else if record.InsutypeType == "310" {
  981. data["med_type"] = "990502"
  982. }
  983. } else if record.MedType == 11 {
  984. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  985. }
  986. data["psn_no"] = record.PsnNo
  987. data["number"] = record.Number
  988. data["customs"] = customs[start-1 : stop]
  989. data["chrg_bchno"] = chrg_bchno
  990. data["dept"] = strconv.FormatInt(department.ID, 10)
  991. data["dept_code"] = department.Number
  992. data["doctor_code"] = doctor_info.DoctorNumber
  993. data["doctor_name"] = doctor_info.UserName
  994. data["org_name"] = miConfig.OrgName
  995. data["opertor"] = roles.UserName
  996. data["fixmedins_code"] = miConfig.Code
  997. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  998. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  999. data["secret_key"] = miConfig.SecretKey
  1000. var req *http.Request
  1001. bytesData, _ := json.Marshal(data)
  1002. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2301", bytes.NewReader(bytesData))
  1003. client := &http.Client{}
  1004. resp, _ := client.Do(req)
  1005. defer resp.Body.Close()
  1006. body, ioErr := ioutil.ReadAll(resp.Body)
  1007. if ioErr != nil {
  1008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. var respJSON map[string]interface{}
  1013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1019. result_byte, _ := json.Marshal(respJSON)
  1020. result = string(result_byte)
  1021. } else {
  1022. result, requestLog = service.ZHGdyb2301(record.PsnNo, record.Number, customs[start-1:stop], chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(department.ID, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["med_type"].(string), doctor_info.DoctorNumber, doctor_info.UserName)
  1023. saveLog(result, requestLog, "2301", "上传明细")
  1024. }
  1025. var dat map[string]interface{}
  1026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1027. fmt.Println(dat)
  1028. } else {
  1029. fmt.Println(err)
  1030. }
  1031. userJSONBytes, _ := json.Marshal(dat)
  1032. var res ResultFour
  1033. var resFour10265 ResultFour10265
  1034. if miConfig.Code == "H15049901371" {
  1035. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  1036. utils.ErrorLog("解析失败:%v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. res.WarnMsg = resFour10265.WarnMsg
  1041. res.Output = resFour10265.Output
  1042. res.ErrMsg = resFour10265.ErrMsg
  1043. res.RespondTime = resFour10265.RespondTime
  1044. res.InfRefmsgid = resFour10265.InfRefmsgid
  1045. Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  1046. res.Infcode = Infcode
  1047. } else {
  1048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1049. utils.ErrorLog("解析失败:%v", err)
  1050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1051. return
  1052. }
  1053. }
  1054. if res.Infcode == 0 {
  1055. ress = append(ress, &res)
  1056. } else {
  1057. isSuccess = false
  1058. errlog := &models.HisOrderError{
  1059. UserOrgId: adminUser.CurrentOrgId,
  1060. Ctime: time.Now().Unix(),
  1061. Mtime: time.Now().Unix(),
  1062. Number: chrg_bchno,
  1063. ErrMsg: "",
  1064. Status: 1,
  1065. PatientId: id,
  1066. RecordTime: recordDateTime,
  1067. Stage: 4,
  1068. }
  1069. service.CreateErrMsgLog(errlog)
  1070. c.ServeSuccessJSON(map[string]interface{}{
  1071. "failed_code": -10,
  1072. "msg": "上传明细错误,请联系his厂商",
  1073. })
  1074. return
  1075. }
  1076. }
  1077. if isSuccess == true {
  1078. if settle_accounts_type == 1 {
  1079. for _, subItem := range ress {
  1080. for _, item := range subItem.Output.Result {
  1081. temp := strings.Split(item.FeedetlSn, "-")
  1082. var advice_id int64 = 0
  1083. var project_id int64 = 0
  1084. var types int64 = 0
  1085. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1086. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1087. if temp[1] == "1" {
  1088. advice_id = id
  1089. project_id = 0
  1090. } else if temp[1] == "2" {
  1091. advice_id = 0
  1092. project_id = id
  1093. }
  1094. info := &models.HisOrderInfo{
  1095. OrderNumber: record.Number,
  1096. FeedetlSn: item.FeedetlSn,
  1097. UploadDate: recordDateTime,
  1098. AdviceId: advice_id,
  1099. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1100. Cnt: item.Cnt,
  1101. Pric: float64(item.Pric),
  1102. PatientId: record.PatientId,
  1103. PricUplmtAmt: item.PricUplmtAmt,
  1104. SelfpayProp: item.SelfpayProp,
  1105. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1106. OverlmtAmt: item.OverlmtAmt,
  1107. PreselfpayAmt: item.PreselfpayAmt,
  1108. BasMednFlag: item.BasMednFlag,
  1109. MedChrgitmType: item.MedChrgitmType,
  1110. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1111. Status: 1,
  1112. Memo: item.Memo,
  1113. Mtime: time.Now().Unix(),
  1114. InscpScpAmt: item.InscpScpAmt,
  1115. DrtReimFlag: item.DrtReimFlag,
  1116. Ctime: time.Now().Unix(),
  1117. ListSpItemFlag: item.ListSpItemFlag,
  1118. ChldMedcFlag: item.ChldMedcFlag,
  1119. LmtUsedFlag: item.LmtUsedFlag,
  1120. ChrgitmLv: item.ChrgitmLv,
  1121. UserOrgId: adminUser.CurrentOrgId,
  1122. HisPatientId: record.ID,
  1123. OrderId: 0,
  1124. ProjectId: project_id,
  1125. Type: types,
  1126. SettleType: settle_accounts_type,
  1127. }
  1128. service.CreateOrderInfo(info)
  1129. }
  1130. }
  1131. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1132. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1133. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1134. if err == nil {
  1135. c.ServeSuccessJSON(map[string]interface{}{
  1136. "msg": "上传费用明细成功",
  1137. })
  1138. return
  1139. } else {
  1140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1141. return
  1142. }
  1143. } else {
  1144. for _, subItem := range ress {
  1145. for _, item := range subItem.Output.Result {
  1146. temp := strings.Split(item.FeedetlSn, "-")
  1147. var advice_id int64 = 0
  1148. var project_id int64 = 0
  1149. var types int64 = 0
  1150. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1151. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1152. if temp[1] == "1" {
  1153. advice_id = id
  1154. project_id = 0
  1155. } else if temp[1] == "2" {
  1156. advice_id = 0
  1157. project_id = id
  1158. }
  1159. info := &models.HisOrderInfo{
  1160. OrderNumber: record.Number,
  1161. FeedetlSn: item.FeedetlSn,
  1162. UploadDate: time.Now().Unix(),
  1163. AdviceId: advice_id,
  1164. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1165. Cnt: item.Cnt,
  1166. Pric: float64(item.Pric),
  1167. PatientId: record.PatientId,
  1168. PricUplmtAmt: item.PricUplmtAmt,
  1169. SelfpayProp: item.SelfpayProp,
  1170. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1171. OverlmtAmt: item.OverlmtAmt,
  1172. PreselfpayAmt: item.PreselfpayAmt,
  1173. BasMednFlag: item.BasMednFlag,
  1174. MedChrgitmType: item.MedChrgitmType,
  1175. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1176. Status: 1,
  1177. Memo: item.Memo,
  1178. Mtime: time.Now().Unix(),
  1179. InscpScpAmt: item.InscpScpAmt,
  1180. DrtReimFlag: item.DrtReimFlag,
  1181. Ctime: time.Now().Unix(),
  1182. ListSpItemFlag: item.ListSpItemFlag,
  1183. ChldMedcFlag: item.ChldMedcFlag,
  1184. LmtUsedFlag: item.LmtUsedFlag,
  1185. ChrgitmLv: item.ChrgitmLv,
  1186. UserOrgId: adminUser.CurrentOrgId,
  1187. HisPatientId: record.ID,
  1188. ProjectId: project_id,
  1189. Type: types,
  1190. SettleType: settle_accounts_type,
  1191. }
  1192. service.CreateOrderInfo(info)
  1193. }
  1194. }
  1195. service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1196. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1197. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1198. c.ServeSuccessJSON(map[string]interface{}{
  1199. "msg": "上传费用明细成功",
  1200. })
  1201. }
  1202. }
  1203. }
  1204. }
  1205. func (c *ZHHisApiController) RefundLingBao() {
  1206. }
  1207. func (c *ZHHisApiController) GetLingBao() {
  1208. }
  1209. func (c *ZHHisApiController) ReadEleCard() {
  1210. id_card_type, _ := c.GetInt64("id_card_type")
  1211. admin_user_id, _ := c.GetInt64("admin_user_id")
  1212. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1214. var api string
  1215. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1216. "&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
  1217. fmt.Println(api)
  1218. resp, requestErr := http.Get(api)
  1219. if requestErr != nil {
  1220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1221. return
  1222. }
  1223. body, ioErr := ioutil.ReadAll(resp.Body)
  1224. if ioErr != nil {
  1225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1227. return
  1228. }
  1229. var respJSON map[string]interface{}
  1230. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1233. return
  1234. }
  1235. var status string
  1236. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1237. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1238. var token string
  1239. var res ResultTwo //1101结果
  1240. var res10265 ResultTwo10265 //1101结果
  1241. if status == "0" { //读卡成功
  1242. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1243. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1244. result, _ := json.Marshal(respJSON)
  1245. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1246. utils.ErrorLog("解析失败:%v", err)
  1247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1248. return
  1249. }
  1250. res.ErrMsg = res10265.ErrMsg
  1251. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1252. res.Infcode = infocode
  1253. res.Output = res10265.Output
  1254. res.InfRefmsgid = res10265.InfRefmsgid
  1255. if res.Infcode == 0 {
  1256. c.ServeSuccessJSON(map[string]interface{}{
  1257. "number": token,
  1258. })
  1259. }
  1260. } else {
  1261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1262. return
  1263. }
  1264. }
  1265. func (c *ZHHisApiController) ClearSettle() {
  1266. order_id, _ := c.GetInt64("order_id")
  1267. admin_user_id, _ := c.GetInt64("admin_user_id")
  1268. adminUser := c.GetAdminUserInfo()
  1269. var order models.HisOrder
  1270. order, _ = service.GetHisOrderByID(order_id)
  1271. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1272. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1273. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1274. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1275. if miConfig.MdtrtareaAdmvs == "350500" {
  1276. record, _ := service.GetUploadRecord(order_id)
  1277. record.Status = 0
  1278. service.UpdateRecord(&record)
  1279. c.ServeSuccessJSON(map[string]interface{}{
  1280. "msg": "撤销成功",
  1281. })
  1282. } else {
  1283. if config.IsOpen == 1 { //对接了医保,走医保流程
  1284. var result string
  1285. var requestLog string
  1286. result, requestLog = service.Gdyb90306(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1287. saveLog(result, requestLog, "90306", "撤销结算清单")
  1288. var dat map[string]interface{}
  1289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1290. fmt.Println(dat)
  1291. } else {
  1292. fmt.Println(err)
  1293. }
  1294. userJSONBytes, _ := json.Marshal(dat)
  1295. var res ResultSix
  1296. //var resSixteen ResultSixteen10265
  1297. if miConfig.Code == "H15049901371" {
  1298. //if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  1299. // utils.ErrorLog("解析失败:%v", err)
  1300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1301. // return
  1302. //}
  1303. //res.Cainfo = resSixteen.Cainfo
  1304. //res.WarnMsg = resSixteen.WarnMsg
  1305. //res.Output = resSixteen.Output
  1306. //res.ErrMsg = resSixteen.ErrMsg
  1307. //res.RespondTime = resSixteen.RespondTime
  1308. //Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  1309. //res.Infcode = Infcode
  1310. } else {
  1311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1312. utils.ErrorLog("解析失败:%v", err)
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1314. return
  1315. }
  1316. }
  1317. if res.Infcode == 0 {
  1318. record, _ := service.GetUploadRecord(order_id)
  1319. record.Status = 0
  1320. service.UpdateRecord(&record)
  1321. c.ServeSuccessJSON(map[string]interface{}{
  1322. "msg": "撤销成功",
  1323. })
  1324. } else {
  1325. c.ServeSuccessJSON(map[string]interface{}{
  1326. "code": -10,
  1327. "msg": res.ErrMsg,
  1328. })
  1329. }
  1330. }
  1331. }
  1332. }
  1333. func (c *ZHHisApiController) GetZHPatientInfo() {
  1334. id_card_no := c.GetString("id_card_no")
  1335. admin_user_id, _ := c.GetInt64("admin_user_id")
  1336. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1337. if patient.ID == 0 {
  1338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1339. return
  1340. }
  1341. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1342. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1343. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  1344. if config.IsOpen == 1 {
  1345. var result string
  1346. var request_log string
  1347. var result_log string
  1348. if miConfig.MdtrtareaAdmvs == "150499" {
  1349. var insuplc_admdvs string
  1350. if len(patient.InsuplcAdmdvs) > 0 {
  1351. insuplc_admdvs = patient.InsuplcAdmdvs
  1352. } else {
  1353. insuplc_admdvs = miConfig.InsuplcAdmdvs
  1354. }
  1355. //请求内网数据
  1356. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  1357. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  1358. "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
  1359. resp, requestErr := http.Get(api)
  1360. if requestErr != nil {
  1361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1362. return
  1363. }
  1364. body, ioErr := ioutil.ReadAll(resp.Body)
  1365. if ioErr != nil {
  1366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. var respJSON map[string]interface{}
  1371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1377. result_byte, _ := json.Marshal(respJSON)
  1378. result = string(result_byte)
  1379. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  1380. } else if miConfig.MdtrtareaAdmvs == "360399" || miConfig.MdtrtareaAdmvs == "361025" {
  1381. result, request_log = service.JxybZY1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 0, miConfig.Url, miConfig.AccessKey, patient.Name, patient.IdCardNo, patient.Name)
  1382. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  1383. }else if miConfig.MdtrtareaAdmvs == "341203"{
  1384. var insuplc_admdvs string
  1385. if len(patient.InsuplcAdmdvs) > 0 {
  1386. insuplc_admdvs = patient.InsuplcAdmdvs
  1387. } else {
  1388. insuplc_admdvs = miConfig.InsuplcAdmdvs
  1389. }
  1390. //请求内网数据
  1391. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  1392. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  1393. "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name+"&token="+""
  1394. resp, requestErr := http.Get(api)
  1395. if requestErr != nil {
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. return
  1398. }
  1399. body, ioErr := ioutil.ReadAll(resp.Body)
  1400. if ioErr != nil {
  1401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1403. return
  1404. }
  1405. var respJSON map[string]interface{}
  1406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1409. return
  1410. }
  1411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  1412. if status == "0"{
  1413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  1414. c.ServeSuccessJSON(map[string]interface{}{
  1415. "failed_code": -10,
  1416. "msg": err_msg,
  1417. })
  1418. return
  1419. }
  1420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1421. result_byte, _ := json.Marshal(respJSON)
  1422. result = string(result_byte)
  1423. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  1424. }else if miConfig.MdtrtareaAdmvs == "340699"{
  1425. var insuplc_admdvs string
  1426. if len(patient.InsuplcAdmdvs) > 0 {
  1427. insuplc_admdvs = patient.InsuplcAdmdvs
  1428. } else {
  1429. insuplc_admdvs = miConfig.InsuplcAdmdvs
  1430. }
  1431. //请求内网数据
  1432. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  1433. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  1434. "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name+"&token="+""
  1435. resp, requestErr := http.Get(api)
  1436. if requestErr != nil {
  1437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1438. return
  1439. }
  1440. body, ioErr := ioutil.ReadAll(resp.Body)
  1441. if ioErr != nil {
  1442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1444. return
  1445. }
  1446. var respJSON map[string]interface{}
  1447. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. status := respJSON["data"].(map[string]interface{})["status"].(string)
  1453. if status == "0"{
  1454. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  1455. c.ServeSuccessJSON(map[string]interface{}{
  1456. "failed_code": -10,
  1457. "msg": err_msg,
  1458. })
  1459. return
  1460. }
  1461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1462. result_byte, _ := json.Marshal(respJSON)
  1463. result = string(result_byte)
  1464. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  1465. } else {
  1466. var insuplc_admdvs string
  1467. if len(patient.InsuplcAdmdvs) > 0 {
  1468. insuplc_admdvs = patient.InsuplcAdmdvs
  1469. } else {
  1470. insuplc_admdvs = miConfig.InsuplcAdmdvs
  1471. }
  1472. result, request_log, result_log = service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, "",admin_user_id)
  1473. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  1474. }
  1475. //result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  1476. var dat map[string]interface{}
  1477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1478. fmt.Println(dat)
  1479. } else {
  1480. fmt.Println(err)
  1481. }
  1482. userJSONBytes, _ := json.Marshal(dat)
  1483. var res ResultTwo
  1484. var resTwo10265 ResultTwo10265
  1485. if miConfig.Code == "H15049901371" {
  1486. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  1487. utils.ErrorLog("解析失败:%v", err)
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1489. return
  1490. }
  1491. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  1492. res.Infcode = Infcode
  1493. res.ErrMsg = resTwo10265.ErrMsg
  1494. res.Output = resTwo10265.Output
  1495. res.InfRefmsgid = resTwo10265.InfRefmsgid
  1496. res.RespondTime = resTwo10265.RespondTime
  1497. res.WarnInfo = resTwo10265.WarnInfo
  1498. }else if miConfig.MdtrtareaAdmvs == "441799" {
  1499. //请求内网数据
  1500. api := miConfig.Url + "gdyb/1101?cert_no=" + patient.IdCardNo +
  1501. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  1502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
  1503. resp, requestErr := http.Get(api)
  1504. if requestErr != nil {
  1505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1506. return
  1507. }
  1508. body, ioErr := ioutil.ReadAll(resp.Body)
  1509. if ioErr != nil {
  1510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1512. return
  1513. }
  1514. var respJSON map[string]interface{}
  1515. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1518. return
  1519. }
  1520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1521. result_byte, _ := json.Marshal(respJSON)
  1522. result = string(result_byte)
  1523. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  1524. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1525. utils.ErrorLog("解析失败:%v", err)
  1526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1527. return
  1528. }
  1529. } else if miConfig.MdtrtareaAdmvs == "450721"{
  1530. c.ServeSuccessJSON(map[string]interface{}{
  1531. "msg": "",
  1532. })
  1533. } else {
  1534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1535. utils.ErrorLog("解析失败:%v", err)
  1536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1537. return
  1538. }
  1539. }
  1540. var insutypes []string
  1541. var insutype string
  1542. var is390 int = 0
  1543. var is310 int = 0
  1544. for _, item := range res.Output.Iinfo {
  1545. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1546. insutypes = append(insutypes, item.Insutype)
  1547. }
  1548. }
  1549. if len(insutypes) == 1 {
  1550. insutype = insutypes[0]
  1551. } else {
  1552. for _, i := range insutypes {
  1553. if i == "390" {
  1554. is390 = 1
  1555. }
  1556. if i == "310" {
  1557. is310 = 1
  1558. }
  1559. }
  1560. }
  1561. if is390 == 1 {
  1562. insutype = "390"
  1563. }
  1564. if is310 == 1 {
  1565. insutype = "310"
  1566. }
  1567. if len(insutypes) == 0 {
  1568. insutype = "310"
  1569. }
  1570. var InsuplcAdmdvs string
  1571. for _, item := range res.Output.Iinfo {
  1572. utils.ErrorLog("解析失败:%v", item.Insutype)
  1573. utils.ErrorLog("解析失败:%v", insutype)
  1574. if item.Insutype == insutype {
  1575. InsuplcAdmdvs = item.InsuplcAdmdvs
  1576. }
  1577. }
  1578. utils.ErrorLog("解析失败:%v", InsuplcAdmdvs)
  1579. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1580. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1581. infoStr := string(Iinfos)
  1582. idetinfoStr := string(Idetinfos)
  1583. psn := &models.HisPsn{
  1584. PsnNo: res.Output.Baseinfo.PsnNo,
  1585. Age: res.Output.Baseinfo.Age,
  1586. PatientId: patient.ID,
  1587. Certno: res.Output.Baseinfo.Certno,
  1588. Gend: res.Output.Baseinfo.Gend,
  1589. Naty: res.Output.Baseinfo.Naty,
  1590. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1591. PsnName: res.Output.Baseinfo.PsnName,
  1592. Idetinfo: idetinfoStr,
  1593. Insuinfo: infoStr,
  1594. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1595. VerifyNumber: "",
  1596. InsuplcAdmdvs: InsuplcAdmdvs,
  1597. }
  1598. service.CreateHisPsn(psn)
  1599. if res.Infcode == -1 {
  1600. c.ServeSuccessJSON(map[string]interface{}{
  1601. "failed_code": -10,
  1602. "msg": res.ErrMsg,
  1603. })
  1604. } else {
  1605. c.ServeSuccessJSON(map[string]interface{}{
  1606. "failed_code": 0,
  1607. "info": res,
  1608. "insutype": insutype,
  1609. })
  1610. }
  1611. }
  1612. }
  1613. func (c *ZHHisApiController) GetZHInHospitalCheck() {
  1614. id, _ := c.GetInt64("id")
  1615. record_time := c.GetString("record_time")
  1616. name := c.GetString("name")
  1617. phone := c.GetString("phone")
  1618. id_card_type, _ := c.GetInt64("id_card_type")
  1619. certificates, _ := c.GetInt64("certificates")
  1620. id_card_no := c.GetString("id_card_no")
  1621. doctor, _ := c.GetInt64("doctor")
  1622. admin_user_id, _ := c.GetInt64("admin_user_id")
  1623. department, _ := c.GetInt64("department")
  1624. adm_bed, _ := c.GetInt64("adm_bed")
  1625. diagnosis_ids := c.GetString("diagnosis")
  1626. sick_type, _ := c.GetInt64("sick_type")
  1627. start_time := c.GetString("start_time")
  1628. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1629. balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
  1630. social_type, _ := c.GetInt64("social_type")
  1631. psn_type, _ := c.GetInt64("psn_type")
  1632. //reg_type, _ := c.GetInt64("p_type")
  1633. med_type, _ := c.GetInt64("med_type")
  1634. diagnosis_ids_arr := strings.Split(diagnosis_ids, "-")
  1635. timeLayout := "2006-01-02"
  1636. loc, _ := time.LoadLocation("Local")
  1637. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1638. if err != nil {
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1640. return
  1641. }
  1642. recordDateTime := theTime.Unix()
  1643. adminInfo := c.GetAdminUserInfo()
  1644. record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
  1645. if record.ID != 0 {
  1646. if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
  1647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
  1648. return
  1649. }
  1650. }
  1651. var patient service.Patients
  1652. if id == 0 {
  1653. patient, _ = service.GetPatientByIDCard(id_card_no, adminInfo.CurrentOrgId)
  1654. } else {
  1655. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  1656. }
  1657. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  1658. sickConfig, _ := service.FindSickById(sick_type)
  1659. departmentInfo, _ := service.GetDepartMentDetail(department)
  1660. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1661. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1662. var result string
  1663. var request_log string
  1664. var result_log string
  1665. var res2 ResultTwo
  1666. var resTwo10265 ResultTwo10265
  1667. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  1668. if miConfig.MdtrtareaAdmvs == "150499" {
  1669. if id_card_type == 2 {
  1670. mdtrt_cert_no := ""
  1671. mdtrt_cert_no = id_card_no
  1672. //请求内网数据
  1673. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + mdtrt_cert_no +
  1674. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  1675. "&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) + "&name=" + patient.Name
  1676. resp, requestErr := http.Get(api)
  1677. if requestErr != nil {
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. return
  1680. }
  1681. body, ioErr := ioutil.ReadAll(resp.Body)
  1682. if ioErr != nil {
  1683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1685. return
  1686. }
  1687. var respJSON map[string]interface{}
  1688. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1691. return
  1692. }
  1693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1694. result_byte, _ := json.Marshal(respJSON)
  1695. result = string(result_byte)
  1696. var dat map[string]interface{}
  1697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1698. fmt.Println(dat)
  1699. } else {
  1700. fmt.Println(err)
  1701. }
  1702. userJSONBytes, _ := json.Marshal(dat)
  1703. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  1704. utils.ErrorLog("解析失败:%v", err)
  1705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1706. return
  1707. }
  1708. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  1709. res2.Infcode = Infcode
  1710. res2.ErrMsg = resTwo10265.ErrMsg
  1711. res2.Output = resTwo10265.Output
  1712. res2.InfRefmsgid = resTwo10265.InfRefmsgid
  1713. res2.RespondTime = resTwo10265.RespondTime
  1714. res2.WarnInfo = resTwo10265.WarnInfo
  1715. } else {
  1716. res2.Infcode = 0
  1717. res2.Output.Baseinfo.PsnNo = psn_info.PsnNo
  1718. res2.Output.Baseinfo.Certno = patient.IdCardNo
  1719. }
  1720. } else if miConfig.MdtrtareaAdmvs == "421182" {
  1721. res2.Infcode = 0
  1722. res2.Output.Baseinfo.PsnNo = psn_info.PsnNo
  1723. res2.Output.Baseinfo.Certno = patient.IdCardNo
  1724. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1725. //res2.Infcode = 0
  1726. //res2.Output.Baseinfo.PsnNo = psn_info.PsnNo
  1727. //res2.Output.Baseinfo.Certno = patient.IdCardNo
  1728. //result, request_log = service.JxybZY1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, ca, certificates, miConfig.Url, miConfig.AccessKey, "", patient.IdCardNo, "")
  1729. if id_card_type == 1{
  1730. bas := strings.Split(psn_info.CardInfo, "|")
  1731. cardNumber := bas[3]
  1732. result, request_log = service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, cardNumber, "1", miConfig.Url, miConfig.AccessKey, "")
  1733. saveLog(result, request_log, "1101", "人员基本信息获取")
  1734. }else{
  1735. cardNumber := psn_info.VerifyNumber
  1736. result, request_log = service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, cardNumber, "1", miConfig.Url, miConfig.AccessKey, psn_info.PsnName)
  1737. saveLog(result, request_log, "1101", "人员基本信息获取")
  1738. }
  1739. } else {
  1740. result, request_log, result_log = service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates, name,admin_user_id)
  1741. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  1742. }
  1743. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  1744. deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
  1745. if miConfig.MdtrtareaAdmvs != "150499" && miConfig.MdtrtareaAdmvs != "421182" {
  1746. var dat map[string]interface{}
  1747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1748. fmt.Println(dat)
  1749. } else {
  1750. fmt.Println(err)
  1751. }
  1752. userJSONBytes, _ := json.Marshal(dat)
  1753. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1754. utils.ErrorLog("解析失败:%v", err)
  1755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1756. return
  1757. }
  1758. }
  1759. var infoStr string
  1760. if miConfig.MdtrtareaAdmvs == "150499" {
  1761. if id_card_type == 2 {
  1762. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  1763. infoStr = string(Iinfos)
  1764. } else {
  1765. infoStr = psn_info.Insuinfo
  1766. }
  1767. } else if miConfig.MdtrtareaAdmvs == "421182" {
  1768. infoStr = psn_info.Insuinfo
  1769. } else {
  1770. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  1771. infoStr = string(Iinfos)
  1772. }
  1773. var rf []*ResultFive
  1774. json.Unmarshal([]byte(infoStr), &rf)
  1775. var insutypes []*ResultFive
  1776. var insutype string
  1777. var is390 int = 0
  1778. var is310 int = 0
  1779. for _, item := range rf {
  1780. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1781. insutypes = append(insutypes, item)
  1782. }
  1783. }
  1784. if len(insutypes) == 1 {
  1785. insutype = insutypes[0].Insutype
  1786. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1787. } else {
  1788. for _, i := range insutypes {
  1789. if i.Insutype == "390" {
  1790. is390 = 1
  1791. }
  1792. if i.Insutype == "310" {
  1793. is310 = 1
  1794. }
  1795. }
  1796. }
  1797. if is390 == 1 {
  1798. insutype = "390"
  1799. }
  1800. if is310 == 1 {
  1801. insutype = "310"
  1802. }
  1803. if len(insutypes) == 0 {
  1804. insutype = "310"
  1805. }
  1806. if len(insutypes) == 2 {
  1807. insutype = strconv.FormatInt(social_type, 10)
  1808. }
  1809. //for _, item := range rf {
  1810. // if item.Insutype == insutype {
  1811. // insuplc_admdvs = item.InsuplcAdmdvs
  1812. // }
  1813. //}
  1814. if res2.Infcode == 0 {
  1815. //var insutypes []string
  1816. //
  1817. //var insutype string
  1818. //var is390 int = 0
  1819. //var is310 int = 0
  1820. //for _, item := range res2.Output.Iinfo {
  1821. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1822. // insutypes = append(insutypes, item.Insutype)
  1823. // }
  1824. //}
  1825. //if len(insutypes) == 1 {
  1826. // insutype = insutypes[0]
  1827. //} else {
  1828. // for _, i := range insutypes {
  1829. // if i == "390" {
  1830. // is390 = 1
  1831. // }
  1832. //
  1833. // if i == "310" {
  1834. // is310 = 1
  1835. // }
  1836. // }
  1837. //}
  1838. //if is390 == 1 {
  1839. // insutype = "390"
  1840. //}
  1841. //if is310 == 1 {
  1842. // insutype = "310"
  1843. //}
  1844. //
  1845. //if len(insutypes) == 0 {
  1846. // insutype = "310"
  1847. //}
  1848. if len(insuplc_admdvs) == 0 {
  1849. insuplc_admdvs = miConfig.InsuplcAdmdvs
  1850. }
  1851. timestamp := time.Now().Unix()
  1852. tempTime := time.Unix(timestamp, 0)
  1853. timeFormat := tempTime.Format("20060102150405")
  1854. chrgBchno := rand.Intn(100000) + 10000
  1855. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
  1856. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1857. var struct2401 service.Struct2401
  1858. //insutype = "310"
  1859. struct2401.Insutype = insutype
  1860. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  1861. if id_card_type == 1 {
  1862. struct2401.MdtrtCertType = "03"
  1863. bas := strings.Split(psn_info.CardInfo, "|")
  1864. cardNumber := bas[2]
  1865. struct2401.MdtrtCertNo = cardNumber
  1866. struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
  1867. } else if id_card_type == 4 {
  1868. struct2401.MdtrtCertType = "01"
  1869. struct2401.MdtrtCertNo = psn_info.VerifyNumber
  1870. struct2401.PsnNo = psn_info.PsnNo
  1871. } else {
  1872. struct2401.MdtrtCertType = "02"
  1873. struct2401.MdtrtCertNo = id_card_no
  1874. struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
  1875. }
  1876. if miConfig.Code == "H15049901371" {
  1877. if med_type == 14 {
  1878. if insutype == "390" {
  1879. struct2401.MedType = "9933"
  1880. } else if insutype == "310" {
  1881. struct2401.MedType = "990502"
  1882. }
  1883. } else if med_type == 11 {
  1884. struct2401.MedType = "21"
  1885. }
  1886. } else {
  1887. if med_type == 11 {
  1888. struct2401.MedType = "21"
  1889. med_type = 21
  1890. } else {
  1891. struct2401.MedType = strconv.FormatInt(int64(med_type), 10)
  1892. }
  1893. }
  1894. struct2401.IptNo = ipt_otp_no
  1895. struct2401.AtddrNo = doctorInfo.DoctorNumber
  1896. struct2401.ChfpdrName = doctorInfo.UserName
  1897. struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
  1898. struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  1899. struct2401.AdmDeptName = departmentInfo.Name
  1900. struct2401.AdmBed = deviceNumber.Number
  1901. struct2401.AdmBed = "待定"
  1902. struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
  1903. struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
  1904. struct2401.Begntime = start_time
  1905. struct2401.DiseCodg = sickConfig.CountryCode
  1906. struct2401.DiseName = sickConfig.ClassName
  1907. var dises []service.DiseinfoStruct
  1908. for index, item := range diagnosisConfig {
  1909. var dise service.DiseinfoStruct
  1910. if id_card_type == 4 || id_card_type == 1 {
  1911. dise.PsnNo = psn_info.PsnNo
  1912. } else {
  1913. dise.PsnNo = res2.Output.Baseinfo.PsnNo
  1914. }
  1915. dise.DiagType = "1"
  1916. if index == 0 {
  1917. dise.MaindiagFlag = "1"
  1918. } else {
  1919. dise.MaindiagFlag = "2"
  1920. }
  1921. dise.DiagSrtNo = strconv.FormatInt(int64(index), 10)
  1922. dise.DiseDorName = doctorInfo.UserName
  1923. dise.DiagCode = item.CountryCode
  1924. dise.DiagName = item.ClassName
  1925. dise.DiagDept = departmentInfo.Name
  1926. dise.DiseDorNo = doctorInfo.DoctorNumber
  1927. dise.DiagTime = timeFormatOne
  1928. dises = append(dises, dise)
  1929. }
  1930. struct2401.Diseinfo = dises
  1931. var result string
  1932. var request_log string
  1933. if miConfig.MdtrtareaAdmvs == "150499" {
  1934. data := make(map[string]interface{})
  1935. data["org_name"] = miConfig.OrgName
  1936. data["doctor"] = role.UserName
  1937. data["fixmedins_code"] = miConfig.Code
  1938. data["insuplc_admdvs"] = insuplc_admdvs
  1939. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1940. data["secret_key"] = miConfig.SecretKey
  1941. data["struct_2401"] = struct2401
  1942. var req *http.Request
  1943. bytesData, _ := json.Marshal(data)
  1944. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2401", bytes.NewReader(bytesData))
  1945. client := &http.Client{}
  1946. resp, _ := client.Do(req)
  1947. defer resp.Body.Close()
  1948. body, ioErr := ioutil.ReadAll(resp.Body)
  1949. if ioErr != nil {
  1950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1952. return
  1953. }
  1954. var respJSON map[string]interface{}
  1955. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1958. return
  1959. }
  1960. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1961. result_byte, _ := json.Marshal(respJSON)
  1962. result = string(result_byte)
  1963. } else if miConfig.MdtrtareaAdmvs == "421182" {
  1964. data := make(map[string]interface{})
  1965. data["org_name"] = miConfig.OrgName
  1966. data["doctor"] = role.UserName
  1967. data["fixmedins_code"] = miConfig.Code
  1968. data["insuplc_admdvs"] = insuplc_admdvs
  1969. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1970. data["secret_key"] = miConfig.SecretKey
  1971. data["struct_2401"] = struct2401
  1972. var req *http.Request
  1973. bytesData, _ := json.Marshal(data)
  1974. req, _ = http.NewRequest("POST", miConfig.Url +"hbyb/2401", bytes.NewReader(bytesData))
  1975. client := &http.Client{}
  1976. resp, _ := client.Do(req)
  1977. defer resp.Body.Close()
  1978. body, ioErr := ioutil.ReadAll(resp.Body)
  1979. if ioErr != nil {
  1980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1982. return
  1983. }
  1984. var respJSON map[string]interface{}
  1985. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1988. return
  1989. }
  1990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1991. //result, _ := json.Marshal(respJSON)
  1992. //result = string(result_byte)
  1993. //decoder := simplifiedchinese.GBK.NewDecoder()
  1994. result_byte, _ := json.Marshal(respJSON)
  1995. result = string(result_byte)
  1996. //enc := mahonia.NewEncoder("gbk")
  1997. //result = enc.ConvertString(string(result_byte))
  1998. fmt.Println(string(result)) // 输出:中文
  1999. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2000. if !strings.Contains(insuplc_admdvs, "3603") {
  2001. if id_card_type == 1 {
  2002. bas := strings.Split(psn_info.CardInfo, "|")
  2003. card_sn := bas[3]
  2004. card_no := bas[1]
  2005. struct2401.Cardsn = card_sn
  2006. struct2401.PsnCertType = "01"
  2007. struct2401.Certno = card_no
  2008. struct2401.PsnType = psn_type
  2009. struct2401.PsnName = patient.Name
  2010. }
  2011. }
  2012. result, request_log = service.Jxyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  2013. saveLog(result, request_log, "2401", "入院登记")
  2014. } else {
  2015. //住院登记调用事前
  2016. //var hisPrescription []*models.HisPrescription
  2017. //res3101 := Check3101ForOne(c, patient.ID, struct2401, admin_user_id, "3", record_time, hisPrescription, res2, recordDateTime)
  2018. var res3101 Result3101
  2019. res3101.Infcode = 0
  2020. if res3101.Infcode == 0 {
  2021. result, request_log = service.ZHGdyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs)
  2022. saveLog(result, request_log, "2401", "入院登记")
  2023. } else {
  2024. c.ServeSuccessJSON(map[string]interface{}{
  2025. "failed_code": -10,
  2026. "msg": res3101.ErrMsg,
  2027. })
  2028. return
  2029. }
  2030. }
  2031. var dat map[string]interface{}
  2032. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2033. fmt.Println(dat)
  2034. } else {
  2035. fmt.Println(err)
  2036. }
  2037. userJSONBytes, _ := json.Marshal(dat)
  2038. var res ResultThree
  2039. var resThree10265 ResultThree10265
  2040. if miConfig.Code == "H15049901371" {
  2041. if err := json.Unmarshal(userJSONBytes, &resThree10265); err != nil {
  2042. utils.ErrorLog("解析失败:%v", err)
  2043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2044. return
  2045. }
  2046. Infcode, _ := strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2047. res.Infcode = Infcode
  2048. res.ErrMsg = resThree10265.ErrMsg
  2049. res.Output = resThree10265.Output
  2050. res.InfRefmsgid = resThree10265.InfRefmsgid
  2051. res.RespondTime = resThree10265.RespondTime
  2052. } else {
  2053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2054. utils.ErrorLog("解析失败:%v", err)
  2055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2056. return
  2057. }
  2058. }
  2059. if res.Infcode == 0 {
  2060. //result2 := service.Gdyb5301Two(res2.Output.Baseinfo.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2061. //fmt.Println(result2)
  2062. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  2063. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  2064. infoStr := string(Iinfos)
  2065. idetinfoStr := string(Idetinfos)
  2066. inHospital := &models.HisHospitalCheckRecord{
  2067. PatientId: id,
  2068. Name: name,
  2069. MedicalTreatmentType: med_type,
  2070. RecordDate: recordDateTime,
  2071. IdCardNo: id_card_no,
  2072. AdminUserId: admin_user_id,
  2073. Departments: department,
  2074. UserOrgId: adminInfo.CurrentOrgId,
  2075. Status: 1,
  2076. Ctime: time.Now().Unix(),
  2077. Mtime: time.Now().Unix(),
  2078. Number: res.Output.Result.MdtrtID,
  2079. Doctor: doctor,
  2080. PsnNo: res2.Output.Baseinfo.PsnNo,
  2081. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  2082. Certno: res2.Output.Baseinfo.Certno,
  2083. PsnName: res2.Output.Baseinfo.PsnName,
  2084. Gend: res2.Output.Baseinfo.Gend,
  2085. Naty: res2.Output.Baseinfo.Naty,
  2086. MedType: med_type,
  2087. InsutypeType: insutype,
  2088. Iinfo: infoStr,
  2089. Idetinfo: idetinfoStr,
  2090. IptOtpNo: ipt_otp_no,
  2091. AdmBed: adm_bed,
  2092. IdCardType: id_card_type,
  2093. Diagnosis: diagnosis_ids,
  2094. SickType: sick_type,
  2095. MdtrtCertType: "02",
  2096. InHosptialTime: start_time,
  2097. OutHosptialTime: "",
  2098. InHospitalStatus: 1,
  2099. Certificates: certificates,
  2100. Phone: phone,
  2101. BalanceAccountsType: balance_accounts_type,
  2102. PsnType: psn_type,
  2103. InsuplcAdmdvs: insuplc_admdvs,
  2104. }
  2105. service.CreateHospitalRecord(inHospital)
  2106. c.ServeSuccessJSON(map[string]interface{}{
  2107. "msg": "办理入院成功",
  2108. "info": inHospital,
  2109. })
  2110. } else {
  2111. c.ServeSuccessJSON(map[string]interface{}{
  2112. "failed_code": -10,
  2113. "msg": res.ErrMsg,
  2114. })
  2115. }
  2116. } else {
  2117. c.ServeSuccessJSON(map[string]interface{}{
  2118. "failed_code": -10,
  2119. "msg": res2.ErrMsg,
  2120. })
  2121. return
  2122. }
  2123. }
  2124. func (this *ZHHisApiController) GetZHOutHospitalCheck() {
  2125. id, _ := this.GetInt64("id")
  2126. patient_id, _ := this.GetInt64("patient_id")
  2127. admin_user_id, _ := this.GetInt64("admin_user_id")
  2128. record_time := this.GetString("record_time")
  2129. out_time := this.GetString("out_time")
  2130. adminInfo := this.GetAdminUserInfo()
  2131. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2132. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2133. //service.getpre
  2134. record, _ := service.GetInHospitalRecord(id)
  2135. if record.ID == 0 {
  2136. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  2137. return
  2138. }
  2139. infos, _ := service.FindLastPatientPrescriptionInfoTwo2(this.GetAdminUserInfo().CurrentOrgId, patient_id, strings.Split(record.InHosptialTime, " ")[0], strings.Split(out_time, " ")[0])
  2140. timeLayout := "2006-01-02"
  2141. loc, _ := time.LoadLocation("Local")
  2142. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2143. if err != nil {
  2144. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2145. return
  2146. }
  2147. recordDateTime := theTime.Unix()
  2148. //var patient service.Patients
  2149. //if patient_id == 0 {
  2150. // patient, _ = service.GetPatientByIDCard(record.IdCardNo, adminInfo.CurrentOrgId)
  2151. //} else {
  2152. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2153. //}
  2154. for _, item := range infos {
  2155. record.Diagnosis = record.Diagnosis + "," + item.Diagnosis
  2156. }
  2157. diagnosis_ids_arr := strings.Split(record.Diagnosis, ",")
  2158. fmt.Println(diagnosis_ids_arr)
  2159. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  2160. fmt.Println(diagnosis_ids_arr)
  2161. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  2162. departmentInfo, _ := service.GetDepartMentDetail(record.Departments)
  2163. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, record.Doctor)
  2164. //deviceNumber, _ := service.GetDeviceNumberByID(record.AdmBed, adminInfo.CurrentOrgId)
  2165. sickConfig, _ := service.FindSickById(record.SickType)
  2166. var struct2402 service.Struct2402
  2167. timestamp := time.Now().Unix()
  2168. tempTime := time.Unix(timestamp, 0)
  2169. //timeFormat := tempTime.Format("20060102150405")
  2170. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2171. struct2402.PsnNo = record.PsnNo
  2172. struct2402.Insutype = record.InsutypeType
  2173. struct2402.DscgWay = "1"
  2174. struct2402.Endtime = out_time
  2175. struct2402.DscgDeptName = departmentInfo.Number
  2176. struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  2177. struct2402.MdtrtId = record.Number
  2178. var dises []service.Diseinfo2402Struct
  2179. for index, item := range diagnosisConfig {
  2180. var dise service.Diseinfo2402Struct
  2181. dise.PsnNo = record.PsnNo
  2182. if index == 0 {
  2183. dise.DiagType = "1"
  2184. dise.MaindiagFlag = "1"
  2185. } else {
  2186. dise.DiagType = "1"
  2187. dise.MaindiagFlag = "0"
  2188. }
  2189. dise.MdtrtId = record.Number
  2190. dise.DiagSrtNo = strconv.FormatInt(int64(index), 10)
  2191. dise.DiseDorName = doctorInfo.UserName
  2192. dise.DiagCode = item.CountryCode
  2193. dise.DiagName = item.ClassName
  2194. dise.DiagDept = departmentInfo.Name
  2195. dise.DiseDorNo = doctorInfo.DoctorNumber
  2196. dise.DiagTime = timeFormatOne
  2197. dises = append(dises, dise)
  2198. }
  2199. struct2402.Diseinfo = dises
  2200. struct2402.DiseName = sickConfig.ClassName
  2201. struct2402.DiseCode = sickConfig.CountryCode
  2202. var result string
  2203. var request_log string
  2204. if miConfig.MdtrtareaAdmvs == "150499" {
  2205. data := make(map[string]interface{})
  2206. data["org_name"] = miConfig.OrgName
  2207. data["doctor"] = role.UserName
  2208. data["fixmedins_code"] = miConfig.Code
  2209. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  2210. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2211. data["secret_key"] = miConfig.SecretKey
  2212. data["struct_2402"] = struct2402
  2213. var req *http.Request
  2214. bytesData, _ := json.Marshal(data)
  2215. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2402", bytes.NewReader(bytesData))
  2216. client := &http.Client{}
  2217. resp, _ := client.Do(req)
  2218. defer resp.Body.Close()
  2219. body, ioErr := ioutil.ReadAll(resp.Body)
  2220. if ioErr != nil {
  2221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2222. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2223. return
  2224. }
  2225. var respJSON map[string]interface{}
  2226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2228. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2229. return
  2230. }
  2231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2232. result_byte, _ := json.Marshal(respJSON)
  2233. result = string(result_byte)
  2234. } else if miConfig.MdtrtareaAdmvs == "421182" {
  2235. data := make(map[string]interface{})
  2236. data["org_name"] = miConfig.OrgName
  2237. data["doctor"] = role.UserName
  2238. data["fixmedins_code"] = miConfig.Code
  2239. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  2240. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2241. data["secret_key"] = miConfig.SecretKey
  2242. data["struct_2402"] = struct2402
  2243. var req *http.Request
  2244. bytesData, _ := json.Marshal(data)
  2245. req, _ = http.NewRequest("POST", miConfig.Url +"hbyb/2402", bytes.NewReader(bytesData))
  2246. client := &http.Client{}
  2247. resp, _ := client.Do(req)
  2248. defer resp.Body.Close()
  2249. body, ioErr := ioutil.ReadAll(resp.Body)
  2250. if ioErr != nil {
  2251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2252. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2253. return
  2254. }
  2255. var respJSON map[string]interface{}
  2256. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2258. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2259. return
  2260. }
  2261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2262. result_byte, _ := json.Marshal(respJSON)
  2263. result = string(result_byte)
  2264. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2265. result, request_log = service.Jxyb2402(struct2402, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  2266. saveLog(result, request_log, "2402", "出院")
  2267. } else {
  2268. result, request_log = service.ZHGdyb2402(struct2402, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  2269. saveLog(result, request_log, "2402", "出院")
  2270. }
  2271. var dat map[string]interface{}
  2272. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2273. fmt.Println(dat)
  2274. } else {
  2275. fmt.Println(err)
  2276. }
  2277. userJSONBytes, _ := json.Marshal(dat)
  2278. var res ResultEmpty
  2279. var resEmpty10265 ResultEmpty10265
  2280. if miConfig.Code == "H15049901371" {
  2281. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  2282. utils.ErrorLog("解析失败:%v", err)
  2283. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2284. return
  2285. }
  2286. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2287. res.Infcode = Infcode
  2288. res.RespondTime = resEmpty10265.RespondTime
  2289. res.ErrMsg = resEmpty10265.ErrMsg
  2290. res.Output = resEmpty10265.Output
  2291. res.WarnMsg = resEmpty10265.WarnMsg
  2292. } else {
  2293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2294. utils.ErrorLog("解析失败:%v", err)
  2295. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2296. return
  2297. }
  2298. }
  2299. if res.Infcode == 0 {
  2300. record.OutHospitalStatus = 1
  2301. record.OutHosptialTime = struct2402.Endtime
  2302. record.OutWay = 1
  2303. service.CreateHospitalRecord(&record)
  2304. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  2305. var total float64
  2306. for _, item := range orders {
  2307. total = total + item.DetItemFeeSumamt
  2308. }
  2309. order := &models.HisOrder{
  2310. UserOrgId: adminInfo.CurrentOrgId,
  2311. HisPatientId: record.ID,
  2312. PatientId: record.PatientId,
  2313. SettleAccountsDate: recordDateTime,
  2314. Ctime: time.Now().Unix(),
  2315. Mtime: time.Now().Unix(),
  2316. Status: 1,
  2317. Number: record.Number,
  2318. Infcode: 0,
  2319. WarnMsg: "",
  2320. Cainfo: "",
  2321. ErrMsg: "",
  2322. RespondTime: "",
  2323. InfRefmsgid: "",
  2324. OrderStatus: 1,
  2325. MdtrtId: record.Number,
  2326. IsMedicineInsurance: 1,
  2327. PType: 1,
  2328. MedfeeSumamt: total,
  2329. }
  2330. err = service.CreateOrder(order)
  2331. if err != nil {
  2332. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2333. return
  2334. }
  2335. this.ServeSuccessJSON(map[string]interface{}{
  2336. "msg": "出院成功",
  2337. })
  2338. } else {
  2339. this.ServeSuccessJSON(map[string]interface{}{
  2340. "failed_code": -10,
  2341. "msg": res.ErrMsg,
  2342. })
  2343. }
  2344. }
  2345. func (c *ZHHisApiController) Get4102() {
  2346. order_id, _ := c.GetInt64("order_id")
  2347. admin_user_id, _ := c.GetInt64("admin_user_id")
  2348. stas_type := c.GetString("stas_type")
  2349. adminUser := c.GetAdminUserInfo()
  2350. order, _ := service.GetHisOrderByID(order_id)
  2351. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2352. var user_name string
  2353. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2354. if role.ID == 0 {
  2355. user_name = "管理员"
  2356. } else {
  2357. user_name = role.UserName
  2358. }
  2359. baseParams := models.BaseParams{
  2360. SecretKey: miConfig.SecretKey,
  2361. FixmedinsCode: miConfig.Code,
  2362. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  2363. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  2364. OrgName: miConfig.OrgName,
  2365. Doctor: user_name,
  2366. RequestUrl: miConfig.Url,
  2367. AccessKey: miConfig.AccessKey,
  2368. }
  2369. businessParams := models.BusinessParams{
  2370. PsnNo: order.PsnNo,
  2371. MdtrtId: order.MdtrtId,
  2372. SetlId: order.SetlId,
  2373. StasType: stas_type,
  2374. }
  2375. api := "http://172.16.13.254:9532/" + "nmyb/4102?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  2376. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  2377. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&stas_type=" + stas_type
  2378. resp, requestErr := http.Get(api)
  2379. if requestErr != nil {
  2380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2381. return
  2382. }
  2383. body, ioErr := ioutil.ReadAll(resp.Body)
  2384. if ioErr != nil {
  2385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2387. return
  2388. }
  2389. var respJSON map[string]interface{}
  2390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2393. return
  2394. }
  2395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2396. result, _ := json.Marshal(respJSON)
  2397. fmt.Println("log")
  2398. fmt.Println(string(result))
  2399. var res2 ResultSix
  2400. var resEmpty10265 ResultEmpty10265
  2401. if err := json.Unmarshal(result, &resEmpty10265); err != nil {
  2402. utils.ErrorLog("解析失败:%v", err)
  2403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2404. return
  2405. }
  2406. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2407. res2.Infcode = Infcode
  2408. res2.RespondTime = resEmpty10265.RespondTime
  2409. res2.ErrMsg = resEmpty10265.ErrMsg
  2410. res2.Output = resEmpty10265.Output
  2411. res2.WarnMsg = resEmpty10265.WarnMsg
  2412. if res2.Infcode == 0 {
  2413. c.ServeSuccessJSON(map[string]interface{}{
  2414. "msg": "确认成功",
  2415. })
  2416. } else {
  2417. c.ServeSuccessJSON(map[string]interface{}{
  2418. "failed_code": -10,
  2419. "msg": res2.ErrMsg,
  2420. })
  2421. }
  2422. }
  2423. func (c *ZHHisApiController) Get4103() {
  2424. order_id, _ := c.GetInt64("order_id")
  2425. admin_user_id, _ := c.GetInt64("admin_user_id")
  2426. stas_type := c.GetString("stas_type")
  2427. adminUser := c.GetAdminUserInfo()
  2428. order, _ := service.GetHisOrderByID(order_id)
  2429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2430. var user_name string
  2431. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2432. if role.ID == 0 {
  2433. user_name = "管理员"
  2434. } else {
  2435. user_name = role.UserName
  2436. }
  2437. baseParams := models.BaseParams{
  2438. SecretKey: miConfig.SecretKey,
  2439. FixmedinsCode: miConfig.Code,
  2440. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  2441. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  2442. OrgName: miConfig.OrgName,
  2443. Doctor: user_name,
  2444. RequestUrl: miConfig.Url,
  2445. AccessKey: miConfig.AccessKey,
  2446. }
  2447. businessParams := models.BusinessParams{
  2448. PsnNo: order.PsnNo,
  2449. MdtrtId: order.MdtrtId,
  2450. SetlId: order.SetlId,
  2451. StasType: stas_type,
  2452. }
  2453. api := "http://172.16.13.254:9532/" + "nmyb/4103?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  2454. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  2455. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&stas_type=" + stas_type
  2456. resp, requestErr := http.Get(api)
  2457. if requestErr != nil {
  2458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2459. return
  2460. }
  2461. body, ioErr := ioutil.ReadAll(resp.Body)
  2462. if ioErr != nil {
  2463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2465. return
  2466. }
  2467. var respJSON map[string]interface{}
  2468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2471. return
  2472. }
  2473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2474. result, _ := json.Marshal(respJSON)
  2475. fmt.Println("log")
  2476. fmt.Println(string(result))
  2477. var res2 ResultSix
  2478. var resEmpty10265 ResultEmpty10265
  2479. if err := json.Unmarshal(result, &resEmpty10265); err != nil {
  2480. utils.ErrorLog("解析失败:%v", err)
  2481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2482. return
  2483. }
  2484. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2485. res2.Infcode = Infcode
  2486. res2.RespondTime = resEmpty10265.RespondTime
  2487. res2.ErrMsg = resEmpty10265.ErrMsg
  2488. res2.Output = resEmpty10265.Output
  2489. res2.WarnMsg = resEmpty10265.WarnMsg
  2490. if res2.Infcode == 0 {
  2491. c.ServeSuccessJSON(map[string]interface{}{
  2492. "msg": string(result),
  2493. })
  2494. } else {
  2495. c.ServeSuccessJSON(map[string]interface{}{
  2496. "failed_code": -10,
  2497. "msg": res2.ErrMsg,
  2498. })
  2499. }
  2500. }
  2501. //func (c *ZHHisApiController) Get4104() {
  2502. // order_id, _ := c.GetInt64("order_id")
  2503. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2504. // adminUser := c.GetAdminUserInfo()
  2505. // order, _ := service.GetHisOrderByID(order_id)
  2506. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2507. // var user_name string
  2508. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2509. // if role.ID == 0 {
  2510. // user_name = "管理员"
  2511. // } else {
  2512. // user_name = role.UserName
  2513. // }
  2514. // baseParams := models.BaseParams{
  2515. // SecretKey: miConfig.SecretKey,
  2516. // FixmedinsCode: miConfig.Code,
  2517. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  2518. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  2519. // OrgName: miConfig.OrgName,
  2520. // Doctor: user_name,
  2521. // RequestUrl: miConfig.Url,
  2522. // AccessKey: miConfig.AccessKey,
  2523. // }
  2524. //
  2525. // businessParams := models.BusinessParams{
  2526. // PsnNo: order.PsnNo,
  2527. // MdtrtId: order.MdtrtId,
  2528. // SetlId: order.SetlId,
  2529. // }
  2530. //
  2531. // api := "http://172.16.13.254:9532/" + "nmyb/4104?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  2532. // "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  2533. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&stas_type=" + stas_type
  2534. // resp, requestErr := http.Get(api)
  2535. // if requestErr != nil {
  2536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2537. // return
  2538. // }
  2539. // body, ioErr := ioutil.ReadAll(resp.Body)
  2540. // if ioErr != nil {
  2541. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2543. // return
  2544. // }
  2545. // var respJSON map[string]interface{}
  2546. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2547. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2549. // return
  2550. // }
  2551. //
  2552. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2553. // result, _ := json.Marshal(respJSON)
  2554. // fmt.Println("log")
  2555. // fmt.Println(string(result))
  2556. //
  2557. // var res2 ResultSix
  2558. // var resEmpty10265 ResultEmpty10265
  2559. //
  2560. // if err := json.Unmarshal(result, &resEmpty10265); err != nil {
  2561. // utils.ErrorLog("解析失败:%v", err)
  2562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2563. // return
  2564. // }
  2565. // Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2566. // res2.Infcode = Infcode
  2567. // res2.RespondTime = resEmpty10265.RespondTime
  2568. // res2.ErrMsg = resEmpty10265.ErrMsg
  2569. // res2.Output = resEmpty10265.Output
  2570. // res2.WarnMsg = resEmpty10265.WarnMsg
  2571. //
  2572. // if res2.Infcode == 0 {
  2573. // c.ServeSuccessJSON(map[string]interface{}{
  2574. // "msg": "确认成功",
  2575. // })
  2576. //
  2577. // } else {
  2578. // c.ServeSuccessJSON(map[string]interface{}{
  2579. // "failed_code": -10,
  2580. // "msg": res2.ErrMsg,
  2581. // })
  2582. //
  2583. // }
  2584. //
  2585. //}
  2586. func (c *ZHHisApiController) GetSettleInfo() {
  2587. order_id, _ := c.GetInt64("order_id")
  2588. patient_id, _ := c.GetInt64("patient_id")
  2589. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  2590. admin_user_id, _ := c.GetInt64("admin_user_id")
  2591. pay_way, _ := c.GetInt64("pay_way")
  2592. pay_price, _ := c.GetFloat("pay_price")
  2593. pay_card_no := c.GetString("pay_card_no")
  2594. discount_price, _ := c.GetFloat("discount_price")
  2595. preferential_price, _ := c.GetFloat("preferential_price")
  2596. reality_price, _ := c.GetFloat("reality_price")
  2597. found_price, _ := c.GetFloat("found_price")
  2598. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2599. private_price, _ := c.GetFloat("private_price")
  2600. fapiao_code := c.GetString("fapiao_code")
  2601. fapiao_number := c.GetString("fapiao_number")
  2602. record, _ := service.GetInHospitalRecord(in_hospital_id)
  2603. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2604. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2605. order, _ := service.GetHisOrderByID(order_id)
  2606. //dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  2607. //tmp_decimal := c.GetString("tmp_decimal")
  2608. //var decimal float64 //本次使用的押金
  2609. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  2610. tmp_decimal := c.GetString("tmp_decimal")
  2611. var decimal float64 //本次使用的押金
  2612. var errmsg error
  2613. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  2614. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  2615. return
  2616. }
  2617. if len(tmp_decimal) > 0 {
  2618. if tmp_decimal[0] == 45 {
  2619. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  2620. return
  2621. }
  2622. }
  2623. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  2624. if errs != nil {
  2625. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
  2626. return
  2627. }
  2628. decimal = tt
  2629. var rf []*ResultFive
  2630. json.Unmarshal([]byte(record.Iinfo), &rf)
  2631. chrg_bchno := order.Number
  2632. cert_no := record.Certno
  2633. if record.ID == 0 {
  2634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2635. return
  2636. }
  2637. if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  2638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  2639. return
  2640. }
  2641. if record.IdCardType == 1 {
  2642. } else {
  2643. cert_no = record.Certno
  2644. }
  2645. var result string
  2646. var src_resquest string
  2647. timeLayout := "2006-01-02"
  2648. loc, _ := time.LoadLocation("Local")
  2649. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record.InHosptialTime, loc)
  2650. if err != nil {
  2651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2652. return
  2653. }
  2654. recordStartDateTime := theTime.Unix()
  2655. theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", record.OutHosptialTime, loc)
  2656. if err != nil {
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2658. return
  2659. }
  2660. recordEndDateTime := theTimeEnd.Unix()
  2661. prescriptions, _ := service.GetZHSettleMonthHisPrescription(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordStartDateTime, recordEndDateTime)
  2662. var total float64
  2663. for _, item := range prescriptions {
  2664. if item.Type == 1 { //药品
  2665. for _, subItem := range item.HisDoctorAdviceInfo {
  2666. total = total + (subItem.Price * subItem.PrescribingNumber)
  2667. }
  2668. }
  2669. if item.Type == 2 { //项目
  2670. for _, subItem := range item.HisPrescriptionProject {
  2671. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2672. total = total + (subItem.Price * cnt)
  2673. }
  2674. }
  2675. }
  2676. //allTotal := fmt.Sprintf("%.2f", total)
  2677. var allTotal string
  2678. if record.OutHospitalStatus == 0 && order.ID == 0 {
  2679. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  2680. var total float64
  2681. for _, item := range orders {
  2682. total = total + item.DetItemFeeSumamt
  2683. }
  2684. allTotal = fmt.Sprintf("%.4f", total)
  2685. } else {
  2686. allTotal = fmt.Sprintf("%.4f", order.MedfeeSumamt)
  2687. }
  2688. if miConfig.MdtrtareaAdmvs == "150499" {
  2689. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2690. mdtrt_cert_no := ""
  2691. if record.IdCardType == 1 {
  2692. bas := strings.Split(psn_info.CardInfo, "|")
  2693. cardNumber := bas[2]
  2694. mdtrt_cert_no = cardNumber
  2695. } else {
  2696. mdtrt_cert_no = record.Certno
  2697. }
  2698. var acct_used_flag string
  2699. if pay_way == 4 {
  2700. acct_used_flag = "1"
  2701. } else {
  2702. acct_used_flag = "0"
  2703. }
  2704. if pay_way == 6 {
  2705. mdtrt_cert_no = psn_info.VerifyNumber
  2706. acct_used_flag = "1"
  2707. record.IdCardType = 4
  2708. } else {
  2709. acct_used_flag = "0"
  2710. }
  2711. fmt.Println(mdtrt_cert_no)
  2712. fmt.Println(acct_used_flag)
  2713. fmt.Println(record.IdCardType)
  2714. //请求内网数据
  2715. api := "http://172.16.13.254:9532/" + "nmyb/2304?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
  2716. "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
  2717. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2718. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + mdtrt_cert_no + "&fapiao_number=" + fapiao_number + "&acct_used_flag=" + acct_used_flag
  2719. resp, requestErr := http.Get(api)
  2720. if requestErr != nil {
  2721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2722. return
  2723. }
  2724. body, ioErr := ioutil.ReadAll(resp.Body)
  2725. if ioErr != nil {
  2726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2728. return
  2729. }
  2730. var respJSON map[string]interface{}
  2731. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2734. return
  2735. }
  2736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2737. result_byte, _ := json.Marshal(respJSON)
  2738. result = string(result_byte)
  2739. } else if miConfig.MdtrtareaAdmvs == "421182" {
  2740. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2741. mdtrt_cert_no := ""
  2742. if record.IdCardType == 1 {
  2743. bas := strings.Split(psn_info.CardInfo, "|")
  2744. cardNumber := bas[2]
  2745. mdtrt_cert_no = cardNumber
  2746. } else {
  2747. mdtrt_cert_no = record.Certno
  2748. }
  2749. var acct_used_flag string
  2750. if pay_way == 4 {
  2751. acct_used_flag = "1"
  2752. } else {
  2753. acct_used_flag = "0"
  2754. }
  2755. if pay_way == 6 {
  2756. mdtrt_cert_no = psn_info.VerifyNumber
  2757. acct_used_flag = "1"
  2758. record.IdCardType = 4
  2759. } else {
  2760. acct_used_flag = "0"
  2761. }
  2762. fmt.Println(mdtrt_cert_no)
  2763. fmt.Println(acct_used_flag)
  2764. fmt.Println(record.IdCardType)
  2765. //请求内网数据
  2766. api := miConfig.Url + "hbyb/2304?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
  2767. "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
  2768. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2769. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + mdtrt_cert_no + "&fapiao_number=" + fapiao_number + "&acct_used_flag=" + acct_used_flag
  2770. resp, requestErr := http.Get(api)
  2771. if requestErr != nil {
  2772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2773. return
  2774. }
  2775. body, ioErr := ioutil.ReadAll(resp.Body)
  2776. if ioErr != nil {
  2777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2779. return
  2780. }
  2781. var respJSON map[string]interface{}
  2782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. return
  2786. }
  2787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2788. result_byte, _ := json.Marshal(respJSON)
  2789. result = string(result_byte)
  2790. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2791. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2792. if len(psn_info.CardInfo) > 0 && len(psn_info.VerifyNumber) == 0{
  2793. cert_no = record.Certno
  2794. } else if len(psn_info.CardInfo) == 0 && len(psn_info.VerifyNumber) > 0{
  2795. cert_no = psn_info.VerifyNumber
  2796. }
  2797. //result, src_resquest = service.Jxyb2304(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, "", "1")
  2798. if strings.Contains(record.InsuplcAdmdvs, "3603") {
  2799. bas := strings.Split(psn_info.CardInfo, "|")
  2800. card_sn := bas[3]
  2801. result, src_resquest = service.Jxyb2304(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, "", "1",card_sn,"","","","")
  2802. saveLog(result, src_resquest, "2304", "住院结算")
  2803. //if record.IdCardType == 1 {
  2804. //basNumber := bas[2]
  2805. // result, src_resquest = service.Jxyb2303(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, card_sn, record.PsnType, record.PsnCertType, record.IdCardNo, record.Name)
  2806. // saveLog(result, src_resquest, "2303", "住院预结算")
  2807. //}
  2808. }else{
  2809. bas := strings.Split(psn_info.CardInfo, "|")
  2810. card_sn := bas[3]
  2811. result, src_resquest = service.Jxyb2304a(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, "", "1",card_sn,record.PsnType,record.PsnCertType,record.IdCardNo,record.Name)
  2812. //result, src_resquest = service.Jxyb2303(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey,"",record.PsnType,record.PsnCertType,record.IdCardNo,record.Name)
  2813. saveLog(result, src_resquest, "2303", "住院预结算")
  2814. }
  2815. } else {
  2816. result3101 := Check3102(c, record.PatientId, record.ID, admin_user_id, "8", order.ID)
  2817. if result3101.Infcode == 0 {
  2818. if len(result3101.Output.Result) > 0 {
  2819. var errMsgs []string
  2820. for _, item := range result3101.Output.Result {
  2821. errMsgs = append(errMsgs, item.VolaCont)
  2822. }
  2823. c.ServeSuccessJSON(map[string]interface{}{
  2824. "failed_code": -10,
  2825. "msg": errMsgs,
  2826. })
  2827. return
  2828. } else {
  2829. result, src_resquest = service.ZHGdyb2304(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates, "", "1")
  2830. saveLog(result, src_resquest, "2304", "住院结算")
  2831. }
  2832. } else {
  2833. c.ServeSuccessJSON(map[string]interface{}{
  2834. "failed_code": -10,
  2835. "msg": result3101.ErrMsg,
  2836. })
  2837. return
  2838. }
  2839. }
  2840. var dat map[string]interface{}
  2841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2842. fmt.Println(dat)
  2843. } else {
  2844. fmt.Println(err)
  2845. }
  2846. userJSONBytes, _ := json.Marshal(dat)
  2847. var res ResultSeven
  2848. var resSeven10265 ResultSeven10265
  2849. if miConfig.Code == "H15049901371" {
  2850. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  2851. utils.ErrorLog("解析失败:%v", err)
  2852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2853. return
  2854. }
  2855. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  2856. res.Infcode = Infcode
  2857. res.InfRefmsgid = resSeven10265.InfRefmsgid
  2858. res.RespondTime = resSeven10265.RespondTime
  2859. res.ErrMsg = resSeven10265.ErrMsg
  2860. res.Output = resSeven10265.Output
  2861. res.WarnMsg = resSeven10265.WarnMsg
  2862. res.Cainfo = resSeven10265.Cainfo
  2863. } else {
  2864. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2865. utils.ErrorLog("解析失败:%v", err)
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. return
  2868. }
  2869. }
  2870. if res.Infcode != 0 {
  2871. errlog := &models.HisOrderError{
  2872. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2873. Ctime: time.Now().Unix(),
  2874. Mtime: time.Now().Unix(),
  2875. Number: chrg_bchno,
  2876. ErrMsg: res.ErrMsg,
  2877. Status: 1,
  2878. PatientId: patient_id,
  2879. RecordTime: time.Now().Unix(),
  2880. Stage: 6,
  2881. }
  2882. service.CreateErrMsgLog(errlog)
  2883. c.ServeSuccessJSON(map[string]interface{}{
  2884. "failed_code": -10,
  2885. "msg": res.ErrMsg,
  2886. })
  2887. return
  2888. } else {
  2889. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2890. order.OrderStatus = 2
  2891. order.DiscountPrice = discount_price
  2892. order.MedicalInsurancePrice = medical_insurance_price
  2893. order.FaPiaoNumber = fapiao_number
  2894. order.FaPiaoCode = fapiao_code
  2895. order.PayWay = pay_way
  2896. order.PayPrice = pay_price
  2897. order.PayCardNo = pay_card_no
  2898. order.PreferentialPrice = preferential_price
  2899. order.RealityPrice = reality_price
  2900. order.FoundPrice = found_price
  2901. order.PrivatePrice = private_price
  2902. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2903. order.SetlId = res.Output.Setlinfo.SetlID
  2904. order.PsnNo = res.Output.Setlinfo.PsnNo
  2905. order.PsnName = res.Output.Setlinfo.PsnName
  2906. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2907. order.Certno = res.Output.Setlinfo.Certno
  2908. order.Gend = res.Output.Setlinfo.Gend
  2909. order.Naty = res.Output.Setlinfo.Naty
  2910. order.Age = res.Output.Setlinfo.Age
  2911. order.Insutype = res.Output.Setlinfo.Insutype
  2912. order.PsnType = res.Output.Setlinfo.PsnType
  2913. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2914. order.SetlTime = res.Output.Setlinfo.SetlTime
  2915. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2916. if res.Output.Setlinfo.MedType == "140104" {
  2917. order.MedType = "14"
  2918. } else {
  2919. order.MedType = res.Output.Setlinfo.MedType
  2920. }
  2921. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2922. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2923. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2924. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2925. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2926. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2927. order.HifpPay = res.Output.Setlinfo.HifpPay
  2928. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2929. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2930. order.HifesPay = res.Output.Setlinfo.HifesPay
  2931. order.HifobPay = res.Output.Setlinfo.HifobPay
  2932. order.MafPay = res.Output.Setlinfo.MafPay
  2933. order.OthPay = res.Output.Setlinfo.OthPay
  2934. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2935. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2936. order.AcctPay = res.Output.Setlinfo.AcctPay
  2937. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2938. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2939. order.Balc = res.Output.Setlinfo.Balc
  2940. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2941. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2942. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2943. order.ClrWay = res.Output.Setlinfo.ClrWay
  2944. order.Creator = order.Creator
  2945. order.Modify = roles.AdminUserId
  2946. order.RequestLog = src_resquest
  2947. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2948. detailStr := string(setlDetail)
  2949. order.SetlDetail = detailStr
  2950. err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  2951. err = service.UpDateOrder(order)
  2952. if err == nil {
  2953. //判断是否使用了押金
  2954. if dec_way == "true" {
  2955. tmpstring := strconv.FormatInt(order.ID, 10)
  2956. order.Decimal = decimal
  2957. err = service.UpDateOrder(order)
  2958. //扣押金
  2959. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, patient_id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  2960. if errmsg != nil {
  2961. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  2962. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  2963. return
  2964. }
  2965. }
  2966. c.ServeSuccessJSON(map[string]interface{}{
  2967. "msg": "结算成功",
  2968. })
  2969. } else {
  2970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2971. return
  2972. }
  2973. }
  2974. }
  2975. func (c *ZHHisApiController) GetPreSettleInfo() {
  2976. order_id, _ := c.GetInt64("order_id")
  2977. patient_id, _ := c.GetInt64("patient_id")
  2978. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  2979. admin_user_id, _ := c.GetInt64("admin_user_id")
  2980. record, _ := service.GetInHospitalRecord(in_hospital_id)
  2981. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2982. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2983. order, _ := service.GetHisOrderByID(order_id)
  2984. var allTotal string
  2985. if record.OutHospitalStatus == 0 && order.ID == 0 {
  2986. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  2987. var total float64
  2988. for _, item := range orders {
  2989. total = total + item.DetItemFeeSumamt
  2990. }
  2991. allTotal = fmt.Sprintf("%.2f", total)
  2992. } else {
  2993. allTotal = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2994. }
  2995. var rf []*ResultFive
  2996. json.Unmarshal([]byte(record.Iinfo), &rf)
  2997. chrg_bchno := order.Number
  2998. cert_no := record.Certno
  2999. if record.ID == 0 {
  3000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3001. return
  3002. }
  3003. //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  3004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  3005. // return
  3006. //}
  3007. psn_info, _ := service.GetPsnByPatientId(patient_id)
  3008. if record.IdCardType == 1 {
  3009. bas := strings.Split(psn_info.CardInfo, "|")
  3010. cardNumber := bas[2]
  3011. cert_no = cardNumber
  3012. } else if record.IdCardType == 4 {
  3013. cert_no = psn_info.VerifyNumber
  3014. } else {
  3015. cert_no = record.Certno
  3016. }
  3017. var result string
  3018. var src_resquest string
  3019. if miConfig.MdtrtareaAdmvs == "150499" {
  3020. //请求内网数据
  3021. api := "http://172.16.13.254:9532/" + "nmyb/2303?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
  3022. "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
  3023. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3024. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + cert_no
  3025. resp, requestErr := http.Get(api)
  3026. if requestErr != nil {
  3027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3028. return
  3029. }
  3030. body, ioErr := ioutil.ReadAll(resp.Body)
  3031. if ioErr != nil {
  3032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3034. return
  3035. }
  3036. var respJSON map[string]interface{}
  3037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3040. return
  3041. }
  3042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3043. result_byte, _ := json.Marshal(respJSON)
  3044. result = string(result_byte)
  3045. }else if miConfig.MdtrtareaAdmvs == "421182" {
  3046. //请求内网数据
  3047. api := miConfig.Url + "hbyb/2303?psn_no=" + record.PsnNo + "&mdtrt_id=" + record.Number + "&chrg_bchno=" + chrg_bchno +
  3048. "&insutype_type=" + record.InsutypeType + "&total=" + allTotal +
  3049. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3050. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(record.IdCardType, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(record.Certificates, 10) + "&name=" + record.Name + "&cert_no=" + cert_no
  3051. resp, requestErr := http.Get(api)
  3052. if requestErr != nil {
  3053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3054. return
  3055. }
  3056. body, ioErr := ioutil.ReadAll(resp.Body)
  3057. if ioErr != nil {
  3058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3060. return
  3061. }
  3062. var respJSON map[string]interface{}
  3063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3066. return
  3067. }
  3068. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3069. result_byte, _ := json.Marshal(respJSON)
  3070. result = string(result_byte)
  3071. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3072. if !strings.Contains(record.InsuplcAdmdvs, "3603") {
  3073. if record.IdCardType == 1 {
  3074. bas := strings.Split(psn_info.CardInfo, "|")
  3075. //basNumber := bas[2]
  3076. card_sn := bas[3]
  3077. result, src_resquest = service.Jxyb2303(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey, card_sn, record.PsnType, record.PsnCertType, record.IdCardNo, record.Name)
  3078. saveLog(result, src_resquest, "2303", "住院预结算")
  3079. }
  3080. }else{
  3081. result, src_resquest = service.Jxyb2303(record.PsnNo, record.Number, cert_no, record.InsutypeType, allTotal, record.Certificates, record.IdCardType, "", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey,"",record.PsnType,record.PsnCertType,record.IdCardNo,record.Name)
  3082. saveLog(result, src_resquest, "2303", "住院预结算")
  3083. }
  3084. } else {
  3085. if record.OutHospitalStatus == 1 && order.ID > 0 { //出院的情况下,再去做事中监测
  3086. result3101 := Check3102(c, record.PatientId, record.ID, admin_user_id, "8", order.ID)
  3087. if result3101.Infcode == 0 {
  3088. if len(result3101.Output.Result) > 0 {
  3089. var errMsgs []string
  3090. for _, item := range result3101.Output.Result {
  3091. errMsgs = append(errMsgs, item.VolaCont)
  3092. }
  3093. c.ServeSuccessJSON(map[string]interface{}{
  3094. "failed_code": -10,
  3095. "msg": errMsgs,
  3096. })
  3097. return
  3098. } else {
  3099. result, src_resquest = service.ZHGdyb2303(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
  3100. saveLog(result, src_resquest, "2303", "住院预结算")
  3101. }
  3102. } else {
  3103. c.ServeSuccessJSON(map[string]interface{}{
  3104. "failed_code": -10,
  3105. "msg": result3101.ErrMsg,
  3106. })
  3107. return
  3108. }
  3109. } else {
  3110. result, src_resquest = service.ZHGdyb2303(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
  3111. saveLog(result, src_resquest, "2303", "住院预结算")
  3112. }
  3113. }
  3114. var dat map[string]interface{}
  3115. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3116. fmt.Println(dat)
  3117. } else {
  3118. fmt.Println(err)
  3119. }
  3120. userJSONBytes, _ := json.Marshal(dat)
  3121. var res2 ResultSevenTwo
  3122. var res ResultSeven
  3123. var resSeven10265 ResultSeven10265
  3124. if miConfig.MdtrtareaAdmvs == "360399" {
  3125. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3126. utils.ErrorLog("解析失败:%v", err)
  3127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3128. return
  3129. }
  3130. if res2.Infcode != 0 {
  3131. errlog := &models.HisOrderError{
  3132. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3133. Ctime: time.Now().Unix(),
  3134. Mtime: time.Now().Unix(),
  3135. Number: chrg_bchno,
  3136. ErrMsg: res.ErrMsg,
  3137. Status: 1,
  3138. PatientId: patient_id,
  3139. RecordTime: time.Now().Unix(),
  3140. Stage: 6,
  3141. }
  3142. service.CreateErrMsgLog(errlog)
  3143. c.ServeSuccessJSON(map[string]interface{}{
  3144. "failed_code": -10,
  3145. "msg": res.ErrMsg,
  3146. })
  3147. return
  3148. } else {
  3149. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3150. order.OrderStatus = 1
  3151. order.MdtrtId = res2.Output.Setlinfo.MdtrtID
  3152. order.SetlId = res2.Output.Setlinfo.SetlID
  3153. order.PsnNo = res2.Output.Setlinfo.PsnNo
  3154. order.PsnName = res2.Output.Setlinfo.PsnName
  3155. order.PsnCertType = res2.Output.Setlinfo.PsnCertType
  3156. order.Certno = res2.Output.Setlinfo.Certno
  3157. order.Gend = res2.Output.Setlinfo.Gend
  3158. order.Naty = res2.Output.Setlinfo.Naty
  3159. val, _ := strconv.ParseFloat(res2.Output.Setlinfo.Age, 64)
  3160. order.Age = val
  3161. order.Insutype = res2.Output.Setlinfo.Insutype
  3162. order.PsnType = res2.Output.Setlinfo.PsnType
  3163. order.CvlservFlag = res2.Output.Setlinfo.CvlservFlag
  3164. order.SetlTime = res2.Output.Setlinfo.SetlTime
  3165. order.MdtrtCertType = res2.Output.Setlinfo.MdtrtCertType
  3166. if res.Output.Setlinfo.MedType == "140104" {
  3167. order.MedType = "14"
  3168. } else {
  3169. order.MedType = res2.Output.Setlinfo.MedType
  3170. }
  3171. order.MedfeeSumamt = res2.Output.Setlinfo.MedfeeSumamt
  3172. order.FulamtOwnpayAmt = res2.Output.Setlinfo.FulamtOwnpayAmt
  3173. order.OverlmtSelfPay = res2.Output.Setlinfo.OverlmtSelfpay
  3174. order.PreselfpayAmt = res2.Output.Setlinfo.PreselfpayAmt
  3175. order.InscpScpAmt = res2.Output.Setlinfo.InscpScpAmt
  3176. order.ActPayDedc = res2.Output.Setlinfo.ActPayDedc
  3177. order.HifmiPay = res2.Output.Setlinfo.HifmiPay
  3178. order.HifpPay = res2.Output.Setlinfo.HifpPay
  3179. order.HifesPay = res2.Output.Setlinfo.HifesPay
  3180. order.HifobPay = res2.Output.Setlinfo.HifobPay
  3181. order.MafPay = res2.Output.Setlinfo.MafPay
  3182. order.OthPay = res2.Output.Setlinfo.OthPay
  3183. order.CvlservPay = res2.Output.Setlinfo.CvlservPay
  3184. order.PoolPropSelfpay = res2.Output.Setlinfo.PoolPropSelfpay
  3185. order.FundPaySumamt = res2.Output.Setlinfo.FundPaySumamt
  3186. order.PsnPartAmt = res2.Output.Setlinfo.PsnPartAmt
  3187. order.AcctPay = res2.Output.Setlinfo.AcctPay
  3188. order.PsnCashPay = res2.Output.Setlinfo.PsnCashPay
  3189. order.HospPartAmt = res2.Output.Setlinfo.HospPartAmt
  3190. order.Balc = res2.Output.Setlinfo.Balc
  3191. order.AcctMulaidPay = res2.Output.Setlinfo.AcctMulaidPay
  3192. order.MedinsSetlId = res2.Output.Setlinfo.MedinsSetlID
  3193. order.ClrOptins = res2.Output.Setlinfo.ClrOptins
  3194. order.ClrWay = res2.Output.Setlinfo.ClrWay
  3195. order.Creator = order.Creator
  3196. order.Modify = roles.AdminUserId
  3197. order.RequestLog = src_resquest
  3198. setlDetail, _ := json.Marshal(res2.Output.Setldetail)
  3199. detailStr := string(setlDetail)
  3200. order.SetlDetail = detailStr
  3201. //err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  3202. if record.OutHospitalStatus == 1 && order.ID > 0 {
  3203. err := service.UpDateOrder(order)
  3204. if err == nil {
  3205. c.ServeSuccessJSON(map[string]interface{}{
  3206. "msg": "预结算成功",
  3207. "order_way": 1,
  3208. })
  3209. } else {
  3210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3211. return
  3212. }
  3213. } else if record.OutHospitalStatus == 0 && order.ID == 0 {
  3214. var order models.HisOrder
  3215. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3216. order.OrderStatus = 1
  3217. order.MdtrtId = res2.Output.Setlinfo.MdtrtID
  3218. order.SetlId = res2.Output.Setlinfo.SetlID
  3219. order.PsnNo = res2.Output.Setlinfo.PsnNo
  3220. order.PsnName = res2.Output.Setlinfo.PsnName
  3221. order.PsnCertType = res2.Output.Setlinfo.PsnCertType
  3222. order.Certno = res2.Output.Setlinfo.Certno
  3223. order.Gend = res2.Output.Setlinfo.Gend
  3224. order.Naty = res2.Output.Setlinfo.Naty
  3225. val, _ := strconv.ParseFloat(res2.Output.Setlinfo.Age, 64)
  3226. order.Age = val
  3227. order.Insutype = res2.Output.Setlinfo.Insutype
  3228. order.PsnType = res2.Output.Setlinfo.PsnType
  3229. order.CvlservFlag = res2.Output.Setlinfo.CvlservFlag
  3230. order.SetlTime = res2.Output.Setlinfo.SetlTime
  3231. order.MdtrtCertType = res2.Output.Setlinfo.MdtrtCertType
  3232. if res2.Output.Setlinfo.MedType == "140104" {
  3233. order.MedType = "14"
  3234. } else {
  3235. order.MedType = res2.Output.Setlinfo.MedType
  3236. }
  3237. order.MedfeeSumamt = res2.Output.Setlinfo.MedfeeSumamt
  3238. order.FulamtOwnpayAmt = res2.Output.Setlinfo.FulamtOwnpayAmt
  3239. order.OverlmtSelfPay = res2.Output.Setlinfo.OverlmtSelfpay
  3240. order.PreselfpayAmt = res2.Output.Setlinfo.PreselfpayAmt
  3241. order.InscpScpAmt = res2.Output.Setlinfo.InscpScpAmt
  3242. order.ActPayDedc = res2.Output.Setlinfo.ActPayDedc
  3243. order.HifmiPay = res2.Output.Setlinfo.HifmiPay
  3244. order.HifpPay = res2.Output.Setlinfo.HifpPay
  3245. order.HifesPay = res2.Output.Setlinfo.HifesPay
  3246. order.HifobPay = res2.Output.Setlinfo.HifobPay
  3247. order.MafPay = res2.Output.Setlinfo.MafPay
  3248. order.OthPay = res2.Output.Setlinfo.OthPay
  3249. order.CvlservPay = res2.Output.Setlinfo.CvlservPay
  3250. order.PoolPropSelfpay = res2.Output.Setlinfo.PoolPropSelfpay
  3251. order.FundPaySumamt = res2.Output.Setlinfo.FundPaySumamt
  3252. order.PsnPartAmt = res2.Output.Setlinfo.PsnPartAmt
  3253. order.AcctPay = res2.Output.Setlinfo.AcctPay
  3254. order.PsnCashPay = res2.Output.Setlinfo.PsnCashPay
  3255. order.HospPartAmt = res2.Output.Setlinfo.HospPartAmt
  3256. order.Balc = res2.Output.Setlinfo.Balc
  3257. order.AcctMulaidPay = res2.Output.Setlinfo.AcctMulaidPay
  3258. order.MedinsSetlId = res2.Output.Setlinfo.MedinsSetlID
  3259. order.ClrOptins = res2.Output.Setlinfo.ClrOptins
  3260. order.ClrWay = res2.Output.Setlinfo.ClrWay
  3261. order.Creator = order.Creator
  3262. order.Modify = roles.AdminUserId
  3263. order.RequestLog = src_resquest
  3264. setlDetail, _ := json.Marshal(res2.Output.Setldetail)
  3265. detailStr := string(setlDetail)
  3266. order.SetlDetail = detailStr
  3267. c.ServeSuccessJSON(map[string]interface{}{
  3268. "msg": "预结算成功",
  3269. "order": order,
  3270. "order_way": 2,
  3271. })
  3272. }
  3273. }
  3274. } else {
  3275. if miConfig.Code == "H15049901371" {
  3276. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3277. utils.ErrorLog("解析失败:%v", err)
  3278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3279. return
  3280. }
  3281. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3282. res.Infcode = Infcode
  3283. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3284. res.RespondTime = resSeven10265.RespondTime
  3285. res.ErrMsg = resSeven10265.ErrMsg
  3286. res.Output = resSeven10265.Output
  3287. res.WarnMsg = resSeven10265.WarnMsg
  3288. res.Cainfo = resSeven10265.Cainfo
  3289. } else {
  3290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3291. utils.ErrorLog("解析失败:%v", err)
  3292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3293. return
  3294. }
  3295. }
  3296. if res.Infcode != 0 {
  3297. errlog := &models.HisOrderError{
  3298. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3299. Ctime: time.Now().Unix(),
  3300. Mtime: time.Now().Unix(),
  3301. Number: chrg_bchno,
  3302. ErrMsg: res.ErrMsg,
  3303. Status: 1,
  3304. PatientId: patient_id,
  3305. RecordTime: time.Now().Unix(),
  3306. Stage: 6,
  3307. }
  3308. service.CreateErrMsgLog(errlog)
  3309. c.ServeSuccessJSON(map[string]interface{}{
  3310. "failed_code": -10,
  3311. "msg": res.ErrMsg,
  3312. })
  3313. return
  3314. } else {
  3315. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3316. order.OrderStatus = 1
  3317. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3318. order.SetlId = res.Output.Setlinfo.SetlID
  3319. order.PsnNo = res.Output.Setlinfo.PsnNo
  3320. order.PsnName = res.Output.Setlinfo.PsnName
  3321. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3322. order.Certno = res.Output.Setlinfo.Certno
  3323. order.Gend = res.Output.Setlinfo.Gend
  3324. order.Naty = res.Output.Setlinfo.Naty
  3325. order.Age = res.Output.Setlinfo.Age
  3326. order.Insutype = res.Output.Setlinfo.Insutype
  3327. order.PsnType = res.Output.Setlinfo.PsnType
  3328. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3329. order.SetlTime = res.Output.Setlinfo.SetlTime
  3330. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3331. if res.Output.Setlinfo.MedType == "140104" {
  3332. order.MedType = "14"
  3333. } else {
  3334. order.MedType = res.Output.Setlinfo.MedType
  3335. }
  3336. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3337. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3338. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3339. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3340. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3341. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3342. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3343. order.HifpPay = res.Output.Setlinfo.HifpPay
  3344. order.HifesPay = res.Output.Setlinfo.HifesPay
  3345. order.HifobPay = res.Output.Setlinfo.HifobPay
  3346. order.MafPay = res.Output.Setlinfo.MafPay
  3347. order.OthPay = res.Output.Setlinfo.OthPay
  3348. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3349. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3350. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3351. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3352. order.AcctPay = res.Output.Setlinfo.AcctPay
  3353. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3354. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3355. order.Balc = res.Output.Setlinfo.Balc
  3356. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3357. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3358. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3359. order.ClrWay = res.Output.Setlinfo.ClrWay
  3360. order.Creator = order.Creator
  3361. order.Modify = roles.AdminUserId
  3362. order.RequestLog = src_resquest
  3363. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3364. detailStr := string(setlDetail)
  3365. order.SetlDetail = detailStr
  3366. //err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  3367. if record.OutHospitalStatus == 1 && order.ID > 0 {
  3368. err := service.UpDateOrder(order)
  3369. if err == nil {
  3370. c.ServeSuccessJSON(map[string]interface{}{
  3371. "msg": "预结算成功",
  3372. "order_way": 1,
  3373. })
  3374. } else {
  3375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3376. return
  3377. }
  3378. } else if record.OutHospitalStatus == 0 && order.ID == 0 {
  3379. c.ServeSuccessJSON(map[string]interface{}{
  3380. "msg": "预结算成功",
  3381. "order": order,
  3382. "order_way": 2,
  3383. })
  3384. }
  3385. }
  3386. }
  3387. }
  3388. func (c *ZHHisApiController) GetUploadInfo() {
  3389. id, _ := c.GetInt64("id")
  3390. record_time := c.GetString("record_time")
  3391. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  3392. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3393. admin_user_id, _ := c.GetInt64("admin_user_id")
  3394. timeLayout := "2006-01-02"
  3395. loc, _ := time.LoadLocation("Local")
  3396. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3397. if err != nil {
  3398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3399. return
  3400. }
  3401. recordDateTime := theTime.Unix()
  3402. adminUser := c.GetAdminUserInfo()
  3403. var prescriptions []*models.HisPrescription
  3404. data := make(map[string]interface{})
  3405. if settle_accounts_type == 1 { //日结
  3406. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3407. } else { //月结
  3408. start_time_str := c.GetString("start_time")
  3409. end_time_str := c.GetString("end_time")
  3410. timeLayout := "2006-01-02"
  3411. loc, _ := time.LoadLocation("Local")
  3412. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3413. if err != nil {
  3414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3415. return
  3416. }
  3417. recordStartTime := theStartTime.Unix()
  3418. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3419. if err != nil {
  3420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3421. return
  3422. }
  3423. recordEndTime := theEndTime.Unix()
  3424. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3425. }
  3426. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3427. record, _ := service.GetInHospitalRecord(in_hospital_id)
  3428. if record.ID == 0 {
  3429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3430. return
  3431. }
  3432. timestamp := time.Now().Unix()
  3433. tempTime := time.Unix(timestamp, 0)
  3434. timeFormat := tempTime.Format("20060102150405")
  3435. chrgBchno := rand.Intn(100000) + 10000
  3436. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
  3437. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3438. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3439. department, _ := service.GetDepartMentDetail(record.Departments)
  3440. strconv.FormatInt(record.PatientId, 10)
  3441. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.Creator)
  3442. //client := &http.Client{}
  3443. data["psn_no"] = record.PsnNo
  3444. data["mdtrt_id"] = record.Number
  3445. data["chrg_bchno"] = chrg_bchno
  3446. data["org_name"] = miConfig.OrgName
  3447. data["doctor"] = roles.UserName
  3448. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3449. data["dept"] = strconv.FormatInt(department.ID, 10)
  3450. data["fixmedins_code"] = miConfig.Code
  3451. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3452. data["dept_code"] = "15"
  3453. } else {
  3454. data["dept_code"] = department.Number
  3455. }
  3456. if miConfig.Code == "H15049901371" {
  3457. if record.MedType == 14 {
  3458. if record.InsutypeType == "390" {
  3459. data["med_type"] = ""
  3460. } else if record.InsutypeType == "310" {
  3461. data["med_type"] = ""
  3462. }
  3463. } else if record.MedType == 11 {
  3464. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  3465. }
  3466. } else {
  3467. if record.MedType == 1112 {
  3468. data["med_type"] = strconv.FormatInt(11, 10)
  3469. } else {
  3470. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  3471. }
  3472. }
  3473. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  3474. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3475. data["secret_key"] = miConfig.SecretKey
  3476. var ids []int64
  3477. fmt.Println(data)
  3478. for _, item := range prescriptions {
  3479. ids = append(ids, item.ID)
  3480. }
  3481. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3482. if config.IsOpen == 1 { //对接了医保,走医保流程
  3483. var pagesize int = 10
  3484. var start int = 1
  3485. var stop int
  3486. var pagecount int
  3487. var curpage int
  3488. var isSuccess bool = true
  3489. var customs []*models.NewCustom
  3490. var empty_code_errs []string
  3491. for _, item := range prescriptions {
  3492. if item.Type == 1 { //药品
  3493. for _, subItem := range item.HisDoctorAdviceInfo {
  3494. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) == 0 && subItem.Price > 0{
  3495. empty_code_errs = append(empty_code_errs,subItem.BaseDrugLib.DrugName)
  3496. }
  3497. }
  3498. }
  3499. if item.Type == 2 { //项目
  3500. for _, subItem := range item.HisPrescriptionProject {
  3501. //var randNum int
  3502. //randNum = rand.Intn(10000) + 1000
  3503. if subItem.Type == 2 {
  3504. if len(subItem.HisProject.MedicalCode) == 0 && subItem.Price > 0{
  3505. empty_code_errs = append(empty_code_errs,subItem.HisProject.ProjectName)
  3506. }
  3507. } else if subItem.Type == 3 {
  3508. if len(subItem.GoodInfo.MedicalInsuranceNumber) == 0 && subItem.Price > 0 {
  3509. empty_code_errs = append(empty_code_errs,subItem.GoodInfo.GoodName)
  3510. }
  3511. }
  3512. }
  3513. }
  3514. }
  3515. if len(empty_code_errs) > 0{
  3516. var err string
  3517. for _, item := range empty_code_errs{
  3518. if len(err) == 0{
  3519. err = item
  3520. }else{
  3521. err = err +"," + item
  3522. }
  3523. }
  3524. c.ServeSuccessJSON(map[string]interface{}{
  3525. "failed_code": -10,
  3526. "msg": err +" "+ "没有填写国家编码",
  3527. })
  3528. return
  3529. }
  3530. for _, item := range prescriptions {
  3531. tm := time.Unix(item.PreTime, 0)
  3532. if item.Type == 1 { //药品
  3533. for _, subItem := range item.HisDoctorAdviceInfo {
  3534. //var randNum int
  3535. //randNum = rand.Intn(10000) + 1000
  3536. cus := &models.NewCustom{
  3537. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  3538. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  3539. FeedetlSn: subItem.FeedetlSn,
  3540. Price: fmt.Sprintf("%.4f", subItem.Price),
  3541. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  3542. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  3543. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  3544. DoctorId: item.Creator,
  3545. }
  3546. customs = append(customs, cus)
  3547. }
  3548. }
  3549. if item.Type == 2 { //项目
  3550. for _, subItem := range item.HisPrescriptionProject {
  3551. //var randNum int
  3552. //randNum = rand.Intn(10000) + 1000
  3553. if subItem.Type == 2 {
  3554. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3555. cus := &models.NewCustom{
  3556. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  3557. Cut: fmt.Sprintf("%.4f", cnt),
  3558. FeedetlSn: subItem.FeedetlSn,
  3559. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  3560. MedListCodg: subItem.HisProject.MedicalCode,
  3561. HospApprFlag: -1,
  3562. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  3563. DoctorId: item.Creator,
  3564. }
  3565. customs = append(customs, cus)
  3566. } else if subItem.Type == 3 {
  3567. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3568. cus := &models.NewCustom{
  3569. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  3570. Cut: fmt.Sprintf("%.4f", cnt),
  3571. FeedetlSn: subItem.FeedetlSn,
  3572. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  3573. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  3574. HospApprFlag: -1,
  3575. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  3576. DoctorId: item.Creator,
  3577. }
  3578. customs = append(customs, cus)
  3579. }
  3580. }
  3581. }
  3582. }
  3583. //总页数,向上取整,注意除之前要先转换类型为float64
  3584. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  3585. var ress []*ResultFour
  3586. for curpage = 1; curpage <= pagecount; curpage++ {
  3587. if curpage == 1 {
  3588. start = 1
  3589. } else {
  3590. start = (curpage-1)*pagesize + 1
  3591. }
  3592. stop = curpage * pagesize
  3593. if stop > len(customs) {
  3594. stop = len(customs)
  3595. }
  3596. var result string
  3597. var requestLog string
  3598. if miConfig.MdtrtareaAdmvs == "150499" {
  3599. data := make(map[string]interface{})
  3600. if record.MedType == 14 {
  3601. if record.InsutypeType == "390" {
  3602. data["med_type"] = "9933"
  3603. } else if record.InsutypeType == "310" {
  3604. data["med_type"] = "990502"
  3605. }
  3606. } else if record.MedType == 11 {
  3607. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  3608. }
  3609. data["psn_no"] = record.PsnNo
  3610. data["number"] = record.Number
  3611. data["customs"] = customs[start-1 : stop]
  3612. data["chrg_bchno"] = chrg_bchno
  3613. data["dept"] = strconv.FormatInt(department.ID, 10)
  3614. data["dept_code"] = department.Number
  3615. data["doctor_code"] = doctor_info.DoctorNumber
  3616. data["doctor_name"] = doctor_info.UserName
  3617. data["org_name"] = miConfig.OrgName
  3618. data["opertor"] = roles.UserName
  3619. data["fixmedins_code"] = miConfig.Code
  3620. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  3621. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3622. data["secret_key"] = miConfig.SecretKey
  3623. var req *http.Request
  3624. bytesData, _ := json.Marshal(data)
  3625. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2301", bytes.NewReader(bytesData))
  3626. client := &http.Client{}
  3627. resp, _ := client.Do(req)
  3628. defer resp.Body.Close()
  3629. body, ioErr := ioutil.ReadAll(resp.Body)
  3630. if ioErr != nil {
  3631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3633. return
  3634. }
  3635. var respJSON map[string]interface{}
  3636. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3639. return
  3640. }
  3641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3642. result_byte, _ := json.Marshal(respJSON)
  3643. result = string(result_byte)
  3644. } else if miConfig.MdtrtareaAdmvs == "421182" {
  3645. data := make(map[string]interface{})
  3646. //if record.MedType == 14 {
  3647. // if record.InsutypeType == "390" {
  3648. //
  3649. // data["med_type"] = "9933"
  3650. //
  3651. // } else if record.InsutypeType == "310" {
  3652. //
  3653. // data["med_type"] = "990502"
  3654. //
  3655. // }
  3656. //
  3657. //} else if record.MedType == 11 {
  3658. //
  3659. //
  3660. //}
  3661. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  3662. data["psn_no"] = record.PsnNo
  3663. data["number"] = record.Number
  3664. data["customs"] = customs[start-1 : stop]
  3665. data["chrg_bchno"] = chrg_bchno
  3666. data["dept"] = strconv.FormatInt(department.ID, 10)
  3667. data["dept_code"] = department.Number
  3668. data["doctor_code"] = doctor_info.DoctorNumber
  3669. data["doctor_name"] = doctor_info.UserName
  3670. data["org_name"] = miConfig.OrgName
  3671. data["opertor"] = roles.UserName
  3672. data["fixmedins_code"] = miConfig.Code
  3673. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  3674. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3675. data["secret_key"] = miConfig.SecretKey
  3676. var req *http.Request
  3677. bytesData, _ := json.Marshal(data)
  3678. req, _ = http.NewRequest("POST", miConfig.Url +"hbyb/2301", bytes.NewReader(bytesData))
  3679. client := &http.Client{}
  3680. resp, _ := client.Do(req)
  3681. defer resp.Body.Close()
  3682. body, ioErr := ioutil.ReadAll(resp.Body)
  3683. if ioErr != nil {
  3684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3686. return
  3687. }
  3688. var respJSON map[string]interface{}
  3689. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3692. return
  3693. }
  3694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3695. result_byte, _ := json.Marshal(respJSON)
  3696. result = string(result_byte)
  3697. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3698. result, requestLog = service.Jxyb2301(record.PsnNo, record.Number, customs[start-1:stop], data["med_type"].(string), chrg_bchno, department.Number, strconv.FormatInt(department.ID, 10), strconv.FormatInt(roles.AdminUserId, 10), miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  3699. saveLog(result, requestLog, "2301", "上传明细")
  3700. } else {
  3701. fmt.Println("--------")
  3702. fmt.Println(prescriptions)
  3703. fmt.Println("--------")
  3704. res3101 := Check3101(c, record.PatientId, record.ID, admin_user_id, "4", record_time, prescriptions)
  3705. if res3101.Infcode == 0 {
  3706. if len(res3101.Output.Result) > 0 {
  3707. var errMsgs []string
  3708. for _, item := range res3101.Output.Result {
  3709. errMsgs = append(errMsgs, item.VolaCont)
  3710. }
  3711. c.ServeSuccessJSON(map[string]interface{}{
  3712. "failed_code": -10,
  3713. "msg": errMsgs,
  3714. })
  3715. return
  3716. } else {
  3717. result, requestLog = service.ZHGdyb2301(record.PsnNo, record.Number, customs[start-1:stop], chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(department.ID, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["med_type"].(string), doctor_info.UserName, doctor_info.DoctorNumber)
  3718. saveLog(result, requestLog, "2301", "上传明细")
  3719. }
  3720. } else {
  3721. c.ServeSuccessJSON(map[string]interface{}{
  3722. "failed_code": -10,
  3723. "msg": res3101.ErrMsg,
  3724. })
  3725. return
  3726. }
  3727. }
  3728. var dat map[string]interface{}
  3729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3730. fmt.Println(dat)
  3731. } else {
  3732. fmt.Println(err)
  3733. }
  3734. userJSONBytes, _ := json.Marshal(dat)
  3735. var res ResultFour
  3736. var resFour10265 ResultFour10265
  3737. if miConfig.Code == "H15049901371" {
  3738. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3739. utils.ErrorLog("解析失败:%v", err)
  3740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3741. return
  3742. }
  3743. res.WarnMsg = resFour10265.WarnMsg
  3744. res.Output = resFour10265.Output
  3745. res.ErrMsg = resFour10265.ErrMsg
  3746. res.RespondTime = resFour10265.RespondTime
  3747. res.InfRefmsgid = resFour10265.InfRefmsgid
  3748. Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3749. res.Infcode = Infcode
  3750. } else {
  3751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3752. utils.ErrorLog("解析失败:%v", err)
  3753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3754. return
  3755. }
  3756. }
  3757. if res.Infcode == 0 {
  3758. ress = append(ress, &res)
  3759. } else {
  3760. isSuccess = false
  3761. errlog := &models.HisOrderError{
  3762. UserOrgId: adminUser.CurrentOrgId,
  3763. Ctime: time.Now().Unix(),
  3764. Mtime: time.Now().Unix(),
  3765. Number: chrg_bchno,
  3766. ErrMsg: "",
  3767. Status: 1,
  3768. PatientId: id,
  3769. RecordTime: recordDateTime,
  3770. Stage: 4,
  3771. }
  3772. service.CreateErrMsgLog(errlog)
  3773. c.ServeSuccessJSON(map[string]interface{}{
  3774. "failed_code": -10,
  3775. "msg": "上传明细错误,请联系his厂商",
  3776. })
  3777. return
  3778. }
  3779. }
  3780. if isSuccess == true {
  3781. if settle_accounts_type == 1 {
  3782. for _, subItem := range ress {
  3783. for _, item := range subItem.Output.Result {
  3784. temp := strings.Split(item.FeedetlSn, "-")
  3785. var advice_id int64 = 0
  3786. var project_id int64 = 0
  3787. var types int64 = 0
  3788. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3789. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3790. if temp[1] == "1" {
  3791. advice_id = id
  3792. project_id = 0
  3793. } else if temp[1] == "2" {
  3794. advice_id = 0
  3795. project_id = id
  3796. }
  3797. info := &models.HisOrderInfo{
  3798. OrderNumber: record.Number,
  3799. FeedetlSn: item.FeedetlSn,
  3800. UploadDate: recordDateTime,
  3801. AdviceId: advice_id,
  3802. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3803. Cnt: item.Cnt,
  3804. Pric: float64(item.Pric),
  3805. PatientId: record.PatientId,
  3806. PricUplmtAmt: item.PricUplmtAmt,
  3807. SelfpayProp: item.SelfpayProp,
  3808. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3809. OverlmtAmt: item.OverlmtAmt,
  3810. PreselfpayAmt: item.PreselfpayAmt,
  3811. BasMednFlag: item.BasMednFlag,
  3812. MedChrgitmType: item.MedChrgitmType,
  3813. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3814. Status: 1,
  3815. Memo: item.Memo,
  3816. Mtime: time.Now().Unix(),
  3817. InscpScpAmt: item.InscpScpAmt,
  3818. DrtReimFlag: item.DrtReimFlag,
  3819. Ctime: time.Now().Unix(),
  3820. ListSpItemFlag: item.ListSpItemFlag,
  3821. ChldMedcFlag: item.ChldMedcFlag,
  3822. LmtUsedFlag: item.LmtUsedFlag,
  3823. ChrgitmLv: item.ChrgitmLv,
  3824. UserOrgId: adminUser.CurrentOrgId,
  3825. HisPatientId: record.ID,
  3826. OrderId: 0,
  3827. ProjectId: project_id,
  3828. Type: types,
  3829. SettleType: settle_accounts_type,
  3830. }
  3831. service.CreateOrderInfo(info)
  3832. }
  3833. }
  3834. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  3835. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  3836. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  3837. if err == nil {
  3838. c.ServeSuccessJSON(map[string]interface{}{
  3839. "msg": "上传费用明细成功",
  3840. })
  3841. return
  3842. } else {
  3843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3844. return
  3845. }
  3846. } else {
  3847. for _, subItem := range ress {
  3848. for _, item := range subItem.Output.Result {
  3849. temp := strings.Split(item.FeedetlSn, "-")
  3850. var advice_id int64 = 0
  3851. var project_id int64 = 0
  3852. var types int64 = 0
  3853. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3854. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3855. if temp[1] == "1" {
  3856. advice_id = id
  3857. project_id = 0
  3858. } else if temp[1] == "2" {
  3859. advice_id = 0
  3860. project_id = id
  3861. }
  3862. info := &models.HisOrderInfo{
  3863. OrderNumber: record.Number,
  3864. FeedetlSn: item.FeedetlSn,
  3865. UploadDate: time.Now().Unix(),
  3866. AdviceId: advice_id,
  3867. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3868. Cnt: item.Cnt,
  3869. Pric: float64(item.Pric),
  3870. PatientId: record.PatientId,
  3871. PricUplmtAmt: item.PricUplmtAmt,
  3872. SelfpayProp: item.SelfpayProp,
  3873. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3874. OverlmtAmt: item.OverlmtAmt,
  3875. PreselfpayAmt: item.PreselfpayAmt,
  3876. BasMednFlag: item.BasMednFlag,
  3877. MedChrgitmType: item.MedChrgitmType,
  3878. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3879. Status: 1,
  3880. Memo: item.Memo,
  3881. Mtime: time.Now().Unix(),
  3882. InscpScpAmt: item.InscpScpAmt,
  3883. DrtReimFlag: item.DrtReimFlag,
  3884. Ctime: time.Now().Unix(),
  3885. ListSpItemFlag: item.ListSpItemFlag,
  3886. ChldMedcFlag: item.ChldMedcFlag,
  3887. LmtUsedFlag: item.LmtUsedFlag,
  3888. ChrgitmLv: item.ChrgitmLv,
  3889. UserOrgId: adminUser.CurrentOrgId,
  3890. HisPatientId: record.ID,
  3891. ProjectId: project_id,
  3892. Type: types,
  3893. SettleType: settle_accounts_type,
  3894. }
  3895. service.CreateOrderInfo(info)
  3896. }
  3897. }
  3898. service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  3899. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  3900. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  3901. c.ServeSuccessJSON(map[string]interface{}{
  3902. "msg": "上传费用明细成功",
  3903. })
  3904. }
  3905. }
  3906. }
  3907. }
  3908. func (c *ZHHisApiController) ZHRefund() {
  3909. order_id, _ := c.GetInt64("order_id")
  3910. admin_user_id, _ := c.GetInt64("admin_user_id")
  3911. adminUser := c.GetAdminUserInfo()
  3912. var order models.HisOrder
  3913. order, _ = service.GetHisOrderByID(order_id)
  3914. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3915. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3916. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3917. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3918. if config.IsOpen == 1 { //对接了医保,走医保流程
  3919. var result string
  3920. var requestLog string
  3921. if miConfig.MdtrtareaAdmvs == "150499" {
  3922. //请求内网数据
  3923. api := "http://172.16.13.254:9532/" + "nmyb/2305?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo + "&setl_id=" + order.SetlId +
  3924. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3925. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3926. resp, requestErr := http.Get(api)
  3927. if requestErr != nil {
  3928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3929. return
  3930. }
  3931. body, ioErr := ioutil.ReadAll(resp.Body)
  3932. if ioErr != nil {
  3933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3935. return
  3936. }
  3937. var respJSON map[string]interface{}
  3938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3941. return
  3942. }
  3943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3944. result_byte, _ := json.Marshal(respJSON)
  3945. result = string(result_byte)
  3946. //saveLog(result, requestLog, "2404", "入院登记撤销")
  3947. saveLog(result, requestLog, "2305", "退费")
  3948. } else if miConfig.MdtrtareaAdmvs == "421182" {
  3949. //请求内网数据
  3950. api := miConfig.Url + "hbyb/2305?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo + "&setl_id=" + order.SetlId +
  3951. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3952. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3953. resp, requestErr := http.Get(api)
  3954. if requestErr != nil {
  3955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3956. return
  3957. }
  3958. body, ioErr := ioutil.ReadAll(resp.Body)
  3959. if ioErr != nil {
  3960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. return
  3963. }
  3964. var respJSON map[string]interface{}
  3965. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3968. return
  3969. }
  3970. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3971. result_byte, _ := json.Marshal(respJSON)
  3972. result = string(result_byte)
  3973. saveLog(result, requestLog, "2305", "退费")
  3974. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3975. result, requestLog := service.Jxyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  3976. saveLog(result, requestLog, "2305", "退费")
  3977. } else {
  3978. result, requestLog := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  3979. saveLog(result, requestLog, "2305", "退费")
  3980. }
  3981. var dat map[string]interface{}
  3982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3983. fmt.Println(dat)
  3984. } else {
  3985. fmt.Println(err)
  3986. }
  3987. userJSONBytes, _ := json.Marshal(dat)
  3988. var res ResultSixteen
  3989. var resSixteen ResultSixteen10265
  3990. if miConfig.Code == "H15049901371" {
  3991. if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  3992. utils.ErrorLog("解析失败:%v", err)
  3993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3994. return
  3995. }
  3996. res.Cainfo = resSixteen.Cainfo
  3997. res.WarnMsg = resSixteen.WarnMsg
  3998. res.Output = resSixteen.Output
  3999. res.ErrMsg = resSixteen.ErrMsg
  4000. res.RespondTime = resSixteen.RespondTime
  4001. Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  4002. res.Infcode = Infcode
  4003. } else {
  4004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4005. utils.ErrorLog("解析失败:%v", err)
  4006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4007. return
  4008. }
  4009. }
  4010. if res.Infcode == 0 {
  4011. err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, "", result)
  4012. //不同地区退费流程不一样,肇庆那边退费就包括撤销出院,内蒙古退费不包括撤销明细,所以下面需要根据不同情况进行判断
  4013. if miConfig.UserOrgId == 10215 {
  4014. record.OutHospitalStatus = 0
  4015. service.CreateHospitalRecord(&record)
  4016. }
  4017. service.UpdataOrderStatusByNumber(record.Number)
  4018. if err == nil {
  4019. ////当押金不为零时产生退费记录
  4020. if order.Decimal != 0 {
  4021. tmp := strconv.FormatInt(order.ID, 10)
  4022. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  4023. if err != nil {
  4024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4025. return
  4026. }
  4027. }
  4028. c.ServeSuccessJSON(map[string]interface{}{
  4029. "msg": "退费成功",
  4030. })
  4031. } else {
  4032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4033. return
  4034. }
  4035. } else {
  4036. c.ServeSuccessJSON(map[string]interface{}{
  4037. "code": -10,
  4038. "msg": res.ErrMsg,
  4039. })
  4040. }
  4041. } else {
  4042. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  4043. if err == nil {
  4044. c.ServeSuccessJSON(map[string]interface{}{
  4045. "msg": "退费成功",
  4046. })
  4047. } else {
  4048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4049. return
  4050. }
  4051. }
  4052. }
  4053. func (c *ZHHisApiController) ZHRefundDetail() {
  4054. patient_id, _ := c.GetInt64("patient_id")
  4055. his_patient_id, _ := c.GetInt64("his_patient_id")
  4056. record_time := c.GetString("record_time")
  4057. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4058. //order_id, _ := c.GetInt64("order_id")
  4059. admin_user_id, _ := c.GetInt64("admin_user_id")
  4060. timeLayout := "2006-01-02"
  4061. loc, _ := time.LoadLocation("Local")
  4062. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4063. if err != nil {
  4064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4065. return
  4066. }
  4067. recordDateTime := theTime.Unix()
  4068. adminUser := c.GetAdminUserInfo()
  4069. theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
  4070. if err != nil {
  4071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4072. return
  4073. }
  4074. recordDateTimeTwo := theTimeTwo.Unix()
  4075. //var prescriptions []*models.HisPrescription
  4076. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4077. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4078. if settle_accounts_type == 1 { //日结
  4079. record, _ := service.GetInHospitalRecord(his_patient_id)
  4080. infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime, recordDateTimeTwo, record.Number)
  4081. var isSuccess bool = true
  4082. for _, item := range infos {
  4083. var result string
  4084. var requestLog string
  4085. if miConfig.MdtrtareaAdmvs == "150499" {
  4086. //请求内网数据
  4087. api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&feedetl_sn=" + item.FeedetlSn +
  4088. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4089. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "1"
  4090. resp, requestErr := http.Get(api)
  4091. if requestErr != nil {
  4092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4093. return
  4094. }
  4095. body, ioErr := ioutil.ReadAll(resp.Body)
  4096. if ioErr != nil {
  4097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4099. return
  4100. }
  4101. var respJSON map[string]interface{}
  4102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4105. return
  4106. }
  4107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4108. result_byte, _ := json.Marshal(respJSON)
  4109. result = string(result_byte)
  4110. saveLog(result, requestLog, "2302", "日结退明细")
  4111. } else if miConfig.MdtrtareaAdmvs == "421182" {
  4112. //请求内网数据
  4113. api := miConfig.Url + "hbyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&feedetl_sn=" + item.FeedetlSn +
  4114. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4115. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "1"
  4116. resp, requestErr := http.Get(api)
  4117. if requestErr != nil {
  4118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4119. return
  4120. }
  4121. body, ioErr := ioutil.ReadAll(resp.Body)
  4122. if ioErr != nil {
  4123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4125. return
  4126. }
  4127. var respJSON map[string]interface{}
  4128. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4131. return
  4132. }
  4133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4134. result_byte, _ := json.Marshal(respJSON)
  4135. result = string(result_byte)
  4136. saveLog(result, requestLog, "2302", "日结退明细")
  4137. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4138. result, requestLog := service.Jxyb2302(record.PsnNo, record.Number, 1, item.FeedetlSn, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  4139. saveLog(result, requestLog, "2302", "日结退明细")
  4140. } else {
  4141. result, requestLog := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
  4142. saveLog(result, requestLog, "2302", "日结退明细")
  4143. }
  4144. var dat map[string]interface{}
  4145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4146. fmt.Println(dat)
  4147. } else {
  4148. fmt.Println(err)
  4149. }
  4150. userJSONBytes, _ := json.Marshal(dat)
  4151. var res2 ResultEmpty
  4152. var resEmpty10265 ResultEmpty10265
  4153. if miConfig.Code == "H15049901371" {
  4154. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  4155. utils.ErrorLog("解析失败:%v", err)
  4156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4157. return
  4158. }
  4159. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  4160. res2.Infcode = Infcode
  4161. res2.RespondTime = resEmpty10265.RespondTime
  4162. res2.ErrMsg = resEmpty10265.ErrMsg
  4163. res2.Output = resEmpty10265.Output
  4164. res2.WarnMsg = resEmpty10265.WarnMsg
  4165. } else {
  4166. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4167. utils.ErrorLog("解析失败:%v", err)
  4168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4169. return
  4170. }
  4171. }
  4172. if res2.Infcode == -1 {
  4173. isSuccess = false
  4174. }
  4175. }
  4176. if isSuccess {
  4177. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
  4178. if err != nil {
  4179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4180. return
  4181. }
  4182. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  4183. if err1 != nil {
  4184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4185. return
  4186. }
  4187. c.ServeSuccessJSON(map[string]interface{}{
  4188. "msg": "撤销明细成功",
  4189. })
  4190. }
  4191. } else {
  4192. //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4193. //var order models.HisOrder
  4194. //order, _ = service.GetHisOrderByID(order_id)
  4195. //record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4196. var result string
  4197. var requestLog string
  4198. record, _ := service.GetInHospitalRecord(his_patient_id)
  4199. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4200. if config.IsOpen == 1 { //对接了医保,走医保流程
  4201. if miConfig.MdtrtareaAdmvs == "150499" {
  4202. //请求内网数据
  4203. api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=0000" +
  4204. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4205. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "0"
  4206. resp, requestErr := http.Get(api)
  4207. if requestErr != nil {
  4208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4209. return
  4210. }
  4211. body, ioErr := ioutil.ReadAll(resp.Body)
  4212. if ioErr != nil {
  4213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4215. return
  4216. }
  4217. var respJSON map[string]interface{}
  4218. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4221. return
  4222. }
  4223. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4224. result_byte, _ := json.Marshal(respJSON)
  4225. result = string(result_byte)
  4226. //saveLog(result, requestLog, "2302", "日结退明细")
  4227. } else if miConfig.MdtrtareaAdmvs == "421182" {
  4228. //请求内网数据
  4229. api := miConfig.Url + "hbyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=0000" +
  4230. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4231. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=" + "0"
  4232. resp, requestErr := http.Get(api)
  4233. if requestErr != nil {
  4234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4235. return
  4236. }
  4237. body, ioErr := ioutil.ReadAll(resp.Body)
  4238. if ioErr != nil {
  4239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4241. return
  4242. }
  4243. var respJSON map[string]interface{}
  4244. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4247. return
  4248. }
  4249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4250. result_byte, _ := json.Marshal(respJSON)
  4251. result = string(result_byte)
  4252. //saveLog(result, requestLog, "2302", "日结退明细")
  4253. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4254. result, requestLog = service.Jxyb2302(record.PsnNo, record.Number, 0, "0000", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  4255. saveLog(result, requestLog, "2302", "月结退明细")
  4256. } else {
  4257. result, requestLog = service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  4258. saveLog(result, requestLog, "2302", "月结退明细")
  4259. }
  4260. var dat map[string]interface{}
  4261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4262. fmt.Println(dat)
  4263. } else {
  4264. fmt.Println(err)
  4265. }
  4266. userJSONBytes, _ := json.Marshal(dat)
  4267. var res2 ResultEmpty
  4268. var resEmpty10265 ResultEmpty10265
  4269. if miConfig.Code == "H15049901371" {
  4270. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  4271. utils.ErrorLog("解析失败:%v", err)
  4272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4273. return
  4274. }
  4275. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  4276. res2.Infcode = Infcode
  4277. res2.RespondTime = resEmpty10265.RespondTime
  4278. res2.ErrMsg = resEmpty10265.ErrMsg
  4279. res2.Output = resEmpty10265.Output
  4280. res2.WarnMsg = resEmpty10265.WarnMsg
  4281. } else {
  4282. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4283. utils.ErrorLog("解析失败:%v", err)
  4284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4285. return
  4286. }
  4287. }
  4288. if res2.Infcode == 0 {
  4289. err := service.UpdataHospitalOrderStatus(record.Number, adminUser.CurrentOrgId)
  4290. if err == nil {
  4291. c.ServeSuccessJSON(map[string]interface{}{
  4292. "msg": "撤销明细成功",
  4293. })
  4294. } else {
  4295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4296. return
  4297. }
  4298. } else {
  4299. c.ServeSuccessJSON(map[string]interface{}{
  4300. "code": -10,
  4301. "msg": res2.ErrMsg,
  4302. })
  4303. }
  4304. }
  4305. }
  4306. }
  4307. func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
  4308. id, _ := this.GetInt64("id")
  4309. admin_user_id, _ := this.GetInt64("admin_user_id")
  4310. adminInfo := this.GetAdminUserInfo()
  4311. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4312. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4313. record, _ := service.GetInHospitalRecord(id)
  4314. if record.ID == 0 {
  4315. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  4316. return
  4317. }
  4318. var result string
  4319. var requestLog string
  4320. if miConfig.MdtrtareaAdmvs == "150499" {
  4321. //请求内网数据
  4322. api := "http://172.16.13.254:9532/" + "nmyb/2405?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
  4323. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  4324. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4325. fmt.Println(api)
  4326. resp, requestErr := http.Get(api)
  4327. if requestErr != nil {
  4328. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4329. return
  4330. }
  4331. body, ioErr := ioutil.ReadAll(resp.Body)
  4332. if ioErr != nil {
  4333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4334. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4335. return
  4336. }
  4337. var respJSON map[string]interface{}
  4338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4340. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4341. return
  4342. }
  4343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4344. result_byte, _ := json.Marshal(respJSON)
  4345. result = string(result_byte)
  4346. } else if miConfig.MdtrtareaAdmvs == "421182" {
  4347. //请求内网数据
  4348. api := miConfig.Url + "hbyb/2405?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
  4349. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  4350. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4351. fmt.Println(api)
  4352. resp, requestErr := http.Get(api)
  4353. if requestErr != nil {
  4354. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4355. return
  4356. }
  4357. body, ioErr := ioutil.ReadAll(resp.Body)
  4358. if ioErr != nil {
  4359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4360. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4361. return
  4362. }
  4363. var respJSON map[string]interface{}
  4364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4366. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4367. return
  4368. }
  4369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4370. result_byte, _ := json.Marshal(respJSON)
  4371. result = string(result_byte)
  4372. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4373. result, requestLog = service.Jxyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  4374. saveLog(result, requestLog, "2405", "出院登记撤销")
  4375. } else {
  4376. result, requestLog = service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  4377. saveLog(result, requestLog, "2405", "出院登记撤销")
  4378. }
  4379. var dat map[string]interface{}
  4380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4381. fmt.Println(dat)
  4382. } else {
  4383. fmt.Println(err)
  4384. }
  4385. userJSONBytes, _ := json.Marshal(dat)
  4386. var res ResultEmpty
  4387. var resEmpty10265 ResultEmpty10265
  4388. if miConfig.Code == "H15049901371" {
  4389. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  4390. utils.ErrorLog("解析失败:%v", err)
  4391. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4392. return
  4393. }
  4394. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  4395. res.Infcode = Infcode
  4396. res.RespondTime = resEmpty10265.RespondTime
  4397. res.ErrMsg = resEmpty10265.ErrMsg
  4398. res.Output = resEmpty10265.Output
  4399. res.WarnMsg = resEmpty10265.WarnMsg
  4400. } else {
  4401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4402. utils.ErrorLog("解析失败:%v", err)
  4403. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. }
  4407. if res.Infcode == 0 {
  4408. record.OutHospitalStatus = 0
  4409. service.CreateHospitalRecord(&record)
  4410. service.UpdataOrderStatusByNumber(record.Number)
  4411. this.ServeSuccessJSON(map[string]interface{}{
  4412. "msg": "撤销出院成功",
  4413. })
  4414. } else {
  4415. this.ServeSuccessJSON(map[string]interface{}{
  4416. "failed_code": -10,
  4417. "msg": res.ErrMsg,
  4418. })
  4419. }
  4420. }
  4421. func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
  4422. id, _ := this.GetInt64("id")
  4423. admin_user_id, _ := this.GetInt64("admin_user_id")
  4424. adminInfo := this.GetAdminUserInfo()
  4425. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4426. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4427. record, _ := service.GetInHospitalRecord(id)
  4428. if record.ID == 0 {
  4429. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  4430. return
  4431. }
  4432. var result string
  4433. var requestLog string
  4434. orders, _ := service.GetHisOrderInfoByNumber(record.Number)
  4435. if len(orders) > 0 { //判断是否上传过明细,有的话需要退明细,后撤销入院
  4436. if miConfig.MdtrtareaAdmvs == "150499" {
  4437. //请求内网数据
  4438. api := "http://172.16.13.254:9532/" + "nmyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=" + "0000" +
  4439. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  4440. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=0"
  4441. resp, requestErr := http.Get(api)
  4442. if requestErr != nil {
  4443. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4444. return
  4445. }
  4446. body, ioErr := ioutil.ReadAll(resp.Body)
  4447. if ioErr != nil {
  4448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4449. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4450. return
  4451. }
  4452. var respJSON map[string]interface{}
  4453. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4455. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4456. return
  4457. }
  4458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4459. result_byte, _ := json.Marshal(respJSON)
  4460. result = string(result_byte)
  4461. saveLog(result, requestLog, "2302", "月结退明细")
  4462. }else if miConfig.MdtrtareaAdmvs == "421182" {
  4463. //请求内网数据
  4464. api := miConfig.Url + "hbyb/2302?psn_no=" + record.PsnNo + "&mdtrtId=" + record.Number + "&number=" + "0000" +
  4465. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  4466. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&refund_type=0"
  4467. resp, requestErr := http.Get(api)
  4468. if requestErr != nil {
  4469. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4470. return
  4471. }
  4472. body, ioErr := ioutil.ReadAll(resp.Body)
  4473. if ioErr != nil {
  4474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4475. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4476. return
  4477. }
  4478. var respJSON map[string]interface{}
  4479. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4481. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4482. return
  4483. }
  4484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4485. result_byte, _ := json.Marshal(respJSON)
  4486. result = string(result_byte)
  4487. saveLog(result, requestLog, "2302", "月结退明细")
  4488. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4489. result, requestLog = service.Jxyb2302(record.PsnNo, record.Number, 0, "0000", miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  4490. saveLog(result, requestLog, "2302", "月结退明细")
  4491. } else {
  4492. result, requestLog = service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  4493. saveLog(result, requestLog, "2302", "月结退明细")
  4494. }
  4495. var dat map[string]interface{}
  4496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4497. fmt.Println(dat)
  4498. } else {
  4499. fmt.Println(err)
  4500. }
  4501. userJSONBytes, _ := json.Marshal(dat)
  4502. var res2 ResultEmpty
  4503. var resEmpty10265 ResultEmpty10265
  4504. if miConfig.Code == "H15049901371" {
  4505. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  4506. utils.ErrorLog("解析失败:%v", err)
  4507. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  4511. res2.Infcode = Infcode
  4512. res2.RespondTime = resEmpty10265.RespondTime
  4513. res2.ErrMsg = resEmpty10265.ErrMsg
  4514. res2.Output = resEmpty10265.Output
  4515. res2.WarnMsg = resEmpty10265.WarnMsg
  4516. } else {
  4517. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4518. utils.ErrorLog("解析失败:%v", err)
  4519. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4520. return
  4521. }
  4522. }
  4523. if res2.Infcode == 0 {
  4524. service.UpdataHospitalOrderStatus(record.Number, adminInfo.CurrentOrgId)
  4525. var result string
  4526. var requestLog string
  4527. if miConfig.MdtrtareaAdmvs == "150499" {
  4528. //请求内网数据
  4529. api := "http://172.16.13.254:9532/" + "nmyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
  4530. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  4531. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4532. resp, requestErr := http.Get(api)
  4533. if requestErr != nil {
  4534. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4535. return
  4536. }
  4537. body, ioErr := ioutil.ReadAll(resp.Body)
  4538. if ioErr != nil {
  4539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4540. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4541. return
  4542. }
  4543. var respJSON map[string]interface{}
  4544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4546. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4547. return
  4548. }
  4549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4550. result_byte, _ := json.Marshal(respJSON)
  4551. result = string(result_byte)
  4552. } else if miConfig.MdtrtareaAdmvs == "421182" {
  4553. //请求内网数据
  4554. api := miConfig.Url + "hbyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
  4555. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  4556. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4557. resp, requestErr := http.Get(api)
  4558. if requestErr != nil {
  4559. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4560. return
  4561. }
  4562. body, ioErr := ioutil.ReadAll(resp.Body)
  4563. if ioErr != nil {
  4564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4565. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4566. return
  4567. }
  4568. var respJSON map[string]interface{}
  4569. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4571. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4572. return
  4573. }
  4574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4575. result_byte, _ := json.Marshal(respJSON)
  4576. result = string(result_byte)
  4577. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4578. result, requestLog = service.Jxyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  4579. saveLog(result, requestLog, "2404", "入院登记撤销")
  4580. } else {
  4581. result, requestLog = service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  4582. saveLog(result, requestLog, "2404", "入院登记撤销")
  4583. }
  4584. var dat map[string]interface{}
  4585. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4586. fmt.Println(dat)
  4587. } else {
  4588. fmt.Println(err)
  4589. }
  4590. userJSONBytes, _ := json.Marshal(dat)
  4591. var res ResultEmpty
  4592. var resEmpty10265 ResultEmpty10265
  4593. if miConfig.Code == "H15049901371" {
  4594. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  4595. utils.ErrorLog("解析失败:%v", err)
  4596. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4597. return
  4598. }
  4599. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  4600. res.Infcode = Infcode
  4601. res.RespondTime = resEmpty10265.RespondTime
  4602. res.ErrMsg = resEmpty10265.ErrMsg
  4603. res.Output = resEmpty10265.Output
  4604. res.WarnMsg = resEmpty10265.WarnMsg
  4605. } else {
  4606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4607. utils.ErrorLog("解析失败:%v", err)
  4608. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. return
  4610. }
  4611. }
  4612. if res.Infcode == 0 {
  4613. record.Status = 0
  4614. service.CreateHospitalRecord(&record)
  4615. this.ServeSuccessJSON(map[string]interface{}{
  4616. "msg": "撤销入院成功",
  4617. })
  4618. } else {
  4619. this.ServeSuccessJSON(map[string]interface{}{
  4620. "failed_code": -10,
  4621. "msg": res.ErrMsg,
  4622. })
  4623. }
  4624. } else {
  4625. this.ServeSuccessJSON(map[string]interface{}{
  4626. "code": -10,
  4627. "msg": res2.ErrMsg,
  4628. })
  4629. }
  4630. } else { //没有上传过明细的,直接撤销入院
  4631. var result string
  4632. var requestLog string
  4633. if miConfig.MdtrtareaAdmvs == "150499" {
  4634. //请求内网数据
  4635. api := "http://172.16.13.254:9532/" + "nmyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
  4636. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  4637. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4638. resp, requestErr := http.Get(api)
  4639. if requestErr != nil {
  4640. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4641. return
  4642. }
  4643. body, ioErr := ioutil.ReadAll(resp.Body)
  4644. if ioErr != nil {
  4645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4646. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4647. return
  4648. }
  4649. var respJSON map[string]interface{}
  4650. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4652. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4653. return
  4654. }
  4655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4656. result_byte, _ := json.Marshal(respJSON)
  4657. result = string(result_byte)
  4658. } else if miConfig.MdtrtareaAdmvs == "421182" {
  4659. //请求内网数据
  4660. api := miConfig.Url + "hbyb/2404?mdtrt_id=" + record.Number + "&psn_no=" + record.PsnNo +
  4661. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  4662. "&insuplc_admdvs=" + record.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4663. resp, requestErr := http.Get(api)
  4664. if requestErr != nil {
  4665. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4666. return
  4667. }
  4668. body, ioErr := ioutil.ReadAll(resp.Body)
  4669. if ioErr != nil {
  4670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4671. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4672. return
  4673. }
  4674. var respJSON map[string]interface{}
  4675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4677. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4678. return
  4679. }
  4680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4681. result_byte, _ := json.Marshal(respJSON)
  4682. result = string(result_byte)
  4683. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4684. result, requestLog = service.Jxyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, "", miConfig.AccessKey)
  4685. saveLog(result, requestLog, "2404", "入院登记撤销")
  4686. } else {
  4687. result, requestLog = service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  4688. saveLog(result, requestLog, "2404", "入院登记撤销")
  4689. }
  4690. var dat map[string]interface{}
  4691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4692. fmt.Println(dat)
  4693. } else {
  4694. fmt.Println(err)
  4695. }
  4696. userJSONBytes, _ := json.Marshal(dat)
  4697. var res ResultEmpty
  4698. var resEmpty10265 ResultEmpty10265
  4699. if miConfig.Code == "H15049901371" {
  4700. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  4701. utils.ErrorLog("解析失败:%v", err)
  4702. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4703. return
  4704. }
  4705. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  4706. res.Infcode = Infcode
  4707. res.RespondTime = resEmpty10265.RespondTime
  4708. res.ErrMsg = resEmpty10265.ErrMsg
  4709. res.Output = resEmpty10265.Output
  4710. res.WarnMsg = resEmpty10265.WarnMsg
  4711. } else {
  4712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4713. utils.ErrorLog("解析失败:%v", err)
  4714. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4715. return
  4716. }
  4717. }
  4718. if res.Infcode == 0 {
  4719. record.Status = 0
  4720. service.CreateHospitalRecord(&record)
  4721. this.ServeSuccessJSON(map[string]interface{}{
  4722. "msg": "撤销入院成功",
  4723. })
  4724. } else {
  4725. this.ServeSuccessJSON(map[string]interface{}{
  4726. "failed_code": -10,
  4727. "msg": res.ErrMsg,
  4728. })
  4729. }
  4730. }
  4731. }
  4732. func saveLog(result string, request string, infno string, desc string) {
  4733. org_id, _ := beego.AppConfig.Int64("org_id")
  4734. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  4735. dir := miConfig.OrgName + "日志"
  4736. utils.Mkdir(dir)
  4737. month := time.Unix(1557042972, 0).Format("1")
  4738. year := time.Now().Format("2006")
  4739. month = time.Now().Format("01")
  4740. day := time.Now().Format("02")
  4741. hour := time.Now().Format("15")
  4742. min := time.Now().Format("04")
  4743. sec := time.Now().Format("05")
  4744. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  4745. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  4746. file_name := file + ".txt"
  4747. file_path := miConfig.OrgName + "日志" + "/" + file_name
  4748. exist, _ := utils.PathExists(file_path)
  4749. if exist { //存在
  4750. fmt.Println("存在")
  4751. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  4752. if err != nil {
  4753. fmt.Println("read fail")
  4754. }
  4755. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  4756. n, _ := f.Seek(0, 2)
  4757. _, err = f.WriteAt([]byte(content), n)
  4758. } else { //不存在
  4759. fmt.Println("文件不存在,创建文件")
  4760. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  4761. defer f.Close()
  4762. if err != nil {
  4763. } else {
  4764. _, err = f.Write([]byte("记录日志"))
  4765. }
  4766. }
  4767. }
  4768. type Charset string
  4769. const (
  4770. UTF8 = Charset("UTF-8")
  4771. GB18030 = Charset("GB18030")
  4772. )
  4773. func ConvertToString(src string, srcCode string, tagCode string) string {
  4774. srcCoder := mahonia.NewDecoder(srcCode)
  4775. srcResult := srcCoder.ConvertString(src)
  4776. tagCoder := mahonia.NewDecoder(tagCode)
  4777. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  4778. result := string(cdata)
  4779. return result
  4780. }
  4781. type ELeData struct {
  4782. Data struct {
  4783. IdNo string `json:"idNo"`
  4784. IdType string `json:"idType"`
  4785. UserName string `json:"userName"`
  4786. EcToken string `json:"ecToken"`
  4787. InsuOrg string `json:"insuOrg"`
  4788. Gender string `json:"gender"`
  4789. Birthday string `json:"birthday"`
  4790. Nationality string `json:"nationality"`
  4791. Email string `json:"email"`
  4792. Extra string `json:"extra"`
  4793. } `json:"data"`
  4794. Code int `json:"code"`
  4795. Message string `json:"message"`
  4796. }
  4797. var initFlagTwo int64 = 0
  4798. func (c *ZHHisApiController) TestGetJiangXiBasBaseInit() {
  4799. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4800. Iinit := DllDef.MustFindProc("Init")
  4801. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4802. //http://10.77.211.236/CSB/hsa-fsi-1303
  4803. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  4804. if ret != 0 {
  4805. fmt.Println("SSCard的报错原因:", err)
  4806. fmt.Println("SSCard的运算结果为:", ret)
  4807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4808. return
  4809. }
  4810. result := int(ret)
  4811. fmt.Println("SSCard的运算结果为1:", result)
  4812. initFlag = 1
  4813. return
  4814. }
  4815. func (c *ZHHisApiController) GetBasBaseInfoxxx() string {
  4816. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4817. readCard := DllDef.MustFindProc("ReadCardBas")
  4818. if readCard == nil {
  4819. fmt.Println("readcard is nil")
  4820. readCard = DllDef.MustFindProc("ReadCardBas")
  4821. }
  4822. str := make([]byte, 1024)
  4823. str1 := make([]byte, 1024)
  4824. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  4825. fmt.Println(string(str1))
  4826. fmt.Println(string(str))
  4827. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  4828. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  4829. if ret2 != 0 {
  4830. return ""
  4831. }
  4832. return string(str)
  4833. }
  4834. func (c *ZHHisApiController) ReadEleCardfordevice() {
  4835. admin_user_id, _ := c.GetInt64("admin_user_id")
  4836. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4837. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4838. GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  4839. }
  4840. func (c *ZHHisApiController) ReadCard() {
  4841. id_card_type, _ := c.GetInt64("id_card_type")
  4842. admin_user_id, _ := c.GetInt64("admin_user_id")
  4843. is_settle := c.GetString("is_settle")
  4844. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4845. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4846. switch id_card_type {
  4847. case 1: //社保卡
  4848. if miConfig.MdtrtareaAdmvs == "150499" {
  4849. var api string
  4850. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4851. "&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
  4852. fmt.Println(api)
  4853. resp, requestErr := http.Get(api)
  4854. if requestErr != nil {
  4855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4856. return
  4857. }
  4858. body, ioErr := ioutil.ReadAll(resp.Body)
  4859. if ioErr != nil {
  4860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4862. return
  4863. }
  4864. var respJSON map[string]interface{}
  4865. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4868. return
  4869. }
  4870. var status string
  4871. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4872. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4873. //console.log()
  4874. fmt.Println("type===")
  4875. fmt.Println(card_type)
  4876. var token string
  4877. var res ResultTwo //1101结果
  4878. var res10265 ResultTwo10265 //1101结果
  4879. var card_info string //卡信息
  4880. var busi_card_info string
  4881. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4882. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4883. if status == "0" { //读卡成功
  4884. if card_type == "1" {
  4885. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4886. result, _ := json.Marshal(respJSON)
  4887. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4888. utils.ErrorLog("解析失败:%v", err)
  4889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4890. return
  4891. }
  4892. res.ErrMsg = res10265.ErrMsg
  4893. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4894. res.Infcode = infocode
  4895. res.Output = res10265.Output
  4896. res.InfRefmsgid = res10265.InfRefmsgid
  4897. } else {
  4898. //var card_info string //卡信息
  4899. //var busi_card_info string
  4900. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4901. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4902. //fmt.Println(card_info)
  4903. //fmt.Println(busi_card_info)
  4904. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4905. result, _ := json.Marshal(respJSON)
  4906. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4907. utils.ErrorLog("解析失败:%v", err)
  4908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4909. return
  4910. }
  4911. res.ErrMsg = res10265.ErrMsg
  4912. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4913. res.Infcode = infocode
  4914. res.Output = res10265.Output
  4915. res.InfRefmsgid = res10265.InfRefmsgid
  4916. }
  4917. if res.Infcode == 0 {
  4918. var insutypes []string
  4919. var insutype string
  4920. var is390 int = 0
  4921. var is310 int = 0
  4922. for _, item := range res.Output.Iinfo {
  4923. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4924. insutypes = append(insutypes, item.Insutype)
  4925. }
  4926. }
  4927. if len(insutypes) == 1 {
  4928. insutype = insutypes[0]
  4929. } else {
  4930. for _, i := range insutypes {
  4931. if i == "390" {
  4932. is390 = 1
  4933. }
  4934. if i == "310" {
  4935. is310 = 1
  4936. }
  4937. }
  4938. }
  4939. if is390 == 1 {
  4940. insutype = "390"
  4941. }
  4942. if is310 == 1 {
  4943. insutype = "310"
  4944. }
  4945. if len(insutypes) == 0 {
  4946. insutype = "310"
  4947. }
  4948. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4949. if err == gorm.ErrRecordNotFound {
  4950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4951. return
  4952. } else if err != nil {
  4953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4954. return
  4955. } else {
  4956. if card_type == "1" {
  4957. bas := strings.Split(card_info, "|")
  4958. basNumber := bas[2]
  4959. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4960. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4961. infoStr := string(Iinfos)
  4962. idetinfoStr := string(Idetinfos)
  4963. psn := &models.HisPsn{
  4964. PsnNo: res.Output.Baseinfo.PsnNo,
  4965. Age: res.Output.Baseinfo.Age,
  4966. PatientId: patient.ID,
  4967. Certno: res.Output.Baseinfo.Certno,
  4968. Gend: res.Output.Baseinfo.Gend,
  4969. Naty: res.Output.Baseinfo.Naty,
  4970. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4971. PsnName: res.Output.Baseinfo.PsnName,
  4972. Idetinfo: idetinfoStr,
  4973. Insuinfo: infoStr,
  4974. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4975. CardInfo: card_info,
  4976. VerifyNumber: busi_card_info,
  4977. }
  4978. service.CreateHisPsn(psn)
  4979. c.ServeSuccessJSON(map[string]interface{}{
  4980. "patient": patient,
  4981. "number": basNumber,
  4982. "info": res,
  4983. "insutype": insutype,
  4984. })
  4985. } else {
  4986. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4987. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4988. infoStr := string(Iinfos)
  4989. idetinfoStr := string(Idetinfos)
  4990. psn := &models.HisPsn{
  4991. PsnNo: res.Output.Baseinfo.PsnNo,
  4992. Age: res.Output.Baseinfo.Age,
  4993. PatientId: patient.ID,
  4994. Certno: res.Output.Baseinfo.Certno,
  4995. Gend: res.Output.Baseinfo.Gend,
  4996. Naty: res.Output.Baseinfo.Naty,
  4997. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4998. PsnName: res.Output.Baseinfo.PsnName,
  4999. Idetinfo: idetinfoStr,
  5000. Insuinfo: infoStr,
  5001. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5002. CardInfo: card_info,
  5003. VerifyNumber: token,
  5004. }
  5005. service.CreateHisPsn(psn)
  5006. c.ServeSuccessJSON(map[string]interface{}{
  5007. "patient": patient,
  5008. "number": token,
  5009. "info": res,
  5010. "insutype": insutype,
  5011. })
  5012. }
  5013. }
  5014. } else {
  5015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5016. return
  5017. }
  5018. } else { //读卡失败
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5020. return
  5021. }
  5022. } else if miConfig.MdtrtareaAdmvs == "421182" {
  5023. var res ResultTwohb
  5024. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  5025. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5026. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=1"
  5027. resp, requestErr := http.Get(api)
  5028. if requestErr != nil {
  5029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5030. return
  5031. }
  5032. body, ioErr := ioutil.ReadAll(resp.Body)
  5033. if ioErr != nil {
  5034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5036. return
  5037. }
  5038. var respJSON map[string]interface{}
  5039. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5042. return
  5043. }
  5044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5045. result, _ := json.Marshal(respJSON)
  5046. fmt.Println("log")
  5047. fmt.Println(string(result))
  5048. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5049. utils.ErrorLog("解析失败:%v", err)
  5050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5051. return
  5052. }
  5053. if res.Infcode == 0 {
  5054. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5055. if err == gorm.ErrRecordNotFound {
  5056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5057. return
  5058. } else if err != nil {
  5059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5060. return
  5061. } else {
  5062. var insuplc_admdvs_temp string
  5063. var insutypes []string
  5064. var insutype string
  5065. var is390 int = 0
  5066. var is310 int = 0
  5067. for _, item := range res.Output.Iinfo {
  5068. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5069. insutypes = append(insutypes, item.Insutype)
  5070. }
  5071. }
  5072. if len(insutypes) == 1 {
  5073. insutype = insutypes[0]
  5074. } else {
  5075. for _, i := range insutypes {
  5076. if i == "390" {
  5077. is390 = 1
  5078. }
  5079. if i == "310" {
  5080. is310 = 1
  5081. }
  5082. }
  5083. }
  5084. if is390 == 1 {
  5085. insutype = "390"
  5086. }
  5087. if is310 == 1 {
  5088. insutype = "310"
  5089. }
  5090. if len(insutypes) == 0 {
  5091. insutype = "310"
  5092. }
  5093. for _, item := range insutypes {
  5094. if item == insutype {
  5095. insuplc_admdvs_temp = item
  5096. }
  5097. }
  5098. //insuplcAdmdvs := strconv.Itoa(insuplc_admdvs_temp)
  5099. card_info_two := insuplc_admdvs_temp + "|" + res.Output.Baseinfo.Certno + "|" + res.Output.Baseinfo.ExpContent.MdtrtCertNo
  5100. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5101. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5102. infoStr := string(Iinfos)
  5103. idetinfoStr := string(Idetinfos)
  5104. psn := &models.HisPsn{
  5105. PsnNo: res.Output.Baseinfo.PsnNo,
  5106. PatientId: patient.ID,
  5107. Certno: res.Output.Baseinfo.Certno,
  5108. Gend: res.Output.Baseinfo.Gend,
  5109. Naty: res.Output.Baseinfo.Naty,
  5110. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5111. PsnName: res.Output.Baseinfo.PsnName,
  5112. Idetinfo: idetinfoStr,
  5113. Insuinfo: infoStr,
  5114. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5115. InsuplcAdmdvs: insuplc_admdvs_temp,
  5116. CardInfo:card_info_two,
  5117. }
  5118. service.CreateHisPsn(psn)
  5119. c.ServeSuccessJSON(map[string]interface{}{
  5120. "patient": patient,
  5121. "number": res.Output.Baseinfo.Certno,
  5122. })
  5123. }
  5124. } else {
  5125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5126. return
  5127. }
  5128. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5129. fmt.Println(initFlag)
  5130. fmt.Println("initFlag")
  5131. if initFlag == 0 {
  5132. c.TestGetJiangXiBasBaseInit()
  5133. }
  5134. basStr := c.GetBasBaseInfoxxx()
  5135. if len(basStr) == 0 {
  5136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5137. return
  5138. }
  5139. fmt.Println(basStr)
  5140. bas := strings.Split(basStr, "|")
  5141. basNumber := bas[1]
  5142. fmt.Println(basNumber)
  5143. card_sn := bas[3]
  5144. fmt.Println(card_sn)
  5145. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  5146. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  5147. var dat map[string]interface{}
  5148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5149. fmt.Println(dat)
  5150. } else {
  5151. fmt.Println(err)
  5152. }
  5153. userJSONBytes, _ := json.Marshal(dat)
  5154. var res ResultTwo
  5155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5156. utils.ErrorLog("解析失败:%v", err)
  5157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5158. return
  5159. }
  5160. if res.Infcode == 0 {
  5161. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5162. if err == gorm.ErrRecordNotFound {
  5163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5164. return
  5165. } else if err != nil {
  5166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5167. return
  5168. } else {
  5169. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5170. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5171. infoStr := string(Iinfos)
  5172. idetinfoStr := string(Idetinfos)
  5173. psn := &models.HisPsn{
  5174. PsnNo: res.Output.Baseinfo.PsnNo,
  5175. Age: res.Output.Baseinfo.Age,
  5176. PatientId: patient.ID,
  5177. Certno: res.Output.Baseinfo.Certno,
  5178. Gend: res.Output.Baseinfo.Gend,
  5179. Naty: res.Output.Baseinfo.Naty,
  5180. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5181. PsnName: res.Output.Baseinfo.PsnName,
  5182. Idetinfo: idetinfoStr,
  5183. Insuinfo: infoStr,
  5184. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5185. CardInfo: basStr,
  5186. VerifyNumber: "",
  5187. }
  5188. service.CreateHisPsn(psn)
  5189. var rf []*ResultFive
  5190. json.Unmarshal([]byte(infoStr), &rf)
  5191. var insutypes []*ResultFive
  5192. var insutype string
  5193. var is390 int = 0
  5194. var is310 int = 0
  5195. for _, item := range rf {
  5196. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5197. insutypes = append(insutypes, item)
  5198. }
  5199. }
  5200. if len(insutypes) == 1 {
  5201. insutype = insutypes[0].Insutype
  5202. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5203. } else {
  5204. for _, i := range insutypes {
  5205. if i.Insutype == "390" {
  5206. is390 = 1
  5207. }
  5208. if i.Insutype == "310" {
  5209. is310 = 1
  5210. }
  5211. }
  5212. }
  5213. if is390 == 1 {
  5214. insutype = "390"
  5215. }
  5216. if is310 == 1 {
  5217. insutype = "310"
  5218. }
  5219. if len(insutypes) == 0 {
  5220. insutype = "310"
  5221. }
  5222. c.ServeSuccessJSON(map[string]interface{}{
  5223. "patient": patient,
  5224. "number": basNumber,
  5225. "info": res,
  5226. "insutype": insutype,
  5227. })
  5228. }
  5229. } else {
  5230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5231. return
  5232. }
  5233. } else {
  5234. if initFlagTwo == 0 {
  5235. c.TestGetBasBaseInitTwo()
  5236. }
  5237. basStr := c.GetBasBaseInfoTwo()
  5238. if len(basStr) == 0 {
  5239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5240. return
  5241. }
  5242. fmt.Println(basStr)
  5243. bas := strings.Split(basStr, "|")
  5244. id_card_no := bas[1]
  5245. result, _ := service.ZHGdyb1101B(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "", 1, "")
  5246. //result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  5247. var dat map[string]interface{}
  5248. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5249. fmt.Println(dat)
  5250. } else {
  5251. fmt.Println(err)
  5252. }
  5253. userJSONBytes, _ := json.Marshal(dat)
  5254. var res ResultTwo
  5255. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5256. utils.ErrorLog("解析失败:%v", err)
  5257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5258. return
  5259. }
  5260. if res.Infcode == 0 {
  5261. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  5262. if err == gorm.ErrRecordNotFound {
  5263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5264. return
  5265. } else if err != nil {
  5266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5267. return
  5268. } else {
  5269. var insutypes []string
  5270. var insutype string
  5271. var is390 int = 0
  5272. var is310 int = 0
  5273. for _, item := range res.Output.Iinfo {
  5274. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5275. insutypes = append(insutypes, item.Insutype)
  5276. }
  5277. }
  5278. if len(insutypes) == 1 {
  5279. insutype = insutypes[0]
  5280. } else {
  5281. for _, i := range insutypes {
  5282. if i == "390" {
  5283. is390 = 1
  5284. }
  5285. if i == "310" {
  5286. is310 = 1
  5287. }
  5288. }
  5289. }
  5290. if is390 == 1 {
  5291. insutype = "390"
  5292. }
  5293. if is310 == 1 {
  5294. insutype = "310"
  5295. }
  5296. if len(insutypes) == 0 {
  5297. insutype = "310"
  5298. }
  5299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5300. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5301. infoStr := string(Iinfos)
  5302. idetinfoStr := string(Idetinfos)
  5303. psn := &models.HisPsn{
  5304. PsnNo: res.Output.Baseinfo.PsnNo,
  5305. Age: res.Output.Baseinfo.Age,
  5306. PatientId: patient.ID,
  5307. Certno: res.Output.Baseinfo.Certno,
  5308. Gend: res.Output.Baseinfo.Gend,
  5309. Naty: res.Output.Baseinfo.Naty,
  5310. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5311. PsnName: res.Output.Baseinfo.PsnName,
  5312. Idetinfo: idetinfoStr,
  5313. Insuinfo: infoStr,
  5314. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5315. CardInfo: basStr,
  5316. VerifyNumber: "",
  5317. }
  5318. service.CreateHisPsn(psn)
  5319. c.ServeSuccessJSON(map[string]interface{}{
  5320. "patient": patient,
  5321. "number": id_card_no,
  5322. "info": res,
  5323. "insutype": insutype,
  5324. })
  5325. }
  5326. } else {
  5327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5328. return
  5329. }
  5330. }
  5331. break
  5332. case 2:
  5333. if miConfig.MdtrtareaAdmvs == "421182" {
  5334. var res ResultTwohb
  5335. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  5336. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5337. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=1"
  5338. resp, requestErr := http.Get(api)
  5339. if requestErr != nil {
  5340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5341. return
  5342. }
  5343. body, ioErr := ioutil.ReadAll(resp.Body)
  5344. if ioErr != nil {
  5345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5347. return
  5348. }
  5349. var respJSON map[string]interface{}
  5350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5353. return
  5354. }
  5355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5356. result, _ := json.Marshal(respJSON)
  5357. fmt.Println("log")
  5358. fmt.Println(string(result))
  5359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5360. utils.ErrorLog("解析失败:%v", err)
  5361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5362. return
  5363. }
  5364. if res.Infcode == 0 {
  5365. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5366. if err == gorm.ErrRecordNotFound {
  5367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5368. return
  5369. } else if err != nil {
  5370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5371. return
  5372. } else {
  5373. var insuplc_admdvs_temp string
  5374. var insutypes []string
  5375. var insutype string
  5376. var is390 int = 0
  5377. var is310 int = 0
  5378. for _, item := range res.Output.Iinfo {
  5379. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5380. insutypes = append(insutypes, item.Insutype)
  5381. }
  5382. }
  5383. if len(insutypes) == 1 {
  5384. insutype = insutypes[0]
  5385. } else {
  5386. for _, i := range insutypes {
  5387. if i == "390" {
  5388. is390 = 1
  5389. }
  5390. if i == "310" {
  5391. is310 = 1
  5392. }
  5393. }
  5394. }
  5395. if is390 == 1 {
  5396. insutype = "390"
  5397. }
  5398. if is310 == 1 {
  5399. insutype = "310"
  5400. }
  5401. if len(insutypes) == 0 {
  5402. insutype = "310"
  5403. }
  5404. for _, item := range insutypes {
  5405. if item == insutype {
  5406. insuplc_admdvs_temp = item
  5407. }
  5408. }
  5409. //insuplcAdmdvs := strconv.Itoa(insuplc_admdvs_temp)
  5410. card_info_two := insuplc_admdvs_temp + "|" + res.Output.Baseinfo.Certno + "|" + res.Output.Baseinfo.ExpContent.MdtrtCertNo
  5411. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5412. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5413. infoStr := string(Iinfos)
  5414. idetinfoStr := string(Idetinfos)
  5415. psn := &models.HisPsn{
  5416. PsnNo: res.Output.Baseinfo.PsnNo,
  5417. PatientId: patient.ID,
  5418. Certno: res.Output.Baseinfo.Certno,
  5419. Gend: res.Output.Baseinfo.Gend,
  5420. Naty: res.Output.Baseinfo.Naty,
  5421. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5422. PsnName: res.Output.Baseinfo.PsnName,
  5423. Idetinfo: idetinfoStr,
  5424. Insuinfo: infoStr,
  5425. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5426. InsuplcAdmdvs: insuplc_admdvs_temp,
  5427. CardInfo:card_info_two,
  5428. }
  5429. service.CreateHisPsn(psn)
  5430. c.ServeSuccessJSON(map[string]interface{}{
  5431. "patient": patient,
  5432. "number": res.Output.Baseinfo.Certno,
  5433. })
  5434. }
  5435. } else {
  5436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5437. return
  5438. }
  5439. }
  5440. case 4: //电子凭证
  5441. if miConfig.MdtrtareaAdmvs == "150499" {
  5442. var api string
  5443. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5444. "&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 + "&is_settle=" + is_settle
  5445. resp, requestErr := http.Get(api)
  5446. if requestErr != nil {
  5447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5448. return
  5449. }
  5450. body, ioErr := ioutil.ReadAll(resp.Body)
  5451. if ioErr != nil {
  5452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5454. return
  5455. }
  5456. var respJSON map[string]interface{}
  5457. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5460. return
  5461. }
  5462. var status string
  5463. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5464. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5465. var token string
  5466. var res ResultTwo //1101结果
  5467. var res10265 ResultTwo10265 //1101结果
  5468. if status == "0" { //读卡成功
  5469. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5470. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5471. result, _ := json.Marshal(respJSON)
  5472. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5473. utils.ErrorLog("解析失败:%v", err)
  5474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5475. return
  5476. }
  5477. res.ErrMsg = res10265.ErrMsg
  5478. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5479. res.Infcode = infocode
  5480. res.Output = res10265.Output
  5481. res.InfRefmsgid = res10265.InfRefmsgid
  5482. if res.Infcode == 0 {
  5483. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5484. if err == gorm.ErrRecordNotFound {
  5485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5486. return
  5487. } else if err != nil {
  5488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5489. return
  5490. } else {
  5491. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5492. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5493. infoStr := string(Iinfos)
  5494. idetinfoStr := string(Idetinfos)
  5495. psn := &models.HisPsn{
  5496. PsnNo: res.Output.Baseinfo.PsnNo,
  5497. Age: res.Output.Baseinfo.Age,
  5498. PatientId: patient.ID,
  5499. Certno: res.Output.Baseinfo.Certno,
  5500. Gend: res.Output.Baseinfo.Gend,
  5501. Naty: res.Output.Baseinfo.Naty,
  5502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5503. PsnName: res.Output.Baseinfo.PsnName,
  5504. Idetinfo: idetinfoStr,
  5505. Insuinfo: infoStr,
  5506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5507. CardInfo: "",
  5508. VerifyNumber: token,
  5509. }
  5510. service.CreateHisPsn(psn)
  5511. var insutypes []string
  5512. var insutype string
  5513. var is390 int = 0
  5514. var is310 int = 0
  5515. for _, item := range res.Output.Iinfo {
  5516. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5517. insutypes = append(insutypes, item.Insutype)
  5518. }
  5519. }
  5520. if len(insutypes) == 1 {
  5521. insutype = insutypes[0]
  5522. } else {
  5523. for _, i := range insutypes {
  5524. if i == "390" {
  5525. is390 = 1
  5526. }
  5527. if i == "310" {
  5528. is310 = 1
  5529. }
  5530. }
  5531. }
  5532. if is390 == 1 {
  5533. insutype = "390"
  5534. }
  5535. if is310 == 1 {
  5536. insutype = "310"
  5537. }
  5538. if len(insutypes) == 0 {
  5539. insutype = "390"
  5540. }
  5541. c.ServeSuccessJSON(map[string]interface{}{
  5542. "failed_code": 0,
  5543. "info": res,
  5544. "insutype": insutype,
  5545. "patient": patient,
  5546. })
  5547. }
  5548. } else {
  5549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5550. return
  5551. }
  5552. }
  5553. } else if miConfig.MdtrtareaAdmvs == "421182" {
  5554. var res ResultTwohb
  5555. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  5556. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5557. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=1"
  5558. resp, requestErr := http.Get(api)
  5559. if requestErr != nil {
  5560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5561. return
  5562. }
  5563. body, ioErr := ioutil.ReadAll(resp.Body)
  5564. if ioErr != nil {
  5565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5567. return
  5568. }
  5569. var respJSON map[string]interface{}
  5570. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5573. return
  5574. }
  5575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5576. result, _ := json.Marshal(respJSON)
  5577. fmt.Println("log")
  5578. fmt.Println(string(result))
  5579. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5580. utils.ErrorLog("解析失败:%v", err)
  5581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5582. return
  5583. }
  5584. if res.Infcode == 0 {
  5585. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5586. if err == gorm.ErrRecordNotFound {
  5587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5588. return
  5589. } else if err != nil {
  5590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5591. return
  5592. } else {
  5593. var insuplc_admdvs_temp string
  5594. var insutypes []string
  5595. var insutype string
  5596. var is390 int = 0
  5597. var is310 int = 0
  5598. for _, item := range res.Output.Iinfo {
  5599. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5600. insutypes = append(insutypes, item.Insutype)
  5601. }
  5602. }
  5603. if len(insutypes) == 1 {
  5604. insutype = insutypes[0]
  5605. } else {
  5606. for _, i := range insutypes {
  5607. if i == "390" {
  5608. is390 = 1
  5609. }
  5610. if i == "310" {
  5611. is310 = 1
  5612. }
  5613. }
  5614. }
  5615. if is390 == 1 {
  5616. insutype = "390"
  5617. }
  5618. if is310 == 1 {
  5619. insutype = "310"
  5620. }
  5621. if len(insutypes) == 0 {
  5622. insutype = "310"
  5623. }
  5624. for _, item := range insutypes {
  5625. if item == insutype {
  5626. insuplc_admdvs_temp = item
  5627. }
  5628. }
  5629. //insuplcAdmdvs := strconv.Itoa(insuplc_admdvs_temp)
  5630. card_info_two := insuplc_admdvs_temp + "|" + res.Output.Baseinfo.Certno + "|" + res.Output.Baseinfo.ExpContent.MdtrtCertNo
  5631. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5632. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5633. infoStr := string(Iinfos)
  5634. idetinfoStr := string(Idetinfos)
  5635. psn := &models.HisPsn{
  5636. PsnNo: res.Output.Baseinfo.PsnNo,
  5637. PatientId: patient.ID,
  5638. Certno: res.Output.Baseinfo.Certno,
  5639. Gend: res.Output.Baseinfo.Gend,
  5640. Naty: res.Output.Baseinfo.Naty,
  5641. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5642. PsnName: res.Output.Baseinfo.PsnName,
  5643. Idetinfo: idetinfoStr,
  5644. Insuinfo: infoStr,
  5645. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5646. InsuplcAdmdvs: insuplc_admdvs_temp,
  5647. CardInfo:card_info_two,
  5648. }
  5649. service.CreateHisPsn(psn)
  5650. c.ServeSuccessJSON(map[string]interface{}{
  5651. "patient": patient,
  5652. "number": res.Output.Baseinfo.Certno,
  5653. })
  5654. }
  5655. } else {
  5656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5657. return
  5658. }
  5659. } else if miConfig.MdtrtareaAdmvs =="360399"{
  5660. //if initFlag == 0 {
  5661. //c.TestGetJiangXiBasBaseInit()
  5662. //}
  5663. //if initEleFlag == 0 {
  5664. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  5665. //}
  5666. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  5667. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  5668. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  5669. type ELeData struct {
  5670. Data struct {
  5671. IdNo string `json:"idNo"`
  5672. IdType string `json:"idType"`
  5673. UserName string `json:"userName"`
  5674. EcToken string `json:"ecToken"`
  5675. InsuOrg string `json:"insuOrg"`
  5676. Gender string `json:"gender"`
  5677. Birthday string `json:"birthday"`
  5678. Nationality string `json:"nationality"`
  5679. Email string `json:"email"`
  5680. Extra string `json:"extra"`
  5681. } `json:"data"`
  5682. Code int `json:"code"`
  5683. Message string `json:"message"`
  5684. }
  5685. var ele ELeData
  5686. err := json.Unmarshal([]byte(result), &ele)
  5687. if err != nil {
  5688. utils.ErrorLog("解析失败:%v", err)
  5689. }
  5690. token := ele.Data.EcToken
  5691. token = Remove0000(token)
  5692. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  5693. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5694. var res ResultTwo
  5695. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5696. utils.ErrorLog("解析失败:%v", err)
  5697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5698. return
  5699. }
  5700. if res.Infcode == 0 {
  5701. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5702. if err == gorm.ErrRecordNotFound {
  5703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5704. return
  5705. } else if err != nil {
  5706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5707. return
  5708. } else {
  5709. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5710. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5711. infoStr := string(Iinfos)
  5712. idetinfoStr := string(Idetinfos)
  5713. psn := &models.HisPsn{
  5714. PsnNo: res.Output.Baseinfo.PsnNo,
  5715. Age: res.Output.Baseinfo.Age,
  5716. PatientId: patient.ID,
  5717. Certno: res.Output.Baseinfo.Certno,
  5718. Gend: res.Output.Baseinfo.Gend,
  5719. Naty: res.Output.Baseinfo.Naty,
  5720. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5721. PsnName: res.Output.Baseinfo.PsnName,
  5722. Idetinfo: idetinfoStr,
  5723. Insuinfo: infoStr,
  5724. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5725. CardInfo: "",
  5726. VerifyNumber: token,
  5727. }
  5728. service.CreateHisPsn(psn)
  5729. var rf []*ResultFive
  5730. json.Unmarshal([]byte(infoStr), &rf)
  5731. var insutypes []*ResultFive
  5732. var insutype string
  5733. var is390 int = 0
  5734. var is310 int = 0
  5735. for _, item := range rf {
  5736. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5737. insutypes = append(insutypes, item)
  5738. }
  5739. }
  5740. if len(insutypes) == 1 {
  5741. insutype = insutypes[0].Insutype
  5742. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5743. } else {
  5744. for _, i := range insutypes {
  5745. if i.Insutype == "390" {
  5746. is390 = 1
  5747. }
  5748. if i.Insutype == "310" {
  5749. is310 = 1
  5750. }
  5751. }
  5752. }
  5753. if is390 == 1 {
  5754. insutype = "390"
  5755. }
  5756. if is310 == 1 {
  5757. insutype = "310"
  5758. }
  5759. if len(insutypes) == 0 {
  5760. insutype = "310"
  5761. }
  5762. c.ServeSuccessJSON(map[string]interface{}{
  5763. "patient": patient,
  5764. "number": token,
  5765. "info": res,
  5766. "insutype": insutype,
  5767. })
  5768. }
  5769. } else {
  5770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5771. return
  5772. }
  5773. }else {
  5774. if initFlagTwo == 0 {
  5775. c.TestGetBasBaseInitTwo()
  5776. }
  5777. token := c.GetEleBaseInfoTwo()
  5778. token = Remove0000(token)
  5779. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  5780. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5781. //
  5782. var res ResultTwo
  5783. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5784. utils.ErrorLog("解析失败:%v", err)
  5785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5786. return
  5787. }
  5788. if res.Infcode == 0 {
  5789. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5790. if err == gorm.ErrRecordNotFound {
  5791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5792. return
  5793. } else if err != nil {
  5794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5795. return
  5796. } else {
  5797. var insutypes []string
  5798. var insutype string
  5799. var is390 int = 0
  5800. var is310 int = 0
  5801. for _, item := range res.Output.Iinfo {
  5802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5803. insutypes = append(insutypes, item.Insutype)
  5804. }
  5805. }
  5806. if len(insutypes) == 1 {
  5807. insutype = insutypes[0]
  5808. } else {
  5809. for _, i := range insutypes {
  5810. if i == "390" {
  5811. is390 = 1
  5812. }
  5813. if i == "310" {
  5814. is310 = 1
  5815. }
  5816. }
  5817. }
  5818. if is390 == 1 {
  5819. insutype = "390"
  5820. }
  5821. if is310 == 1 {
  5822. insutype = "310"
  5823. }
  5824. if len(insutypes) == 0 {
  5825. insutype = "310"
  5826. }
  5827. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5828. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5829. infoStr := string(Iinfos)
  5830. idetinfoStr := string(Idetinfos)
  5831. psn := &models.HisPsn{
  5832. PsnNo: res.Output.Baseinfo.PsnNo,
  5833. Age: res.Output.Baseinfo.Age,
  5834. PatientId: patient.ID,
  5835. Certno: res.Output.Baseinfo.Certno,
  5836. Gend: res.Output.Baseinfo.Gend,
  5837. Naty: res.Output.Baseinfo.Naty,
  5838. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5839. PsnName: res.Output.Baseinfo.PsnName,
  5840. Idetinfo: idetinfoStr,
  5841. Insuinfo: infoStr,
  5842. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5843. CardInfo: "",
  5844. VerifyNumber: token,
  5845. }
  5846. service.CreateHisPsn(psn)
  5847. c.ServeSuccessJSON(map[string]interface{}{
  5848. "patient": patient,
  5849. "number": token,
  5850. "info": res,
  5851. "insutype": insutype,
  5852. })
  5853. }
  5854. } else {
  5855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5856. return
  5857. }
  5858. }
  5859. break
  5860. }
  5861. }
  5862. func GetjxELekeyInfo(code string, operator_id string, operator_name string) (string, string) {
  5863. // WebSocket服务器地址
  5864. serverURL := "ws://127.0.0.1:8899"
  5865. // 解析WebSocket服务器地址
  5866. u, err := url.Parse(serverURL)
  5867. if err != nil {
  5868. }
  5869. // 建立WebSocket连接
  5870. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  5871. if err != nil {
  5872. }
  5873. defer conn.Close()
  5874. input2 := make(map[string]interface{})
  5875. input := make(map[string]interface{})
  5876. inputData := make(map[string]interface{})
  5877. inputData["orgId"] = code
  5878. inputData["businessType"] = "01101"
  5879. inputData["operatorId"] = operator_id
  5880. inputData["operatorName"] = operator_name
  5881. inputData["officeId"] = "001"
  5882. inputData["officeName"] = "血透室"
  5883. inputData["deviceType"] = ""
  5884. input["data"] = inputData
  5885. input["orgId"] = code
  5886. input["transType"] = "ec.query"
  5887. //if md == ""
  5888. input2["url"] = "http://10.77.211.236/1.0.0/getEncDynamicKey"
  5889. input2["indata"] = input
  5890. fmt.Println(input2)
  5891. bytesData, _ := json.Marshal(input2)
  5892. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  5893. if err != nil {
  5894. fmt.Println(err)
  5895. }
  5896. // 接收消息
  5897. _, receivedMessage, err := conn.ReadMessage()
  5898. if err != nil {
  5899. fmt.Println(err)
  5900. }
  5901. return "", string(receivedMessage)
  5902. }
  5903. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  5904. // WebSocket服务器地址
  5905. serverURL := "ws://127.0.0.1:8899"
  5906. // 解析WebSocket服务器地址
  5907. u, err := url.Parse(serverURL)
  5908. if err != nil {
  5909. }
  5910. // 建立WebSocket连接
  5911. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  5912. if err != nil {
  5913. }
  5914. defer conn.Close()
  5915. input2 := make(map[string]interface{})
  5916. input := make(map[string]interface{})
  5917. inputData := make(map[string]interface{})
  5918. inputData["orgId"] = code
  5919. inputData["businessType"] = "01103"
  5920. inputData["operatorId"] = operator_id
  5921. inputData["operatorName"] = operator_name
  5922. inputData["officeId"] = "001"
  5923. inputData["officeName"] = "血透室"
  5924. inputData["deviceType"] = ""
  5925. input["data"] = inputData
  5926. input["orgId"] = code
  5927. input["transType"] = "ec.query"
  5928. //if md ==
  5929. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  5930. input2["indata"] = input
  5931. fmt.Println(input2)
  5932. bytesData, _ := json.Marshal(input2)
  5933. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  5934. if err != nil {
  5935. fmt.Println(err)
  5936. }
  5937. // 接收消息
  5938. _, receivedMessage, err := conn.ReadMessage()
  5939. if err != nil {
  5940. fmt.Println(err)
  5941. }
  5942. return "", string(receivedMessage)
  5943. }
  5944. func (c *ZHHisApiController) GetEleBaseInfoTwo() string {
  5945. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5946. readCard := DllDef.MustFindProc("GetQRBase")
  5947. fmt.Println(readCard)
  5948. if readCard == nil {
  5949. fmt.Println("readcard is nil")
  5950. readCard = DllDef.MustFindProc("GetQRBase")
  5951. }
  5952. str := make([]byte, 1024)
  5953. str1 := make([]byte, 1024)
  5954. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5955. fmt.Println(ret2)
  5956. fmt.Println(string(str1))
  5957. fmt.Println(string(str))
  5958. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5959. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5960. if ret2 != 0 {
  5961. return ""
  5962. }
  5963. return string(str)
  5964. }
  5965. func (c *ZHHisApiController) TestGetBasBaseInitTwo() {
  5966. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5967. Iinit := DllDef.MustFindProc("Init")
  5968. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5969. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.MdtrtareaAdmvs))
  5970. if ret != 0 {
  5971. fmt.Println("SSCard的报错原因:", err)
  5972. fmt.Println("SSCard的运算结果为:", ret)
  5973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5974. return
  5975. }
  5976. result := int(ret)
  5977. fmt.Println("SSCard的运算结果为1:", result)
  5978. initFlagTwo = 1
  5979. return
  5980. }
  5981. func (c *ZHHisApiController) GetBasBaseInfoTwo() string {
  5982. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5983. readCard := DllDef.MustFindProc("ReadCardBas")
  5984. if readCard == nil {
  5985. fmt.Println("readcard is nil")
  5986. readCard = DllDef.MustFindProc("ReadCardBas")
  5987. }
  5988. str := make([]byte, 1024)
  5989. str1 := make([]byte, 1024)
  5990. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5991. fmt.Println(string(str1))
  5992. fmt.Println(string(str))
  5993. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5994. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5995. if ret2 != 0 {
  5996. return ""
  5997. }
  5998. return string(str)
  5999. }
  6000. var initFlag int64 = 0
  6001. func (c *ZHHisApiController) TestGetBasBaseInit() {
  6002. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  6003. Iinit := DllDef.MustFindProc("Init")
  6004. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6005. str := make([]byte, 2048)
  6006. inputData := make(map[string]interface{})
  6007. inputData["IP"] = "10.144.211.75"
  6008. inputData["PORT"] = 7021
  6009. inputData["TIMEOUT"] = 180
  6010. inputData["LOG_PATH"] = "C:\\log\\"
  6011. //inputData["SFZ_DRIVER_TYPE"] = 0
  6012. inputData["URL"] = "/call1"
  6013. bytesData, _ := json.Marshal(inputData)
  6014. fmt.Println(inputData)
  6015. fmt.Println(bytesData)
  6016. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  6017. if ret != 0 {
  6018. fmt.Println("SSCard的报错原因:", err)
  6019. fmt.Println("SSCard的运算结果为:", ret)
  6020. fmt.Println("SSCard的返回结果为:", string(str))
  6021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  6022. return
  6023. }
  6024. fmt.Println("SSCard的返回结果为:", string(str))
  6025. result := int(ret)
  6026. fmt.Println("SSCard的运算结果为1:", result)
  6027. //initFlag = 1
  6028. return
  6029. }
  6030. func (c *ZHHisApiController) GetSFZBaseInfo() string {
  6031. DllDef := syscall.MustLoadDLL("SSCard.dll")
  6032. readCard := DllDef.MustFindProc("ReadSFZ")
  6033. if readCard == nil {
  6034. fmt.Println("readcard is nil")
  6035. readCard = DllDef.MustFindProc("ReadSFZ")
  6036. }
  6037. str := make([]byte, 256)
  6038. str1 := make([]byte, 256)
  6039. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  6040. fmt.Println(r)
  6041. return string(str)
  6042. }
  6043. func (c *ZHHisApiController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
  6044. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  6045. readCard := DllDef.MustFindProc("ReadCardBas")
  6046. fmt.Println(readCard)
  6047. fmt.Println("!!!!!")
  6048. month := time.Unix(1557042972, 0).Format("1")
  6049. year := time.Now().Format("2006")
  6050. month = time.Now().Format("01")
  6051. day := time.Now().Format("02")
  6052. hour := time.Now().Format("15")
  6053. min := time.Now().Format("04")
  6054. sec := time.Now().Format("05")
  6055. msec := time.Now().Format("000")
  6056. timestamp := time.Now().Unix()
  6057. tempTime := time.Unix(timestamp, 0)
  6058. //timeFormat := tempTime.Format("20060102150405")
  6059. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6060. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  6061. inputData := make(map[string]interface{})
  6062. inputData["infno"] = "1199"
  6063. //inputData["msgid"] = "7021"
  6064. inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  6065. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs // 发送方报文 ID
  6066. inputData["recer_sys_code"] = "01"
  6067. inputData["infver"] = "V1.0"
  6068. inputData["opter_type"] = "1"
  6069. inputData["opter"] = opter_id
  6070. inputData["opter_name"] = opter_name
  6071. inputData["inf_time"] = timeFormatOne
  6072. inputData["fixmedins_code"] = fixmedins_code
  6073. inputData["fixmedins_name"] = fixmedins_name
  6074. inputData["dev_no"] = ""
  6075. inputData["dev_safe_info"] = ""
  6076. inputData["cainfo"] = ""
  6077. inputData["signtype"] = ""
  6078. inputData["sign_no"] = ""
  6079. bytesData, _ := json.Marshal(inputData)
  6080. fmt.Println(string(bytesData))
  6081. pBusiCardInfo := make([]byte, 8192)
  6082. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  6083. fmt.Println(ret2)
  6084. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  6085. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  6086. if ret2 != 0 {
  6087. return ""
  6088. }
  6089. return DeleteExtraSpace(string(pBusiCardInfo))
  6090. }
  6091. func DeleteExtraSpace(s string) string {
  6092. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  6093. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  6094. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  6095. reg, _ := regexp.Compile(regstr) //编译正则表达式
  6096. s2 := make([]byte, len(s1)) //定义字符数组切片
  6097. copy(s2, s1) //将字符串复制到切片
  6098. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  6099. for len(spc_index) > 0 { //找到适配项
  6100. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  6101. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  6102. }
  6103. return string(s2)
  6104. }
  6105. func (c *ZHHisApiController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  6106. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  6107. readCard := DllDef.MustFindProc("NationEcTrans")
  6108. fmt.Println(readCard)
  6109. fmt.Println("!!!!!")
  6110. pBusiCardInfo := make([]byte, 8192)
  6111. input := make(map[string]interface{})
  6112. inputData := make(map[string]interface{})
  6113. inputData["orgId"] = code
  6114. inputData["businessType"] = "01101"
  6115. inputData["operatorId"] = operator_id
  6116. inputData["operatorName"] = operator_name
  6117. inputData["officeId"] = "001"
  6118. inputData["officeName"] = "血透室"
  6119. inputData["deviceType"] = ""
  6120. input["data"] = inputData
  6121. input["orgId"] = code
  6122. input["transType"] = "ec.query"
  6123. bytesData, _ := json.Marshal(input)
  6124. gdyb_url := beego.AppConfig.String("gdyb_url")
  6125. url := gdyb_url + "/localcfc/api/hsecfc/localQrCodeQuery"
  6126. ret2, _, _ := readCard.Call(StrPtr(url), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  6127. fmt.Println(ret2)
  6128. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  6129. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  6130. if ret2 != 0 {
  6131. return "", ""
  6132. }
  6133. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  6134. }
  6135. func StrPtr(s string) uintptr {
  6136. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  6137. }
  6138. func Remove0000(s string) string {
  6139. str := make([]rune, 0, len(s))
  6140. for _, v := range []rune(s) {
  6141. if v == 0 {
  6142. continue
  6143. }
  6144. str = append(str, v)
  6145. }
  6146. return string(str)
  6147. }
  6148. func IntPtr(n int) uintptr {
  6149. return uintptr(n)
  6150. }
  6151. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  6152. newArr = make([]string, 0)
  6153. for i := 0; i < len(arr); i++ {
  6154. repeat := false
  6155. for j := i + 1; j < len(arr); j++ {
  6156. if arr[i] == arr[j] {
  6157. repeat = true
  6158. break
  6159. }
  6160. }
  6161. if !repeat {
  6162. newArr = append(newArr, arr[i])
  6163. }
  6164. }
  6165. return
  6166. }
  6167. type Result3101 struct {
  6168. Infcode int64 `json:"infcode"`
  6169. InfRefmsgid string `json:"inf_refmsgid"`
  6170. RefmsgTime string `json:"refmsg_time"`
  6171. RespondTime string `json:"respond_time"`
  6172. Enctype string `json:"enctype"`
  6173. Signtype string `json:"signtype"`
  6174. ErrMsg string `json:"err_msg"`
  6175. Output struct {
  6176. Result []struct {
  6177. JudgeResultDetailDtos []struct {
  6178. VolaItemType string `json:"vola_item_type"`
  6179. MdtrtID string `json:"mdtrt_id"`
  6180. JrdID string `json:"jrd_id"`
  6181. PatnID string `json:"patn_id"`
  6182. RxID string `json:"rx_id"`
  6183. VolaAmt interface{} `json:"vola_amt"`
  6184. } `json:"judge_result_detail_dtos"`
  6185. RuleID string `json:"rule_id"`
  6186. VolaEvid string `json:"vola_evid"`
  6187. MdtrtID string `json:"mdtrt_id"`
  6188. RuleName string `json:"rule_name"`
  6189. VolaAmtStas string `json:"vola_amt_stas"`
  6190. JrID string `json:"jr_id"`
  6191. PatnID string `json:"patn_id"`
  6192. SevDeg string `json:"sev_deg"`
  6193. VolaAmt float64 `json:"vola_amt"`
  6194. VolaBhvrType string `json:"vola_bhvr_type"`
  6195. VolaCont string `json:"vola_cont"`
  6196. } `json:"result"`
  6197. } `json:"output"`
  6198. }
  6199. func Check3101ForOne(c *ZHHisApiController, patient_id int64, his service.Struct2401, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription, ress ResultTwo, record_date int64) (res2 Result3101) {
  6200. var res Result3101
  6201. adminUser := c.GetAdminUserInfo()
  6202. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6203. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6204. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6205. //record_time := c.GetString("record_time")
  6206. //trig_scen := c.GetString("trig_scen")
  6207. timeLayout := "2006-01-02"
  6208. loc, _ := time.LoadLocation("Local")
  6209. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6210. if err != nil {
  6211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6212. return res
  6213. }
  6214. recordDateTime := theTime.Unix()
  6215. p, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6216. var patientPrescription models.HisPrescriptionInfo
  6217. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6218. //if patientPrescription.ID == 0 {
  6219. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6220. //}
  6221. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6222. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6223. //
  6224. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6225. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6226. var pp models.PublicParams
  6227. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6228. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6229. pp.FixmedinsName = miConfig.OrgName
  6230. pp.FixmedinsCode = miConfig.Code
  6231. pp.RequestUrl = miConfig.Url
  6232. pp.Cainfo = miConfig.Cainfo
  6233. pp.SecretKey = miConfig.SecretKey
  6234. pp.AccessKey = miConfig.AccessKey
  6235. pp.OpterName = roles.UserName
  6236. var config []*models.HisXtDiagnoseConfig
  6237. for _, item := range diagnosis_ids {
  6238. id, _ := strconv.ParseInt(item, 10, 64)
  6239. if id > 0 {
  6240. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6241. config = append(config, &diagnosisConfig)
  6242. }
  6243. }
  6244. var pd models.PatientDtos
  6245. pd.PatnID = his.PsnNo
  6246. pd.PatnName = p.Name
  6247. pd.Gend = ress.Output.Baseinfo.Gend
  6248. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6249. pd.CurrMdtrtID = strconv.FormatInt(patientPrescription.ID, 10)
  6250. var fed models.FsiEncounterDtos
  6251. fed.MdtrtID = p.IdCardNo
  6252. fed.MedinsID = miConfig.Code
  6253. fed.MedinsName = miConfig.OrgName
  6254. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6255. fed.MedMdtrtType = "1"
  6256. fed.MedinsType = "1"
  6257. fed.MedinsLv = "11"
  6258. tm := time.Unix(record_date, 0)
  6259. s_tm := tm.Format("2006-01-02 15:04:05")
  6260. fed.AdmDate = s_tm
  6261. fed.DscgDate = s_tm
  6262. fed.DscgMainDiseCodg = config[0].CountryCode
  6263. fed.DscgMainDiseName = config[0].CountryContentName
  6264. //诊断信息
  6265. var fdds []*models.FsiDiagnoseDtos
  6266. for index, item := range config {
  6267. if index == 0 {
  6268. var fdd models.FsiDiagnoseDtos
  6269. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6270. fdd.InoutDiseType = "1"
  6271. fdd.MaindiseFlag = "1"
  6272. fdd.DiseDate = s_tm
  6273. fdd.DiasSrtNo = "1"
  6274. fdd.DiseName = item.CountryContentName
  6275. fdd.DiseCodg = item.CountryCode
  6276. fdds = append(fdds, &fdd)
  6277. } else {
  6278. var fdd models.FsiDiagnoseDtos
  6279. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6280. fdd.InoutDiseType = "1"
  6281. fdd.MaindiseFlag = "1"
  6282. fdd.DiseDate = s_tm
  6283. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6284. fdd.DiseName = item.CountryContentName
  6285. fdd.DiseCodg = item.CountryCode
  6286. fdds = append(fdds, &fdd)
  6287. }
  6288. }
  6289. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6290. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6291. fed.AdmDeptName = department.Name
  6292. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6293. fed.DscgDeptName = department.Name
  6294. fed.MedMdtrtType = "1"
  6295. fed.MedType = "11"
  6296. //if his.Insutype == "390" {
  6297. // fed.MedType = "1402"
  6298. //} else {
  6299. // fed.MedType = "9933"
  6300. //}
  6301. var orders []*models.FsiOrderDtos
  6302. if trig_scen == "4" {
  6303. //处方医嘱信息
  6304. for _, item := range prescriptions {
  6305. for _, subItem := range item.HisDoctorAdviceInfo {
  6306. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  6307. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6308. var order models.FsiOrderDtos
  6309. order.RxID = strconv.FormatInt(item.ID, 10)
  6310. order.Rxno = strconv.FormatInt(item.ID, 10)
  6311. order.LongDrordFlag = "0"
  6312. order.HilistType = "1"
  6313. order.ChrgType = "1"
  6314. order.DrordBhvr = "0"
  6315. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6316. order.HosplistName = subItem.BaseDrugLib.DrugName
  6317. order.HilistLv = "1"
  6318. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6319. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6320. order.HosplistName = subItem.BaseDrugLib.DrugName
  6321. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6322. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6323. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6324. order.OwnpayAmt = ""
  6325. order.SelfpayAmt = ""
  6326. order.Spec = spec
  6327. order.SpecUnt = subItem.PrescribingNumberUnit
  6328. order.DrordBegnDate = s_tm
  6329. order.DrordStopDate = ""
  6330. order.DrordDrCodg = doctor_info.DoctorNumber
  6331. order.DrordDeptName = department.Name
  6332. order.DrordDeptCodg = department.Number
  6333. order.DrordDrName = doctor_info.UserName
  6334. order.DrordDrProfttl = "234"
  6335. order.CurrDrordFlag = "1"
  6336. orders = append(orders, &order)
  6337. }
  6338. }
  6339. for _, subItem := range item.HisPrescriptionProject {
  6340. if len(subItem.HisProject.MedicalCode) > 0 {
  6341. if subItem.Type == 2 {
  6342. var order models.FsiOrderDtos
  6343. order.RxID = strconv.FormatInt(item.ID, 10)
  6344. order.Rxno = strconv.FormatInt(item.ID, 10)
  6345. order.LongDrordFlag = "0"
  6346. order.HilistType = "1"
  6347. order.ChrgType = "1"
  6348. order.DrordBhvr = "0"
  6349. order.HilistCode = subItem.HisProject.MedicalCode
  6350. order.HosplistName = subItem.HisProject.ProjectName
  6351. order.HilistLv = "1"
  6352. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6353. order.HosplistCode = subItem.HisProject.MedicalCode
  6354. order.HosplistName = subItem.HisProject.ProjectName
  6355. order.Cnt = subItem.Count
  6356. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6357. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6358. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6359. order.OwnpayAmt = ""
  6360. order.SelfpayAmt = ""
  6361. order.Spec = subItem.Unit
  6362. order.SpecUnt = subItem.Unit
  6363. order.DrordBegnDate = s_tm
  6364. order.DrordStopDate = ""
  6365. order.DrordDrCodg = doctor_info.DoctorNumber
  6366. order.DrordDeptName = department.Name
  6367. order.DrordDeptCodg = department.Number
  6368. order.DrordDrName = doctor_info.UserName
  6369. order.DrordDrProfttl = "234"
  6370. order.CurrDrordFlag = "1"
  6371. orders = append(orders, &order)
  6372. }
  6373. }
  6374. if subItem.Type == 3 {
  6375. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
  6376. var order models.FsiOrderDtos
  6377. order.RxID = strconv.FormatInt(item.ID, 10)
  6378. order.Rxno = strconv.FormatInt(item.ID, 10)
  6379. order.LongDrordFlag = "0"
  6380. order.HilistType = "1"
  6381. order.ChrgType = "1"
  6382. order.DrordBhvr = "0"
  6383. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6384. order.HosplistName = subItem.GoodInfo.GoodName
  6385. order.HilistLv = "1"
  6386. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6387. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6388. order.HosplistName = subItem.GoodInfo.GoodName
  6389. order.Cnt = subItem.Count
  6390. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6391. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6392. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6393. order.OwnpayAmt = ""
  6394. order.SelfpayAmt = ""
  6395. order.Spec = subItem.GoodInfo.SpecificationName
  6396. order.SpecUnt = subItem.Unit
  6397. order.DrordBegnDate = s_tm
  6398. order.DrordStopDate = ""
  6399. order.DrordDrCodg = doctor_info.DoctorNumber
  6400. order.DrordDeptName = department.Name
  6401. order.DrordDeptCodg = department.Number
  6402. order.DrordDrName = doctor_info.UserName
  6403. order.DrordDrProfttl = "234"
  6404. order.CurrDrordFlag = "1"
  6405. orders = append(orders, &order)
  6406. }
  6407. }
  6408. }
  6409. }
  6410. //处方医嘱信息
  6411. }
  6412. fed.MatnStas = "0"
  6413. fed.MedfeeSumamt = "0"
  6414. fed.OwnpayAmt = "0"
  6415. fed.SelfpayAmt = "0"
  6416. fed.AcctPayamt = "0"
  6417. fed.MaAmt = "0"
  6418. fed.HifpPayamt = "0"
  6419. fed.SetlTotlnum = "1"
  6420. fed.Insutype = his.Insutype
  6421. fed.ReimFlag = "0"
  6422. fed.OutSetlFlag = "0"
  6423. var fopd []*models.FsiOperationDtosData
  6424. data := make(map[string]interface{})
  6425. data["fed"] = fed
  6426. data["fdd"] = fdds
  6427. data["fod"] = orders
  6428. data["pd"] = pd
  6429. data["pp"] = pp
  6430. data["fopd"] = fopd
  6431. data["trig_scen"] = trig_scen
  6432. fmt.Println(data)
  6433. fmt.Println(fed)
  6434. fmt.Println(fdds)
  6435. fmt.Println(orders)
  6436. fmt.Println(pd)
  6437. fmt.Println(pp)
  6438. fmt.Println(fopd)
  6439. client := &http.Client{}
  6440. bytesData, _ := json.Marshal(data)
  6441. var req *http.Request
  6442. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6443. if miConfig.MdtrtareaAdmvs == "320921" {
  6444. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6445. } else {
  6446. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6447. }
  6448. resp, _ := client.Do(req)
  6449. defer resp.Body.Close()
  6450. body, ioErr := ioutil.ReadAll(resp.Body)
  6451. if ioErr != nil {
  6452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6454. return res
  6455. }
  6456. var respJSON map[string]interface{}
  6457. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6460. return res
  6461. }
  6462. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6463. fmt.Println(respJSON)
  6464. result, _ := json.Marshal(respJSON)
  6465. fmt.Println(result)
  6466. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6467. utils.ErrorLog("解析失败:%v", err)
  6468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6469. return res
  6470. }
  6471. return res
  6472. } else {
  6473. //if miConfig.MdtrtareaAdmvs == "441202" {
  6474. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6475. saveLog(output, input, "3101", "事前")
  6476. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6477. utils.ErrorLog("解析失败:%v", err)
  6478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6479. return
  6480. }
  6481. return res
  6482. //}
  6483. }
  6484. }
  6485. func Check3101(c *ZHHisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  6486. adminUser := c.GetAdminUserInfo()
  6487. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6488. his, _ := service.GetInHospitalRecord(his_patient_id)
  6489. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6490. //record_time := c.GetString("record_time")
  6491. //trig_scen := c.GetString("trig_scen")
  6492. timeLayout := "2006-01-02"
  6493. loc, _ := time.LoadLocation("Local")
  6494. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6495. if err != nil {
  6496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6497. return res
  6498. }
  6499. recordDateTime := theTime.Unix()
  6500. var patientPrescription models.HisPrescriptionInfo
  6501. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6502. if patientPrescription.ID == 0 {
  6503. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6504. }
  6505. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6506. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6507. //
  6508. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6509. p, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  6510. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6511. var pp models.PublicParams
  6512. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6513. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6514. pp.FixmedinsName = miConfig.OrgName
  6515. pp.FixmedinsCode = miConfig.Code
  6516. pp.RequestUrl = miConfig.Url
  6517. pp.Cainfo = miConfig.Cainfo
  6518. pp.SecretKey = miConfig.SecretKey
  6519. pp.AccessKey = miConfig.AccessKey
  6520. pp.OpterName = roles.UserName
  6521. var config []*models.HisXtDiagnoseConfig
  6522. for _, item := range diagnosis_ids {
  6523. id, _ := strconv.ParseInt(item, 10, 64)
  6524. if id > 0 {
  6525. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6526. config = append(config, &diagnosisConfig)
  6527. }
  6528. }
  6529. var pd models.PatientDtos
  6530. pd.PatnID = his.PsnNo
  6531. pd.PatnName = his.Name
  6532. pd.Gend = his.Gend
  6533. pd.Poolarea = his.InsuplcAdmdvs
  6534. pd.CurrMdtrtID = his.Number
  6535. birthday := time.Unix(p.Birthday, 0)
  6536. // 格式化为生日字符串
  6537. birthdayStr := birthday.Format("2006-01-02") // 格式化模板为 "年-月-日"
  6538. pd.Brdy = birthdayStr
  6539. var fed models.FsiEncounterDtos
  6540. fed.MdtrtID = his.Number
  6541. fed.MedinsID = miConfig.Code
  6542. fed.MedinsName = miConfig.OrgName
  6543. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6544. fed.MedMdtrtType = "1"
  6545. fed.MedinsType = "1"
  6546. fed.MedinsLv = "11"
  6547. tm := time.Unix(his.RecordDate, 0)
  6548. s_tm := tm.Format("2006-01-02 15:04:05")
  6549. fed.AdmDate = s_tm
  6550. fed.DscgDate = s_tm
  6551. fed.DscgMainDiseCodg = config[0].CountryCode
  6552. fed.DscgMainDiseName = config[0].CountryContentName
  6553. //诊断信息
  6554. var fdds []*models.FsiDiagnoseDtos
  6555. for index, item := range config {
  6556. if index == 0 {
  6557. var fdd models.FsiDiagnoseDtos
  6558. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6559. fdd.InoutDiseType = "1"
  6560. fdd.MaindiseFlag = "1"
  6561. fdd.DiseDate = s_tm
  6562. fdd.DiasSrtNo = "1"
  6563. fdd.DiseName = item.CountryContentName
  6564. fdd.DiseCodg = item.CountryCode
  6565. fdds = append(fdds, &fdd)
  6566. } else {
  6567. var fdd models.FsiDiagnoseDtos
  6568. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6569. fdd.InoutDiseType = "1"
  6570. fdd.MaindiseFlag = "1"
  6571. fdd.DiseDate = s_tm
  6572. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6573. fdd.DiseName = item.CountryContentName
  6574. fdd.DiseCodg = item.CountryCode
  6575. fdds = append(fdds, &fdd)
  6576. }
  6577. }
  6578. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6579. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6580. fed.AdmDeptName = department.Name
  6581. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6582. fed.DscgDeptName = department.Name
  6583. fed.MedMdtrtType = "1"
  6584. fed.MedType = "11"
  6585. //if his.Insutype == "390" {
  6586. // fed.MedType = "1402"
  6587. //} else {
  6588. // fed.MedType = "9933"
  6589. //}
  6590. var orders []*models.FsiOrderDtos
  6591. if trig_scen == "4" {
  6592. //处方医嘱信息
  6593. for _, item := range prescriptions {
  6594. for _, subItem := range item.HisDoctorAdviceInfo {
  6595. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  6596. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6597. var order models.FsiOrderDtos
  6598. order.RxID = strconv.FormatInt(item.ID, 10)
  6599. order.Rxno = strconv.FormatInt(item.ID, 10)
  6600. order.LongDrordFlag = "0"
  6601. order.HilistType = "1"
  6602. order.ChrgType = "1"
  6603. order.DrordBhvr = "0"
  6604. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6605. order.HosplistName = subItem.BaseDrugLib.DrugName
  6606. order.HilistLv = "1"
  6607. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6608. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6609. order.HosplistName = subItem.BaseDrugLib.DrugName
  6610. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6611. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6612. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6613. order.OwnpayAmt = ""
  6614. order.SelfpayAmt = ""
  6615. order.Spec = spec
  6616. order.SpecUnt = subItem.PrescribingNumberUnit
  6617. order.DrordBegnDate = s_tm
  6618. order.DrordStopDate = ""
  6619. order.DrordDrCodg = doctor_info.DoctorNumber
  6620. order.DrordDeptName = department.Name
  6621. order.DrordDeptCodg = department.Number
  6622. order.DrordDrName = doctor_info.UserName
  6623. order.DrordDrProfttl = "234"
  6624. order.CurrDrordFlag = "1"
  6625. orders = append(orders, &order)
  6626. }
  6627. }
  6628. for _, subItem := range item.HisPrescriptionProject {
  6629. if len(subItem.HisProject.MedicalCode) > 0 {
  6630. if subItem.Type == 2 {
  6631. var order models.FsiOrderDtos
  6632. order.RxID = strconv.FormatInt(item.ID, 10)
  6633. order.Rxno = strconv.FormatInt(item.ID, 10)
  6634. order.LongDrordFlag = "0"
  6635. order.HilistType = "1"
  6636. order.ChrgType = "1"
  6637. order.DrordBhvr = "0"
  6638. order.HilistCode = subItem.HisProject.MedicalCode
  6639. order.HosplistName = subItem.HisProject.ProjectName
  6640. order.HilistLv = "1"
  6641. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6642. order.HosplistCode = subItem.HisProject.MedicalCode
  6643. order.HosplistName = subItem.HisProject.ProjectName
  6644. order.Cnt = subItem.Count
  6645. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6646. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6647. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6648. order.OwnpayAmt = ""
  6649. order.SelfpayAmt = ""
  6650. order.Spec = subItem.Unit
  6651. order.SpecUnt = subItem.Unit
  6652. order.DrordBegnDate = s_tm
  6653. order.DrordStopDate = ""
  6654. order.DrordDrCodg = doctor_info.DoctorNumber
  6655. order.DrordDeptName = department.Name
  6656. order.DrordDeptCodg = department.Number
  6657. order.DrordDrName = doctor_info.UserName
  6658. order.DrordDrProfttl = "234"
  6659. order.CurrDrordFlag = "1"
  6660. orders = append(orders, &order)
  6661. }
  6662. }
  6663. if subItem.Type == 3 {
  6664. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
  6665. var order models.FsiOrderDtos
  6666. order.RxID = strconv.FormatInt(item.ID, 10)
  6667. order.Rxno = strconv.FormatInt(item.ID, 10)
  6668. order.LongDrordFlag = "0"
  6669. order.HilistType = "1"
  6670. order.ChrgType = "1"
  6671. order.DrordBhvr = "0"
  6672. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6673. order.HosplistName = subItem.GoodInfo.GoodName
  6674. order.HilistLv = "1"
  6675. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6676. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6677. order.HosplistName = subItem.GoodInfo.GoodName
  6678. order.Cnt = subItem.Count
  6679. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6680. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6681. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6682. order.OwnpayAmt = ""
  6683. order.SelfpayAmt = ""
  6684. order.Spec = subItem.GoodInfo.SpecificationName
  6685. order.SpecUnt = subItem.Unit
  6686. order.DrordBegnDate = s_tm
  6687. order.DrordStopDate = ""
  6688. order.DrordDrCodg = doctor_info.DoctorNumber
  6689. order.DrordDeptName = department.Name
  6690. order.DrordDeptCodg = department.Number
  6691. order.DrordDrName = doctor_info.UserName
  6692. order.DrordDrProfttl = "234"
  6693. order.CurrDrordFlag = "1"
  6694. orders = append(orders, &order)
  6695. }
  6696. }
  6697. }
  6698. }
  6699. //处方医嘱信息
  6700. }
  6701. fed.MatnStas = "0"
  6702. fed.MedfeeSumamt = "0"
  6703. fed.OwnpayAmt = "0"
  6704. fed.SelfpayAmt = "0"
  6705. fed.AcctPayamt = "0"
  6706. fed.MaAmt = "0"
  6707. fed.HifpPayamt = "0"
  6708. fed.SetlTotlnum = "1"
  6709. fed.Insutype = his.InsutypeType
  6710. fed.ReimFlag = "0"
  6711. fed.OutSetlFlag = "0"
  6712. var fopd []*models.FsiOperationDtosData
  6713. data := make(map[string]interface{})
  6714. data["fed"] = fed
  6715. data["fdd"] = fdds
  6716. data["fod"] = orders
  6717. data["pd"] = pd
  6718. data["pp"] = pp
  6719. data["fopd"] = fopd
  6720. data["trig_scen"] = trig_scen
  6721. fmt.Println(data)
  6722. fmt.Println(fed)
  6723. fmt.Println(fdds)
  6724. fmt.Println(orders)
  6725. fmt.Println(pd)
  6726. fmt.Println(pp)
  6727. fmt.Println(fopd)
  6728. client := &http.Client{}
  6729. bytesData, _ := json.Marshal(data)
  6730. var req *http.Request
  6731. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6732. if miConfig.MdtrtareaAdmvs == "320921" {
  6733. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6734. } else {
  6735. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6736. }
  6737. resp, _ := client.Do(req)
  6738. defer resp.Body.Close()
  6739. body, ioErr := ioutil.ReadAll(resp.Body)
  6740. if ioErr != nil {
  6741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6743. return res
  6744. }
  6745. var respJSON map[string]interface{}
  6746. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6749. return res
  6750. }
  6751. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6752. fmt.Println(respJSON)
  6753. result, _ := json.Marshal(respJSON)
  6754. fmt.Println(result)
  6755. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6756. utils.ErrorLog("解析失败:%v", err)
  6757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6758. return res
  6759. }
  6760. return res
  6761. } else {
  6762. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6763. saveLog(output, input, "3101", "事前")
  6764. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6765. utils.ErrorLog("解析失败:%v", err)
  6766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6767. return
  6768. }
  6769. return res
  6770. }
  6771. return res
  6772. }
  6773. func Check3102(c *ZHHisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  6774. ////patient_id, _ := c.GetInt64("patient_id")
  6775. //order_id, _ := c.GetInt64("order_id")
  6776. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6777. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6778. //trig_scen := c.GetString("trig_scen")
  6779. adminUser := c.GetAdminUserInfo()
  6780. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6781. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6782. his, _ := service.GetInHospitalRecord(his_patient_id)
  6783. p, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  6784. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6785. record_time := c.GetString("record_time")
  6786. order, _ := service.GetHisOrderByID(order_id)
  6787. timeLayout := "2006-01-02"
  6788. loc, _ := time.LoadLocation("Local")
  6789. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6790. if err != nil {
  6791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6792. return
  6793. }
  6794. recordDateTime := theTime.Unix()
  6795. var patientPrescription models.HisPrescriptionInfo
  6796. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6797. if patientPrescription.ID == 0 {
  6798. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6799. }
  6800. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6801. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6802. //
  6803. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6804. prescriptions, _ := service.GetNewHisPrescriptionTenone(adminUser.CurrentOrgId, his.Number)
  6805. var pp models.PublicParams
  6806. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6807. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6808. pp.FixmedinsName = miConfig.OrgName
  6809. pp.FixmedinsCode = miConfig.Code
  6810. pp.RequestUrl = miConfig.Url
  6811. pp.Cainfo = miConfig.Cainfo
  6812. pp.SecretKey = miConfig.SecretKey
  6813. pp.AccessKey = miConfig.AccessKey
  6814. pp.OpterName = roles.UserName
  6815. var config []*models.HisXtDiagnoseConfig
  6816. for _, item := range diagnosis_ids {
  6817. id, _ := strconv.ParseInt(item, 10, 64)
  6818. if id > 0 {
  6819. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6820. config = append(config, &diagnosisConfig)
  6821. }
  6822. }
  6823. var pd models.PatientDtos
  6824. pd.PatnID = his.PsnNo
  6825. pd.PatnName = his.Name
  6826. pd.Gend = his.Gend
  6827. pd.Poolarea = his.InsuplcAdmdvs
  6828. pd.CurrMdtrtID = his.Number
  6829. // 将时间戳转换为 time.Time 类型
  6830. birthday := time.Unix(p.Birthday, 0)
  6831. // 格式化为生日字符串
  6832. birthdayStr := birthday.Format("2006-01-02") // 格式化模板为 "年-月-日"
  6833. pd.Brdy = birthdayStr
  6834. var fed models.FsiEncounterDtos
  6835. fed.MdtrtID = his.Number
  6836. fed.MedinsID = miConfig.Code
  6837. fed.MedinsName = miConfig.OrgName
  6838. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6839. fed.MedMdtrtType = "1"
  6840. fed.MedinsType = "1"
  6841. fed.MedinsLv = "11"
  6842. tm := time.Unix(his.RecordDate, 0)
  6843. s_tm := tm.Format("2006-01-02 15:04:05")
  6844. fed.AdmDate = s_tm
  6845. fed.DscgDate = s_tm
  6846. fed.DscgMainDiseCodg = config[0].CountryCode
  6847. fed.DscgMainDiseName = config[0].CountryContentName
  6848. //诊断信息
  6849. var fdds []*models.FsiDiagnoseDtos
  6850. for index, item := range config {
  6851. if index == 0 {
  6852. var fdd models.FsiDiagnoseDtos
  6853. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6854. fdd.InoutDiseType = "1"
  6855. fdd.MaindiseFlag = "1"
  6856. fdd.DiseDate = s_tm
  6857. fdd.DiasSrtNo = "1"
  6858. fdd.DiseName = item.CountryContentName
  6859. fdd.DiseCodg = item.CountryCode
  6860. fdds = append(fdds, &fdd)
  6861. } else {
  6862. var fdd models.FsiDiagnoseDtos
  6863. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6864. fdd.InoutDiseType = "1"
  6865. fdd.MaindiseFlag = "1"
  6866. fdd.DiseDate = s_tm
  6867. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6868. fdd.DiseName = item.CountryContentName
  6869. fdd.DiseCodg = item.CountryCode
  6870. fdds = append(fdds, &fdd)
  6871. }
  6872. }
  6873. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6874. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6875. fed.AdmDeptName = department.Name
  6876. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6877. fed.DscgDeptName = department.Name
  6878. fed.MedType = "14"
  6879. //处方医嘱信息
  6880. var orders []*models.FsiOrderDtos
  6881. //for _, item := range prescriptions {
  6882. // for _, subItem := range item.HisDoctorAdviceInfo {
  6883. // var order models.FsiOrderDtos
  6884. // order.RxID = strconv.FormatInt(item.ID, 10)
  6885. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6886. // order.LongDrordFlag = "0"
  6887. // order.HilistType = "1"
  6888. // order.ChrgType = "1"
  6889. // order.DrordBhvr = "-"
  6890. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6891. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6892. // order.HilistLv = "1"
  6893. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6894. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6895. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6896. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6897. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6898. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6899. // order.OwnpayAmt = ""
  6900. // order.SelfpayAmt = ""
  6901. // order.Spec = ""
  6902. // order.SpecUnt = ""
  6903. // order.DrordBegnDate = s_tm
  6904. // order.DrordStopDate = ""
  6905. // order.DrordDrCodg = "1"
  6906. // order.DrordDeptName = department.Name
  6907. // order.DrordDrCodg = "1"
  6908. // order.DrordDrName = doctor_info.UserName
  6909. // order.DrordDrProfttl = ""
  6910. // order.CurrDrordFlag = "1"
  6911. // orders = append(orders, &order)
  6912. // }
  6913. // for _, subItem := range item.HisPrescriptionProject {
  6914. // if subItem.Type == 2 {
  6915. // var order models.FsiOrderDtos
  6916. // order.RxID = strconv.FormatInt(item.ID, 10)
  6917. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6918. // order.LongDrordFlag = "0"
  6919. // order.HilistType = "1"
  6920. // order.ChrgType = "1"
  6921. // order.DrordBhvr = "-"
  6922. // order.HilistCode = subItem.HisProject.MedicalCode
  6923. // order.HosplistName = subItem.HisProject.ProjectName
  6924. // order.HilistLv = "1"
  6925. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6926. // order.HosplistCode = subItem.HisProject.MedicalCode
  6927. // order.HosplistName = subItem.HisProject.ProjectName
  6928. // order.Cnt = subItem.Count
  6929. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6930. //
  6931. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6932. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6933. // order.OwnpayAmt = ""
  6934. // order.SelfpayAmt = ""
  6935. // order.Spec = ""
  6936. // order.SpecUnt = ""
  6937. // order.DrordBegnDate = s_tm
  6938. // order.DrordStopDate = ""
  6939. // order.DrordDrCodg = "1"
  6940. // order.DrordDeptName = department.Name
  6941. // order.DrordDrCodg = "1"
  6942. // order.DrordDrName = doctor_info.UserName
  6943. // order.DrordDrProfttl = ""
  6944. // order.CurrDrordFlag = "1"
  6945. // orders = append(orders, &order)
  6946. //
  6947. // }
  6948. // if subItem.Type == 3 {
  6949. //
  6950. // var order models.FsiOrderDtos
  6951. // order.RxID = strconv.FormatInt(item.ID, 10)
  6952. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6953. // order.LongDrordFlag = "0"
  6954. // order.HilistType = "1"
  6955. // order.ChrgType = "1"
  6956. // order.DrordBhvr = "-"
  6957. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6958. // order.HosplistName = subItem.GoodInfo.GoodName
  6959. // order.HilistLv = "1"
  6960. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6961. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6962. // order.HosplistName = subItem.GoodInfo.GoodName
  6963. // order.Cnt = subItem.Count
  6964. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6965. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6966. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6967. // order.OwnpayAmt = ""
  6968. // order.SelfpayAmt = ""
  6969. // order.Spec = ""
  6970. // order.SpecUnt = ""
  6971. // order.DrordBegnDate = s_tm
  6972. // order.DrordStopDate = ""
  6973. // order.DrordDrCodg = "1"
  6974. // order.DrordDeptName = department.Name
  6975. // order.DrordDrCodg = "1"
  6976. // order.DrordDrName = doctor_info.UserName
  6977. // order.DrordDrProfttl = ""
  6978. // order.CurrDrordFlag = "1"
  6979. // orders = append(orders, &order)
  6980. //
  6981. // }
  6982. // }
  6983. //}
  6984. for _, item := range prescriptions {
  6985. for _, subItem := range item.HisDoctorAdviceInfo {
  6986. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  6987. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6988. var order models.FsiOrderDtos
  6989. order.RxID = strconv.FormatInt(item.ID, 10)
  6990. order.Rxno = strconv.FormatInt(item.ID, 10)
  6991. order.LongDrordFlag = "0"
  6992. order.HilistType = "1"
  6993. order.ChrgType = "1"
  6994. order.DrordBhvr = "0"
  6995. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6996. order.HosplistName = subItem.BaseDrugLib.DrugName
  6997. order.HilistLv = "1"
  6998. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6999. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7000. order.HosplistName = subItem.BaseDrugLib.DrugName
  7001. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7002. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7003. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7004. order.OwnpayAmt = ""
  7005. order.SelfpayAmt = ""
  7006. order.Spec = spec
  7007. order.SpecUnt = subItem.PrescribingNumberUnit
  7008. order.DrordBegnDate = s_tm
  7009. order.DrordStopDate = ""
  7010. order.DrordDrCodg = doctor_info.DoctorNumber
  7011. order.DrordDeptName = department.Name
  7012. order.DrordDeptCodg = department.Number
  7013. order.DrordDrName = doctor_info.UserName
  7014. order.DrordDrProfttl = "234"
  7015. order.CurrDrordFlag = "1"
  7016. orders = append(orders, &order)
  7017. }
  7018. }
  7019. for _, subItem := range item.HisPrescriptionProject {
  7020. if len(subItem.HisProject.MedicalCode) > 0 {
  7021. if subItem.Type == 2 {
  7022. var order models.FsiOrderDtos
  7023. order.RxID = strconv.FormatInt(item.ID, 10)
  7024. order.Rxno = strconv.FormatInt(item.ID, 10)
  7025. order.LongDrordFlag = "0"
  7026. order.HilistType = "1"
  7027. order.ChrgType = "1"
  7028. order.DrordBhvr = "0"
  7029. order.HilistCode = subItem.HisProject.MedicalCode
  7030. order.HosplistName = subItem.HisProject.ProjectName
  7031. order.HilistLv = "1"
  7032. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7033. order.HosplistCode = subItem.HisProject.MedicalCode
  7034. order.HosplistName = subItem.HisProject.ProjectName
  7035. order.Cnt = subItem.Count
  7036. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7037. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7038. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7039. order.OwnpayAmt = ""
  7040. order.SelfpayAmt = ""
  7041. order.Spec = subItem.Unit
  7042. order.SpecUnt = subItem.Unit
  7043. order.DrordBegnDate = s_tm
  7044. order.DrordStopDate = ""
  7045. order.DrordDrCodg = doctor_info.DoctorNumber
  7046. order.DrordDeptName = department.Name
  7047. order.DrordDeptCodg = department.Number
  7048. order.DrordDrName = doctor_info.UserName
  7049. order.DrordDrProfttl = "234"
  7050. order.CurrDrordFlag = "1"
  7051. orders = append(orders, &order)
  7052. }
  7053. }
  7054. if subItem.Type == 3 {
  7055. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
  7056. var order models.FsiOrderDtos
  7057. order.RxID = strconv.FormatInt(item.ID, 10)
  7058. order.Rxno = strconv.FormatInt(item.ID, 10)
  7059. order.LongDrordFlag = "0"
  7060. order.HilistType = "1"
  7061. order.ChrgType = "1"
  7062. order.DrordBhvr = "0"
  7063. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7064. order.HosplistName = subItem.GoodInfo.GoodName
  7065. order.HilistLv = "1"
  7066. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7067. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7068. order.HosplistName = subItem.GoodInfo.GoodName
  7069. order.Cnt = subItem.Count
  7070. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7071. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7072. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7073. order.OwnpayAmt = ""
  7074. order.SelfpayAmt = ""
  7075. order.Spec = subItem.GoodInfo.SpecificationName
  7076. order.SpecUnt = subItem.Unit
  7077. order.DrordBegnDate = s_tm
  7078. order.DrordStopDate = ""
  7079. order.DrordDrCodg = doctor_info.DoctorNumber
  7080. order.DrordDeptName = department.Name
  7081. order.DrordDeptCodg = department.Number
  7082. order.DrordDrName = doctor_info.UserName
  7083. order.DrordDrProfttl = "234"
  7084. order.CurrDrordFlag = "1"
  7085. orders = append(orders, &order)
  7086. }
  7087. }
  7088. }
  7089. }
  7090. //for _, item := range prescriptions {
  7091. // for _, subItem := range item.HisDoctorAdviceInfo {
  7092. // spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7093. //
  7094. // var order models.FsiOrderDtos
  7095. // order.RxID = strconv.FormatInt(item.ID, 10)
  7096. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7097. // order.LongDrordFlag = "0"
  7098. // order.HilistType = "1"
  7099. // order.ChrgType = "1"
  7100. // order.DrordBhvr = "0"
  7101. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7102. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7103. // order.HilistLv = "1"
  7104. // order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7105. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7106. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7107. // order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7108. // order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7109. // order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7110. // order.OwnpayAmt = ""
  7111. // order.SelfpayAmt = ""
  7112. // order.Spec = spec
  7113. // order.SpecUnt = subItem.PrescribingNumberUnit
  7114. // order.DrordBegnDate = s_tm
  7115. // order.DrordStopDate = ""
  7116. // order.DrordDrCodg = doctor_info.DoctorNumber
  7117. // order.DrordDeptName = department.Name
  7118. // order.DrordDeptCodg = department.Number
  7119. // order.DrordDrName = doctor_info.UserName
  7120. // order.DrordDrProfttl = "234"
  7121. // order.CurrDrordFlag = "1"
  7122. // orders = append(orders, &order)
  7123. // }
  7124. // for _, subItem := range item.HisPrescriptionProject {
  7125. // if subItem.Type == 2 {
  7126. // var order models.FsiOrderDtos
  7127. // order.RxID = strconv.FormatInt(item.ID, 10)
  7128. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7129. // order.LongDrordFlag = "0"
  7130. // order.HilistType = "1"
  7131. // order.ChrgType = "1"
  7132. // order.DrordBhvr = "0"
  7133. // order.HilistCode = subItem.HisProject.MedicalCode
  7134. // order.HosplistName = subItem.HisProject.ProjectName
  7135. // order.HilistLv = "1"
  7136. // order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7137. // order.HosplistCode = subItem.HisProject.MedicalCode
  7138. // order.HosplistName = subItem.HisProject.ProjectName
  7139. // order.Cnt = subItem.Count
  7140. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7141. // order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7142. // order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7143. // order.OwnpayAmt = ""
  7144. // order.SelfpayAmt = ""
  7145. // order.Spec = subItem.Unit
  7146. // order.SpecUnt = subItem.Unit
  7147. // order.DrordBegnDate = s_tm
  7148. // order.DrordStopDate = ""
  7149. // order.DrordDrCodg = doctor_info.DoctorNumber
  7150. // order.DrordDeptName = department.Name
  7151. // order.DrordDeptCodg = department.Number
  7152. // order.DrordDrName = doctor_info.UserName
  7153. // order.DrordDrProfttl = "234"
  7154. // order.CurrDrordFlag = "1"
  7155. // orders = append(orders, &order)
  7156. //
  7157. // }
  7158. // if subItem.Type == 3 {
  7159. //
  7160. // var order models.FsiOrderDtos
  7161. // order.RxID = strconv.FormatInt(item.ID, 10)
  7162. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7163. // order.LongDrordFlag = "0"
  7164. // order.HilistType = "1"
  7165. // order.ChrgType = "1"
  7166. // order.DrordBhvr = "0"
  7167. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7168. // order.HosplistName = subItem.GoodInfo.GoodName
  7169. // order.HilistLv = "1"
  7170. // order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7171. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7172. // order.HosplistName = subItem.GoodInfo.GoodName
  7173. // order.Cnt = subItem.Count
  7174. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7175. // order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7176. // order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7177. // order.OwnpayAmt = ""
  7178. // order.SelfpayAmt = ""
  7179. // order.Spec = subItem.GoodInfo.SpecificationName
  7180. // order.SpecUnt = subItem.Unit
  7181. // order.DrordBegnDate = s_tm
  7182. // order.DrordStopDate = ""
  7183. // order.DrordDrCodg = doctor_info.DoctorNumber
  7184. // order.DrordDeptName = department.Name
  7185. // order.DrordDeptCodg = department.Number
  7186. // order.DrordDrName = doctor_info.UserName
  7187. // order.DrordDrProfttl = "234"
  7188. // order.CurrDrordFlag = "1"
  7189. // orders = append(orders, &order)
  7190. //
  7191. // }
  7192. // }
  7193. //}
  7194. //处方医嘱信息
  7195. fed.MatnStas = "0"
  7196. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7197. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7198. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7199. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7200. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7201. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7202. fed.SetlTotlnum = "1"
  7203. fed.Insutype = his.InsutypeType
  7204. fed.ReimFlag = "0"
  7205. fed.OutSetlFlag = "0"
  7206. var fopd []*models.FsiOperationDtosData
  7207. data := make(map[string]interface{})
  7208. data["fed"] = fed
  7209. data["fdd"] = fdds
  7210. data["fod"] = orders
  7211. data["pd"] = pd
  7212. data["pp"] = pp
  7213. data["fopd"] = fopd
  7214. data["trig_scen"] = trig_scen
  7215. client := &http.Client{}
  7216. bytesData, _ := json.Marshal(data)
  7217. var req *http.Request
  7218. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7219. if miConfig.MdtrtareaAdmvs == "320921" {
  7220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7221. } else {
  7222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7223. }
  7224. resp, _ := client.Do(req)
  7225. defer resp.Body.Close()
  7226. body, ioErr := ioutil.ReadAll(resp.Body)
  7227. if ioErr != nil {
  7228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7230. return res
  7231. }
  7232. var respJSON map[string]interface{}
  7233. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. return res
  7237. }
  7238. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7239. result, _ := json.Marshal(respJSON)
  7240. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7241. utils.ErrorLog("解析失败:%v", err)
  7242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7243. return res
  7244. }
  7245. return res
  7246. } else {
  7247. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7248. saveLog(output, input, "3102", "事中")
  7249. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7250. utils.ErrorLog("解析失败:%v", err)
  7251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7252. return
  7253. }
  7254. return res
  7255. }
  7256. return res
  7257. }