zh_his_api_controller.go 231KB

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