his_api_controller.go 482KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. }
  80. type Result3101 struct {
  81. Infcode string `json:"infcode"`
  82. InfRefmsgid string `json:"inf_refmsgid"`
  83. RefmsgTime string `json:"refmsg_time"`
  84. RespondTime string `json:"respond_time"`
  85. Enctype string `json:"enctype"`
  86. Signtype string `json:"signtype"`
  87. ErrMsg string `json:"err_msg"`
  88. Output struct {
  89. Result []struct {
  90. JudgeResultDetailDtos []struct {
  91. VolaItemType string `json:"vola_item_type"`
  92. MdtrtID string `json:"mdtrt_id"`
  93. JrdID string `json:"jrd_id"`
  94. PatnID string `json:"patn_id"`
  95. RxID string `json:"rx_id"`
  96. VolaAmt interface{} `json:"vola_amt"`
  97. } `json:"judge_result_detail_dtos"`
  98. RuleID string `json:"rule_id"`
  99. VolaEvid string `json:"vola_evid"`
  100. MdtrtID string `json:"mdtrt_id"`
  101. RuleName string `json:"rule_name"`
  102. VolaAmtStas string `json:"vola_amt_stas"`
  103. JrID string `json:"jr_id"`
  104. PatnID string `json:"patn_id"`
  105. SevDeg string `json:"sev_deg"`
  106. VolaAmt float64 `json:"vola_amt"`
  107. VolaBhvrType string `json:"vola_bhvr_type"`
  108. VolaCont string `json:"vola_cont"`
  109. } `json:"result"`
  110. } `json:"output"`
  111. }
  112. func (c *HisApiController) Get9001() {
  113. adminUser := c.GetAdminUserInfo()
  114. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  115. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  116. if miConfig.MdtrtareaAdmvs == "350500" {
  117. service.GetFjAuthorizationInfo(miConfig.Code)
  118. } else {
  119. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  120. var dat map[string]interface{}
  121. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  122. fmt.Println(dat)
  123. } else {
  124. fmt.Println(err)
  125. }
  126. userJSONBytes, _ := json.Marshal(dat)
  127. var res models.Result9001
  128. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  129. utils.ErrorLog("解析失败:%v", err)
  130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  131. return
  132. }
  133. }
  134. }
  135. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  136. var res Result3101
  137. adminUser := c.GetAdminUserInfo()
  138. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  139. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  140. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  141. //record_time := c.GetString("record_time")
  142. //trig_scen := c.GetString("trig_scen")
  143. timeLayout := "2006-01-02"
  144. loc, _ := time.LoadLocation("Local")
  145. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  146. if err != nil {
  147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  148. return res
  149. }
  150. recordDateTime := theTime.Unix()
  151. var patientPrescription models.HisPrescriptionInfo
  152. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  153. //if patientPrescription.ID == 0 {
  154. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  155. //}
  156. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  157. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  158. //
  159. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  160. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  161. var pp models.PublicParams
  162. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  163. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  164. pp.FixmedinsName = miConfig.OrgName
  165. pp.FixmedinsCode = miConfig.Code
  166. pp.RequestUrl = miConfig.Url
  167. pp.Cainfo = miConfig.Cainfo
  168. pp.SecretKey = miConfig.SecretKey
  169. pp.AccessKey = miConfig.AccessKey
  170. pp.OpterName = roles.UserName
  171. var config []*models.HisXtDiagnoseConfig
  172. for _, item := range diagnosis_ids {
  173. id, _ := strconv.ParseInt(item, 10, 64)
  174. diagnosisConfig, _ := service.FindDiagnoseById(id)
  175. config = append(config, &diagnosisConfig)
  176. }
  177. var pd models.PatientDtos
  178. pd.PatnID = his.PsnNo
  179. pd.PatnName = his.Name
  180. pd.Gend = his.Gend
  181. pd.Brdy = his.Brdy
  182. pd.Poolarea = miConfig.MdtrtareaAdmvs
  183. pd.CurrMdtrtID = his.Number
  184. var fed models.FsiEncounterDtos
  185. fed.MdtrtID = his.Number
  186. fed.MedinsID = miConfig.Code
  187. fed.MedinsName = miConfig.OrgName
  188. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  189. fed.MedMdtrtType = "1"
  190. fed.MedinsType = "1"
  191. fed.MedinsLv = "11"
  192. tm := time.Unix(his.RecordDate, 0)
  193. s_tm := tm.Format("2006-01-02 15:04:05")
  194. fed.AdmDate = s_tm
  195. fed.DscgDate = s_tm
  196. fed.DscgMainDiseCodg = config[0].CountryCode
  197. fed.DscgMainDiseName = config[0].CountryContentName
  198. //诊断信息
  199. var fdds []*models.FsiDiagnoseDtos
  200. for index, item := range config {
  201. if index == 0 {
  202. var fdd models.FsiDiagnoseDtos
  203. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  204. fdd.InoutDiseType = "1"
  205. fdd.MaindiseFlag = "1"
  206. fdd.DiseDate = s_tm
  207. fdd.DiasSrtNo = "1"
  208. fdd.DiseName = item.CountryContentName
  209. fdd.DiseCodg = item.CountryCode
  210. fdds = append(fdds, &fdd)
  211. } else {
  212. var fdd models.FsiDiagnoseDtos
  213. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  214. fdd.InoutDiseType = "1"
  215. fdd.MaindiseFlag = "1"
  216. fdd.DiseDate = s_tm
  217. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  218. fdd.DiseName = item.CountryContentName
  219. fdd.DiseCodg = item.CountryCode
  220. fdds = append(fdds, &fdd)
  221. }
  222. }
  223. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  224. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  225. fed.AdmDeptName = department.Name
  226. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  227. fed.DscgDeptName = department.Name
  228. fed.MedMdtrtType = "1"
  229. fed.MedType = "11"
  230. //if his.Insutype == "390" {
  231. // fed.MedType = "1402"
  232. //} else {
  233. // fed.MedType = "9933"
  234. //}
  235. var orders []*models.FsiOrderDtos
  236. if trig_scen == "2" {
  237. //处方医嘱信息
  238. for _, item := range prescriptions {
  239. for _, subItem := range item.HisDoctorAdviceInfo {
  240. var order models.FsiOrderDtos
  241. order.RxID = strconv.FormatInt(item.ID, 10)
  242. order.Rxno = strconv.FormatInt(item.ID, 10)
  243. order.LongDrordFlag = "0"
  244. order.HilistType = "1"
  245. order.ChrgType = "1"
  246. order.DrordBhvr = "-"
  247. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  248. order.HosplistName = subItem.BaseDrugLib.DrugName
  249. order.HilistLv = "1"
  250. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  251. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  252. order.HosplistName = subItem.BaseDrugLib.DrugName
  253. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  254. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  255. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  256. order.OwnpayAmt = ""
  257. order.SelfpayAmt = ""
  258. order.Spec = ""
  259. order.SpecUnt = ""
  260. order.DrordBegnDate = s_tm
  261. order.DrordStopDate = ""
  262. order.DrordDrCodg = "1"
  263. order.DrordDeptName = department.Name
  264. order.DrordDrCodg = "1"
  265. order.DrordDrName = doctor_info.UserName
  266. order.DrordDrProfttl = ""
  267. order.CurrDrordFlag = "1"
  268. orders = append(orders, &order)
  269. }
  270. for _, subItem := range item.HisPrescriptionProject {
  271. if subItem.Type == 2 {
  272. var order models.FsiOrderDtos
  273. order.RxID = strconv.FormatInt(item.ID, 10)
  274. order.Rxno = strconv.FormatInt(item.ID, 10)
  275. order.LongDrordFlag = "0"
  276. order.HilistType = "1"
  277. order.ChrgType = "1"
  278. order.DrordBhvr = "-"
  279. order.HilistCode = subItem.HisProject.MedicalCode
  280. order.HosplistName = subItem.HisProject.ProjectName
  281. order.HilistLv = "1"
  282. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  283. order.HosplistCode = subItem.HisProject.MedicalCode
  284. order.HosplistName = subItem.HisProject.ProjectName
  285. order.Cnt = subItem.Count
  286. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  287. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  288. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  289. order.OwnpayAmt = ""
  290. order.SelfpayAmt = ""
  291. order.Spec = ""
  292. order.SpecUnt = ""
  293. order.DrordBegnDate = s_tm
  294. order.DrordStopDate = ""
  295. order.DrordDrCodg = "1"
  296. order.DrordDeptName = department.Name
  297. order.DrordDrCodg = "1"
  298. order.DrordDrName = doctor_info.UserName
  299. order.DrordDrProfttl = ""
  300. order.CurrDrordFlag = "1"
  301. orders = append(orders, &order)
  302. }
  303. if subItem.Type == 3 {
  304. var order models.FsiOrderDtos
  305. order.RxID = strconv.FormatInt(item.ID, 10)
  306. order.Rxno = strconv.FormatInt(item.ID, 10)
  307. order.LongDrordFlag = "0"
  308. order.HilistType = "1"
  309. order.ChrgType = "1"
  310. order.DrordBhvr = "-"
  311. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  312. order.HosplistName = subItem.GoodInfo.GoodName
  313. order.HilistLv = "1"
  314. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  315. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  316. order.HosplistName = subItem.GoodInfo.GoodName
  317. order.Cnt = subItem.Count
  318. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  319. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  320. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  321. order.OwnpayAmt = ""
  322. order.SelfpayAmt = ""
  323. order.Spec = ""
  324. order.SpecUnt = ""
  325. order.DrordBegnDate = s_tm
  326. order.DrordStopDate = ""
  327. order.DrordDrCodg = "1"
  328. order.DrordDeptName = department.Name
  329. order.DrordDrCodg = "1"
  330. order.DrordDrName = doctor_info.UserName
  331. order.DrordDrProfttl = ""
  332. order.CurrDrordFlag = "1"
  333. orders = append(orders, &order)
  334. }
  335. }
  336. }
  337. //处方医嘱信息
  338. }
  339. fed.MatnStas = "0"
  340. fed.MedfeeSumamt = "0"
  341. fed.OwnpayAmt = "0"
  342. fed.SelfpayAmt = "0"
  343. fed.AcctPayamt = "0"
  344. fed.MaAmt = "0"
  345. fed.HifpPayamt = "0"
  346. fed.SetlTotlnum = "1"
  347. fed.Insutype = his.Insutype
  348. fed.ReimFlag = "0"
  349. fed.OutSetlFlag = "0"
  350. var fopd []*models.FsiOperationDtosData
  351. data := make(map[string]interface{})
  352. data["fed"] = fed
  353. data["fdd"] = fdds
  354. data["fod"] = orders
  355. data["pd"] = pd
  356. data["pp"] = pp
  357. data["fopd"] = fopd
  358. data["trig_scen"] = trig_scen
  359. fmt.Println(data)
  360. fmt.Println(fed)
  361. fmt.Println(fdds)
  362. fmt.Println(orders)
  363. fmt.Println(pd)
  364. fmt.Println(pp)
  365. fmt.Println(fopd)
  366. client := &http.Client{}
  367. bytesData, _ := json.Marshal(data)
  368. var req *http.Request
  369. if miConfig.MdtrtareaAdmvs == "320921" {
  370. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  371. } else {
  372. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  373. }
  374. resp, _ := client.Do(req)
  375. defer resp.Body.Close()
  376. body, ioErr := ioutil.ReadAll(resp.Body)
  377. if ioErr != nil {
  378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  380. return res
  381. }
  382. var respJSON map[string]interface{}
  383. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  386. return res
  387. }
  388. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  389. fmt.Println(respJSON)
  390. result, _ := json.Marshal(respJSON)
  391. fmt.Println(result)
  392. if err := json.Unmarshal([]byte(result), &res); err != nil {
  393. utils.ErrorLog("解析失败:%v", err)
  394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  395. return res
  396. }
  397. return res
  398. }
  399. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  400. adminUser := c.GetAdminUserInfo()
  401. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  402. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  403. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  404. //record_time := c.GetString("record_time")
  405. //trig_scen := c.GetString("trig_scen")
  406. timeLayout := "2006-01-02"
  407. loc, _ := time.LoadLocation("Local")
  408. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  409. if err != nil {
  410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  411. return res
  412. }
  413. recordDateTime := theTime.Unix()
  414. var patientPrescription models.HisPrescriptionInfo
  415. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  416. if patientPrescription.ID == 0 {
  417. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  418. }
  419. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  420. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  421. //
  422. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  423. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  424. var pp models.PublicParams
  425. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  426. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  427. pp.FixmedinsName = miConfig.OrgName
  428. pp.FixmedinsCode = miConfig.Code
  429. pp.RequestUrl = miConfig.Url
  430. pp.Cainfo = miConfig.Cainfo
  431. pp.SecretKey = miConfig.SecretKey
  432. pp.AccessKey = miConfig.AccessKey
  433. pp.OpterName = roles.UserName
  434. var config []*models.HisXtDiagnoseConfig
  435. for _, item := range diagnosis_ids {
  436. id, _ := strconv.ParseInt(item, 10, 64)
  437. diagnosisConfig, _ := service.FindDiagnoseById(id)
  438. config = append(config, &diagnosisConfig)
  439. }
  440. var pd models.PatientDtos
  441. pd.PatnID = his.PsnNo
  442. pd.PatnName = his.Name
  443. pd.Gend = his.Gend
  444. pd.Brdy = his.Brdy
  445. pd.Poolarea = his.InsuplcAdmdvs
  446. pd.CurrMdtrtID = his.Number
  447. var fed models.FsiEncounterDtos
  448. fed.MdtrtID = his.Number
  449. fed.MedinsID = miConfig.Code
  450. fed.MedinsName = miConfig.OrgName
  451. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  452. fed.MedMdtrtType = "1"
  453. fed.MedinsType = "1"
  454. fed.MedinsLv = "11"
  455. tm := time.Unix(his.RecordDate, 0)
  456. s_tm := tm.Format("2006-01-02 15:04:05")
  457. fed.AdmDate = s_tm
  458. fed.DscgDate = s_tm
  459. fed.DscgMainDiseCodg = config[0].CountryCode
  460. fed.DscgMainDiseName = config[0].CountryContentName
  461. //诊断信息
  462. var fdds []*models.FsiDiagnoseDtos
  463. for index, item := range config {
  464. if index == 0 {
  465. var fdd models.FsiDiagnoseDtos
  466. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  467. fdd.InoutDiseType = "1"
  468. fdd.MaindiseFlag = "1"
  469. fdd.DiseDate = s_tm
  470. fdd.DiasSrtNo = "1"
  471. fdd.DiseName = item.CountryContentName
  472. fdd.DiseCodg = item.CountryCode
  473. fdds = append(fdds, &fdd)
  474. } else {
  475. var fdd models.FsiDiagnoseDtos
  476. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  477. fdd.InoutDiseType = "1"
  478. fdd.MaindiseFlag = "1"
  479. fdd.DiseDate = s_tm
  480. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  481. fdd.DiseName = item.CountryContentName
  482. fdd.DiseCodg = item.CountryCode
  483. fdds = append(fdds, &fdd)
  484. }
  485. }
  486. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  487. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  488. fed.AdmDeptName = department.Name
  489. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  490. fed.DscgDeptName = department.Name
  491. fed.MedMdtrtType = "1"
  492. fed.MedType = "11"
  493. //if his.Insutype == "390" {
  494. // fed.MedType = "1402"
  495. //} else {
  496. // fed.MedType = "9933"
  497. //}
  498. var orders []*models.FsiOrderDtos
  499. if trig_scen == "2" {
  500. //处方医嘱信息
  501. for _, item := range prescriptions {
  502. for _, subItem := range item.HisDoctorAdviceInfo {
  503. var order models.FsiOrderDtos
  504. order.RxID = strconv.FormatInt(item.ID, 10)
  505. order.Rxno = strconv.FormatInt(item.ID, 10)
  506. order.LongDrordFlag = "0"
  507. order.HilistType = "1"
  508. order.ChrgType = "1"
  509. order.DrordBhvr = "-"
  510. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  511. order.HosplistName = subItem.BaseDrugLib.DrugName
  512. order.HilistLv = "1"
  513. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  514. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  515. order.HosplistName = subItem.BaseDrugLib.DrugName
  516. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  517. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  518. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  519. order.OwnpayAmt = ""
  520. order.SelfpayAmt = ""
  521. order.Spec = ""
  522. order.SpecUnt = ""
  523. order.DrordBegnDate = s_tm
  524. order.DrordStopDate = ""
  525. order.DrordDrCodg = "1"
  526. order.DrordDeptName = department.Name
  527. order.DrordDrCodg = "1"
  528. order.DrordDrName = doctor_info.UserName
  529. order.DrordDrProfttl = ""
  530. order.CurrDrordFlag = "1"
  531. orders = append(orders, &order)
  532. }
  533. for _, subItem := range item.HisPrescriptionProject {
  534. if subItem.Type == 2 {
  535. var order models.FsiOrderDtos
  536. order.RxID = strconv.FormatInt(item.ID, 10)
  537. order.Rxno = strconv.FormatInt(item.ID, 10)
  538. order.LongDrordFlag = "0"
  539. order.HilistType = "1"
  540. order.ChrgType = "1"
  541. order.DrordBhvr = "-"
  542. order.HilistCode = subItem.HisProject.MedicalCode
  543. order.HosplistName = subItem.HisProject.ProjectName
  544. order.HilistLv = "1"
  545. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  546. order.HosplistCode = subItem.HisProject.MedicalCode
  547. order.HosplistName = subItem.HisProject.ProjectName
  548. order.Cnt = subItem.Count
  549. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  550. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  551. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  552. order.OwnpayAmt = ""
  553. order.SelfpayAmt = ""
  554. order.Spec = ""
  555. order.SpecUnt = ""
  556. order.DrordBegnDate = s_tm
  557. order.DrordStopDate = ""
  558. order.DrordDrCodg = "1"
  559. order.DrordDeptName = department.Name
  560. order.DrordDrCodg = "1"
  561. order.DrordDrName = doctor_info.UserName
  562. order.DrordDrProfttl = ""
  563. order.CurrDrordFlag = "1"
  564. orders = append(orders, &order)
  565. }
  566. if subItem.Type == 3 {
  567. var order models.FsiOrderDtos
  568. order.RxID = strconv.FormatInt(item.ID, 10)
  569. order.Rxno = strconv.FormatInt(item.ID, 10)
  570. order.LongDrordFlag = "0"
  571. order.HilistType = "1"
  572. order.ChrgType = "1"
  573. order.DrordBhvr = "-"
  574. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  575. order.HosplistName = subItem.GoodInfo.GoodName
  576. order.HilistLv = "1"
  577. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  578. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  579. order.HosplistName = subItem.GoodInfo.GoodName
  580. order.Cnt = subItem.Count
  581. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  582. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  583. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  584. order.OwnpayAmt = ""
  585. order.SelfpayAmt = ""
  586. order.Spec = ""
  587. order.SpecUnt = ""
  588. order.DrordBegnDate = s_tm
  589. order.DrordStopDate = ""
  590. order.DrordDrCodg = "1"
  591. order.DrordDeptName = department.Name
  592. order.DrordDrCodg = "1"
  593. order.DrordDrName = doctor_info.UserName
  594. order.DrordDrProfttl = ""
  595. order.CurrDrordFlag = "1"
  596. orders = append(orders, &order)
  597. }
  598. }
  599. }
  600. //处方医嘱信息
  601. }
  602. fed.MatnStas = "0"
  603. fed.MedfeeSumamt = "0"
  604. fed.OwnpayAmt = "0"
  605. fed.SelfpayAmt = "0"
  606. fed.AcctPayamt = "0"
  607. fed.MaAmt = "0"
  608. fed.HifpPayamt = "0"
  609. fed.SetlTotlnum = "1"
  610. fed.Insutype = his.Insutype
  611. fed.ReimFlag = "0"
  612. fed.OutSetlFlag = "0"
  613. var fopd []*models.FsiOperationDtosData
  614. data := make(map[string]interface{})
  615. data["fed"] = fed
  616. data["fdd"] = fdds
  617. data["fod"] = orders
  618. data["pd"] = pd
  619. data["pp"] = pp
  620. data["fopd"] = fopd
  621. data["trig_scen"] = trig_scen
  622. fmt.Println(data)
  623. fmt.Println(fed)
  624. fmt.Println(fdds)
  625. fmt.Println(orders)
  626. fmt.Println(pd)
  627. fmt.Println(pp)
  628. fmt.Println(fopd)
  629. client := &http.Client{}
  630. bytesData, _ := json.Marshal(data)
  631. var req *http.Request
  632. if miConfig.MdtrtareaAdmvs == "320921" {
  633. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  634. } else {
  635. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  636. }
  637. resp, _ := client.Do(req)
  638. defer resp.Body.Close()
  639. body, ioErr := ioutil.ReadAll(resp.Body)
  640. if ioErr != nil {
  641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  643. return res
  644. }
  645. var respJSON map[string]interface{}
  646. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  649. return res
  650. }
  651. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  652. result, _ := json.Marshal(respJSON)
  653. if err := json.Unmarshal([]byte(result), &res); err != nil {
  654. utils.ErrorLog("解析失败:%v", err)
  655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  656. return res
  657. }
  658. return res
  659. }
  660. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  661. ////patient_id, _ := c.GetInt64("patient_id")
  662. //order_id, _ := c.GetInt64("order_id")
  663. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  664. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  665. //trig_scen := c.GetString("trig_scen")
  666. adminUser := c.GetAdminUserInfo()
  667. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  668. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  669. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  670. record_time := c.GetString("record_time")
  671. order, _ := service.GetHisOrderByID(order_id)
  672. timeLayout := "2006-01-02"
  673. loc, _ := time.LoadLocation("Local")
  674. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  675. if err != nil {
  676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  677. return
  678. }
  679. recordDateTime := theTime.Unix()
  680. var patientPrescription models.HisPrescriptionInfo
  681. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  682. if patientPrescription.ID == 0 {
  683. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  684. }
  685. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  686. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  687. //
  688. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  689. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  690. var pp models.PublicParams
  691. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  692. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  693. pp.FixmedinsName = miConfig.OrgName
  694. pp.FixmedinsCode = miConfig.Code
  695. pp.RequestUrl = miConfig.Url
  696. pp.Cainfo = miConfig.Cainfo
  697. pp.SecretKey = miConfig.SecretKey
  698. pp.AccessKey = miConfig.AccessKey
  699. pp.OpterName = roles.UserName
  700. var config []*models.HisXtDiagnoseConfig
  701. for _, item := range diagnosis_ids {
  702. id, _ := strconv.ParseInt(item, 10, 64)
  703. diagnosisConfig, _ := service.FindDiagnoseById(id)
  704. config = append(config, &diagnosisConfig)
  705. }
  706. var pd models.PatientDtos
  707. pd.PatnID = his.PsnNo
  708. pd.PatnName = his.Name
  709. pd.Gend = his.Gend
  710. pd.Brdy = his.Brdy
  711. pd.Poolarea = his.InsuplcAdmdvs
  712. pd.CurrMdtrtID = his.Number
  713. var fed models.FsiEncounterDtos
  714. fed.MdtrtID = his.Number
  715. fed.MedinsID = miConfig.Code
  716. fed.MedinsName = miConfig.OrgName
  717. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  718. fed.MedMdtrtType = "1"
  719. fed.MedinsType = "1"
  720. fed.MedinsLv = "11"
  721. tm := time.Unix(his.RecordDate, 0)
  722. s_tm := tm.Format("2006-01-02 15:04:05")
  723. fed.AdmDate = s_tm
  724. fed.DscgDate = s_tm
  725. fed.DscgMainDiseCodg = config[0].CountryCode
  726. fed.DscgMainDiseName = config[0].CountryContentName
  727. //诊断信息
  728. var fdds []*models.FsiDiagnoseDtos
  729. for index, item := range config {
  730. if index == 0 {
  731. var fdd models.FsiDiagnoseDtos
  732. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  733. fdd.InoutDiseType = "1"
  734. fdd.MaindiseFlag = "1"
  735. fdd.DiseDate = s_tm
  736. fdd.DiasSrtNo = "1"
  737. fdd.DiseName = item.CountryContentName
  738. fdd.DiseCodg = item.CountryCode
  739. fdds = append(fdds, &fdd)
  740. } else {
  741. var fdd models.FsiDiagnoseDtos
  742. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  743. fdd.InoutDiseType = "1"
  744. fdd.MaindiseFlag = "1"
  745. fdd.DiseDate = s_tm
  746. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  747. fdd.DiseName = item.CountryContentName
  748. fdd.DiseCodg = item.CountryCode
  749. fdds = append(fdds, &fdd)
  750. }
  751. }
  752. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  753. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  754. fed.AdmDeptName = department.Name
  755. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  756. fed.DscgDeptName = department.Name
  757. fed.MedType = order.MedType
  758. //处方医嘱信息
  759. var orders []*models.FsiOrderDtos
  760. //for _, item := range prescriptions {
  761. // for _, subItem := range item.HisDoctorAdviceInfo {
  762. // var order models.FsiOrderDtos
  763. // order.RxID = strconv.FormatInt(item.ID, 10)
  764. // order.Rxno = strconv.FormatInt(item.ID, 10)
  765. // order.LongDrordFlag = "0"
  766. // order.HilistType = "1"
  767. // order.ChrgType = "1"
  768. // order.DrordBhvr = "-"
  769. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  770. // order.HosplistName = subItem.BaseDrugLib.DrugName
  771. // order.HilistLv = "1"
  772. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  773. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  774. // order.HosplistName = subItem.BaseDrugLib.DrugName
  775. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  776. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  777. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  778. // order.OwnpayAmt = ""
  779. // order.SelfpayAmt = ""
  780. // order.Spec = ""
  781. // order.SpecUnt = ""
  782. // order.DrordBegnDate = s_tm
  783. // order.DrordStopDate = ""
  784. // order.DrordDrCodg = "1"
  785. // order.DrordDeptName = department.Name
  786. // order.DrordDrCodg = "1"
  787. // order.DrordDrName = doctor_info.UserName
  788. // order.DrordDrProfttl = ""
  789. // order.CurrDrordFlag = "1"
  790. // orders = append(orders, &order)
  791. // }
  792. // for _, subItem := range item.HisPrescriptionProject {
  793. // if subItem.Type == 2 {
  794. // var order models.FsiOrderDtos
  795. // order.RxID = strconv.FormatInt(item.ID, 10)
  796. // order.Rxno = strconv.FormatInt(item.ID, 10)
  797. // order.LongDrordFlag = "0"
  798. // order.HilistType = "1"
  799. // order.ChrgType = "1"
  800. // order.DrordBhvr = "-"
  801. // order.HilistCode = subItem.HisProject.MedicalCode
  802. // order.HosplistName = subItem.HisProject.ProjectName
  803. // order.HilistLv = "1"
  804. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  805. // order.HosplistCode = subItem.HisProject.MedicalCode
  806. // order.HosplistName = subItem.HisProject.ProjectName
  807. // order.Cnt = subItem.Count
  808. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  809. //
  810. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  811. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  812. // order.OwnpayAmt = ""
  813. // order.SelfpayAmt = ""
  814. // order.Spec = ""
  815. // order.SpecUnt = ""
  816. // order.DrordBegnDate = s_tm
  817. // order.DrordStopDate = ""
  818. // order.DrordDrCodg = "1"
  819. // order.DrordDeptName = department.Name
  820. // order.DrordDrCodg = "1"
  821. // order.DrordDrName = doctor_info.UserName
  822. // order.DrordDrProfttl = ""
  823. // order.CurrDrordFlag = "1"
  824. // orders = append(orders, &order)
  825. //
  826. // }
  827. // if subItem.Type == 3 {
  828. //
  829. // var order models.FsiOrderDtos
  830. // order.RxID = strconv.FormatInt(item.ID, 10)
  831. // order.Rxno = strconv.FormatInt(item.ID, 10)
  832. // order.LongDrordFlag = "0"
  833. // order.HilistType = "1"
  834. // order.ChrgType = "1"
  835. // order.DrordBhvr = "-"
  836. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  837. // order.HosplistName = subItem.GoodInfo.GoodName
  838. // order.HilistLv = "1"
  839. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  840. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  841. // order.HosplistName = subItem.GoodInfo.GoodName
  842. // order.Cnt = subItem.Count
  843. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  844. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  845. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  846. // order.OwnpayAmt = ""
  847. // order.SelfpayAmt = ""
  848. // order.Spec = ""
  849. // order.SpecUnt = ""
  850. // order.DrordBegnDate = s_tm
  851. // order.DrordStopDate = ""
  852. // order.DrordDrCodg = "1"
  853. // order.DrordDeptName = department.Name
  854. // order.DrordDrCodg = "1"
  855. // order.DrordDrName = doctor_info.UserName
  856. // order.DrordDrProfttl = ""
  857. // order.CurrDrordFlag = "1"
  858. // orders = append(orders, &order)
  859. //
  860. // }
  861. // }
  862. //}
  863. for _, item := range prescriptions {
  864. for _, subItem := range item.HisDoctorAdviceInfo {
  865. var order models.FsiOrderDtos
  866. order.RxID = strconv.FormatInt(item.ID, 10)
  867. order.Rxno = strconv.FormatInt(item.ID, 10)
  868. order.LongDrordFlag = "0"
  869. order.HilistType = "1"
  870. order.ChrgType = "1"
  871. order.DrordBhvr = "-"
  872. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  873. order.HosplistName = subItem.BaseDrugLib.DrugName
  874. order.HilistLv = "1"
  875. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  876. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  877. order.HosplistName = subItem.BaseDrugLib.DrugName
  878. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  879. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  880. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  881. order.OwnpayAmt = ""
  882. order.SelfpayAmt = ""
  883. order.Spec = ""
  884. order.SpecUnt = ""
  885. order.DrordBegnDate = s_tm
  886. order.DrordStopDate = ""
  887. order.DrordDrCodg = "1"
  888. order.DrordDeptName = department.Name
  889. order.DrordDrCodg = "1"
  890. order.DrordDrName = doctor_info.UserName
  891. order.DrordDrProfttl = ""
  892. order.CurrDrordFlag = "1"
  893. orders = append(orders, &order)
  894. }
  895. for _, subItem := range item.HisPrescriptionProject {
  896. if subItem.Type == 2 {
  897. var order models.FsiOrderDtos
  898. order.RxID = strconv.FormatInt(item.ID, 10)
  899. order.Rxno = strconv.FormatInt(item.ID, 10)
  900. order.LongDrordFlag = "0"
  901. order.HilistType = "1"
  902. order.ChrgType = "1"
  903. order.DrordBhvr = "-"
  904. order.HilistCode = subItem.HisProject.MedicalCode
  905. order.HosplistName = subItem.HisProject.ProjectName
  906. order.HilistLv = "1"
  907. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  908. order.HosplistCode = subItem.HisProject.MedicalCode
  909. order.HosplistName = subItem.HisProject.ProjectName
  910. order.Cnt = subItem.Count
  911. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  912. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  913. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  914. order.OwnpayAmt = ""
  915. order.SelfpayAmt = ""
  916. order.Spec = ""
  917. order.SpecUnt = ""
  918. order.DrordBegnDate = s_tm
  919. order.DrordStopDate = ""
  920. order.DrordDrCodg = "1"
  921. order.DrordDeptName = department.Name
  922. order.DrordDrCodg = "1"
  923. order.DrordDrName = doctor_info.UserName
  924. order.DrordDrProfttl = ""
  925. order.CurrDrordFlag = "1"
  926. orders = append(orders, &order)
  927. }
  928. if subItem.Type == 3 {
  929. var order models.FsiOrderDtos
  930. order.RxID = strconv.FormatInt(item.ID, 10)
  931. order.Rxno = strconv.FormatInt(item.ID, 10)
  932. order.LongDrordFlag = "0"
  933. order.HilistType = "1"
  934. order.ChrgType = "1"
  935. order.DrordBhvr = "-"
  936. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  937. order.HosplistName = subItem.GoodInfo.GoodName
  938. order.HilistLv = "1"
  939. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  940. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  941. order.HosplistName = subItem.GoodInfo.GoodName
  942. order.Cnt = subItem.Count
  943. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  944. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  945. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  946. order.OwnpayAmt = ""
  947. order.SelfpayAmt = ""
  948. order.Spec = ""
  949. order.SpecUnt = ""
  950. order.DrordBegnDate = s_tm
  951. order.DrordStopDate = ""
  952. order.DrordDrCodg = "1"
  953. order.DrordDeptName = department.Name
  954. order.DrordDrCodg = "1"
  955. order.DrordDrName = doctor_info.UserName
  956. order.DrordDrProfttl = ""
  957. order.CurrDrordFlag = "1"
  958. orders = append(orders, &order)
  959. }
  960. }
  961. }
  962. //处方医嘱信息
  963. fed.MatnStas = "0"
  964. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  965. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  966. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  967. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  968. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  969. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  970. fed.SetlTotlnum = "1"
  971. fed.Insutype = his.Insutype
  972. fed.ReimFlag = "0"
  973. fed.OutSetlFlag = "0"
  974. var fopd []*models.FsiOperationDtosData
  975. data := make(map[string]interface{})
  976. data["fed"] = fed
  977. data["fdd"] = fdds
  978. data["fod"] = orders
  979. data["pd"] = pd
  980. data["pp"] = pp
  981. data["fopd"] = fopd
  982. data["trig_scen"] = trig_scen
  983. client := &http.Client{}
  984. bytesData, _ := json.Marshal(data)
  985. var req *http.Request
  986. if miConfig.MdtrtareaAdmvs == "320921" {
  987. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  988. } else {
  989. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  990. }
  991. resp, _ := client.Do(req)
  992. defer resp.Body.Close()
  993. body, ioErr := ioutil.ReadAll(resp.Body)
  994. if ioErr != nil {
  995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  997. return res
  998. }
  999. var respJSON map[string]interface{}
  1000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1003. return res
  1004. }
  1005. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1006. result, _ := json.Marshal(respJSON)
  1007. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1008. utils.ErrorLog("解析失败:%v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return res
  1011. }
  1012. return res
  1013. //手术操作集合
  1014. //手术操作集合
  1015. }
  1016. func (c *HisApiController) Check() {
  1017. psn_no := c.GetString("psn_no")
  1018. in := c.GetString("in")
  1019. mt := c.GetString("mt")
  1020. baseParams := models.BaseParams{
  1021. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1022. FixmedinsCode: "H15049901371",
  1023. InsuplcAdmdvs: "150499",
  1024. MdtrtareaAdmvs: "150499",
  1025. OrgName: "赤峰费森血液透析中心",
  1026. Doctor: "1111",
  1027. }
  1028. service.Gdyb2001(baseParams, psn_no, in, mt)
  1029. }
  1030. func (c *HisApiController) GetPsnNcdsInfo() {
  1031. admin_user_id, _ := c.GetInt64("admin_user_id")
  1032. patient_id, _ := c.GetInt64("patient_id")
  1033. id, _ := c.GetInt64("id")
  1034. adminUser := c.GetAdminUserInfo()
  1035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1036. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1037. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1038. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1039. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1040. //
  1041. //if psn_record.ID == 0 {
  1042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1043. // return
  1044. //}
  1045. var res Result5301
  1046. var res10265 Result5301For10265
  1047. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1048. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1049. var api string
  1050. if miConfig.MdtrtareaAdmvs == "320921" {
  1051. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1052. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1053. } else {
  1054. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1055. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1056. }
  1057. resp, requestErr := http.Get(api)
  1058. if requestErr != nil {
  1059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1060. return
  1061. }
  1062. body, ioErr := ioutil.ReadAll(resp.Body)
  1063. if ioErr != nil {
  1064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1066. return
  1067. }
  1068. var respJSON map[string]interface{}
  1069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1072. return
  1073. }
  1074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1075. result, _ := json.Marshal(respJSON)
  1076. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1077. utils.ErrorLog("解析失败:%v", err)
  1078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1079. return
  1080. }
  1081. res.ErrMsg = res10265.ErrMsg
  1082. res.Output = res10265.Output
  1083. res.InfRefmsgid = res10265.InfRefmsgid
  1084. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1085. res.Infcode = infocode
  1086. } else {
  1087. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1088. var dat map[string]interface{}
  1089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1090. fmt.Println(dat)
  1091. } else {
  1092. fmt.Println(err)
  1093. }
  1094. userJSONBytes, _ := json.Marshal(dat)
  1095. if miConfig.Code == "H15049901371" {
  1096. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1097. utils.ErrorLog("解析失败:%v", err)
  1098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1099. return
  1100. }
  1101. res.InfRefmsgid = res10265.InfRefmsgid
  1102. res.Output = res10265.Output
  1103. res.ErrMsg = res10265.ErrMsg
  1104. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1105. res.Infcode = infocode
  1106. } else {
  1107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1108. utils.ErrorLog("解析失败:%v", err)
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1110. return
  1111. }
  1112. }
  1113. }
  1114. if res.Infcode == 0 {
  1115. c.ServeSuccessJSON(map[string]interface{}{
  1116. "result": res.Output.Result,
  1117. })
  1118. }
  1119. }
  1120. func (c *HisApiController) CheckInsutype() {
  1121. his_patient_id, _ := c.GetInt64("his_patient_id")
  1122. admin_user_id, _ := c.GetInt64("admin_user_id")
  1123. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1124. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1125. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1126. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1127. var dat map[string]interface{}
  1128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1129. fmt.Println(dat)
  1130. } else {
  1131. fmt.Println(err)
  1132. }
  1133. userJSONBytes, _ := json.Marshal(dat)
  1134. var res Result90100
  1135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1136. utils.ErrorLog("解析失败:%v", err)
  1137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. return
  1139. }
  1140. if res.Infcode != 0 {
  1141. c.ServeSuccessJSON(map[string]interface{}{
  1142. "failed_code": -10,
  1143. "msg": res.ErrMsg,
  1144. })
  1145. return
  1146. } else {
  1147. fmt.Println(res)
  1148. }
  1149. }
  1150. func (c *HisApiController) CheckCardPWD() {
  1151. card_pwd := c.GetString("card_pwd")
  1152. his_patient_id, _ := c.GetInt64("his_patient_id")
  1153. admin_user_id, _ := c.GetInt64("admin_user_id")
  1154. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1155. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1156. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1157. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1158. bas := strings.Split(psn.CardInfo, "|")
  1159. basNumber := bas[2]
  1160. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1161. var dat map[string]interface{}
  1162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1163. fmt.Println(dat)
  1164. } else {
  1165. fmt.Println(err)
  1166. }
  1167. userJSONBytes, _ := json.Marshal(dat)
  1168. var res Result90991
  1169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1170. utils.ErrorLog("解析失败:%v", err)
  1171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1172. return
  1173. }
  1174. if res.Infcode != 0 {
  1175. c.ServeSuccessJSON(map[string]interface{}{
  1176. "failed_code": -10,
  1177. "msg": res.ErrMsg,
  1178. })
  1179. return
  1180. } else {
  1181. if res.Output.Result.SscnoCheckStat == "0" {
  1182. var msg string
  1183. switch res.Output.Result.CardStat {
  1184. case "00":
  1185. msg = "未激活"
  1186. break
  1187. case "10":
  1188. msg = "激活"
  1189. break
  1190. case "20":
  1191. msg = "窗口挂失"
  1192. break
  1193. case "21":
  1194. msg = "电话挂失"
  1195. break
  1196. case "22":
  1197. msg = "单位网上申报挂失"
  1198. break
  1199. case "23":
  1200. msg = "保健办挂失"
  1201. break
  1202. case "24":
  1203. msg = "个人网上挂失"
  1204. break
  1205. case "25":
  1206. msg = "网上服务大厅挂失"
  1207. break
  1208. case "30":
  1209. msg = "注销"
  1210. break
  1211. case "40":
  1212. msg = "回收"
  1213. break
  1214. case "99":
  1215. msg = "制卡中(无效卡)"
  1216. break
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "failed_code": -10,
  1220. "msg": msg,
  1221. })
  1222. return
  1223. } else {
  1224. c.ServeSuccessJSON(map[string]interface{}{
  1225. "msg": "校验成功",
  1226. })
  1227. return
  1228. }
  1229. }
  1230. }
  1231. func (c *HisApiController) CheckCardPWDTwo() {
  1232. //card_pwd := c.GetString("card_pwd")
  1233. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1234. admin_user_id, _ := c.GetInt64("admin_user_id")
  1235. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1236. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1237. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1238. var dat map[string]interface{}
  1239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1240. fmt.Println(dat)
  1241. } else {
  1242. fmt.Println(err)
  1243. }
  1244. userJSONBytes, _ := json.Marshal(dat)
  1245. var res Result90991
  1246. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1247. utils.ErrorLog("解析失败:%v", err)
  1248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1249. return
  1250. }
  1251. if res.Infcode != 0 {
  1252. c.ServeSuccessJSON(map[string]interface{}{
  1253. "failed_code": -10,
  1254. "msg": res.ErrMsg,
  1255. })
  1256. return
  1257. } else {
  1258. if res.Output.Result.SscnoCheckStat == "0" {
  1259. var msg string
  1260. switch res.Output.Result.CardStat {
  1261. case "00":
  1262. msg = "未激活"
  1263. break
  1264. case "10":
  1265. msg = "激活"
  1266. break
  1267. case "20":
  1268. msg = "窗口挂失"
  1269. break
  1270. case "21":
  1271. msg = "电话挂失"
  1272. break
  1273. case "22":
  1274. msg = "单位网上申报挂失"
  1275. break
  1276. case "23":
  1277. msg = "保健办挂失"
  1278. break
  1279. case "24":
  1280. msg = "个人网上挂失"
  1281. break
  1282. case "25":
  1283. msg = "网上服务大厅挂失"
  1284. break
  1285. case "30":
  1286. msg = "注销"
  1287. break
  1288. case "40":
  1289. msg = "回收"
  1290. break
  1291. case "99":
  1292. msg = "制卡中(无效卡)"
  1293. break
  1294. }
  1295. c.ServeSuccessJSON(map[string]interface{}{
  1296. "failed_code": -10,
  1297. "msg": msg,
  1298. })
  1299. return
  1300. } else {
  1301. c.ServeSuccessJSON(map[string]interface{}{
  1302. "msg": "校验成功",
  1303. })
  1304. return
  1305. }
  1306. }
  1307. }
  1308. type ELeCertData struct {
  1309. Data struct {
  1310. Extra string `json:"extra"`
  1311. IDNo string `json:"idNo"`
  1312. IDType string `json:"idType"`
  1313. EcToken string `json:"ecToken"`
  1314. InsuOrg string `json:"insuOrg"`
  1315. UserName string `json:"userName"`
  1316. EcIndexNo string `json:"ecIndexNo"`
  1317. Gender string `json:"gender"`
  1318. Birthday string `json:"birthday"`
  1319. Nationality string `json:"nationality"`
  1320. Email string `json:"email"`
  1321. } `json:"OutData"`
  1322. }
  1323. func (c *HisApiController) ReadCard() {
  1324. id_card_type, _ := c.GetInt64("id_card_type")
  1325. admin_user_id, _ := c.GetInt64("admin_user_id")
  1326. certificates, _ := c.GetInt64("certificates")
  1327. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1328. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1329. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1330. switch id_card_type {
  1331. case 1:
  1332. if miConfig.MdtrtareaAdmvs == "421300" {
  1333. var res ResultTwo
  1334. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1335. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1336. "&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)
  1337. resp, requestErr := http.Get(api)
  1338. if requestErr != nil {
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. return
  1341. }
  1342. body, ioErr := ioutil.ReadAll(resp.Body)
  1343. if ioErr != nil {
  1344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1346. return
  1347. }
  1348. var respJSON map[string]interface{}
  1349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. return
  1353. }
  1354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1355. result, _ := json.Marshal(respJSON)
  1356. fmt.Println("log")
  1357. fmt.Println(string(result))
  1358. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1359. utils.ErrorLog("解析失败:%v", err)
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1361. return
  1362. }
  1363. if res.Infcode == 0 {
  1364. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1365. if err == gorm.ErrRecordNotFound {
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1367. return
  1368. } else if err != nil {
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1370. return
  1371. } else {
  1372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1374. infoStr := string(Iinfos)
  1375. idetinfoStr := string(Idetinfos)
  1376. psn := &models.HisPsn{
  1377. PsnNo: res.Output.Baseinfo.PsnNo,
  1378. Age: res.Output.Baseinfo.Age,
  1379. PatientId: patient.ID,
  1380. Certno: res.Output.Baseinfo.Certno,
  1381. Brdy: res.Output.Baseinfo.Brdy,
  1382. Gend: res.Output.Baseinfo.Gend,
  1383. Naty: res.Output.Baseinfo.Naty,
  1384. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1385. PsnName: res.Output.Baseinfo.PsnName,
  1386. Idetinfo: idetinfoStr,
  1387. Insuinfo: infoStr,
  1388. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1389. }
  1390. service.CreateHisPsn(psn)
  1391. c.ServeSuccessJSON(map[string]interface{}{
  1392. "patient": patient,
  1393. "number": res.Output.Baseinfo.Certno,
  1394. })
  1395. }
  1396. } else {
  1397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1398. return
  1399. }
  1400. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1401. var api string
  1402. if miConfig.MdtrtareaAdmvs == "320921" {
  1403. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1404. "&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
  1405. fmt.Println(api)
  1406. } else {
  1407. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1408. "&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)
  1409. }
  1410. resp, requestErr := http.Get(api)
  1411. if requestErr != nil {
  1412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1413. return
  1414. }
  1415. body, ioErr := ioutil.ReadAll(resp.Body)
  1416. if ioErr != nil {
  1417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1419. return
  1420. }
  1421. var respJSON map[string]interface{}
  1422. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. return
  1426. }
  1427. var status string
  1428. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1429. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1430. //console.log()
  1431. fmt.Println("type===")
  1432. fmt.Println(card_type)
  1433. var token string
  1434. var res ResultTwo //1101结果
  1435. var res10265 ResultTwo10265 //1101结果
  1436. var card_info string //卡信息
  1437. var busi_card_info string
  1438. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1439. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1440. if status == "0" { //读卡成功
  1441. if card_type == "1" {
  1442. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1443. result, _ := json.Marshal(respJSON)
  1444. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1445. utils.ErrorLog("解析失败:%v", err)
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return
  1448. }
  1449. res.ErrMsg = res10265.ErrMsg
  1450. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1451. res.Infcode = infocode
  1452. res.Output = res10265.Output
  1453. res.InfRefmsgid = res10265.InfRefmsgid
  1454. } else {
  1455. //var card_info string //卡信息
  1456. //var busi_card_info string
  1457. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1458. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1459. //fmt.Println(card_info)
  1460. //fmt.Println(busi_card_info)
  1461. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1462. result, _ := json.Marshal(respJSON)
  1463. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1464. utils.ErrorLog("解析失败:%v", err)
  1465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1466. return
  1467. }
  1468. res.ErrMsg = res10265.ErrMsg
  1469. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1470. res.Infcode = infocode
  1471. res.Output = res10265.Output
  1472. res.InfRefmsgid = res10265.InfRefmsgid
  1473. }
  1474. if res.Infcode == 0 {
  1475. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1476. if err == gorm.ErrRecordNotFound {
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1478. return
  1479. } else if err != nil {
  1480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1481. return
  1482. } else {
  1483. if card_type == "1" {
  1484. bas := strings.Split(card_info, "|")
  1485. basNumber := bas[2]
  1486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1488. infoStr := string(Iinfos)
  1489. idetinfoStr := string(Idetinfos)
  1490. psn := &models.HisPsn{
  1491. PsnNo: res.Output.Baseinfo.PsnNo,
  1492. Age: res.Output.Baseinfo.Age,
  1493. PatientId: patient.ID,
  1494. Certno: res.Output.Baseinfo.Certno,
  1495. Brdy: res.Output.Baseinfo.Brdy,
  1496. Gend: res.Output.Baseinfo.Gend,
  1497. Naty: res.Output.Baseinfo.Naty,
  1498. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1499. PsnName: res.Output.Baseinfo.PsnName,
  1500. Idetinfo: idetinfoStr,
  1501. Insuinfo: infoStr,
  1502. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1503. CardInfo: card_info,
  1504. VerifyNumber: busi_card_info,
  1505. }
  1506. service.CreateHisPsn(psn)
  1507. var rf []*ResultFive
  1508. json.Unmarshal([]byte(infoStr), &rf)
  1509. var insutypes []*ResultFive
  1510. var insutype string
  1511. var is390 int = 0
  1512. var is310 int = 0
  1513. for _, item := range rf {
  1514. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1515. insutypes = append(insutypes, item)
  1516. }
  1517. }
  1518. if len(insutypes) == 1 {
  1519. insutype = insutypes[0].Insutype
  1520. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1521. } else {
  1522. for _, i := range insutypes {
  1523. if i.Insutype == "390" {
  1524. is390 = 1
  1525. }
  1526. if i.Insutype == "310" {
  1527. is310 = 1
  1528. }
  1529. }
  1530. }
  1531. if is390 == 1 {
  1532. insutype = "390"
  1533. }
  1534. if is310 == 1 {
  1535. insutype = "310"
  1536. }
  1537. if len(insutypes) == 0 {
  1538. insutype = "310"
  1539. }
  1540. c.ServeSuccessJSON(map[string]interface{}{
  1541. "patient": patient,
  1542. "number": basNumber,
  1543. "insutype": insutype,
  1544. })
  1545. } else {
  1546. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1547. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1548. infoStr := string(Iinfos)
  1549. idetinfoStr := string(Idetinfos)
  1550. psn := &models.HisPsn{
  1551. PsnNo: res.Output.Baseinfo.PsnNo,
  1552. Age: res.Output.Baseinfo.Age,
  1553. PatientId: patient.ID,
  1554. Certno: res.Output.Baseinfo.Certno,
  1555. Brdy: res.Output.Baseinfo.Brdy,
  1556. Gend: res.Output.Baseinfo.Gend,
  1557. Naty: res.Output.Baseinfo.Naty,
  1558. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1559. PsnName: res.Output.Baseinfo.PsnName,
  1560. Idetinfo: idetinfoStr,
  1561. Insuinfo: infoStr,
  1562. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1563. CardInfo: card_info,
  1564. VerifyNumber: token,
  1565. }
  1566. service.CreateHisPsn(psn)
  1567. c.ServeSuccessJSON(map[string]interface{}{
  1568. "patient": patient,
  1569. "number": token,
  1570. })
  1571. }
  1572. }
  1573. } else {
  1574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1575. return
  1576. }
  1577. } else { //读卡失败
  1578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1579. return
  1580. }
  1581. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1582. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1583. cardnum = DeleteExtraSpaceTwo(cardnum)
  1584. cardCode = DeleteExtraSpaceTwo(cardCode)
  1585. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1586. name = DeleteExtraSpaceTwo(name)
  1587. errmsg = DeleteExtraSpaceTwo(errmsg)
  1588. cardnum = Remove0000(cardnum)
  1589. cardCode = Remove0000(cardCode)
  1590. id_card_no = Remove0000(id_card_no)
  1591. name = Remove0000(name)
  1592. errmsg = Remove0000(errmsg)
  1593. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1594. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1595. saveLog(result, requestLog, "1101", "获取人员信息")
  1596. fmt.Println(errMsgLog)
  1597. if len(errMsgLog) > 0 {
  1598. } else {
  1599. var dat map[string]interface{}
  1600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1601. fmt.Println(dat)
  1602. } else {
  1603. fmt.Println(err)
  1604. }
  1605. userJSONBytes, _ := json.Marshal(dat)
  1606. var res ResultTwo
  1607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1608. utils.ErrorLog("解析失败:%v", err)
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1610. return
  1611. }
  1612. res.ErrMsg = errMsgLog
  1613. if res.Infcode == 0 {
  1614. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1615. if err == gorm.ErrRecordNotFound {
  1616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1617. return
  1618. } else if err != nil {
  1619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1620. return
  1621. } else {
  1622. fmt.Println(res)
  1623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1625. infoStr := string(Iinfos)
  1626. idetinfoStr := string(Idetinfos)
  1627. psn := &models.HisPsn{
  1628. PsnNo: res.Output.Baseinfo.PsnNo,
  1629. Age: res.Output.Baseinfo.Age,
  1630. PatientId: patient.ID,
  1631. Certno: res.Output.Baseinfo.Certno,
  1632. Brdy: res.Output.Baseinfo.Brdy,
  1633. Gend: res.Output.Baseinfo.Gend,
  1634. Naty: res.Output.Baseinfo.Naty,
  1635. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1636. PsnName: res.Output.Baseinfo.PsnName,
  1637. Idetinfo: idetinfoStr,
  1638. Insuinfo: infoStr,
  1639. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1640. CardInfo: basStr,
  1641. VerifyNumber: "",
  1642. }
  1643. service.CreateHisPsn(psn)
  1644. var rf []*ResultFive
  1645. json.Unmarshal([]byte(infoStr), &rf)
  1646. var insutypes []*ResultFive
  1647. var insutype string
  1648. var is390 int = 0
  1649. var is310 int = 0
  1650. for _, item := range rf {
  1651. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1652. insutypes = append(insutypes, item)
  1653. }
  1654. }
  1655. if len(insutypes) == 1 {
  1656. insutype = insutypes[0].Insutype
  1657. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1658. } else {
  1659. for _, i := range insutypes {
  1660. if i.Insutype == "390" {
  1661. is390 = 1
  1662. }
  1663. if i.Insutype == "310" {
  1664. is310 = 1
  1665. }
  1666. }
  1667. }
  1668. if is390 == 1 {
  1669. insutype = "390"
  1670. }
  1671. if is310 == 1 {
  1672. insutype = "310"
  1673. }
  1674. if len(insutypes) == 0 {
  1675. insutype = "310"
  1676. }
  1677. c.ServeSuccessJSON(map[string]interface{}{
  1678. "patient": patient,
  1679. "number": cardnum,
  1680. "insutype": insutype,
  1681. })
  1682. }
  1683. } else {
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1685. return
  1686. }
  1687. }
  1688. } else {
  1689. if initFlag == 0 {
  1690. c.TestGetBasBaseInit()
  1691. }
  1692. basStr := c.GetBasBaseInfo()
  1693. if len(basStr) == 0 {
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1695. return
  1696. }
  1697. fmt.Println(basStr)
  1698. bas := strings.Split(basStr, "|")
  1699. basNumber := bas[1]
  1700. fmt.Println(basNumber)
  1701. card_sn := bas[3]
  1702. fmt.Println(card_sn)
  1703. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1704. var dat map[string]interface{}
  1705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1706. fmt.Println(dat)
  1707. } else {
  1708. fmt.Println(err)
  1709. }
  1710. userJSONBytes, _ := json.Marshal(dat)
  1711. var res ResultTwo
  1712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1713. utils.ErrorLog("解析失败:%v", err)
  1714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1715. return
  1716. }
  1717. if res.Infcode == 0 {
  1718. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1719. if err == gorm.ErrRecordNotFound {
  1720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1721. return
  1722. } else if err != nil {
  1723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1724. return
  1725. } else {
  1726. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1727. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1728. infoStr := string(Iinfos)
  1729. idetinfoStr := string(Idetinfos)
  1730. psn := &models.HisPsn{
  1731. PsnNo: res.Output.Baseinfo.PsnNo,
  1732. Age: res.Output.Baseinfo.Age,
  1733. PatientId: patient.ID,
  1734. Certno: res.Output.Baseinfo.Certno,
  1735. Brdy: res.Output.Baseinfo.Brdy,
  1736. Gend: res.Output.Baseinfo.Gend,
  1737. Naty: res.Output.Baseinfo.Naty,
  1738. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1739. PsnName: res.Output.Baseinfo.PsnName,
  1740. Idetinfo: idetinfoStr,
  1741. Insuinfo: infoStr,
  1742. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1743. CardInfo: basStr,
  1744. VerifyNumber: "",
  1745. }
  1746. service.CreateHisPsn(psn)
  1747. c.ServeSuccessJSON(map[string]interface{}{
  1748. "patient": patient,
  1749. "number": basNumber,
  1750. })
  1751. }
  1752. } else {
  1753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1754. return
  1755. }
  1756. break
  1757. }
  1758. case 2:
  1759. SFZStr := c.GetSFZBaseInfo()
  1760. id_card_str := strings.Split(SFZStr, "^")
  1761. id_card_number := id_card_str[0]
  1762. card_sn := ""
  1763. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1764. var dat map[string]interface{}
  1765. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1766. fmt.Println(dat)
  1767. } else {
  1768. fmt.Println(err)
  1769. }
  1770. userJSONBytes, _ := json.Marshal(dat)
  1771. var res ResultTwo
  1772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1773. utils.ErrorLog("解析失败:%v", err)
  1774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1775. return
  1776. }
  1777. if res.Infcode == 0 {
  1778. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1779. if err == gorm.ErrRecordNotFound {
  1780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1781. return
  1782. } else if err != nil {
  1783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1784. return
  1785. } else {
  1786. c.ServeSuccessJSON(map[string]interface{}{
  1787. "patient": patient,
  1788. "number": id_card_number,
  1789. })
  1790. }
  1791. } else {
  1792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1793. return
  1794. }
  1795. break
  1796. case 3:
  1797. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1798. var api string
  1799. if miConfig.MdtrtareaAdmvs == "320921" {
  1800. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1801. "&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
  1802. fmt.Println(api)
  1803. } else {
  1804. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1805. "&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)
  1806. }
  1807. resp, requestErr := http.Get(api)
  1808. if requestErr != nil {
  1809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1810. return
  1811. }
  1812. body, ioErr := ioutil.ReadAll(resp.Body)
  1813. if ioErr != nil {
  1814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1816. return
  1817. }
  1818. var respJSON map[string]interface{}
  1819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. return
  1823. }
  1824. var status string
  1825. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1826. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1827. var token string
  1828. var res ResultTwo //1101结果
  1829. var res10265 ResultTwo10265 //1101结果
  1830. var card_info string //卡信息
  1831. var busi_card_info string
  1832. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1833. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1834. if status == "0" { //读卡成功
  1835. if card_type == "1" {
  1836. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1837. result, _ := json.Marshal(respJSON)
  1838. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1839. utils.ErrorLog("解析失败:%v", err)
  1840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1841. return
  1842. }
  1843. res.ErrMsg = res10265.ErrMsg
  1844. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1845. res.Infcode = infocode
  1846. res.Output = res10265.Output
  1847. res.InfRefmsgid = res10265.InfRefmsgid
  1848. } else {
  1849. //var card_info string //卡信息
  1850. //var busi_card_info string
  1851. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1852. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1853. //fmt.Println(card_info)
  1854. //fmt.Println(busi_card_info)
  1855. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1856. result, _ := json.Marshal(respJSON)
  1857. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1858. utils.ErrorLog("解析失败:%v", err)
  1859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1860. return
  1861. }
  1862. res.ErrMsg = res10265.ErrMsg
  1863. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1864. res.Infcode = infocode
  1865. res.Output = res10265.Output
  1866. res.InfRefmsgid = res10265.InfRefmsgid
  1867. }
  1868. if res.Infcode == 0 {
  1869. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1870. if err == gorm.ErrRecordNotFound {
  1871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1872. return
  1873. } else if err != nil {
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1875. return
  1876. } else {
  1877. if card_type == "1" {
  1878. bas := strings.Split(card_info, "|")
  1879. basNumber := bas[2]
  1880. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1881. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1882. infoStr := string(Iinfos)
  1883. idetinfoStr := string(Idetinfos)
  1884. psn := &models.HisPsn{
  1885. PsnNo: res.Output.Baseinfo.PsnNo,
  1886. Age: res.Output.Baseinfo.Age,
  1887. PatientId: patient.ID,
  1888. Certno: res.Output.Baseinfo.Certno,
  1889. Brdy: res.Output.Baseinfo.Brdy,
  1890. Gend: res.Output.Baseinfo.Gend,
  1891. Naty: res.Output.Baseinfo.Naty,
  1892. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1893. PsnName: res.Output.Baseinfo.PsnName,
  1894. Idetinfo: idetinfoStr,
  1895. Insuinfo: infoStr,
  1896. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1897. CardInfo: card_info,
  1898. VerifyNumber: busi_card_info,
  1899. }
  1900. service.CreateHisPsn(psn)
  1901. c.ServeSuccessJSON(map[string]interface{}{
  1902. "patient": patient,
  1903. "number": basNumber,
  1904. })
  1905. } else {
  1906. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1907. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1908. infoStr := string(Iinfos)
  1909. idetinfoStr := string(Idetinfos)
  1910. psn := &models.HisPsn{
  1911. PsnNo: res.Output.Baseinfo.PsnNo,
  1912. Age: res.Output.Baseinfo.Age,
  1913. PatientId: patient.ID,
  1914. Certno: res.Output.Baseinfo.Certno,
  1915. Brdy: res.Output.Baseinfo.Brdy,
  1916. Gend: res.Output.Baseinfo.Gend,
  1917. Naty: res.Output.Baseinfo.Naty,
  1918. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1919. PsnName: res.Output.Baseinfo.PsnName,
  1920. Idetinfo: idetinfoStr,
  1921. Insuinfo: infoStr,
  1922. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1923. CardInfo: card_info,
  1924. VerifyNumber: token,
  1925. }
  1926. service.CreateHisPsn(psn)
  1927. var rf []*ResultFive
  1928. json.Unmarshal([]byte(infoStr), &rf)
  1929. var insutypes []*ResultFive
  1930. var insutype string
  1931. var is390 int = 0
  1932. var is310 int = 0
  1933. for _, item := range rf {
  1934. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1935. insutypes = append(insutypes, item)
  1936. }
  1937. }
  1938. if len(insutypes) == 1 {
  1939. insutype = insutypes[0].Insutype
  1940. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1941. } else {
  1942. for _, i := range insutypes {
  1943. if i.Insutype == "390" {
  1944. is390 = 1
  1945. }
  1946. if i.Insutype == "310" {
  1947. is310 = 1
  1948. }
  1949. }
  1950. }
  1951. if is390 == 1 {
  1952. insutype = "390"
  1953. }
  1954. if is310 == 1 {
  1955. insutype = "310"
  1956. }
  1957. if len(insutypes) == 0 {
  1958. insutype = "310"
  1959. }
  1960. c.ServeSuccessJSON(map[string]interface{}{
  1961. "patient": patient,
  1962. "number": token,
  1963. "insutype": insutype,
  1964. })
  1965. }
  1966. }
  1967. } else {
  1968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1969. return
  1970. }
  1971. } else { //读卡失败
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1973. return
  1974. }
  1975. }
  1976. break
  1977. case 4:
  1978. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1979. var api string
  1980. if miConfig.MdtrtareaAdmvs == "320921" {
  1981. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1982. "&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
  1983. fmt.Println(api)
  1984. } else {
  1985. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1986. "&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)
  1987. }
  1988. resp, requestErr := http.Get(api)
  1989. if requestErr != nil {
  1990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1991. return
  1992. }
  1993. body, ioErr := ioutil.ReadAll(resp.Body)
  1994. if ioErr != nil {
  1995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1997. return
  1998. }
  1999. var respJSON map[string]interface{}
  2000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2003. return
  2004. }
  2005. var status string
  2006. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2007. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2008. var token string
  2009. var res ResultTwo //1101结果
  2010. var res10265 ResultTwo10265 //1101结果
  2011. if status == "0" { //读卡成功
  2012. var card_info string //卡信息
  2013. var busi_card_info string
  2014. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2015. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2016. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2017. fmt.Println(card_info)
  2018. fmt.Println(busi_card_info)
  2019. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2020. result, _ := json.Marshal(respJSON)
  2021. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2022. utils.ErrorLog("解析失败:%v", err)
  2023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2024. return
  2025. }
  2026. res.ErrMsg = res10265.ErrMsg
  2027. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2028. res.Infcode = infocode
  2029. res.Output = res10265.Output
  2030. res.InfRefmsgid = res10265.InfRefmsgid
  2031. if res.Infcode == 0 {
  2032. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2033. if err == gorm.ErrRecordNotFound {
  2034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2035. return
  2036. } else if err != nil {
  2037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2038. return
  2039. } else {
  2040. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2041. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2042. infoStr := string(Iinfos)
  2043. idetinfoStr := string(Idetinfos)
  2044. psn := &models.HisPsn{
  2045. PsnNo: res.Output.Baseinfo.PsnNo,
  2046. Age: res.Output.Baseinfo.Age,
  2047. PatientId: patient.ID,
  2048. Certno: res.Output.Baseinfo.Certno,
  2049. Brdy: res.Output.Baseinfo.Brdy,
  2050. Gend: res.Output.Baseinfo.Gend,
  2051. Naty: res.Output.Baseinfo.Naty,
  2052. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2053. PsnName: res.Output.Baseinfo.PsnName,
  2054. Idetinfo: idetinfoStr,
  2055. Insuinfo: infoStr,
  2056. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2057. CardInfo: card_info,
  2058. VerifyNumber: token,
  2059. }
  2060. service.CreateHisPsn(psn)
  2061. c.ServeSuccessJSON(map[string]interface{}{
  2062. "patient": patient,
  2063. "number": token,
  2064. })
  2065. }
  2066. } else {
  2067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2068. return
  2069. }
  2070. } else { //读卡失败
  2071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2072. return
  2073. }
  2074. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2075. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2076. saveLog(result, requestLog, "6101", "电子凭证")
  2077. var ele ELeCertData
  2078. err := json.Unmarshal([]byte(result), &ele)
  2079. if err != nil {
  2080. utils.ErrorLog("解析失败:%v", err)
  2081. }
  2082. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  2083. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2084. var res ResultTwo
  2085. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2086. utils.ErrorLog("解析失败:%v", err)
  2087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2088. return
  2089. }
  2090. if res.Infcode == 0 {
  2091. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2092. if err == gorm.ErrRecordNotFound {
  2093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2094. return
  2095. } else if err != nil {
  2096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2097. return
  2098. } else {
  2099. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2100. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2101. infoStr := string(Iinfos)
  2102. idetinfoStr := string(Idetinfos)
  2103. psn := &models.HisPsn{
  2104. PsnNo: res.Output.Baseinfo.PsnNo,
  2105. Age: res.Output.Baseinfo.Age,
  2106. PatientId: patient.ID,
  2107. Certno: res.Output.Baseinfo.Certno,
  2108. Brdy: res.Output.Baseinfo.Brdy,
  2109. Gend: res.Output.Baseinfo.Gend,
  2110. Naty: res.Output.Baseinfo.Naty,
  2111. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2112. PsnName: res.Output.Baseinfo.PsnName,
  2113. Idetinfo: idetinfoStr,
  2114. Insuinfo: infoStr,
  2115. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2116. CardInfo: "",
  2117. VerifyNumber: ele.Data.EcToken,
  2118. }
  2119. service.CreateHisPsn(psn)
  2120. c.ServeSuccessJSON(map[string]interface{}{
  2121. "patient": patient,
  2122. "number": ele.Data.EcToken,
  2123. })
  2124. }
  2125. } else {
  2126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2127. return
  2128. }
  2129. }
  2130. break
  2131. }
  2132. }
  2133. var initFlag int64 = 0
  2134. func (c *HisApiController) TestGetBasBaseInit() {
  2135. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2136. Iinit := DllDef.MustFindProc("Init")
  2137. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2138. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  2139. if ret != 0 {
  2140. fmt.Println("SSCard的报错原因:", err)
  2141. fmt.Println("SSCard的运算结果为:", ret)
  2142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2143. return
  2144. }
  2145. result := int(ret)
  2146. fmt.Println("SSCard的运算结果为1:", result)
  2147. initFlag = 1
  2148. return
  2149. }
  2150. func (c *HisApiController) GetSFZBaseInfo() string {
  2151. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2152. readCard := DllDef.MustFindProc("ReadSFZ")
  2153. if readCard == nil {
  2154. fmt.Println("readcard is nil")
  2155. readCard = DllDef.MustFindProc("ReadSFZ")
  2156. }
  2157. str := make([]byte, 256)
  2158. str1 := make([]byte, 256)
  2159. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2160. fmt.Println(r)
  2161. return string(str)
  2162. }
  2163. func (c *HisApiController) GetBasBaseInfo() string {
  2164. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2165. readCard := DllDef.MustFindProc("ReadCardBas")
  2166. if readCard == nil {
  2167. fmt.Println("readcard is nil")
  2168. readCard = DllDef.MustFindProc("ReadCardBas")
  2169. }
  2170. str := make([]byte, 1024)
  2171. str1 := make([]byte, 1024)
  2172. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2173. fmt.Println(string(str1))
  2174. fmt.Println(string(str))
  2175. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2176. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2177. if ret2 != 0 {
  2178. return ""
  2179. }
  2180. return string(str)
  2181. }
  2182. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  2183. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2184. readCard := DllDef.MustFindProc("read_cardinfo")
  2185. if readCard == nil {
  2186. fmt.Println("readcard is nil")
  2187. readCard = DllDef.MustFindProc("read_cardinfo")
  2188. }
  2189. str := make([]byte, 1024) //卡号
  2190. str1 := make([]byte, 1024) //卡识别码
  2191. str2 := make([]byte, 1024) //身份证号
  2192. str3 := make([]byte, 1024) //姓名
  2193. str4 := make([]byte, 1024) //错误信息
  2194. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  2195. fmt.Println(string(str1))
  2196. fmt.Println(string(str))
  2197. fmt.Println(string(str2))
  2198. fmt.Println(string(str3))
  2199. fmt.Println(string(str4))
  2200. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2201. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2202. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  2203. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  2204. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  2205. if ret2 != 0 {
  2206. return "", "", "", "", ""
  2207. }
  2208. return string(str), string(str1), string(str2), string(str3), string(str4)
  2209. }
  2210. type CustomFundPay struct {
  2211. FundPayType string `json:"fund_pay_type"`
  2212. FundPayamt float64 `json:"fund_payamt"`
  2213. }
  2214. func (c *HisApiController) GetSettleList() {
  2215. order_id, _ := c.GetInt64("order_id")
  2216. admin_user_id, _ := c.GetInt64("admin_user_id")
  2217. order, _ := service.GetHisOrderByIDTwo(order_id)
  2218. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2219. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2220. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2221. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2222. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2224. if order.ID == 0 {
  2225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2226. return
  2227. }
  2228. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2229. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2230. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2231. fmt.Println(count)
  2232. var zero string
  2233. number := count + 1
  2234. if number >= 1000 {
  2235. zero = "0000" + strconv.FormatInt(number, 10)
  2236. } else if number >= 10000 {
  2237. zero = "000" + strconv.FormatInt(number, 10)
  2238. } else if number >= 100000 {
  2239. zero = "00" + strconv.FormatInt(number, 10)
  2240. } else if number >= 1000000 {
  2241. zero = "0" + strconv.FormatInt(number, 10)
  2242. } else {
  2243. zero = strconv.FormatInt(number, 10)
  2244. }
  2245. fmt.Println(zero)
  2246. struct4101 := service.Struct4101{
  2247. PsnNo: order.PsnNo,
  2248. MdtrtId: order.MdtrtId,
  2249. SetlId: order.SetlId,
  2250. PsnName: order.PsnName,
  2251. Gend: order.Gend,
  2252. Brdy: his.Brdy,
  2253. Age: his.Age,
  2254. Naty: order.Naty,
  2255. PatnCertType: "01",
  2256. Certno: order.Certno,
  2257. Prfs: "90",
  2258. ConerName: roles[0].UserName,
  2259. PatnRlts: "99",
  2260. ConerAddr: miConfig.OrgName,
  2261. ConerTel: admin.Mobile,
  2262. HiType: order.Insutype,
  2263. Insuplc: miConfig.InsuplcAdmdvs,
  2264. MaindiagFlag: "1",
  2265. BillCode: last_order.FaPiaoCode,
  2266. BillNo: zero,
  2267. BizSn: order.Number,
  2268. PsnSelfPay: order.PsnPartAmt,
  2269. PsnOwnPay: order.PsnPartAmt,
  2270. AcctPay: order.AcctPay,
  2271. PsnCashpay: order.PsnCashPay,
  2272. HiPaymtd: "1",
  2273. Hsorg: miConfig.InsuplcAdmdvs,
  2274. HsorgOpter: miConfig.InsuplcAdmdvs,
  2275. MedinsFillPsn: curRoles.UserName,
  2276. MedinsFillDept: depart.Name,
  2277. IptMedType: "2",
  2278. }
  2279. struct4101.SetlBegnDate = order.SetlTime
  2280. struct4101.SetlEndDate = order.SetlTime
  2281. time_arr := strings.Split(order.SetlTime, " ")
  2282. struct4101.AdmTime = time_arr[0]
  2283. struct4101.AdmEndTime = time_arr[0]
  2284. var rf []CustomFundPay
  2285. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2286. var tempFunPays []service.CustomStruct
  2287. for _, item := range rf {
  2288. var tempFunPay service.CustomStruct
  2289. tempFunPay.FundPayamt = item.FundPayamt
  2290. tempFunPay.FundPayType = item.FundPayType
  2291. tempFunPays = append(tempFunPays, tempFunPay)
  2292. }
  2293. struct4101.CustomStruct = tempFunPays
  2294. var tempDiaginfos []service.DiaginfoStructTwo
  2295. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2296. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2297. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2298. var config []*models.HisXtDiagnoseConfig
  2299. for _, item := range diagnosis_ids {
  2300. id, _ := strconv.ParseInt(item, 10, 64)
  2301. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2302. config = append(config, &diagnosisConfig)
  2303. }
  2304. for index, item := range config {
  2305. if index == 0 {
  2306. var tempDiaginfo service.DiaginfoStructTwo
  2307. tempDiaginfo.DiagCode = item.CountryCode
  2308. tempDiaginfo.DiagName = item.CountryContentName
  2309. tempDiaginfo.DiagType = "1"
  2310. tempDiaginfo.MaindiagFlag = "1"
  2311. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2312. } else {
  2313. var tempDiaginfo service.DiaginfoStructTwo
  2314. tempDiaginfo.DiagCode = item.CountryCode
  2315. tempDiaginfo.DiagName = item.CountryContentName
  2316. tempDiaginfo.DiagType = "2"
  2317. tempDiaginfo.MaindiagFlag = "0"
  2318. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2319. }
  2320. }
  2321. struct4101.Diseinfo = tempDiaginfos
  2322. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2323. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2324. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2325. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2326. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2327. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2328. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2329. var iteminfo service.IteminfoStruct
  2330. var bedCostTotal float64 = 0 //床位总费
  2331. var bedCostSelfTotal float64 = 0 //床位自费
  2332. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2333. var operationCostTotal float64 = 0 //手术费
  2334. var operationCostSelfTotal float64 = 0 //手术费
  2335. var operationCostPartSelfTotal float64 = 0 //手术费
  2336. var otherCostTotal float64 = 0 //其他费用
  2337. var otherCostSelfTotal float64 = 0 //其他费用
  2338. var otherCostPartSelfTotal float64 = 0 //其他费用
  2339. var materialCostTotal float64 = 0 //材料费
  2340. var materialCostSelfTotal float64 = 0 //材料费
  2341. var materialCostPartSelfTotal float64 = 0 //材料费
  2342. var westernMedicineCostTotal float64 = 0 //西药费
  2343. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2344. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2345. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2346. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2347. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2348. var checkCostTotal float64 = 0 //检查费
  2349. var checkCostSelfTotal float64 = 0 //检查费
  2350. var checkCostPartSelfTotal float64 = 0 //检查费
  2351. var laboratoryCostTotal float64 = 0 //化验费
  2352. var laboratoryCostSelfTotal float64 = 0 //化验费
  2353. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2354. var treatCostTotal float64 = 0 //治疗费用
  2355. var treatCostSelfTotal float64 = 0 //治疗费用
  2356. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2357. decimal.DivisionPrecision = 2
  2358. var bed_fulamt_ownpay_amt float64 = 0
  2359. var operation_fulamt_ownpay_amt float64 = 0
  2360. var other_fulamt_ownpay_amt float64 = 0
  2361. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2362. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2363. var check_fulamt_ownpay_amt float64 = 0
  2364. var material_fulamt_ownpay_amt float64 = 0
  2365. var laboratory_fulamt_ownpay_amt float64 = 0
  2366. var treat_fulamt_ownpay_amt float64 = 0
  2367. var bed_claa_sunmfee float64 = 0
  2368. var bed_clab_amt float64 = 0
  2369. var bed_other_amt float64 = 0
  2370. var operation_claa_sunmfee float64 = 0
  2371. var operation_clab_amt float64 = 0
  2372. var operation_other_amt float64 = 0
  2373. var other_claa_sunmfee float64 = 0
  2374. var other_clab_amt float64 = 0
  2375. var other_other_amt float64 = 0
  2376. var westernMedicine_claa_sunmfee float64 = 0
  2377. var westernMedicine_clab_amt float64 = 0
  2378. var westernMedicine_other_amt float64 = 0
  2379. var chineseTraditional_claa_sunmfee float64 = 0
  2380. var chineseTraditional_clab_amt float64 = 0
  2381. var chineseTraditional_other_amt float64 = 0
  2382. var check_claa_sunmfee float64 = 0
  2383. var check_clab_amt float64 = 0
  2384. var check_other_amt float64 = 0
  2385. var material_claa_sunmfee float64 = 0
  2386. var material_clab_amt float64 = 0
  2387. var material_other_amt float64 = 0
  2388. var laboratory_claa_sunmfee float64 = 0
  2389. var laboratory_clab_amt float64 = 0
  2390. var laboratory_other_amt float64 = 0
  2391. var treat_claa_sunmfee float64 = 0
  2392. var treat_clab_amt float64 = 0
  2393. var treat_other_amt float64 = 0
  2394. for _, item := range order.HisOrderInfo {
  2395. if item.MedChrgitmType == "01" { //床位费
  2396. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2397. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2398. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2399. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2400. if item.ChrgitmLv == "1" {
  2401. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2402. }
  2403. if item.ChrgitmLv == "2" {
  2404. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2405. }
  2406. if item.ChrgitmLv == "3" {
  2407. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2408. }
  2409. }
  2410. if item.MedChrgitmType == "03" { //检查费
  2411. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2412. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2413. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2414. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2415. if item.ChrgitmLv == "1" {
  2416. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2417. }
  2418. if item.ChrgitmLv == "2" {
  2419. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2420. }
  2421. if item.ChrgitmLv == "3" {
  2422. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2423. }
  2424. }
  2425. if item.MedChrgitmType == "04" { //化验费
  2426. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2427. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2428. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2429. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2430. if item.ChrgitmLv == "1" {
  2431. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2432. }
  2433. if item.ChrgitmLv == "2" {
  2434. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2435. }
  2436. if item.ChrgitmLv == "3" {
  2437. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2438. }
  2439. }
  2440. if item.MedChrgitmType == "05" { //治疗费
  2441. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2442. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2443. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2444. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2445. if item.ChrgitmLv == "1" {
  2446. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2447. }
  2448. if item.ChrgitmLv == "2" {
  2449. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2450. }
  2451. if item.ChrgitmLv == "3" {
  2452. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2453. }
  2454. }
  2455. if item.MedChrgitmType == "06" { //手术费
  2456. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2457. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2458. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2459. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2460. if item.ChrgitmLv == "1" {
  2461. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2462. }
  2463. if item.ChrgitmLv == "2" {
  2464. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2465. }
  2466. if item.ChrgitmLv == "3" {
  2467. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2468. }
  2469. }
  2470. if item.MedChrgitmType == "08" { //材料费
  2471. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2472. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2473. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2474. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2475. if item.ChrgitmLv == "1" {
  2476. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2477. }
  2478. if item.ChrgitmLv == "2" {
  2479. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2480. }
  2481. if item.ChrgitmLv == "3" {
  2482. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2483. }
  2484. }
  2485. if item.MedChrgitmType == "09" { //西药费
  2486. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2487. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2488. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2489. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2490. if item.ChrgitmLv == "1" {
  2491. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2492. }
  2493. if item.ChrgitmLv == "2" {
  2494. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2495. }
  2496. if item.ChrgitmLv == "3" {
  2497. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2498. }
  2499. }
  2500. if item.MedChrgitmType == "11" { //中成费
  2501. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2502. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2503. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2504. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2505. if item.ChrgitmLv == "1" {
  2506. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2507. }
  2508. if item.ChrgitmLv == "2" {
  2509. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2510. }
  2511. if item.ChrgitmLv == "3" {
  2512. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2513. }
  2514. }
  2515. if item.MedChrgitmType == "14" { //其他费
  2516. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2517. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2518. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2519. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2520. if item.ChrgitmLv == "1" {
  2521. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2522. }
  2523. if item.ChrgitmLv == "2" {
  2524. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2525. }
  2526. if item.ChrgitmLv == "3" {
  2527. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2528. }
  2529. }
  2530. }
  2531. var iteminfoStructs []service.IteminfoStruct
  2532. if bedCostTotal != 0 {
  2533. iteminfo.MedChrgitm = "01"
  2534. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2535. iteminfo.Amt = bedCostTotal
  2536. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2537. iteminfo.ClabAmt = bed_clab_amt
  2538. iteminfo.OthAmt = bed_other_amt
  2539. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2540. }
  2541. if checkCostTotal != 0 {
  2542. iteminfo.MedChrgitm = "03"
  2543. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2544. iteminfo.Amt = checkCostTotal
  2545. iteminfo.ClaaSumfee = check_claa_sunmfee
  2546. iteminfo.ClabAmt = check_clab_amt
  2547. iteminfo.OthAmt = check_other_amt
  2548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2549. }
  2550. if laboratoryCostTotal != 0 {
  2551. iteminfo.MedChrgitm = "04"
  2552. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2553. iteminfo.Amt = laboratoryCostTotal
  2554. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2555. iteminfo.ClabAmt = laboratory_clab_amt
  2556. iteminfo.OthAmt = laboratory_other_amt
  2557. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2558. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2559. }
  2560. if treatCostTotal != 0 {
  2561. iteminfo.MedChrgitm = "05"
  2562. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2563. iteminfo.Amt = treatCostTotal
  2564. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2565. iteminfo.ClabAmt = treat_clab_amt
  2566. iteminfo.OthAmt = treat_other_amt
  2567. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2568. //(struct4101.IteminfoStruct, iteminfo)
  2569. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2570. }
  2571. if operationCostTotal != 0 {
  2572. iteminfo.MedChrgitm = "06"
  2573. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2574. iteminfo.Amt = operationCostTotal
  2575. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2576. iteminfo.ClabAmt = operation_clab_amt
  2577. iteminfo.OthAmt = operation_other_amt
  2578. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2579. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2580. }
  2581. if materialCostTotal != 0 {
  2582. iteminfo.MedChrgitm = "08"
  2583. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2584. iteminfo.Amt = materialCostTotal
  2585. iteminfo.ClaaSumfee = material_claa_sunmfee
  2586. iteminfo.ClabAmt = material_clab_amt
  2587. iteminfo.OthAmt = material_other_amt
  2588. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2589. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2590. }
  2591. if westernMedicineCostTotal != 0 {
  2592. iteminfo.MedChrgitm = "09"
  2593. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2594. iteminfo.Amt = westernMedicineCostTotal
  2595. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2596. iteminfo.ClabAmt = westernMedicine_clab_amt
  2597. iteminfo.OthAmt = westernMedicine_other_amt
  2598. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2599. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2600. }
  2601. if chineseTraditionalMedicineCostTotal != 0 {
  2602. iteminfo.MedChrgitm = "11"
  2603. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2604. iteminfo.Amt = westernMedicineCostTotal
  2605. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2606. iteminfo.ClabAmt = westernMedicine_clab_amt
  2607. iteminfo.OthAmt = westernMedicine_other_amt
  2608. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2609. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2610. }
  2611. if otherCostTotal != 0 {
  2612. iteminfo.MedChrgitm = "14"
  2613. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2614. iteminfo.Amt = otherCostTotal
  2615. iteminfo.ClaaSumfee = other_claa_sunmfee
  2616. iteminfo.ClabAmt = other_clab_amt
  2617. iteminfo.OthAmt = other_other_amt
  2618. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2619. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2620. }
  2621. struct4101.IteminfoStruct = iteminfoStructs
  2622. struct4101.Ntly = "中国"
  2623. struct4101.AdmCaty = "A03.06"
  2624. var res ResultSeventeen
  2625. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2626. var resOther ResultSeventeenOther
  2627. var pp models.PublicParams
  2628. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2629. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2630. pp.FixmedinsName = miConfig.OrgName
  2631. pp.FixmedinsCode = miConfig.Code
  2632. pp.RequestUrl = miConfig.Url
  2633. pp.Cainfo = miConfig.Cainfo
  2634. pp.SecretKey = miConfig.SecretKey
  2635. pp.AccessKey = miConfig.AccessKey
  2636. pp.OpterName = curRoles.UserName
  2637. client := &http.Client{}
  2638. var req *http.Request
  2639. data := make(map[string]interface{})
  2640. data["struct4101"] = struct4101
  2641. data["pp"] = pp
  2642. bytesData, _ := json.Marshal(data)
  2643. if miConfig.MdtrtareaAdmvs == "320921" {
  2644. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2645. } else {
  2646. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2647. }
  2648. resp, _ := client.Do(req)
  2649. defer resp.Body.Close()
  2650. body, ioErr := ioutil.ReadAll(resp.Body)
  2651. if ioErr != nil {
  2652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2654. return
  2655. }
  2656. var respJSON map[string]interface{}
  2657. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2660. return
  2661. }
  2662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2663. userJSONBytes, _ := json.Marshal(respJSON)
  2664. fmt.Println("log")
  2665. fmt.Println(string(userJSONBytes))
  2666. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2667. utils.ErrorLog("解析失败:%v", err)
  2668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2669. return
  2670. }
  2671. res.InfRefmsgid = resOther.InfRefmsgid
  2672. res.Output = resOther.Output
  2673. res.ErrMsg = resOther.ErrMsg
  2674. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2675. res.Infcode = infocode
  2676. } else {
  2677. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2678. var dat map[string]interface{}
  2679. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2680. fmt.Println(dat)
  2681. } else {
  2682. fmt.Println(err)
  2683. }
  2684. userJSONBytes, _ := json.Marshal(dat)
  2685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2686. utils.ErrorLog("解析失败:%v", err)
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2688. return
  2689. }
  2690. }
  2691. if res.Infcode != 0 {
  2692. c.ServeSuccessJSON(map[string]interface{}{
  2693. "failed_code": -10,
  2694. "msg": res.ErrMsg,
  2695. })
  2696. return
  2697. } else {
  2698. order.FaPiaoNumber = zero
  2699. order.FaPiaoCode = last_order.FaPiaoCode
  2700. service.UpdateOrder(order)
  2701. hisFundSettleListResult := &models.HisFundSettleListResult{
  2702. Number: res.Output.SetlListId,
  2703. Status: 1,
  2704. Ctime: time.Now().Unix(),
  2705. Mtime: time.Now().Unix(),
  2706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2707. IsUpload: 1,
  2708. OrderId: order_id,
  2709. }
  2710. service.CreateUploadRecord(hisFundSettleListResult)
  2711. c.ServeSuccessJSON(map[string]interface{}{
  2712. "msg": "上传成功",
  2713. "result": hisFundSettleListResult,
  2714. })
  2715. return
  2716. }
  2717. }
  2718. func (c *HisApiController) GetSettleListHospital() {
  2719. order_id, _ := c.GetInt64("order_id")
  2720. admin_user_id, _ := c.GetInt64("admin_user_id")
  2721. order, _ := service.GetHisOrderByIDTwo(order_id)
  2722. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2723. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2724. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2725. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2726. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2727. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2728. if order.ID == 0 {
  2729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2730. return
  2731. }
  2732. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2733. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2734. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2735. fmt.Println(count)
  2736. var zero string
  2737. number := count + 1
  2738. if number >= 1000 {
  2739. zero = "0000" + strconv.FormatInt(number, 10)
  2740. } else if number >= 10000 {
  2741. zero = "000" + strconv.FormatInt(number, 10)
  2742. } else if number >= 100000 {
  2743. zero = "00" + strconv.FormatInt(number, 10)
  2744. } else if number >= 1000000 {
  2745. zero = "0" + strconv.FormatInt(number, 10)
  2746. } else {
  2747. zero = strconv.FormatInt(number, 10)
  2748. }
  2749. fmt.Println(zero)
  2750. struct4101 := service.Struct4101{
  2751. PsnNo: order.PsnNo,
  2752. MdtrtId: order.MdtrtId,
  2753. SetlId: order.SetlId,
  2754. PsnName: order.PsnName,
  2755. Gend: order.Gend,
  2756. Brdy: his.Brdy,
  2757. Age: int64(order.Age),
  2758. Naty: order.Naty,
  2759. PatnCertType: "01",
  2760. Certno: order.Certno,
  2761. Prfs: "90",
  2762. ConerName: roles[0].UserName,
  2763. PatnRlts: "99",
  2764. ConerAddr: miConfig.OrgName,
  2765. ConerTel: admin.Mobile,
  2766. HiType: order.Insutype,
  2767. Insuplc: miConfig.InsuplcAdmdvs,
  2768. MaindiagFlag: "1",
  2769. BillCode: last_order.FaPiaoCode,
  2770. BillNo: zero,
  2771. BizSn: order.Number,
  2772. PsnSelfPay: order.PsnPartAmt,
  2773. PsnOwnPay: order.PsnPartAmt,
  2774. AcctPay: order.AcctPay,
  2775. PsnCashpay: order.PsnCashPay,
  2776. HiPaymtd: "1",
  2777. Hsorg: miConfig.InsuplcAdmdvs,
  2778. HsorgOpter: miConfig.InsuplcAdmdvs,
  2779. MedinsFillPsn: curRoles.UserName,
  2780. MedinsFillDept: depart.Name,
  2781. IptMedType: "2",
  2782. AdmTime: his.InHosptialTime,
  2783. AdmEndTime: his.OutHosptialTime,
  2784. }
  2785. struct4101.SetlBegnDate = order.SetlTime
  2786. struct4101.SetlEndDate = order.SetlTime
  2787. var rf []CustomFundPay
  2788. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2789. var tempFunPays []service.CustomStruct
  2790. for _, item := range rf {
  2791. var tempFunPay service.CustomStruct
  2792. tempFunPay.FundPayamt = item.FundPayamt
  2793. tempFunPay.FundPayType = item.FundPayType
  2794. tempFunPays = append(tempFunPays, tempFunPay)
  2795. }
  2796. struct4101.CustomStruct = tempFunPays
  2797. var tempDiaginfos []service.DiaginfoStructTwo
  2798. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2799. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2800. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2801. var config []*models.HisXtDiagnoseConfig
  2802. for _, item := range diagnosis_ids {
  2803. id, _ := strconv.ParseInt(item, 10, 64)
  2804. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2805. config = append(config, &diagnosisConfig)
  2806. }
  2807. for index, item := range config {
  2808. if index == 0 {
  2809. var tempDiaginfo service.DiaginfoStructTwo
  2810. tempDiaginfo.DiagCode = item.CountryCode
  2811. tempDiaginfo.DiagName = item.CountryContentName
  2812. tempDiaginfo.DiagType = "1"
  2813. tempDiaginfo.MaindiagFlag = "1"
  2814. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2815. } else {
  2816. var tempDiaginfo service.DiaginfoStructTwo
  2817. tempDiaginfo.DiagCode = item.CountryCode
  2818. tempDiaginfo.DiagName = item.CountryContentName
  2819. tempDiaginfo.DiagType = "2"
  2820. tempDiaginfo.MaindiagFlag = "0"
  2821. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2822. }
  2823. }
  2824. struct4101.Diseinfo = tempDiaginfos
  2825. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2826. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2827. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2828. tempOpspdiseinfo2.OprnOprtCode = ""
  2829. tempOpspdiseinfo2.OprnOprtName = ""
  2830. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2831. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2832. var iteminfo service.IteminfoStruct
  2833. var bedCostTotal float64 = 0 //床位总费
  2834. var bedCostSelfTotal float64 = 0 //床位自费
  2835. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2836. var operationCostTotal float64 = 0 //手术费
  2837. var operationCostSelfTotal float64 = 0 //手术费
  2838. var operationCostPartSelfTotal float64 = 0 //手术费
  2839. var otherCostTotal float64 = 0 //其他费用
  2840. var otherCostSelfTotal float64 = 0 //其他费用
  2841. var otherCostPartSelfTotal float64 = 0 //其他费用
  2842. var materialCostTotal float64 = 0 //材料费
  2843. var materialCostSelfTotal float64 = 0 //材料费
  2844. var materialCostPartSelfTotal float64 = 0 //材料费
  2845. var westernMedicineCostTotal float64 = 0 //西药费
  2846. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2847. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2848. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2849. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2850. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2851. var checkCostTotal float64 = 0 //检查费
  2852. var checkCostSelfTotal float64 = 0 //检查费
  2853. var checkCostPartSelfTotal float64 = 0 //检查费
  2854. var laboratoryCostTotal float64 = 0 //化验费
  2855. var laboratoryCostSelfTotal float64 = 0 //化验费
  2856. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2857. var treatCostTotal float64 = 0 //治疗费用
  2858. var treatCostSelfTotal float64 = 0 //治疗费用
  2859. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2860. decimal.DivisionPrecision = 2
  2861. var bed_fulamt_ownpay_amt float64 = 0
  2862. var operation_fulamt_ownpay_amt float64 = 0
  2863. var other_fulamt_ownpay_amt float64 = 0
  2864. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2865. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2866. var check_fulamt_ownpay_amt float64 = 0
  2867. var material_fulamt_ownpay_amt float64 = 0
  2868. var laboratory_fulamt_ownpay_amt float64 = 0
  2869. var treat_fulamt_ownpay_amt float64 = 0
  2870. var bed_claa_sunmfee float64 = 0
  2871. var bed_clab_amt float64 = 0
  2872. var bed_other_amt float64 = 0
  2873. var operation_claa_sunmfee float64 = 0
  2874. var operation_clab_amt float64 = 0
  2875. var operation_other_amt float64 = 0
  2876. var other_claa_sunmfee float64 = 0
  2877. var other_clab_amt float64 = 0
  2878. var other_other_amt float64 = 0
  2879. var westernMedicine_claa_sunmfee float64 = 0
  2880. var westernMedicine_clab_amt float64 = 0
  2881. var westernMedicine_other_amt float64 = 0
  2882. var chineseTraditional_claa_sunmfee float64 = 0
  2883. var chineseTraditional_clab_amt float64 = 0
  2884. var chineseTraditional_other_amt float64 = 0
  2885. var check_claa_sunmfee float64 = 0
  2886. var check_clab_amt float64 = 0
  2887. var check_other_amt float64 = 0
  2888. var material_claa_sunmfee float64 = 0
  2889. var material_clab_amt float64 = 0
  2890. var material_other_amt float64 = 0
  2891. var laboratory_claa_sunmfee float64 = 0
  2892. var laboratory_clab_amt float64 = 0
  2893. var laboratory_other_amt float64 = 0
  2894. var treat_claa_sunmfee float64 = 0
  2895. var treat_clab_amt float64 = 0
  2896. var treat_other_amt float64 = 0
  2897. for _, item := range order.HisOrderInfo {
  2898. if item.MedChrgitmType == "01" { //床位费
  2899. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2900. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2901. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2902. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2903. if item.ChrgitmLv == "1" {
  2904. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2905. }
  2906. if item.ChrgitmLv == "2" {
  2907. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2908. }
  2909. if item.ChrgitmLv == "3" {
  2910. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2911. }
  2912. }
  2913. if item.MedChrgitmType == "03" { //检查费
  2914. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2915. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2916. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2917. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2918. if item.ChrgitmLv == "1" {
  2919. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2920. }
  2921. if item.ChrgitmLv == "2" {
  2922. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2923. }
  2924. if item.ChrgitmLv == "3" {
  2925. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2926. }
  2927. }
  2928. if item.MedChrgitmType == "04" { //化验费
  2929. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2930. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2931. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2932. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2933. if item.ChrgitmLv == "1" {
  2934. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2935. }
  2936. if item.ChrgitmLv == "2" {
  2937. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2938. }
  2939. if item.ChrgitmLv == "3" {
  2940. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2941. }
  2942. }
  2943. if item.MedChrgitmType == "05" { //治疗费
  2944. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2945. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2946. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2947. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2948. if item.ChrgitmLv == "1" {
  2949. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2950. }
  2951. if item.ChrgitmLv == "2" {
  2952. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2953. }
  2954. if item.ChrgitmLv == "3" {
  2955. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2956. }
  2957. }
  2958. if item.MedChrgitmType == "06" { //手术费
  2959. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2960. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2961. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2962. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2963. if item.ChrgitmLv == "1" {
  2964. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2965. }
  2966. if item.ChrgitmLv == "2" {
  2967. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2968. }
  2969. if item.ChrgitmLv == "3" {
  2970. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2971. }
  2972. }
  2973. if item.MedChrgitmType == "08" { //材料费
  2974. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2975. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2976. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2977. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2978. if item.ChrgitmLv == "1" {
  2979. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2980. }
  2981. if item.ChrgitmLv == "2" {
  2982. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2983. }
  2984. if item.ChrgitmLv == "3" {
  2985. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2986. }
  2987. }
  2988. if item.MedChrgitmType == "09" { //西药费
  2989. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2990. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2991. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2992. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2993. if item.ChrgitmLv == "1" {
  2994. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2995. }
  2996. if item.ChrgitmLv == "2" {
  2997. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2998. }
  2999. if item.ChrgitmLv == "3" {
  3000. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3001. }
  3002. }
  3003. if item.MedChrgitmType == "11" { //中成费
  3004. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3005. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3006. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3007. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3008. if item.ChrgitmLv == "1" {
  3009. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3010. }
  3011. if item.ChrgitmLv == "2" {
  3012. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3013. }
  3014. if item.ChrgitmLv == "3" {
  3015. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3016. }
  3017. }
  3018. if item.MedChrgitmType == "14" { //其他费
  3019. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3020. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3021. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3022. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3023. if item.ChrgitmLv == "1" {
  3024. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3025. }
  3026. if item.ChrgitmLv == "2" {
  3027. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3028. }
  3029. if item.ChrgitmLv == "3" {
  3030. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3031. }
  3032. }
  3033. }
  3034. var iteminfoStructs []service.IteminfoStruct
  3035. if bedCostTotal != 0 {
  3036. iteminfo.MedChrgitm = "01"
  3037. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3038. iteminfo.Amt = bedCostTotal
  3039. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3040. iteminfo.ClabAmt = bed_clab_amt
  3041. iteminfo.OthAmt = bed_other_amt
  3042. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3043. }
  3044. if checkCostTotal != 0 {
  3045. iteminfo.MedChrgitm = "03"
  3046. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3047. iteminfo.Amt = checkCostTotal
  3048. iteminfo.ClaaSumfee = check_claa_sunmfee
  3049. iteminfo.ClabAmt = check_clab_amt
  3050. iteminfo.OthAmt = check_other_amt
  3051. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3052. }
  3053. if laboratoryCostTotal != 0 {
  3054. iteminfo.MedChrgitm = "04"
  3055. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3056. iteminfo.Amt = laboratoryCostTotal
  3057. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3058. iteminfo.ClabAmt = laboratory_clab_amt
  3059. iteminfo.OthAmt = laboratory_other_amt
  3060. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3061. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3062. }
  3063. if treatCostTotal != 0 {
  3064. iteminfo.MedChrgitm = "05"
  3065. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3066. iteminfo.Amt = treatCostTotal
  3067. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3068. iteminfo.ClabAmt = treat_clab_amt
  3069. iteminfo.OthAmt = treat_other_amt
  3070. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3071. //(struct4101.IteminfoStruct, iteminfo)
  3072. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3073. }
  3074. if operationCostTotal != 0 {
  3075. iteminfo.MedChrgitm = "06"
  3076. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3077. iteminfo.Amt = operationCostTotal
  3078. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3079. iteminfo.ClabAmt = operation_clab_amt
  3080. iteminfo.OthAmt = operation_other_amt
  3081. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3082. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3083. }
  3084. if materialCostTotal != 0 {
  3085. iteminfo.MedChrgitm = "08"
  3086. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3087. iteminfo.Amt = materialCostTotal
  3088. iteminfo.ClaaSumfee = material_claa_sunmfee
  3089. iteminfo.ClabAmt = material_clab_amt
  3090. iteminfo.OthAmt = material_other_amt
  3091. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3092. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3093. }
  3094. if westernMedicineCostTotal != 0 {
  3095. iteminfo.MedChrgitm = "09"
  3096. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3097. iteminfo.Amt = westernMedicineCostTotal
  3098. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3099. iteminfo.ClabAmt = westernMedicine_clab_amt
  3100. iteminfo.OthAmt = westernMedicine_other_amt
  3101. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3102. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3103. }
  3104. if chineseTraditionalMedicineCostTotal != 0 {
  3105. iteminfo.MedChrgitm = "11"
  3106. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3107. iteminfo.Amt = westernMedicineCostTotal
  3108. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3109. iteminfo.ClabAmt = westernMedicine_clab_amt
  3110. iteminfo.OthAmt = westernMedicine_other_amt
  3111. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3112. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3113. }
  3114. if otherCostTotal != 0 {
  3115. iteminfo.MedChrgitm = "14"
  3116. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3117. iteminfo.Amt = otherCostTotal
  3118. iteminfo.ClaaSumfee = other_claa_sunmfee
  3119. iteminfo.ClabAmt = other_clab_amt
  3120. iteminfo.OthAmt = other_other_amt
  3121. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3122. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3123. }
  3124. struct4101.IteminfoStruct = iteminfoStructs
  3125. struct4101.Ntly = "中国"
  3126. struct4101.AdmCaty = "A03.06"
  3127. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3128. fmt.Println(result)
  3129. var dat map[string]interface{}
  3130. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3131. fmt.Println(dat)
  3132. } else {
  3133. fmt.Println(err)
  3134. }
  3135. userJSONBytes, _ := json.Marshal(dat)
  3136. var res ResultSeventeen
  3137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3138. utils.ErrorLog("解析失败:%v", err)
  3139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3140. return
  3141. }
  3142. if res.Infcode != 0 {
  3143. c.ServeSuccessJSON(map[string]interface{}{
  3144. "failed_code": -10,
  3145. "msg": res.ErrMsg,
  3146. })
  3147. return
  3148. } else {
  3149. order.FaPiaoNumber = zero
  3150. order.FaPiaoCode = last_order.FaPiaoCode
  3151. service.UpdateOrder(order)
  3152. hisFundSettleListResult := &models.HisFundSettleListResult{
  3153. Number: res.Output.SetlListId,
  3154. Status: 1,
  3155. Ctime: time.Now().Unix(),
  3156. Mtime: time.Now().Unix(),
  3157. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3158. IsUpload: 1,
  3159. OrderId: order_id,
  3160. }
  3161. service.CreateUploadRecord(hisFundSettleListResult)
  3162. c.ServeSuccessJSON(map[string]interface{}{
  3163. "msg": "上传成功",
  3164. "result": hisFundSettleListResult,
  3165. })
  3166. return
  3167. }
  3168. }
  3169. func (c *HisApiController) GetBatchSettleList() {
  3170. orders, _ := service.GetAllHisOrder(10138)
  3171. for _, item := range orders {
  3172. order_id := item.ID
  3173. order, _ := service.GetHisOrderByIDTwo(order_id)
  3174. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3175. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3176. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3177. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  3178. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3179. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3180. if order.ID == 0 {
  3181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3182. return
  3183. }
  3184. if his.BalanceAccountsType == 2 {
  3185. continue
  3186. }
  3187. struct4101 := service.Struct4101{
  3188. PsnNo: order.PsnNo,
  3189. MdtrtId: order.MdtrtId,
  3190. SetlId: order.SetlId,
  3191. PsnName: order.PsnName,
  3192. Gend: order.Gend,
  3193. Brdy: his.Brdy,
  3194. Age: his.Age,
  3195. Naty: order.Naty,
  3196. PatnCertType: "01",
  3197. Certno: order.Certno,
  3198. Prfs: "90",
  3199. ConerName: roles[0].UserName,
  3200. PatnRlts: "99",
  3201. ConerAddr: miConfig.OrgName,
  3202. ConerTel: admin.Mobile,
  3203. HiType: order.Insutype,
  3204. Insuplc: his.InsuplcAdmdvs,
  3205. MaindiagFlag: "1",
  3206. BillCode: order.FaPiaoCode,
  3207. BillNo: order.FaPiaoNumber,
  3208. BizSn: order.Number,
  3209. PsnSelfPay: order.PsnPartAmt,
  3210. PsnOwnPay: order.PsnPartAmt,
  3211. AcctPay: order.AcctPay,
  3212. PsnCashpay: order.PsnCashPay,
  3213. HiPaymtd: "1",
  3214. Hsorg: his.InsuplcAdmdvs,
  3215. HsorgOpter: his.InsuplcAdmdvs,
  3216. MedinsFillPsn: curRoles.UserName,
  3217. MedinsFillDept: depart.Name,
  3218. IptMedType: "2",
  3219. }
  3220. struct4101.SetlBegnDate = order.SetlTime
  3221. struct4101.SetlEndDate = order.SetlTime
  3222. //if order.SettleType == 1 {
  3223. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3224. // dateStr := t.Format("2006-01-02")
  3225. // struct4101.SetlBegnDate = dateStr
  3226. // struct4101.SetlEndDate = dateStr
  3227. //} else {
  3228. // t := time.Unix(int64(order.SettleStartTime), 0)
  3229. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3230. // dateStartStr := t.Format("2006-01-02")
  3231. // dateEndStr := t2.Format("2006-01-02")
  3232. // struct4101.SetlBegnDate = dateStartStr
  3233. // struct4101.SetlEndDate = dateEndStr
  3234. //}
  3235. var rf []CustomFundPay
  3236. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3237. var tempFunPays []service.CustomStruct
  3238. var tempFunPay610100 service.CustomStruct
  3239. for _, item := range rf {
  3240. if item.FundPayType == "610100" {
  3241. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3242. tempFunPay610100.FundPayType = item.FundPayType
  3243. } else {
  3244. var tempFunPay service.CustomStruct
  3245. tempFunPay.FundPayamt = item.FundPayamt
  3246. tempFunPay.FundPayType = item.FundPayType
  3247. tempFunPays = append(tempFunPays, tempFunPay)
  3248. }
  3249. }
  3250. tempFunPays = append(tempFunPays, tempFunPay610100)
  3251. struct4101.CustomStruct = tempFunPays
  3252. var tempDiaginfos []service.DiaginfoStructTwo
  3253. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3254. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3255. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3256. var config []*models.HisXtDiagnoseConfig
  3257. for _, item := range diagnosis_ids {
  3258. id, _ := strconv.ParseInt(item, 10, 64)
  3259. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3260. config = append(config, &diagnosisConfig)
  3261. }
  3262. for index, item := range config {
  3263. if index == 0 {
  3264. var tempDiaginfo service.DiaginfoStructTwo
  3265. tempDiaginfo.DiagCode = item.CountryCode
  3266. tempDiaginfo.DiagName = item.CountryContentName
  3267. tempDiaginfo.DiagType = "1"
  3268. tempDiaginfo.MaindiagFlag = "1"
  3269. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3270. } else {
  3271. var tempDiaginfo service.DiaginfoStructTwo
  3272. tempDiaginfo.DiagCode = item.CountryCode
  3273. tempDiaginfo.DiagName = item.CountryContentName
  3274. tempDiaginfo.DiagType = "2"
  3275. tempDiaginfo.MaindiagFlag = "0"
  3276. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3277. }
  3278. }
  3279. struct4101.Diseinfo = tempDiaginfos
  3280. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3281. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3282. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3283. tempOpspdiseinfo2.OprnOprtCode = ""
  3284. tempOpspdiseinfo2.OprnOprtName = ""
  3285. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3286. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3287. var iteminfo service.IteminfoStruct
  3288. var bedCostTotal float64 = 0 //床位总费
  3289. var bedCostSelfTotal float64 = 0 //床位自费
  3290. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3291. var examineCostTotal float64 = 0 //诊查总费
  3292. var examineCostSelfTotal float64 = 0 //诊查自费
  3293. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3294. var nursingCostTotal float64 = 0 //护理总费
  3295. var nursingCostSelfTotal float64 = 0 //护理自费
  3296. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3297. var chineseMedicineCostTotal float64 = 0 //中成药
  3298. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3299. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3300. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3301. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3302. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3303. var registerCostTotal float64 = 0 //一般诊疗费
  3304. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3305. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3306. var operationCostTotal float64 = 0 //手术费
  3307. var operationCostSelfTotal float64 = 0 //手术费
  3308. var operationCostPartSelfTotal float64 = 0 //手术费
  3309. var otherCostTotal float64 = 0 //其他费用
  3310. var otherCostSelfTotal float64 = 0 //其他费用
  3311. var otherCostPartSelfTotal float64 = 0 //其他费用
  3312. var materialCostTotal float64 = 0 //材料费
  3313. var materialCostSelfTotal float64 = 0 //材料费
  3314. var materialCostPartSelfTotal float64 = 0 //材料费
  3315. var westernMedicineCostTotal float64 = 0 //西药费
  3316. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3317. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3318. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3319. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3320. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3321. var checkCostTotal float64 = 0 //检查费
  3322. var checkCostSelfTotal float64 = 0 //检查费
  3323. var checkCostPartSelfTotal float64 = 0 //检查费
  3324. var laboratoryCostTotal float64 = 0 //化验费
  3325. var laboratoryCostSelfTotal float64 = 0 //化验费
  3326. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3327. var treatCostTotal float64 = 0 //治疗费用
  3328. var treatCostSelfTotal float64 = 0 //治疗费用
  3329. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3330. decimal.DivisionPrecision = 2
  3331. var bed_fulamt_ownpay_amt float64 = 0
  3332. var examine_fulamt_ownpay_amt float64 = 0
  3333. var nursing_fulamt_ownpay_amt float64 = 0
  3334. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3335. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3336. var register_fulamt_ownpay_amt float64 = 0
  3337. var operation_fulamt_ownpay_amt float64 = 0
  3338. var other_fulamt_ownpay_amt float64 = 0
  3339. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3340. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3341. var check_fulamt_ownpay_amt float64 = 0
  3342. var material_fulamt_ownpay_amt float64 = 0
  3343. var laboratory_fulamt_ownpay_amt float64 = 0
  3344. var treat_fulamt_ownpay_amt float64 = 0
  3345. var bed_claa_sunmfee float64 = 0
  3346. var bed_clab_amt float64 = 0
  3347. var bed_other_amt float64 = 0
  3348. var examine_claa_sunmfee float64 = 0
  3349. var examine_clab_amt float64 = 0
  3350. var examine_other_amt float64 = 0
  3351. var nursing_claa_sunmfee float64 = 0
  3352. var nursing_clab_amt float64 = 0
  3353. var nursing_other_amt float64 = 0
  3354. var chinese_medicine_claa_sunmfee float64 = 0
  3355. var chinese_medicine_clab_amt float64 = 0
  3356. var chinese_medicine_other_amt float64 = 0
  3357. var commonly_treatment_claa_sunmfee float64 = 0
  3358. var commonly_treatment_clab_amt float64 = 0
  3359. var commonly_treatment_other_amt float64 = 0
  3360. var operation_claa_sunmfee float64 = 0
  3361. var operation_clab_amt float64 = 0
  3362. var operation_other_amt float64 = 0
  3363. var other_claa_sunmfee float64 = 0
  3364. var other_clab_amt float64 = 0
  3365. var other_other_amt float64 = 0
  3366. var westernMedicine_claa_sunmfee float64 = 0
  3367. var westernMedicine_clab_amt float64 = 0
  3368. var westernMedicine_other_amt float64 = 0
  3369. var chineseTraditional_claa_sunmfee float64 = 0
  3370. var chineseTraditional_clab_amt float64 = 0
  3371. var chineseTraditional_other_amt float64 = 0
  3372. var check_claa_sunmfee float64 = 0
  3373. var check_clab_amt float64 = 0
  3374. var check_other_amt float64 = 0
  3375. var material_claa_sunmfee float64 = 0
  3376. var material_clab_amt float64 = 0
  3377. var material_other_amt float64 = 0
  3378. var laboratory_claa_sunmfee float64 = 0
  3379. var laboratory_clab_amt float64 = 0
  3380. var laboratory_other_amt float64 = 0
  3381. var treat_claa_sunmfee float64 = 0
  3382. var treat_clab_amt float64 = 0
  3383. var treat_other_amt float64 = 0
  3384. var register_claa_sunmfee float64 = 0
  3385. var register_clab_amt float64 = 0
  3386. var register_other_amt float64 = 0
  3387. for _, item := range order.HisOrderInfo {
  3388. if item.MedChrgitmType == "01" { //床位费
  3389. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3390. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3391. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3392. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3393. if item.ChrgitmLv == "1" {
  3394. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3395. }
  3396. if item.ChrgitmLv == "2" {
  3397. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3398. }
  3399. if item.ChrgitmLv == "3" {
  3400. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3401. }
  3402. }
  3403. if item.MedChrgitmType == "02" { //诊查
  3404. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3405. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3406. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3407. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3408. if item.ChrgitmLv == "1" {
  3409. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3410. }
  3411. if item.ChrgitmLv == "2" {
  3412. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3413. }
  3414. if item.ChrgitmLv == "3" {
  3415. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3416. }
  3417. }
  3418. if item.MedChrgitmType == "03" { //检查费
  3419. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3420. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3421. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3422. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3423. if item.ChrgitmLv == "1" {
  3424. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3425. }
  3426. if item.ChrgitmLv == "2" {
  3427. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3428. }
  3429. if item.ChrgitmLv == "3" {
  3430. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3431. }
  3432. }
  3433. if item.MedChrgitmType == "04" { //化验费
  3434. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3435. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3436. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3437. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3438. if item.ChrgitmLv == "1" {
  3439. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3440. }
  3441. if item.ChrgitmLv == "2" {
  3442. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3443. }
  3444. if item.ChrgitmLv == "3" {
  3445. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3446. }
  3447. }
  3448. if item.MedChrgitmType == "05" { //治疗费
  3449. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3450. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3451. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3452. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3453. if item.ChrgitmLv == "1" {
  3454. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3455. }
  3456. if item.ChrgitmLv == "2" {
  3457. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3458. }
  3459. if item.ChrgitmLv == "3" {
  3460. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3461. }
  3462. }
  3463. if item.MedChrgitmType == "06" { //手术费
  3464. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3465. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3466. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3467. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3468. if item.ChrgitmLv == "1" {
  3469. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3470. }
  3471. if item.ChrgitmLv == "2" {
  3472. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3473. }
  3474. if item.ChrgitmLv == "3" {
  3475. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3476. }
  3477. }
  3478. if item.MedChrgitmType == "07" { //手术费
  3479. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3480. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3481. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3482. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3483. if item.ChrgitmLv == "1" {
  3484. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3485. }
  3486. if item.ChrgitmLv == "2" {
  3487. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3488. }
  3489. if item.ChrgitmLv == "3" {
  3490. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3491. }
  3492. }
  3493. if item.MedChrgitmType == "08" { //材料费
  3494. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3495. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3496. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3497. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3498. if item.ChrgitmLv == "1" {
  3499. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3500. }
  3501. if item.ChrgitmLv == "2" {
  3502. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3503. }
  3504. if item.ChrgitmLv == "3" {
  3505. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3506. }
  3507. }
  3508. if item.MedChrgitmType == "09" { //西药费
  3509. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3510. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3511. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3512. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3513. if item.ChrgitmLv == "1" {
  3514. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3515. }
  3516. if item.ChrgitmLv == "2" {
  3517. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3518. }
  3519. if item.ChrgitmLv == "3" {
  3520. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3521. }
  3522. }
  3523. if item.MedChrgitmType == "10" { //中药饮片
  3524. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3525. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3526. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3527. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3528. if item.ChrgitmLv == "1" {
  3529. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3530. }
  3531. if item.ChrgitmLv == "2" {
  3532. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3533. }
  3534. if item.ChrgitmLv == "3" {
  3535. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3536. }
  3537. }
  3538. if item.MedChrgitmType == "11" { //中成费
  3539. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3540. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3541. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3542. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3543. if item.ChrgitmLv == "1" {
  3544. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3545. }
  3546. if item.ChrgitmLv == "2" {
  3547. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3548. }
  3549. if item.ChrgitmLv == "3" {
  3550. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3551. }
  3552. }
  3553. if item.MedChrgitmType == "12" { //中成费
  3554. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3555. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3556. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3557. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3558. if item.ChrgitmLv == "1" {
  3559. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3560. }
  3561. if item.ChrgitmLv == "2" {
  3562. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3563. }
  3564. if item.ChrgitmLv == "3" {
  3565. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3566. }
  3567. }
  3568. if item.MedChrgitmType == "13" { //中成费
  3569. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3570. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3571. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3572. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3573. if item.ChrgitmLv == "1" {
  3574. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3575. }
  3576. if item.ChrgitmLv == "2" {
  3577. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3578. }
  3579. if item.ChrgitmLv == "3" {
  3580. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3581. }
  3582. }
  3583. if item.MedChrgitmType == "14" { //其他费
  3584. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3585. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3586. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3587. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3588. if item.ChrgitmLv == "1" {
  3589. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3590. }
  3591. if item.ChrgitmLv == "2" {
  3592. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3593. }
  3594. if item.ChrgitmLv == "3" {
  3595. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3596. }
  3597. }
  3598. }
  3599. var iteminfoStructs []service.IteminfoStruct
  3600. if bedCostTotal != 0 {
  3601. iteminfo.MedChrgitm = "01"
  3602. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3603. iteminfo.Amt = bedCostTotal
  3604. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3605. iteminfo.ClabAmt = bed_clab_amt
  3606. iteminfo.OthAmt = bed_other_amt
  3607. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3608. }
  3609. if examineCostTotal != 0 {
  3610. iteminfo.MedChrgitm = "02"
  3611. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3612. iteminfo.Amt = examineCostTotal
  3613. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3614. iteminfo.ClabAmt = examine_clab_amt
  3615. iteminfo.OthAmt = examine_other_amt
  3616. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3617. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3618. }
  3619. if checkCostTotal != 0 {
  3620. iteminfo.MedChrgitm = "03"
  3621. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3622. iteminfo.Amt = checkCostTotal
  3623. iteminfo.ClaaSumfee = check_claa_sunmfee
  3624. iteminfo.ClabAmt = check_clab_amt
  3625. iteminfo.OthAmt = check_other_amt
  3626. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3627. }
  3628. if laboratoryCostTotal != 0 {
  3629. iteminfo.MedChrgitm = "04"
  3630. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3631. iteminfo.Amt = laboratoryCostTotal
  3632. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3633. iteminfo.ClabAmt = laboratory_clab_amt
  3634. iteminfo.OthAmt = laboratory_other_amt
  3635. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3636. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3637. }
  3638. if treatCostTotal != 0 {
  3639. iteminfo.MedChrgitm = "05"
  3640. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3641. iteminfo.Amt = treatCostTotal
  3642. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3643. iteminfo.ClabAmt = treat_clab_amt
  3644. iteminfo.OthAmt = treat_other_amt
  3645. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3646. //(struct4101.IteminfoStruct, iteminfo)
  3647. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3648. }
  3649. if operationCostTotal != 0 {
  3650. iteminfo.MedChrgitm = "06"
  3651. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3652. iteminfo.Amt = operationCostTotal
  3653. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3654. iteminfo.ClabAmt = operation_clab_amt
  3655. iteminfo.OthAmt = operation_other_amt
  3656. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3657. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3658. }
  3659. if nursingCostTotal != 0 {
  3660. iteminfo.MedChrgitm = "07"
  3661. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3662. iteminfo.Amt = nursingCostTotal
  3663. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3664. iteminfo.ClabAmt = nursing_clab_amt
  3665. iteminfo.OthAmt = nursing_other_amt
  3666. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3667. }
  3668. if materialCostTotal != 0 {
  3669. iteminfo.MedChrgitm = "08"
  3670. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3671. iteminfo.Amt = materialCostTotal
  3672. iteminfo.ClaaSumfee = material_claa_sunmfee
  3673. iteminfo.ClabAmt = material_clab_amt
  3674. iteminfo.OthAmt = material_other_amt
  3675. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3676. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3677. }
  3678. if westernMedicineCostTotal != 0 {
  3679. iteminfo.MedChrgitm = "09"
  3680. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3681. iteminfo.Amt = westernMedicineCostTotal
  3682. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3683. iteminfo.ClabAmt = westernMedicine_clab_amt
  3684. iteminfo.OthAmt = westernMedicine_other_amt
  3685. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3686. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3687. }
  3688. if chineseMedicineCostTotal != 0 {
  3689. iteminfo.MedChrgitm = "10"
  3690. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3691. iteminfo.Amt = chineseMedicineCostTotal
  3692. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3693. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3694. iteminfo.OthAmt = chinese_medicine_other_amt
  3695. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3696. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3697. }
  3698. if chineseTraditionalMedicineCostTotal != 0 {
  3699. iteminfo.MedChrgitm = "11"
  3700. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3701. iteminfo.Amt = westernMedicineCostTotal
  3702. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3703. iteminfo.ClabAmt = westernMedicine_clab_amt
  3704. iteminfo.OthAmt = westernMedicine_other_amt
  3705. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3706. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3707. }
  3708. if commonlyTreatmentCostTotal != 0 {
  3709. iteminfo.MedChrgitm = "12"
  3710. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3711. iteminfo.Amt = commonlyTreatmentCostTotal
  3712. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3713. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3714. iteminfo.OthAmt = commonly_treatment_other_amt
  3715. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3716. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3717. }
  3718. if registerCostTotal != 0 {
  3719. iteminfo.MedChrgitm = "13"
  3720. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3721. iteminfo.Amt = registerCostTotal
  3722. iteminfo.ClaaSumfee = register_claa_sunmfee
  3723. iteminfo.ClabAmt = register_clab_amt
  3724. iteminfo.OthAmt = register_other_amt
  3725. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3726. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3727. }
  3728. if otherCostTotal != 0 {
  3729. iteminfo.MedChrgitm = "14"
  3730. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3731. iteminfo.Amt = otherCostTotal
  3732. iteminfo.ClaaSumfee = other_claa_sunmfee
  3733. iteminfo.ClabAmt = other_clab_amt
  3734. iteminfo.OthAmt = other_other_amt
  3735. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3736. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3737. }
  3738. struct4101.IteminfoStruct = iteminfoStructs
  3739. struct4101.Ntly = "中国"
  3740. struct4101.AdmCaty = "A03.06"
  3741. var res ResultSeventeen
  3742. if miConfig.MdtrtareaAdmvs == "421300" {
  3743. data := make(map[string]interface{})
  3744. data["struct4101"] = struct4101
  3745. data["secret_key"] = miConfig.SecretKey
  3746. data["org_name"] = miConfig.OrgName
  3747. data["opera"] = curRoles.UserName
  3748. data["code"] = miConfig.Code
  3749. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3750. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3751. client := &http.Client{}
  3752. bytesData, _ := json.Marshal(data)
  3753. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3754. resp, _ := client.Do(req)
  3755. defer resp.Body.Close()
  3756. body, ioErr := ioutil.ReadAll(resp.Body)
  3757. if ioErr != nil {
  3758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3760. return
  3761. }
  3762. var respJSON map[string]interface{}
  3763. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3766. return
  3767. }
  3768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3769. userJSONBytes, _ := json.Marshal(respJSON)
  3770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3771. utils.ErrorLog("解析失败:%v", err)
  3772. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3773. adminUser := c.GetAdminUserInfo()
  3774. errlog := &models.HisOrderError{
  3775. UserOrgId: adminUser.CurrentOrgId,
  3776. Ctime: time.Now().Unix(),
  3777. Mtime: time.Now().Unix(),
  3778. ErrMsg: res.ErrMsg + "解析失败",
  3779. Status: 1,
  3780. PatientId: order_id,
  3781. Stage: 10138,
  3782. }
  3783. service.CreateErrMsgLog(errlog)
  3784. continue
  3785. }
  3786. } else {
  3787. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3788. fmt.Println(result)
  3789. var dat map[string]interface{}
  3790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3791. fmt.Println(dat)
  3792. } else {
  3793. fmt.Println(err)
  3794. }
  3795. userJSONBytes, _ := json.Marshal(dat)
  3796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3797. utils.ErrorLog("解析失败:%v", err)
  3798. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3799. adminUser := c.GetAdminUserInfo()
  3800. errlog := &models.HisOrderError{
  3801. UserOrgId: adminUser.CurrentOrgId,
  3802. Ctime: time.Now().Unix(),
  3803. Mtime: time.Now().Unix(),
  3804. ErrMsg: res.ErrMsg + "解析失败",
  3805. Status: 1,
  3806. PatientId: order_id,
  3807. Stage: 10138,
  3808. }
  3809. service.CreateErrMsgLog(errlog)
  3810. continue
  3811. }
  3812. }
  3813. if res.Infcode != 0 {
  3814. adminUser := c.GetAdminUserInfo()
  3815. errlog := &models.HisOrderError{
  3816. UserOrgId: adminUser.CurrentOrgId,
  3817. Ctime: time.Now().Unix(),
  3818. Mtime: time.Now().Unix(),
  3819. ErrMsg: res.ErrMsg,
  3820. Status: 1,
  3821. PatientId: order_id,
  3822. Stage: 10138,
  3823. }
  3824. service.CreateErrMsgLog(errlog)
  3825. continue
  3826. } else {
  3827. hisFundSettleListResult := &models.HisFundSettleListResult{
  3828. Number: res.Output.SetlListId,
  3829. Status: 1,
  3830. Ctime: time.Now().Unix(),
  3831. Mtime: time.Now().Unix(),
  3832. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3833. IsUpload: 1,
  3834. OrderId: order_id,
  3835. }
  3836. service.CreateUploadRecord(hisFundSettleListResult)
  3837. continue
  3838. }
  3839. }
  3840. }
  3841. func (c *HisApiController) GetOrgInfo() {
  3842. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3843. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3844. }
  3845. func (c *HisApiController) GetHisPatientInfo() {
  3846. medical_insurance_card := c.GetString("medical_insurance_card")
  3847. id_card_type, _ := c.GetInt64("id_card_type")
  3848. id_card := c.GetString("id_card")
  3849. adminInfo := c.GetAdminUserInfo()
  3850. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3851. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3852. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3853. IdCardNo := ""
  3854. if id_card_type == 1 {
  3855. IdCardNo = medical_insurance_card
  3856. } else if id_card_type == 2 {
  3857. IdCardNo = id_card
  3858. }
  3859. if config.IsOpen == 1 {
  3860. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3861. resp, requestErr := http.Get(api)
  3862. if requestErr != nil {
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. return
  3865. }
  3866. defer resp.Body.Close()
  3867. body, ioErr := ioutil.ReadAll(resp.Body)
  3868. if ioErr != nil {
  3869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3871. return
  3872. }
  3873. var respJSON map[string]interface{}
  3874. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3877. return
  3878. }
  3879. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3880. userJSONBytes, _ := json.Marshal(userJSON)
  3881. var res ResultTwo
  3882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3883. utils.ErrorLog("解析失败:%v", err)
  3884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3885. return
  3886. }
  3887. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3888. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3889. infoStr := string(Iinfos)
  3890. idetinfoStr := string(Idetinfos)
  3891. if res.Infcode == 0 {
  3892. his := models.VMHisPatient{
  3893. Status: 1,
  3894. Ctime: time.Now().Unix(),
  3895. Mtime: time.Now().Unix(),
  3896. PsnNo: res.Output.Baseinfo.PsnNo,
  3897. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3898. Certno: res.Output.Baseinfo.Certno,
  3899. PsnName: res.Output.Baseinfo.PsnName,
  3900. Gend: res.Output.Baseinfo.Gend,
  3901. Naty: res.Output.Baseinfo.Naty,
  3902. Brdy: res.Output.Baseinfo.Brdy,
  3903. Age: res.Output.Baseinfo.Age,
  3904. Iinfo: infoStr,
  3905. Idetinfo: idetinfoStr,
  3906. UserOrgId: adminInfo.CurrentOrgId,
  3907. IsReturn: 1,
  3908. IdCardType: id_card_type,
  3909. }
  3910. c.ServeSuccessJSON(map[string]interface{}{
  3911. "info": his,
  3912. })
  3913. } else {
  3914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3915. return
  3916. }
  3917. }
  3918. }
  3919. //func GetBasBaseInfo() (jsonStr string, err error) {
  3920. //
  3921. // handle := syscall.NewLazyDLL("SSCard.dll")
  3922. // add := handle.NewProc("ReadCardBas")
  3923. // str := make([]byte, 1024)
  3924. // str1 := make([]byte, 1024)
  3925. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3926. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3927. //
  3928. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3929. //
  3930. // fmt.Println("> Add(4,5)的结果为:", ret)
  3931. // handle.Release()
  3932. //
  3933. // return "", nil
  3934. //
  3935. //}
  3936. //func GetQRBaseInfo() (jsonStr string, err error) {
  3937. // handle := syscall.LoadDLL("SSCard.dll")
  3938. // ReadCardBas := handle.FindProc("GetQRBase")
  3939. //
  3940. // str := make([]byte, 256)
  3941. // str1 := make([]byte, 256)
  3942. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3943. //
  3944. // fmt.Println(string(str))
  3945. // fmt.Println(r)
  3946. // return string(str), nil
  3947. //}
  3948. //func CardInit() int {
  3949. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3950. // add := DllTestDef.MustFindProc("Init")
  3951. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3952. // if err != nil {
  3953. // fmt.Println("SSCard的运算结果为:", ret)
  3954. // }
  3955. // result := int(ret)
  3956. // return result
  3957. //}
  3958. //func CardInit() int {
  3959. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3960. // if err != nil {
  3961. // fmt.Println("SSCard的运算结果为:", ret)
  3962. // }
  3963. // fmt.Println(err)
  3964. // result := int(ret)
  3965. // return result
  3966. //}
  3967. func IntPtr(n int) uintptr {
  3968. return uintptr(n)
  3969. }
  3970. func StrPtr(s string) uintptr {
  3971. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3972. }
  3973. type Result2001 struct {
  3974. Cainfo interface{} `json:"cainfo"`
  3975. ErrMsg string `json:"err_msg"`
  3976. InfRefmsgid string `json:"inf_refmsgid"`
  3977. Infcode int64 `json:"infcode"`
  3978. Output struct {
  3979. Trtinfo struct {
  3980. PsnNo string `json:"psn_no"`
  3981. TrtChkType string `json:"trt_chk_type"`
  3982. FundPayType string `json:"fund_pay_type"`
  3983. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3984. Begndate string `json:"begndate"`
  3985. Enddate string `json:"enddate"`
  3986. TrtChkRslt string `json:"trt_chk_rslt"`
  3987. } `json:"trtinfo"`
  3988. } `json:"output"`
  3989. RefmsgTime string `json:"refmsg_time"`
  3990. RespondTime string `json:"respond_time"`
  3991. Signtype interface{} `json:"signtype"`
  3992. WarnMsg interface{} `json:"warn_msg"`
  3993. }
  3994. type Result2001Org10265 struct {
  3995. Cainfo interface{} `json:"cainfo"`
  3996. ErrMsg string `json:"err_msg"`
  3997. InfRefmsgid string `json:"inf_refmsgid"`
  3998. Infcode string `json:"infcode"`
  3999. Output struct {
  4000. Trtinfo struct {
  4001. PsnNo string `json:"psn_no"`
  4002. TrtChkType string `json:"trt_chk_type"`
  4003. FundPayType string `json:"fund_pay_type"`
  4004. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4005. Begndate string `json:"begndate"`
  4006. Enddate string `json:"enddate"`
  4007. TrtChkRslt string `json:"trt_chk_rslt"`
  4008. } `json:"trtinfo"`
  4009. } `json:"output"`
  4010. RefmsgTime string `json:"refmsg_time"`
  4011. RespondTime string `json:"respond_time"`
  4012. Signtype interface{} `json:"signtype"`
  4013. WarnMsg interface{} `json:"warn_msg"`
  4014. }
  4015. type ResultTwo struct {
  4016. ErrMsg string `json:"err_msg"`
  4017. InfRefmsgid string `json:"inf_refmsgid"`
  4018. Infcode int64 `json:"infcode"`
  4019. Output struct {
  4020. Baseinfo struct {
  4021. Age float64 `json:"age"`
  4022. Brdy string `json:"brdy"`
  4023. Certno string `json:"certno"`
  4024. Gend string `json:"gend"`
  4025. Naty string `json:"naty"`
  4026. PsnCertType string `json:"psn_cert_type"`
  4027. PsnName string `json:"psn_name"`
  4028. PsnNo string `json:"psn_no"`
  4029. } `json:"baseinfo"`
  4030. Idetinfo []interface{} `json:"idetinfo"`
  4031. Iinfo []struct {
  4032. Balc float64 `json:"balc"`
  4033. CvlservFlag string `json:"cvlserv_flag"`
  4034. EmpName string `json:"emp_name"`
  4035. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4036. Insutype string `json:"insutype"`
  4037. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4038. PausInsuDate string `json:"paus_insu_date"`
  4039. PsnInsuDate string `json:"psn_insu_date"`
  4040. PsnInsuStas string `json:"psn_insu_stas"`
  4041. PsnType string `json:"psn_type"`
  4042. } `json:"insuinfo"`
  4043. } `json:"output"`
  4044. RefmsgTime string `json:"refmsg_time"`
  4045. RespondTime string `json:"respond_time"`
  4046. Signtype interface{} `json:"signtype"`
  4047. WarnInfo interface{} `json:"warn_info"`
  4048. }
  4049. type ResultTwo10265 struct {
  4050. ErrMsg string `json:"err_msg"`
  4051. InfRefmsgid string `json:"inf_refmsgid"`
  4052. Infcode string `json:"infcode"`
  4053. Output struct {
  4054. Baseinfo struct {
  4055. Age float64 `json:"age"`
  4056. Brdy string `json:"brdy"`
  4057. Certno string `json:"certno"`
  4058. Gend string `json:"gend"`
  4059. Naty string `json:"naty"`
  4060. PsnCertType string `json:"psn_cert_type"`
  4061. PsnName string `json:"psn_name"`
  4062. PsnNo string `json:"psn_no"`
  4063. } `json:"baseinfo"`
  4064. Idetinfo []interface{} `json:"idetinfo"`
  4065. Iinfo []struct {
  4066. Balc float64 `json:"balc"`
  4067. CvlservFlag string `json:"cvlserv_flag"`
  4068. EmpName string `json:"emp_name"`
  4069. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4070. Insutype string `json:"insutype"`
  4071. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4072. PausInsuDate string `json:"paus_insu_date"`
  4073. PsnInsuDate string `json:"psn_insu_date"`
  4074. PsnInsuStas string `json:"psn_insu_stas"`
  4075. PsnType string `json:"psn_type"`
  4076. } `json:"insuinfo"`
  4077. } `json:"output"`
  4078. RefmsgTime string `json:"refmsg_time"`
  4079. RespondTime string `json:"respond_time"`
  4080. Signtype interface{} `json:"signtype"`
  4081. WarnInfo interface{} `json:"warn_info"`
  4082. }
  4083. type ResultThree struct {
  4084. Cainfo interface{} `json:"cainfo"`
  4085. ErrMsg string `json:"err_msg"`
  4086. InfRefmsgid string `json:"inf_refmsgid"`
  4087. Infcode int64 `json:"infcode"`
  4088. Output struct {
  4089. Data struct {
  4090. IptOtpNo string `json:"ipt_otp_no"`
  4091. MdtrtID string `json:"mdtrt_id"`
  4092. PsnNo string `json:"psn_no"`
  4093. } `json:"data"`
  4094. } `json:"output"`
  4095. RefmsgTime string `json:"refmsg_time"`
  4096. RespondTime string `json:"respond_time"`
  4097. Signtype interface{} `json:"signtype"`
  4098. WarnMsg interface{} `json:"warn_msg"`
  4099. }
  4100. type ResultThree10265 struct {
  4101. Cainfo interface{} `json:"cainfo"`
  4102. ErrMsg string `json:"err_msg"`
  4103. InfRefmsgid string `json:"inf_refmsgid"`
  4104. Infcode string `json:"infcode"`
  4105. Output struct {
  4106. Data struct {
  4107. IptOtpNo string `json:"ipt_otp_no"`
  4108. MdtrtID string `json:"mdtrt_id"`
  4109. PsnNo string `json:"psn_no"`
  4110. } `json:"data"`
  4111. } `json:"output"`
  4112. RefmsgTime string `json:"refmsg_time"`
  4113. RespondTime string `json:"respond_time"`
  4114. Signtype interface{} `json:"signtype"`
  4115. WarnMsg interface{} `json:"warn_msg"`
  4116. }
  4117. type ResultFour struct {
  4118. Cainfo string `json:"cainfo"`
  4119. ErrMsg string `json:"err_msg"`
  4120. InfRefmsgid string `json:"inf_refmsgid"`
  4121. Infcode int64 `json:"infcode"`
  4122. Output struct {
  4123. Result []struct {
  4124. BasMednFlag string `json:"bas_medn_flag"`
  4125. ChldMedcFlag string `json:"chld_medc_flag"`
  4126. ChrgitmLv string `json:"chrgitm_lv"`
  4127. Cnt float64 `json:"cnt"`
  4128. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4129. DrtReimFlag string `json:"drt_reim_flag"`
  4130. FeedetlSn string `json:"feedetl_sn"`
  4131. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4132. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4133. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4134. ListSpItemFlag string `json:"list_sp_item_flag"`
  4135. LmtUsedFlag string `json:"lmt_used_flag"`
  4136. MedChrgitmType string `json:"med_chrgitm_type"`
  4137. Memo string `json:"memo"`
  4138. OverlmtAmt float64 `json:"overlmt_amt"`
  4139. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4140. Pric float64 `json:"pric"`
  4141. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4142. SelfpayProp float64 `json:"selfpay_prop"`
  4143. } `json:"result"`
  4144. } `json:"output"`
  4145. RefmsgTime string `json:"refmsg_time"`
  4146. RespondTime string `json:"respond_time"`
  4147. Signtype string `json:"signtype"`
  4148. WarnMsg string `json:"warn_msg"`
  4149. }
  4150. type ResultFour10265 struct {
  4151. Cainfo string `json:"cainfo"`
  4152. ErrMsg string `json:"err_msg"`
  4153. InfRefmsgid string `json:"inf_refmsgid"`
  4154. Infcode string `json:"infcode"`
  4155. Output struct {
  4156. Result []struct {
  4157. BasMednFlag string `json:"bas_medn_flag"`
  4158. ChldMedcFlag string `json:"chld_medc_flag"`
  4159. ChrgitmLv string `json:"chrgitm_lv"`
  4160. Cnt float64 `json:"cnt"`
  4161. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4162. DrtReimFlag string `json:"drt_reim_flag"`
  4163. FeedetlSn string `json:"feedetl_sn"`
  4164. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4165. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4166. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4167. ListSpItemFlag string `json:"list_sp_item_flag"`
  4168. LmtUsedFlag string `json:"lmt_used_flag"`
  4169. MedChrgitmType string `json:"med_chrgitm_type"`
  4170. Memo string `json:"memo"`
  4171. OverlmtAmt float64 `json:"overlmt_amt"`
  4172. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4173. Pric float64 `json:"pric"`
  4174. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4175. SelfpayProp float64 `json:"selfpay_prop"`
  4176. } `json:"result"`
  4177. } `json:"output"`
  4178. RefmsgTime string `json:"refmsg_time"`
  4179. RespondTime string `json:"respond_time"`
  4180. Signtype string `json:"signtype"`
  4181. WarnMsg string `json:"warn_msg"`
  4182. }
  4183. type ResultFive struct {
  4184. Balc float64 `json:"balc"`
  4185. CvlservFlag string `json:"cvlserv_flag"`
  4186. EmpName string `json:"emp_name"`
  4187. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4188. Insutype string `json:"insutype"`
  4189. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4190. PausInsuDate string `json:"paus_insu_date"`
  4191. PsnInsuDate string `json:"psn_insu_date"`
  4192. PsnInsuStas string `json:"psn_insu_stas"`
  4193. PsnType string `json:"psn_type"`
  4194. }
  4195. type ResultSix struct {
  4196. Cainfo interface{} `json:"cainfo"`
  4197. ErrMsg string `json:"err_msg"`
  4198. InfRefmsgid string `json:"inf_refmsgid"`
  4199. Infcode int64 `json:"infcode"`
  4200. Output struct {
  4201. } `json:"output"`
  4202. RefmsgTime string `json:"refmsg_time"`
  4203. RespondTime string `json:"respond_time"`
  4204. Signtype interface{} `json:"signtype"`
  4205. WarnMsg interface{} `json:"warn_msg"`
  4206. }
  4207. type ResultSix10265 struct {
  4208. Cainfo interface{} `json:"cainfo"`
  4209. ErrMsg string `json:"err_msg"`
  4210. InfRefmsgid string `json:"inf_refmsgid"`
  4211. Infcode string `json:"infcode"`
  4212. Output struct {
  4213. } `json:"output"`
  4214. RefmsgTime string `json:"refmsg_time"`
  4215. RespondTime string `json:"respond_time"`
  4216. Signtype interface{} `json:"signtype"`
  4217. WarnMsg interface{} `json:"warn_msg"`
  4218. }
  4219. type ResultSeven struct {
  4220. Cainfo string `json:"cainfo"`
  4221. ErrMsg string `json:"err_msg"`
  4222. InfRefmsgid string `json:"inf_refmsgid"`
  4223. Infcode int64 `json:"infcode"`
  4224. Output struct {
  4225. Setldetail []interface{} `json:"setldetail"`
  4226. Setlinfo struct {
  4227. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4228. AcctPay float64 `json:"acct_pay"`
  4229. ActPayDedc float64 `json:"act_pay_dedc"`
  4230. Age float64 `json:"age"`
  4231. Balc float64 `json:"balc"`
  4232. Brdy string `json:"brdy"`
  4233. Certno string `json:"certno"`
  4234. ClrOptins string `json:"clr_optins"`
  4235. ClrType string `json:"clr_type"`
  4236. ClrWay string `json:"clr_way"`
  4237. CvlservFlag string `json:"cvlserv_flag"`
  4238. CvlservPay float64 `json:"cvlserv_pay"`
  4239. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4240. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4241. Gend string `json:"gend"`
  4242. HifesPay float64 `json:"hifes_pay"`
  4243. HifmiPay float64 `json:"hifmi_pay"`
  4244. HifpPay float64 `json:"hifp_pay"`
  4245. HospPartAmt float64 `json:"hosp_part_amt"`
  4246. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4247. Insutype string `json:"insutype"`
  4248. MafPay float64 `json:"maf_pay"`
  4249. MdtrtCertType string `json:"mdtrt_cert_type"`
  4250. HifobPay float64 `json:"hifob_pay"`
  4251. MdtrtID string `json:"mdtrt_id"`
  4252. MedType string `json:"med_type"`
  4253. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4254. MedinsSetlID string `json:"medins_setl_id"`
  4255. Naty string `json:"naty"`
  4256. OthPay float64 `json:"oth_pay"`
  4257. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4258. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4259. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4260. PsnCashPay float64 `json:"psn_cash_pay"`
  4261. PsnCertType string `json:"psn_cert_type"`
  4262. PsnName string `json:"psn_name"`
  4263. PsnNo string `json:"psn_no"`
  4264. PsnPartAmt float64 `json:"psn_part_amt"`
  4265. PsnType string `json:"psn_type"`
  4266. SetlID string `json:"setl_id"`
  4267. SetlTime string `json:"setl_time"`
  4268. } `json:"setlinfo"`
  4269. } `json:"output"`
  4270. RefmsgTime string `json:"refmsg_time"`
  4271. RespondTime string `json:"respond_time"`
  4272. Signtype interface{} `json:"signtype"`
  4273. WarnMsg interface{} `json:"warn_msg"`
  4274. }
  4275. type ResultSeven10265 struct {
  4276. Cainfo string `json:"cainfo"`
  4277. ErrMsg string `json:"err_msg"`
  4278. InfRefmsgid string `json:"inf_refmsgid"`
  4279. Infcode string `json:"infcode"`
  4280. Output struct {
  4281. Setldetail []interface{} `json:"setldetail"`
  4282. Setlinfo struct {
  4283. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4284. AcctPay float64 `json:"acct_pay"`
  4285. ActPayDedc float64 `json:"act_pay_dedc"`
  4286. Age float64 `json:"age"`
  4287. Balc float64 `json:"balc"`
  4288. Brdy string `json:"brdy"`
  4289. Certno string `json:"certno"`
  4290. ClrOptins string `json:"clr_optins"`
  4291. ClrType string `json:"clr_type"`
  4292. ClrWay string `json:"clr_way"`
  4293. CvlservFlag string `json:"cvlserv_flag"`
  4294. CvlservPay float64 `json:"cvlserv_pay"`
  4295. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4296. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4297. Gend string `json:"gend"`
  4298. HifesPay float64 `json:"hifes_pay"`
  4299. HifmiPay float64 `json:"hifmi_pay"`
  4300. HifpPay float64 `json:"hifp_pay"`
  4301. HospPartAmt float64 `json:"hosp_part_amt"`
  4302. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4303. Insutype string `json:"insutype"`
  4304. MafPay float64 `json:"maf_pay"`
  4305. MdtrtCertType string `json:"mdtrt_cert_type"`
  4306. HifobPay float64 `json:"hifob_pay"`
  4307. MdtrtID string `json:"mdtrt_id"`
  4308. MedType string `json:"med_type"`
  4309. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4310. MedinsSetlID string `json:"medins_setl_id"`
  4311. Naty string `json:"naty"`
  4312. OthPay float64 `json:"oth_pay"`
  4313. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4314. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4315. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4316. PsnCashPay float64 `json:"psn_cash_pay"`
  4317. PsnCertType string `json:"psn_cert_type"`
  4318. PsnName string `json:"psn_name"`
  4319. PsnNo string `json:"psn_no"`
  4320. PsnPartAmt float64 `json:"psn_part_amt"`
  4321. PsnType string `json:"psn_type"`
  4322. SetlID string `json:"setl_id"`
  4323. SetlTime string `json:"setl_time"`
  4324. } `json:"setlinfo"`
  4325. } `json:"output"`
  4326. RefmsgTime string `json:"refmsg_time"`
  4327. RespondTime string `json:"respond_time"`
  4328. Signtype interface{} `json:"signtype"`
  4329. WarnMsg interface{} `json:"warn_msg"`
  4330. }
  4331. type ResultEight struct {
  4332. Cainfo string `json:"cainfo"`
  4333. ErrMsg string `json:"err_msg"`
  4334. InfRefmsgid string `json:"inf_refmsgid"`
  4335. Infcode int64 `json:"infcode"`
  4336. Output struct {
  4337. Stmtinfo struct {
  4338. SetlOptins string `json:"setl_optins"`
  4339. StmtRslt string `json:"stmt_rslt"`
  4340. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4341. } `json:"stmtinfo"`
  4342. } `json:"output"`
  4343. RefmsgTime string `json:"refmsg_time"`
  4344. RespondTime string `json:"respond_time"`
  4345. Signtype interface{} `json:"signtype"`
  4346. WarnMsg interface{} `json:"warn_msg"`
  4347. }
  4348. type ResultEightFor10188 struct {
  4349. Cainfo string `json:"cainfo"`
  4350. ErrMsg string `json:"err_msg"`
  4351. InfRefmsgid string `json:"inf_refmsgid"`
  4352. Infcode string `json:"infcode"`
  4353. Output struct {
  4354. Stmtinfo struct {
  4355. SetlOptins string `json:"setl_optins"`
  4356. StmtRslt string `json:"stmt_rslt"`
  4357. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4358. } `json:"stmtinfo"`
  4359. } `json:"output"`
  4360. RefmsgTime string `json:"refmsg_time"`
  4361. RespondTime string `json:"respond_time"`
  4362. Signtype interface{} `json:"signtype"`
  4363. WarnMsg interface{} `json:"warn_msg"`
  4364. }
  4365. type ResultNine struct {
  4366. Cainfo string `json:"cainfo"`
  4367. ErrMsg string `json:"err_msg"`
  4368. InfRefmsgid string `json:"inf_refmsgid"`
  4369. Infcode int64 `json:"infcode"`
  4370. Output struct {
  4371. FileQuryNo string `json:"file_qury_no"`
  4372. } `json:"output"`
  4373. RefmsgTime string `json:"refmsg_time"`
  4374. RespondTime string `json:"respond_time"`
  4375. Signtype interface{} `json:"signtype"`
  4376. WarnMsg interface{} `json:"warn_msg"`
  4377. }
  4378. type ResultTen struct {
  4379. Cainfo string `json:"cainfo"`
  4380. ErrMsg string `json:"err_msg"`
  4381. InfRefmsgid string `json:"inf_refmsgid"`
  4382. Infcode int64 `json:"infcode"`
  4383. Output struct {
  4384. DldEndtime string `json:"dld_endtime"`
  4385. FileQuryNo string `json:"file_qury_no"`
  4386. Filename string `json:"filename"`
  4387. } `json:"output"`
  4388. RefmsgTime string `json:"refmsg_time"`
  4389. RespondTime string `json:"respond_time"`
  4390. Signtype interface{} `json:"signtype"`
  4391. WarnMsg interface{} `json:"warn_msg"`
  4392. }
  4393. //type Autogenerated struct {
  4394. // Output struct {
  4395. // Setlinfo struct {
  4396. // SetlTime string `json:"setl_time"`
  4397. // CvlservPay float64 `json:"cvlserv_pay"`
  4398. // Year string `json:"year"`
  4399. // MedType string `json:"med_type"`
  4400. // PsnPay float64 `json:"psn_pay"`
  4401. // OpterID string `json:"opter_id"`
  4402. // Begndate string `json:"begndate"`
  4403. // FlxempeFlag string `json:"flxempe_flag"`
  4404. // HifmiPay float64 `json:"hifmi_pay"`
  4405. // PsnNo string `json:"psn_no"`
  4406. // ActPayDedc float64 `json:"act_pay_dedc"`
  4407. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4408. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4409. // ClrWay string `json:"clr_way"`
  4410. // OthPay float64 `json:"oth_pay"`
  4411. // Gend string `json:"gend"`
  4412. // MdtrtID string `json:"mdtrt_id"`
  4413. // AcctPay float64 `json:"acct_pay"`
  4414. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4415. // Insutype string `json:"insutype"`
  4416. // Invono interface{} `json:"invono"`
  4417. // Enddate string `json:"enddate"`
  4418. // CashPayamt float64 `json:"cash_payamt"`
  4419. // PsnType string `json:"psn_type"`
  4420. // FixmedinsName string `json:"fixmedins_name"`
  4421. // HifpPay float64 `json:"hifp_pay"`
  4422. // NewFlag interface{} `json:"new_flag"`
  4423. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4424. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4425. // PayLoc string `json:"pay_loc"`
  4426. // ClrType string `json:"clr_type"`
  4427. // RefdSetlFlag string `json:"refd_setl_flag"`
  4428. // CvlservFlag string `json:"cvlserv_flag"`
  4429. // EmpName string `json:"emp_name"`
  4430. // Brdy string `json:"brdy"`
  4431. // Naty string `json:"naty"`
  4432. // Certno string `json:"certno"`
  4433. // DiseCode string `json:"dise_code"`
  4434. // FixmedinsCode string `json:"fixmedins_code"`
  4435. // DedcHospLv string `json:"dedc_hosp_lv"`
  4436. // OpterName string `json:"opter_name"`
  4437. // Balc float64 `json:"balc"`
  4438. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4439. // PsnCertType string `json:"psn_cert_type"`
  4440. // HifobPay float64 `json:"hifob_pay"`
  4441. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4442. // HifesPay float64 `json:"hifes_pay"`
  4443. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4444. // OptTime string `json:"opt_time"`
  4445. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4446. // SetlID string `json:"setl_id"`
  4447. // MafPay float64 `json:"maf_pay"`
  4448. // PsnName string `json:"psn_name"`
  4449. // InsuOptins interface{} `json:"insu_optins"`
  4450. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4451. // ClrOptins string `json:"clr_optins"`
  4452. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4453. // DiseName string `json:"dise_name"`
  4454. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4455. // Age float64 `json:"age"`
  4456. // DtrtCertType string `json:"dtrt_cert_type"`
  4457. // HospLv string `json:"hosp_lv"`
  4458. // } `json:"setlinfo"`
  4459. // Setldetail []struct {
  4460. // FundPayType string `json:"fund_pay_type"`
  4461. // FundPayamt float64 `json:"fund_payamt"`
  4462. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4463. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4464. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4465. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4466. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4467. // } `json:"setldetail"`
  4468. // } `json:"output"`
  4469. // Infcode int `json:"infcode"`
  4470. // WarnMsg interface{} `json:"warn_msg"`
  4471. // Cainfo interface{} `json:"cainfo"`
  4472. // ErrMsg interface{} `json:"err_msg"`
  4473. // RefmsgTime string `json:"refmsg_time"`
  4474. // Signtype interface{} `json:"signtype"`
  4475. // RespondTime string `json:"respond_time"`
  4476. // InfRefmsgid string `json:"inf_refmsgid"`
  4477. //}
  4478. type ResultEleven struct {
  4479. Cainfo string `json:"cainfo"`
  4480. ErrMsg string `json:"err_msg"`
  4481. InfRefmsgid string `json:"inf_refmsgid"`
  4482. Infcode int64 `json:"infcode"`
  4483. Output struct {
  4484. Setlinfo struct {
  4485. SetlTime string `json:"setl_time"`
  4486. CvlservPay float64 `json:"cvlserv_pay"`
  4487. Year string `json:"year"`
  4488. MedType string `json:"med_type"`
  4489. PsnPay float64 `json:"psn_pay"`
  4490. OpterID string `json:"opter_id"`
  4491. Begndate string `json:"begndate"`
  4492. FlxempeFlag string `json:"flxempe_flag"`
  4493. HifmiPay float64 `json:"hifmi_pay"`
  4494. PsnNo string `json:"psn_no"`
  4495. ActPayDedc float64 `json:"act_pay_dedc"`
  4496. MedinsSetlID interface{} `json:"medins_setl_id"`
  4497. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4498. ClrWay string `json:"clr_way"`
  4499. OthPay float64 `json:"oth_pay"`
  4500. Gend string `json:"gend"`
  4501. MdtrtID string `json:"mdtrt_id"`
  4502. AcctPay float64 `json:"acct_pay"`
  4503. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4504. Insutype string `json:"insutype"`
  4505. Invono interface{} `json:"invono"`
  4506. Enddate string `json:"enddate"`
  4507. CashPayamt float64 `json:"cash_payamt"`
  4508. PsnType string `json:"psn_type"`
  4509. FixmedinsName string `json:"fixmedins_name"`
  4510. HifpPay float64 `json:"hifp_pay"`
  4511. NewFlag interface{} `json:"new_flag"`
  4512. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4513. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4514. PayLoc string `json:"pay_loc"`
  4515. ClrType string `json:"clr_type"`
  4516. RefdSetlFlag string `json:"refd_setl_flag"`
  4517. CvlservFlag string `json:"cvlserv_flag"`
  4518. EmpName string `json:"emp_name"`
  4519. Brdy string `json:"brdy"`
  4520. Naty string `json:"naty"`
  4521. Certno string `json:"certno"`
  4522. DiseCode string `json:"dise_code"`
  4523. FixmedinsCode string `json:"fixmedins_code"`
  4524. DedcHospLv string `json:"dedc_hosp_lv"`
  4525. OpterName string `json:"opter_name"`
  4526. Balc float64 `json:"balc"`
  4527. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4528. PsnCertType string `json:"psn_cert_type"`
  4529. HifobPay float64 `json:"hifob_pay"`
  4530. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4531. HifesPay float64 `json:"hifes_pay"`
  4532. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4533. OptTime string `json:"opt_time"`
  4534. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4535. SetlID string `json:"setl_id"`
  4536. MafPay float64 `json:"maf_pay"`
  4537. PsnName string `json:"psn_name"`
  4538. InsuOptins interface{} `json:"insu_optins"`
  4539. PrefFundPay interface{} `json:"pref_fund_pay"`
  4540. ClrOptins string `json:"clr_optins"`
  4541. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4542. DiseName string `json:"dise_name"`
  4543. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4544. Age float64 `json:"age"`
  4545. DtrtCertType string `json:"dtrt_cert_type"`
  4546. HospLv string `json:"hosp_lv"`
  4547. } `json:"setlinfo"`
  4548. } `json:"output"`
  4549. RefmsgTime string `json:"refmsg_time"`
  4550. RespondTime string `json:"respond_time"`
  4551. Signtype interface{} `json:"signtype"`
  4552. WarnMsg interface{} `json:"warn_msg"`
  4553. }
  4554. type ResultEleven10265 struct {
  4555. Cainfo string `json:"cainfo"`
  4556. ErrMsg string `json:"err_msg"`
  4557. InfRefmsgid string `json:"inf_refmsgid"`
  4558. Infcode string `json:"infcode"`
  4559. Output struct {
  4560. Setlinfo struct {
  4561. SetlTime string `json:"setl_time"`
  4562. CvlservPay float64 `json:"cvlserv_pay"`
  4563. Year string `json:"year"`
  4564. MedType string `json:"med_type"`
  4565. PsnPay float64 `json:"psn_pay"`
  4566. OpterID string `json:"opter_id"`
  4567. Begndate string `json:"begndate"`
  4568. FlxempeFlag string `json:"flxempe_flag"`
  4569. HifmiPay float64 `json:"hifmi_pay"`
  4570. PsnNo string `json:"psn_no"`
  4571. ActPayDedc float64 `json:"act_pay_dedc"`
  4572. MedinsSetlID interface{} `json:"medins_setl_id"`
  4573. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4574. ClrWay string `json:"clr_way"`
  4575. OthPay float64 `json:"oth_pay"`
  4576. Gend string `json:"gend"`
  4577. MdtrtID string `json:"mdtrt_id"`
  4578. AcctPay float64 `json:"acct_pay"`
  4579. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4580. Insutype string `json:"insutype"`
  4581. Invono interface{} `json:"invono"`
  4582. Enddate string `json:"enddate"`
  4583. CashPayamt float64 `json:"cash_payamt"`
  4584. PsnType string `json:"psn_type"`
  4585. FixmedinsName string `json:"fixmedins_name"`
  4586. HifpPay float64 `json:"hifp_pay"`
  4587. NewFlag interface{} `json:"new_flag"`
  4588. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4589. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4590. PayLoc string `json:"pay_loc"`
  4591. ClrType string `json:"clr_type"`
  4592. RefdSetlFlag string `json:"refd_setl_flag"`
  4593. CvlservFlag string `json:"cvlserv_flag"`
  4594. EmpName string `json:"emp_name"`
  4595. Brdy string `json:"brdy"`
  4596. Naty string `json:"naty"`
  4597. Certno string `json:"certno"`
  4598. DiseCode string `json:"dise_code"`
  4599. FixmedinsCode string `json:"fixmedins_code"`
  4600. DedcHospLv string `json:"dedc_hosp_lv"`
  4601. OpterName string `json:"opter_name"`
  4602. Balc float64 `json:"balc"`
  4603. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4604. PsnCertType string `json:"psn_cert_type"`
  4605. HifobPay float64 `json:"hifob_pay"`
  4606. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4607. HifesPay float64 `json:"hifes_pay"`
  4608. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4609. OptTime string `json:"opt_time"`
  4610. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4611. SetlID string `json:"setl_id"`
  4612. MafPay float64 `json:"maf_pay"`
  4613. PsnName string `json:"psn_name"`
  4614. InsuOptins interface{} `json:"insu_optins"`
  4615. PrefFundPay interface{} `json:"pref_fund_pay"`
  4616. ClrOptins string `json:"clr_optins"`
  4617. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4618. DiseName string `json:"dise_name"`
  4619. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4620. Age float64 `json:"age"`
  4621. DtrtCertType string `json:"dtrt_cert_type"`
  4622. HospLv string `json:"hosp_lv"`
  4623. } `json:"setlinfo"`
  4624. } `json:"output"`
  4625. RefmsgTime string `json:"refmsg_time"`
  4626. RespondTime string `json:"respond_time"`
  4627. Signtype interface{} `json:"signtype"`
  4628. WarnMsg interface{} `json:"warn_msg"`
  4629. }
  4630. type ResultTwelve struct {
  4631. Cainfo string `json:"cainfo"`
  4632. ErrMsg string `json:"err_msg"`
  4633. InfRefmsgid string `json:"inf_refmsgid"`
  4634. Infcode int64 `json:"infcode"`
  4635. Output struct {
  4636. MdtrtId string `json:"mdtrt_id"`
  4637. ChrgBchno string `json:"chrg_bchno"`
  4638. PsnNo string `json:"psn_no"`
  4639. } `json:"output"`
  4640. RefmsgTime string `json:"refmsg_time"`
  4641. RespondTime string `json:"respond_time"`
  4642. Signtype interface{} `json:"signtype"`
  4643. WarnMsg interface{} `json:"warn_msg"`
  4644. }
  4645. type ResultThirteen struct {
  4646. ErrMsg string `json:"err_msg"`
  4647. InfRefmsgid string `json:"inf_refmsgid"`
  4648. Infcode int64 `json:"infcode"`
  4649. Output struct {
  4650. Result struct {
  4651. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4652. } `json:"result"`
  4653. } `json:"output"`
  4654. RefmsgTime string `json:"refmsg_time"`
  4655. RespondTime string `json:"respond_time"`
  4656. Signtype interface{} `json:"signtype"`
  4657. WarnInfo interface{} `json:"warn_info"`
  4658. }
  4659. type ResultThirteen10265 struct {
  4660. ErrMsg string `json:"err_msg"`
  4661. InfRefmsgid string `json:"inf_refmsgid"`
  4662. Infcode string `json:"infcode"`
  4663. Output struct {
  4664. Result struct {
  4665. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4666. } `json:"result"`
  4667. } `json:"output"`
  4668. RefmsgTime string `json:"refmsg_time"`
  4669. RespondTime string `json:"respond_time"`
  4670. Signtype interface{} `json:"signtype"`
  4671. WarnInfo interface{} `json:"warn_info"`
  4672. }
  4673. type ResultFourteen struct {
  4674. ErrMsg string `json:"err_msg"`
  4675. InfRefmsgid string `json:"inf_refmsgid"`
  4676. Infcode int64 `json:"infcode"`
  4677. Output struct {
  4678. } `json:"output"`
  4679. RefmsgTime string `json:"refmsg_time"`
  4680. RespondTime string `json:"respond_time"`
  4681. Signtype interface{} `json:"signtype"`
  4682. WarnInfo interface{} `json:"warn_info"`
  4683. }
  4684. type ResultFourteen10265 struct {
  4685. ErrMsg string `json:"err_msg"`
  4686. InfRefmsgid string `json:"inf_refmsgid"`
  4687. Infcode string `json:"infcode"`
  4688. Output struct {
  4689. } `json:"output"`
  4690. RefmsgTime string `json:"refmsg_time"`
  4691. RespondTime string `json:"respond_time"`
  4692. Signtype interface{} `json:"signtype"`
  4693. WarnInfo interface{} `json:"warn_info"`
  4694. }
  4695. type ResultSixteen struct {
  4696. Cainfo string `json:"cainfo"`
  4697. ErrMsg string `json:"err_msg"`
  4698. InfRefmsgid string `json:"inf_refmsgid"`
  4699. Infcode int64 `json:"infcode"`
  4700. Output struct {
  4701. Setldetail []interface{} `json:"setldetail"`
  4702. Setlinfo struct {
  4703. MdtrtID string `json:"mdtrt_id"`
  4704. SetlID string `json:"setl_id"`
  4705. ClrOptins string `json:"clr_optins"`
  4706. SetlTime string `json:"setl_time"`
  4707. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4708. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4709. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4710. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4711. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4712. ActPayDedc float64 `json:"act_pay_dedc"`
  4713. HifpPay float64 `json:"hifp_pay"`
  4714. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4715. Lfpay float64 `json:"selfpay"`
  4716. CvlservPay float64 `json:"cvlserv_pay"`
  4717. HifesPay float64 `json:"hifes_pay"`
  4718. HifmiPay float64 `json:"hifmi_pay"`
  4719. HifobPay float64 `json:"hifob_pay"`
  4720. MafPay float64 `json:"maf_pay"`
  4721. OthPay float64 `json:"oth_pay"`
  4722. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4723. PsnPartAmt float64 `json:"psn_part_amt"`
  4724. AcctPay float64 `json:"acct_pay"`
  4725. Balc float64 `json:"balc"`
  4726. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4727. HospPartAmt float64 `json:"hosp_part_amt"`
  4728. MedinsSetlID string `json:"medins_setl_id"`
  4729. PdnCashPay string `json:"pdn_cash_pay"`
  4730. } `json:"setlinfo"`
  4731. } `json:"output"`
  4732. RefmsgTime string `json:"refmsg_time"`
  4733. RespondTime string `json:"respond_time"`
  4734. Signtype interface{} `json:"signtype"`
  4735. WarnMsg interface{} `json:"warn_msg"`
  4736. }
  4737. type ResultSixteen10265 struct {
  4738. Cainfo string `json:"cainfo"`
  4739. ErrMsg string `json:"err_msg"`
  4740. InfRefmsgid string `json:"inf_refmsgid"`
  4741. Infcode string `json:"infcode"`
  4742. Output struct {
  4743. Setldetail []interface{} `json:"setldetail"`
  4744. Setlinfo struct {
  4745. MdtrtID string `json:"mdtrt_id"`
  4746. SetlID string `json:"setl_id"`
  4747. ClrOptins string `json:"clr_optins"`
  4748. SetlTime string `json:"setl_time"`
  4749. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4750. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4751. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4752. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4753. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4754. ActPayDedc float64 `json:"act_pay_dedc"`
  4755. HifpPay float64 `json:"hifp_pay"`
  4756. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4757. Lfpay float64 `json:"selfpay"`
  4758. CvlservPay float64 `json:"cvlserv_pay"`
  4759. HifesPay float64 `json:"hifes_pay"`
  4760. HifmiPay float64 `json:"hifmi_pay"`
  4761. HifobPay float64 `json:"hifob_pay"`
  4762. MafPay float64 `json:"maf_pay"`
  4763. OthPay float64 `json:"oth_pay"`
  4764. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4765. PsnPartAmt float64 `json:"psn_part_amt"`
  4766. AcctPay float64 `json:"acct_pay"`
  4767. Balc float64 `json:"balc"`
  4768. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4769. HospPartAmt float64 `json:"hosp_part_amt"`
  4770. MedinsSetlID string `json:"medins_setl_id"`
  4771. PdnCashPay string `json:"pdn_cash_pay"`
  4772. } `json:"setlinfo"`
  4773. } `json:"output"`
  4774. RefmsgTime string `json:"refmsg_time"`
  4775. RespondTime string `json:"respond_time"`
  4776. Signtype interface{} `json:"signtype"`
  4777. WarnMsg interface{} `json:"warn_msg"`
  4778. }
  4779. type ResultSeventeen struct {
  4780. ErrMsg string `json:"err_msg"`
  4781. InfRefmsgid string `json:"inf_refmsgid"`
  4782. Infcode int64 `json:"infcode"`
  4783. Output struct {
  4784. SetlListId string `json:"setl_list_id"`
  4785. } `json:"output"`
  4786. RefmsgTime string `json:"refmsg_time"`
  4787. RespondTime string `json:"respond_time"`
  4788. Signtype string `json:"signtype"`
  4789. WarnInfo string `json:"warn_info"`
  4790. }
  4791. type ResultSeventeenOther struct {
  4792. ErrMsg string `json:"err_msg"`
  4793. InfRefmsgid string `json:"inf_refmsgid"`
  4794. Infcode string `json:"infcode"`
  4795. Output struct {
  4796. SetlListId string `json:"setl_list_id"`
  4797. } `json:"output"`
  4798. RefmsgTime string `json:"refmsg_time"`
  4799. RespondTime string `json:"respond_time"`
  4800. Signtype string `json:"signtype"`
  4801. WarnInfo string `json:"warn_info"`
  4802. }
  4803. type Result90991 struct {
  4804. ErrMsg string `json:"err_msg"`
  4805. InfRefmsgid string `json:"inf_refmsgid"`
  4806. Infcode int64 `json:"infcode"`
  4807. Output struct {
  4808. Result struct {
  4809. PsnNo string `json:"psn_no"`
  4810. CardStat string `json:"card_stat"`
  4811. Certno string `json:"certno"`
  4812. PsnName string `json:"psn_name"`
  4813. CheckStat string `json:"check_stat"`
  4814. SscnoCheckStat string `json:"sscno_check_stat"`
  4815. } `json:"result"`
  4816. } `json:"output"`
  4817. RefmsgTime string `json:"refmsg_time"`
  4818. RespondTime string `json:"respond_time"`
  4819. Signtype interface{} `json:"signtype"`
  4820. WarnInfo interface{} `json:"warn_info"`
  4821. }
  4822. type Result90100 struct {
  4823. ErrMsg string `json:"err_msg"`
  4824. InfRefmsgid string `json:"inf_refmsgid"`
  4825. Infcode int64 `json:"infcode"`
  4826. Output struct {
  4827. PoolareaNo string `json:"poolarea_no"`
  4828. PoolareaNoName string `json:"poolarea_no_name"`
  4829. Insutype string `json:"insutype"`
  4830. InsutypeName string `json:"insutype_name"`
  4831. ClctType string `json:"clct_type"`
  4832. ClctTypeName string `json:"clct_type_name"`
  4833. ClctFlag string `json:"clct_flag"`
  4834. ClctFlagName string `json:"clct_flag_name"`
  4835. AccrymBegn string `json:"accrym_begn"`
  4836. AccrymEnd string `json:"accrym_end"`
  4837. ClctTime string `json:"clct_time"`
  4838. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4839. } `json:"output"`
  4840. RefmsgTime string `json:"refmsg_time"`
  4841. RespondTime string `json:"respond_time"`
  4842. Signtype interface{} `json:"signtype"`
  4843. WarnInfo interface{} `json:"warn_info"`
  4844. }
  4845. type Custom struct {
  4846. DetItemFeeSumamt string
  4847. Cut string
  4848. FeedetlSn string
  4849. Price string
  4850. MedListCodg string
  4851. Type int64
  4852. AdviceId int64
  4853. ProjectId int64
  4854. ItemId int64
  4855. }
  4856. type Result5301 struct {
  4857. ErrMsg string `json:"err_msg"`
  4858. InfRefmsgid string `json:"inf_refmsgid"`
  4859. Infcode int64 `json:"infcode"`
  4860. Output struct {
  4861. Result []struct {
  4862. OpspDiseCode string `json:"opsp_dise_code"`
  4863. OpspDiseName string `json:"opsp_dise_name"`
  4864. Begndate string `json:"begndate"`
  4865. Enddate string `json:"enddate"`
  4866. } `json:"feedetail"`
  4867. } `json:"output"`
  4868. RefmsgTime string `json:"refmsg_time"`
  4869. RespondTime string `json:"respond_time"`
  4870. Signtype interface{} `json:"signtype"`
  4871. WarnInfo interface{} `json:"warn_info"`
  4872. }
  4873. type Result5301For10265 struct {
  4874. ErrMsg string `json:"err_msg"`
  4875. InfRefmsgid string `json:"inf_refmsgid"`
  4876. Infcode string `json:"infcode"`
  4877. Output struct {
  4878. Result []struct {
  4879. OpspDiseCode string `json:"opsp_dise_code"`
  4880. OpspDiseName string `json:"opsp_dise_name"`
  4881. Begndate string `json:"begndate"`
  4882. Enddate string `json:"enddate"`
  4883. } `json:"feedetail"`
  4884. } `json:"output"`
  4885. RefmsgTime string `json:"refmsg_time"`
  4886. RespondTime string `json:"respond_time"`
  4887. Signtype interface{} `json:"signtype"`
  4888. WarnInfo interface{} `json:"warn_info"`
  4889. }
  4890. //获取个人信息----挂号-----上传就诊信息
  4891. func (c *HisApiController) GetRegisterInfo() {
  4892. id, _ := c.GetInt64("id")
  4893. record_time := c.GetString("record_time")
  4894. settlementValue, _ := c.GetInt64("settlement_value")
  4895. medical_insurance_card := c.GetString("medical_insurance_card")
  4896. name := c.GetString("name")
  4897. id_card_type, _ := c.GetInt64("id_card_type")
  4898. certificates, _ := c.GetInt64("certificates")
  4899. medical_care, _ := c.GetInt64("medical_care")
  4900. birthday := c.GetString("birthday")
  4901. id_card := c.GetString("id_card")
  4902. register_type, _ := c.GetInt64("register")
  4903. doctor, _ := c.GetInt64("doctor")
  4904. department, _ := c.GetInt64("department")
  4905. gender, _ := c.GetInt64("sex")
  4906. registration_fee, _ := c.GetFloat("registration_fee")
  4907. medical_expenses, _ := c.GetFloat("medical_expenses")
  4908. social_type, _ := c.GetInt64("social_type")
  4909. med_type := c.GetString("social_type")
  4910. admin_user_id, _ := c.GetInt64("admin_user_id")
  4911. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4912. timeLayout := "2006-01-02"
  4913. loc, _ := time.LoadLocation("Local")
  4914. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4915. birthUnix := birthdays.Unix()
  4916. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4917. if err != nil {
  4918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4919. return
  4920. }
  4921. recordDateTime := theTime.Unix()
  4922. adminInfo := c.GetAdminUserInfo()
  4923. var patient service.Patients
  4924. if id == 0 {
  4925. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4926. } else {
  4927. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4928. }
  4929. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4930. if patientPrescription.ID == 0 {
  4931. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4932. }
  4933. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4934. if patient.ID == 0 {
  4935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4936. return
  4937. }
  4938. if len(patient.IdCardNo) == 0 {
  4939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4940. return
  4941. }
  4942. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4943. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4944. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4945. //就诊结算未完成,不能进行二次挂号
  4946. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4947. if len(his) >= 1 {
  4948. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4949. if len(his) >= 1 && order.ID == 0 {
  4950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4951. return
  4952. }
  4953. }
  4954. //var register_log string
  4955. if config.IsOpen == 1 {
  4956. var res ResultTwo
  4957. var res10265 ResultTwo10265
  4958. var PsnNo string
  4959. var PsnCertType string
  4960. var Certno string
  4961. var PsnName string
  4962. var Gend string
  4963. var Naty string
  4964. var Brdy string
  4965. var Age float64
  4966. var infoStr string
  4967. var idetinfoStr string
  4968. var infocode int64
  4969. var verify_number string
  4970. fmt.Println(verify_number)
  4971. if miConfig.MdtrtareaAdmvs == "421300" {
  4972. psn_info, _ := service.GetPsnByPatientId(id)
  4973. PsnNo = psn_info.PsnNo
  4974. PsnCertType = psn_info.PsnCertType
  4975. Certno = psn_info.Certno
  4976. PsnName = psn_info.PsnName
  4977. Gend = psn_info.Gend
  4978. Naty = psn_info.Naty
  4979. Brdy = psn_info.Brdy
  4980. Age = psn_info.Age
  4981. infoStr = psn_info.Insuinfo
  4982. idetinfoStr = psn_info.Idetinfo
  4983. infocode = 0
  4984. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4985. psn_info, _ := service.GetPsnByPatientId(id)
  4986. PsnNo = psn_info.PsnNo
  4987. PsnCertType = psn_info.PsnCertType
  4988. Certno = psn_info.Certno
  4989. PsnName = psn_info.PsnName
  4990. Gend = psn_info.Gend
  4991. Naty = psn_info.Naty
  4992. Brdy = psn_info.Brdy
  4993. Age = psn_info.Age
  4994. infoStr = psn_info.Insuinfo
  4995. idetinfoStr = psn_info.Idetinfo
  4996. infocode = 0
  4997. verify_number = psn_info.VerifyNumber
  4998. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4999. if id_card_type == 1 {
  5000. psn_info, _ := service.GetPsnByPatientId(id)
  5001. PsnNo = psn_info.PsnNo
  5002. PsnCertType = psn_info.PsnCertType
  5003. Certno = psn_info.Certno
  5004. PsnName = psn_info.PsnName
  5005. Gend = psn_info.Gend
  5006. Naty = psn_info.Naty
  5007. Brdy = psn_info.Brdy
  5008. Age = psn_info.Age
  5009. infoStr = psn_info.Insuinfo
  5010. idetinfoStr = psn_info.Idetinfo
  5011. infocode = 0
  5012. verify_number = psn_info.VerifyNumber
  5013. } else if id_card_type == 2 {
  5014. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5015. fmt.Println(errMsgLog)
  5016. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5017. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5018. utils.ErrorLog("解析失败:%v", err)
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. return
  5021. }
  5022. PsnNo = res.Output.Baseinfo.PsnNo
  5023. PsnCertType = res.Output.Baseinfo.PsnCertType
  5024. Certno = res.Output.Baseinfo.Certno
  5025. PsnName = res.Output.Baseinfo.PsnName
  5026. Gend = res.Output.Baseinfo.Gend
  5027. Naty = res.Output.Baseinfo.Naty
  5028. Brdy = res.Output.Baseinfo.Brdy
  5029. Age = res.Output.Baseinfo.Age
  5030. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5031. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5032. infoStr = string(Iinfos)
  5033. idetinfoStr = string(Idetinfos)
  5034. infocode = res.Infcode
  5035. }
  5036. } else {
  5037. var result string
  5038. var requestLog string
  5039. if miConfig.UserOrgId == 10138 {
  5040. if id_card_type == 4 {
  5041. psn_info, _ := service.GetPsnByPatientId(id)
  5042. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5043. } else {
  5044. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  5045. }
  5046. } else {
  5047. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  5048. }
  5049. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5050. if miConfig.Code == "H15049901371" {
  5051. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5052. utils.ErrorLog("解析失败:%v", err)
  5053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5054. return
  5055. }
  5056. res.ErrMsg = res10265.ErrMsg
  5057. res.Output = res10265.Output
  5058. res.InfRefmsgid = res10265.InfRefmsgid
  5059. } else {
  5060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5061. utils.ErrorLog("解析失败:%v", err)
  5062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5063. return
  5064. }
  5065. }
  5066. PsnNo = res.Output.Baseinfo.PsnNo
  5067. PsnCertType = res.Output.Baseinfo.PsnCertType
  5068. Certno = res.Output.Baseinfo.Certno
  5069. PsnName = res.Output.Baseinfo.PsnName
  5070. Gend = res.Output.Baseinfo.Gend
  5071. Naty = res.Output.Baseinfo.Naty
  5072. Brdy = res.Output.Baseinfo.Brdy
  5073. Age = res.Output.Baseinfo.Age
  5074. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5075. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5076. infoStr = string(Iinfos)
  5077. idetinfoStr = string(Idetinfos)
  5078. if miConfig.Code == "H15049901371" {
  5079. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5080. } else {
  5081. infocode = res.Infcode
  5082. }
  5083. }
  5084. if infocode == 0 {
  5085. his := models.VMHisPatient{
  5086. Name: name,
  5087. Gender: gender,
  5088. Birthday: birthUnix,
  5089. MedicalTreatmentType: medical_care,
  5090. IdType: certificates,
  5091. IdCardNo: id_card,
  5092. BalanceAccountsType: settlementValue,
  5093. SocialType: social_type,
  5094. MedicalInsuranceNumber: medical_insurance_card,
  5095. RegisterType: register_type,
  5096. RegisterCost: registration_fee,
  5097. TreatmentCost: medical_expenses,
  5098. Status: 1,
  5099. Ctime: time.Now().Unix(),
  5100. Mtime: time.Now().Unix(),
  5101. PsnNo: PsnNo,
  5102. PsnCertType: PsnCertType,
  5103. Certno: Certno,
  5104. PsnName: PsnName,
  5105. Gend: Gend,
  5106. Naty: Naty,
  5107. Brdy: Brdy,
  5108. Age: Age,
  5109. Iinfo: infoStr,
  5110. Idetinfo: idetinfoStr,
  5111. PatientId: patient.ID,
  5112. RecordDate: theTime.Unix(),
  5113. UserOrgId: adminInfo.CurrentOrgId,
  5114. AdminUserId: admin_user_id,
  5115. IsReturn: 1,
  5116. IdCardType: id_card_type,
  5117. Doctor: doctor,
  5118. Departments: department,
  5119. }
  5120. timestamp := time.Now().Unix()
  5121. tempTime := time.Unix(timestamp, 0)
  5122. timeFormat := tempTime.Format("20060102150405")
  5123. chrgBchno := rand.Intn(100000) + 10000
  5124. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5125. his.Number = ipt_otp_no
  5126. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5127. department, _ := service.GetDepartMentDetail(department)
  5128. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5129. IdCardNo := ""
  5130. if id_card_type == 1 {
  5131. // IdCardNo = medical_insurance_card
  5132. IdCardNo = patient.IdCardNo
  5133. } else {
  5134. IdCardNo = patient.IdCardNo
  5135. }
  5136. var rf []*ResultFive
  5137. json.Unmarshal([]byte(his.Iinfo), &rf)
  5138. var insutypes []*ResultFive
  5139. var insutype string
  5140. var insuplc_admdvs_temp string
  5141. var is390 int = 0
  5142. var is310 int = 0
  5143. for _, item := range rf {
  5144. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5145. insutypes = append(insutypes, item)
  5146. }
  5147. }
  5148. if len(insutypes) == 1 {
  5149. insutype = insutypes[0].Insutype
  5150. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5151. } else {
  5152. for _, i := range insutypes {
  5153. if i.Insutype == "390" {
  5154. is390 = 1
  5155. }
  5156. if i.Insutype == "310" {
  5157. is310 = 1
  5158. }
  5159. }
  5160. }
  5161. if is390 == 1 {
  5162. insutype = "390"
  5163. }
  5164. if is310 == 1 {
  5165. insutype = "310"
  5166. }
  5167. if len(insutypes) == 0 {
  5168. insutype = "310"
  5169. }
  5170. if len(insutypes) == 2 {
  5171. insutype = med_type
  5172. }
  5173. if len(med_type) > 0 {
  5174. insutype = med_type
  5175. }
  5176. var infocode int64
  5177. var resThree ResultThree
  5178. var resThree10265 ResultThree10265
  5179. if len(insuplc_admdvs) == 0 {
  5180. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5181. } else {
  5182. insuplc_admdvs_temp = insuplc_admdvs
  5183. }
  5184. if miConfig.MdtrtareaAdmvs == "421300" {
  5185. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5186. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5187. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5188. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  5189. resp, requestErr := http.Get(api)
  5190. if requestErr != nil {
  5191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5192. return
  5193. }
  5194. body, ioErr := ioutil.ReadAll(resp.Body)
  5195. if ioErr != nil {
  5196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5198. return
  5199. }
  5200. var respJSON map[string]interface{}
  5201. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5204. return
  5205. }
  5206. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5207. result, _ := json.Marshal(respJSON)
  5208. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5209. utils.ErrorLog("解析失败:%v", err)
  5210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5211. return
  5212. }
  5213. infocode = resThree.Infcode
  5214. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5215. psn_info, _ := service.GetPsnByPatientId(id)
  5216. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5217. var cert_no string
  5218. if id_card_type == 3 {
  5219. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5220. cert_no = IdCardNo
  5221. } else if id_card_type == 4 {
  5222. cert_no = IdCardNo
  5223. psn_info.VerifyNumber = psn_info.VerifyNumber
  5224. } else {
  5225. bas := strings.Split(psn_info.CardInfo, "|")
  5226. cert_no = bas[2]
  5227. }
  5228. var hisPrescription []*models.HisPrescription
  5229. for _, item := range rf {
  5230. if item.Insutype == insutype {
  5231. //insuplc_admdvs = item.InsuplcAdmdvs
  5232. his.InsuplcAdmdvs = insuplc_admdvs
  5233. }
  5234. }
  5235. his.Insutype = insutype
  5236. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5237. fmt.Println(res3101)
  5238. fmt.Println(res3101.Infcode)
  5239. if res3101.Infcode == "0" {
  5240. fmt.Println("33333333")
  5241. if len(res3101.Output.Result) > 0 {
  5242. fmt.Println("222222")
  5243. for _, item := range res3101.Output.Result {
  5244. if len(res3101.ErrMsg) == 0 {
  5245. res3101.ErrMsg = item.VolaCont
  5246. } else {
  5247. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5248. }
  5249. }
  5250. c.ServeSuccessJSON(map[string]interface{}{
  5251. "failed_code": -10,
  5252. "msg": res3101.ErrMsg,
  5253. })
  5254. return
  5255. } else {
  5256. fmt.Println("11111")
  5257. var api string
  5258. if miConfig.MdtrtareaAdmvs == "320921" {
  5259. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5260. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5261. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5262. } else {
  5263. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5264. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5265. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5266. }
  5267. resp, requestErr := http.Get(api)
  5268. if requestErr != nil {
  5269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. return
  5271. }
  5272. body, ioErr := ioutil.ReadAll(resp.Body)
  5273. if ioErr != nil {
  5274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. return
  5277. }
  5278. var respJSON map[string]interface{}
  5279. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5282. return
  5283. }
  5284. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5285. result, _ := json.Marshal(respJSON)
  5286. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5287. utils.ErrorLog("解析失败:%v", err)
  5288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5289. return
  5290. }
  5291. resThree.ErrMsg = resThree10265.ErrMsg
  5292. resThree.Output = resThree10265.Output
  5293. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5294. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5295. }
  5296. } else if res3101.Infcode != "0" {
  5297. c.ServeSuccessJSON(map[string]interface{}{
  5298. "failed_code": -10,
  5299. "msg": res3101.ErrMsg,
  5300. })
  5301. return
  5302. }
  5303. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5304. psn_info, _ := service.GetPsnByPatientId(id)
  5305. var cert_no string
  5306. if id_card_type == 1 {
  5307. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5308. } else {
  5309. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5310. }
  5311. fmt.Println(cert_no)
  5312. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  5313. saveLog(result, requestLog, "2201", "挂号")
  5314. if miConfig.Code == "H15049901371" {
  5315. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5316. utils.ErrorLog("解析失败:%v", err)
  5317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5318. return
  5319. }
  5320. resThree.ErrMsg = resThree10265.ErrMsg
  5321. resThree.Output = resThree10265.Output
  5322. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5323. } else {
  5324. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5325. utils.ErrorLog("解析失败:%v", err)
  5326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5327. return
  5328. }
  5329. }
  5330. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5331. } else {
  5332. psn_info, _ := service.GetPsnByPatientId(id)
  5333. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  5334. saveLog(result, requestLog, "2201A", "挂号")
  5335. if miConfig.Code == "H15049901371" {
  5336. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5337. utils.ErrorLog("解析失败:%v", err)
  5338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5339. return
  5340. }
  5341. resThree.ErrMsg = resThree10265.ErrMsg
  5342. resThree.Output = resThree10265.Output
  5343. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5344. } else {
  5345. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5346. utils.ErrorLog("解析失败:%v", err)
  5347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5348. return
  5349. }
  5350. }
  5351. if miConfig.Code == "H15049901371" {
  5352. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5353. } else {
  5354. infocode = resThree.Infcode
  5355. }
  5356. }
  5357. if infocode != 0 {
  5358. adminUser := c.GetAdminUserInfo()
  5359. errlog := &models.HisOrderError{
  5360. UserOrgId: adminUser.CurrentOrgId,
  5361. Ctime: time.Now().Unix(),
  5362. Mtime: time.Now().Unix(),
  5363. ErrMsg: resThree.ErrMsg,
  5364. Status: 1,
  5365. PatientId: id,
  5366. RecordTime: recordDateTime,
  5367. Stage: 2,
  5368. }
  5369. service.CreateErrMsgLog(errlog)
  5370. c.ServeSuccessJSON(map[string]interface{}{
  5371. "failed_code": -10,
  5372. "msg": resThree.ErrMsg,
  5373. })
  5374. return
  5375. }
  5376. his.Number = resThree.Output.Data.MdtrtID
  5377. his.PsnNo = resThree.Output.Data.PsnNo
  5378. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5379. his.IdCardNo = patient.IdCardNo
  5380. his.PhoneNumber = patient.Phone
  5381. his.UserOrgId = adminInfo.CurrentOrgId
  5382. his.Insutype = insutype
  5383. his.Ctime = time.Now().Unix()
  5384. his.Mtime = time.Now().Unix()
  5385. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5386. his.Status = 1
  5387. service.UpdateHisPatientStatus(&his)
  5388. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5389. c.ServeSuccessJSON(map[string]interface{}{
  5390. "his_info": his,
  5391. })
  5392. } else {
  5393. adminUser := c.GetAdminUserInfo()
  5394. errlog := &models.HisOrderError{
  5395. UserOrgId: adminUser.CurrentOrgId,
  5396. Ctime: time.Now().Unix(),
  5397. Mtime: time.Now().Unix(),
  5398. ErrMsg: res.ErrMsg,
  5399. Status: 1,
  5400. PatientId: id,
  5401. RecordTime: recordDateTime,
  5402. Stage: 1,
  5403. }
  5404. service.CreateErrMsgLog(errlog)
  5405. c.ServeSuccessJSON(map[string]interface{}{
  5406. "failed_code": -10,
  5407. "msg": res.ErrMsg,
  5408. })
  5409. return
  5410. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5411. }
  5412. }
  5413. }
  5414. //上传明细----预结算----确认订单
  5415. func (c *HisApiController) GetUploadInfo() {
  5416. id, _ := c.GetInt64("id")
  5417. record_time := c.GetString("record_time")
  5418. his_patient_id, _ := c.GetInt64("his_patient_id")
  5419. order_id, _ := c.GetInt64("order_id")
  5420. pay_way, _ := c.GetInt64("pay_way")
  5421. pay_price, _ := c.GetFloat("pay_price")
  5422. pay_card_no := c.GetString("pay_card_no")
  5423. token := c.GetString("token")
  5424. discount_price, _ := c.GetFloat("discount_price")
  5425. preferential_price, _ := c.GetFloat("preferential_price")
  5426. reality_price, _ := c.GetFloat("reality_price")
  5427. found_price, _ := c.GetFloat("found_price")
  5428. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5429. private_price, _ := c.GetFloat("private_price")
  5430. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5431. admin_user_id, _ := c.GetInt64("admin_user_id")
  5432. fapiao_code := c.GetString("fapiao_code")
  5433. fapiao_number := c.GetString("fapiao_number")
  5434. diagnosis_id := c.GetString("diagnosis")
  5435. sick_type, _ := c.GetInt64("sick_type")
  5436. reg_type, _ := c.GetInt64("p_type")
  5437. begin_time := c.GetString("begin_time")
  5438. id_str := c.GetString("ids")
  5439. ids_arr := strings.Split(id_str, ",")
  5440. timeLayout := "2006-01-02"
  5441. loc, _ := time.LoadLocation("Local")
  5442. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5443. if err != nil {
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5445. return
  5446. }
  5447. recordDateTime := theTime.Unix()
  5448. adminUser := c.GetAdminUserInfo()
  5449. var tempOrder models.HisOrder
  5450. tempOrder, _ = service.GetHisOrderByID(order_id)
  5451. var prescriptions []*models.HisPrescription
  5452. var start_time int64
  5453. var end_time int64
  5454. //押金模块
  5455. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5456. tmp_decimal := c.GetString("tmp_decimal")
  5457. var decimal float64 //本次使用的押金
  5458. var errmsg error
  5459. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5460. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5461. return
  5462. }
  5463. if len(tmp_decimal) > 0 {
  5464. if tmp_decimal[0] == 45 {
  5465. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5466. return
  5467. }
  5468. }
  5469. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5470. fmt.Println(errs)
  5471. decimal = tt
  5472. //if adminUser.CurrentOrgId == 10106{
  5473. // if len(fapiao_code) == 0{
  5474. // fapiao_code = "144072080589"
  5475. // }
  5476. // if len(fapiao_number) == 0{
  5477. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5478. // if order.ID == 0{
  5479. // fapiao_number = "00001520"
  5480. // }else{
  5481. // //fapiao_code = "00001520"
  5482. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5483. // var zero string
  5484. // if fpNumber >= 1000{
  5485. // zero = "0000" + strconv.Itoa(fpNumber)
  5486. // }else if fpNumber >= 10000{
  5487. // zero = "000" + strconv.Itoa(fpNumber)
  5488. // } else if fpNumber >= 100000{
  5489. // zero = "00" + strconv.Itoa(fpNumber)
  5490. // } else if fpNumber >= 1000000{
  5491. // zero = "0" + strconv.Itoa(fpNumber)
  5492. // }else {
  5493. // zero = strconv.Itoa(fpNumber)
  5494. // }
  5495. // fapiao_number = zero
  5496. // }
  5497. // }
  5498. //}
  5499. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5500. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5501. var patientPrescription models.HisPrescriptionInfo
  5502. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5503. if patientPrescription.ID == 0 {
  5504. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5505. }
  5506. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5507. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5508. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5509. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5510. var config []*models.HisXtDiagnoseConfig
  5511. for _, item := range diagnosis_ids {
  5512. id, _ := strconv.ParseInt(item, 10, 64)
  5513. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5514. config = append(config, &diagnosisConfig)
  5515. }
  5516. sickConfig, _ := service.FindSickById(sick_type)
  5517. //if tempOrder.ID == 0 {
  5518. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5519. //}
  5520. if tempOrder.ID == 0 {
  5521. var result string
  5522. var requestLog string
  5523. var res2 ResultSix
  5524. var ressix10265 ResultSix10265
  5525. if miConfig.MdtrtareaAdmvs == "421300" {
  5526. data := make(map[string]interface{})
  5527. client := &http.Client{}
  5528. data["psn_no"] = his.PsnNo
  5529. data["mdtrt_id"] = his.Number
  5530. data["opter"] = roles.UserName
  5531. data["org_name"] = miConfig.OrgName
  5532. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5533. data["doctor_id"] = doctor_info.DoctorNumber
  5534. data["doctor_name"] = doctor_info.UserName
  5535. data["department"] = department.Name
  5536. data["fixmedins_code"] = miConfig.Code
  5537. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5538. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5539. data["secret_key"] = miConfig.SecretKey
  5540. data["sick_code"] = sickConfig.CountryCode
  5541. data["sick_name"] = sickConfig.ClassName
  5542. data["dept"] = strconv.FormatInt(department.ID, 10)
  5543. data["config"] = config
  5544. data["begin_time"] = begin_time
  5545. bytesData, _ := json.Marshal(data)
  5546. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5547. resp, _ := client.Do(req)
  5548. defer resp.Body.Close()
  5549. body, ioErr := ioutil.ReadAll(resp.Body)
  5550. if ioErr != nil {
  5551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5553. return
  5554. }
  5555. var respJSON map[string]interface{}
  5556. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5559. return
  5560. }
  5561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5562. userJSONBytes, _ := json.Marshal(respJSON)
  5563. fmt.Println("log")
  5564. fmt.Println(string(userJSONBytes))
  5565. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5566. utils.ErrorLog("解析失败:%v", err)
  5567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5568. return
  5569. }
  5570. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5571. //江苏地区国家医保医疗类别
  5572. //职工透析:医疗类别选特殊情况门诊9933
  5573. //居民血透门慢: 医疗类别选门诊慢病1402
  5574. //var med_type string
  5575. //if his.Insutype == "310" {
  5576. // if reg_type == 14 {
  5577. // med_type = "9933"
  5578. // } else if reg_type == 11 {
  5579. // med_type = "11"
  5580. //
  5581. // }
  5582. //} else if his.Insutype == "390" {
  5583. // if reg_type == 14 {
  5584. // med_type = "1402"
  5585. // } else if reg_type == 11 {
  5586. // med_type = "11"
  5587. // }
  5588. //}
  5589. data := make(map[string]interface{})
  5590. client := &http.Client{}
  5591. data["psn_no"] = his.PsnNo
  5592. data["mdtrt_id"] = his.Number
  5593. data["doctor"] = roles.UserName
  5594. data["department"] = department.Name
  5595. data["org_name"] = miConfig.OrgName
  5596. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5597. data["doctor_id"] = doctor_info.DoctorNumber
  5598. data["new_doctor_name"] = doctor_info.UserName
  5599. data["fixmedins_code"] = miConfig.Code
  5600. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5601. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5602. data["secret_key"] = miConfig.SecretKey
  5603. data["sick_code"] = sickConfig.CountryCode
  5604. data["sick_name"] = sickConfig.ClassName
  5605. data["url"] = miConfig.Url
  5606. data["ak"] = miConfig.AccessKey
  5607. data["begin_time"] = begin_time
  5608. data["cainfo"] = miConfig.Cainfo
  5609. data["dept"] = strconv.FormatInt(department.ID, 10)
  5610. data["config"] = config
  5611. bytesData, _ := json.Marshal(data)
  5612. var req *http.Request
  5613. if miConfig.MdtrtareaAdmvs == "320921" {
  5614. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5615. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5616. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5617. } else {
  5618. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5619. }
  5620. resp, _ := client.Do(req)
  5621. defer resp.Body.Close()
  5622. body, ioErr := ioutil.ReadAll(resp.Body)
  5623. if ioErr != nil {
  5624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5626. return
  5627. }
  5628. var respJSON map[string]interface{}
  5629. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5632. return
  5633. }
  5634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5635. userJSONBytes, _ := json.Marshal(respJSON)
  5636. fmt.Println("log")
  5637. fmt.Println(string(userJSONBytes))
  5638. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5639. utils.ErrorLog("解析失败:%v", err)
  5640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5641. return
  5642. }
  5643. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5644. res2.Output = ressix10265.Output
  5645. res2.ErrMsg = ressix10265.ErrMsg
  5646. res2.Cainfo = ressix10265.Cainfo
  5647. res2.WarnMsg = ressix10265.WarnMsg
  5648. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5649. res2.Infcode = infocode
  5650. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5651. result, requestLog, _ = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5652. saveLog(result, requestLog, "2203", "上传就诊信息")
  5653. var respJSON2 map[string]interface{}
  5654. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5657. return
  5658. }
  5659. userJSONBytes2, _ := json.Marshal(respJSON2)
  5660. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5661. utils.ErrorLog("解析失败:%v", err)
  5662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5663. return
  5664. }
  5665. } else {
  5666. if miConfig.MdtrtareaAdmvs == "440781" { //
  5667. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5668. } else {
  5669. if miConfig.Code == "H15049901371" {
  5670. //赤峰地区国家医保医疗类别
  5671. //职工透析:医疗类别选特殊情况门诊990502
  5672. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5673. var med_type string
  5674. if his.Insutype == "390" {
  5675. if reg_type == 14 {
  5676. med_type = "9933"
  5677. } else if reg_type == 11 {
  5678. med_type = "11"
  5679. }
  5680. } else if his.Insutype == "310" {
  5681. if reg_type == 14 {
  5682. med_type = "990502"
  5683. } else if reg_type == 11 {
  5684. med_type = "11"
  5685. }
  5686. }
  5687. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5688. } else {
  5689. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5690. }
  5691. }
  5692. saveLog(result, requestLog, "2203", "上传就诊信息")
  5693. var respJSON2 map[string]interface{}
  5694. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5697. return
  5698. }
  5699. userJSONBytes2, _ := json.Marshal(respJSON2)
  5700. if miConfig.Code == "H15049901371" {
  5701. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5702. utils.ErrorLog("解析失败:%v", err)
  5703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5704. return
  5705. }
  5706. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5707. res2.Output = ressix10265.Output
  5708. res2.ErrMsg = ressix10265.ErrMsg
  5709. res2.Cainfo = ressix10265.Cainfo
  5710. res2.WarnMsg = ressix10265.WarnMsg
  5711. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5712. res2.Infcode = infocode
  5713. } else {
  5714. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5715. utils.ErrorLog("解析失败:%v", err)
  5716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5717. return
  5718. }
  5719. }
  5720. }
  5721. if res2.Infcode != 0 {
  5722. adminUser := c.GetAdminUserInfo()
  5723. errlog := &models.HisOrderError{
  5724. UserOrgId: adminUser.CurrentOrgId,
  5725. Ctime: time.Now().Unix(),
  5726. Mtime: time.Now().Unix(),
  5727. ErrMsg: res2.ErrMsg,
  5728. Status: 1,
  5729. PatientId: id,
  5730. RecordTime: recordDateTime,
  5731. Stage: 3,
  5732. }
  5733. service.CreateErrMsgLog(errlog)
  5734. c.ServeSuccessJSON(map[string]interface{}{
  5735. "failed_code": -10,
  5736. "msg": res2.ErrMsg,
  5737. })
  5738. return
  5739. } else {
  5740. his.Diagnosis = diagnosis_id
  5741. his.SickType = sickConfig.ID
  5742. //var p_type int64
  5743. //if reg_type == 1111 || reg_type == 1112 {
  5744. // p_type = 11
  5745. //
  5746. //}
  5747. his.PType = fmt.Sprintf("%d", reg_type)
  5748. service.UpdateHisPatientThree(&his)
  5749. data := make(map[string]interface{})
  5750. if settle_accounts_type == 1 { //日结
  5751. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5752. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5753. } else {
  5754. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5755. }
  5756. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5757. data["pre"] = prescriptions
  5758. } else { //月结
  5759. start_time_str := c.GetString("start_time")
  5760. end_time_str := c.GetString("end_time")
  5761. timeLayout := "2006-01-02"
  5762. loc, _ := time.LoadLocation("Local")
  5763. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5764. if err != nil {
  5765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5766. return
  5767. }
  5768. recordStartTime := theStartTime.Unix()
  5769. start_time = recordStartTime
  5770. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5771. if err != nil {
  5772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5773. return
  5774. }
  5775. recordEndTime := theEndTime.Unix()
  5776. end_time = recordEndTime
  5777. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5778. data["pre"] = prescriptions
  5779. }
  5780. timestamp := time.Now().Unix()
  5781. tempTime := time.Unix(timestamp, 0)
  5782. timeFormat := tempTime.Format("20060102150405")
  5783. chrgBchno := rand.Intn(100000) + 10000
  5784. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5785. strconv.FormatInt(his.PatientId, 10)
  5786. client := &http.Client{}
  5787. data["psn_no"] = his.PsnNo
  5788. data["mdtrt_id"] = his.Number
  5789. data["chrg_bchno"] = chrg_bchno
  5790. data["org_name"] = miConfig.OrgName
  5791. data["doctor"] = doctor_info.UserName
  5792. data["doctor_id"] = doctor_info.DoctorNumber
  5793. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5794. data["fixmedins_code"] = miConfig.Code
  5795. data["opter"] = roles.UserName
  5796. data["dept_code"] = department.Number
  5797. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5798. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5799. data["secret_key"] = miConfig.SecretKey
  5800. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5801. data["url"] = miConfig.Url
  5802. data["ak"] = miConfig.AccessKey
  5803. data["new_doctor_name"] = patientPrescription.Doctor
  5804. data["diag_code"] = sickConfig.CountryCode
  5805. data["cainfo"] = miConfig.Cainfo
  5806. var ids []int64
  5807. for _, item := range prescriptions {
  5808. ids = append(ids, item.ID)
  5809. }
  5810. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5811. if config.IsOpen == 1 { //对接了医保,走医保流程
  5812. var res ResultFour
  5813. var resFour10265 ResultFour10265
  5814. if miConfig.MdtrtareaAdmvs == "421300" {
  5815. bytesData, _ := json.Marshal(data)
  5816. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5817. resp, _ := client.Do(req)
  5818. defer resp.Body.Close()
  5819. body, ioErr := ioutil.ReadAll(resp.Body)
  5820. if ioErr != nil {
  5821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5823. return
  5824. }
  5825. var respJSON map[string]interface{}
  5826. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5829. return
  5830. }
  5831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5832. userJSONBytes, _ := json.Marshal(respJSON)
  5833. fmt.Println("log")
  5834. fmt.Println(string(userJSONBytes))
  5835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5836. utils.ErrorLog("解析失败:%v", err)
  5837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5838. return
  5839. }
  5840. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5841. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5842. if result3101.Infcode == "0" {
  5843. if len(result3101.Output.Result) > 0 {
  5844. var errMsgs []string
  5845. for _, item := range result3101.Output.Result {
  5846. errMsgs = append(errMsgs, item.VolaCont)
  5847. }
  5848. c.ServeSuccessJSON(map[string]interface{}{
  5849. "failed_code": -10,
  5850. "msg": errMsgs,
  5851. })
  5852. return
  5853. }
  5854. }
  5855. bytesData, _ := json.Marshal(data)
  5856. var req *http.Request
  5857. if miConfig.MdtrtareaAdmvs == "320921" {
  5858. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5859. } else {
  5860. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5861. }
  5862. resp, _ := client.Do(req)
  5863. defer resp.Body.Close()
  5864. body, ioErr := ioutil.ReadAll(resp.Body)
  5865. if ioErr != nil {
  5866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5868. return
  5869. }
  5870. var respJSON map[string]interface{}
  5871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5874. return
  5875. }
  5876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5877. userJSONBytes, _ := json.Marshal(respJSON)
  5878. fmt.Println("log")
  5879. fmt.Println(string(userJSONBytes))
  5880. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5881. utils.ErrorLog("解析失败:%v", err)
  5882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5883. return
  5884. }
  5885. res.InfRefmsgid = resFour10265.InfRefmsgid
  5886. res.Output = resFour10265.Output
  5887. res.ErrMsg = resFour10265.ErrMsg
  5888. res.Cainfo = resFour10265.Cainfo
  5889. res.WarnMsg = resFour10265.WarnMsg
  5890. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5891. res.Infcode = infocode
  5892. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5893. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  5894. var dat map[string]interface{}
  5895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5896. fmt.Println(dat)
  5897. } else {
  5898. fmt.Println(err)
  5899. }
  5900. saveLog(result, request_log, "2204", "上传费用明细")
  5901. userJSONBytes, _ := json.Marshal(dat)
  5902. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5903. utils.ErrorLog("解析失败:%v", err)
  5904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5905. return
  5906. }
  5907. res.InfRefmsgid = resFour10265.InfRefmsgid
  5908. res.Output = resFour10265.Output
  5909. res.ErrMsg = resFour10265.ErrMsg
  5910. res.Cainfo = resFour10265.Cainfo
  5911. res.WarnMsg = resFour10265.WarnMsg
  5912. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5913. res.Infcode = infocode
  5914. } else {
  5915. if miConfig.Code == "H15049901371" {
  5916. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  5917. var dat map[string]interface{}
  5918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5919. fmt.Println(dat)
  5920. } else {
  5921. fmt.Println(err)
  5922. }
  5923. saveLog(result, request_log, "2204", "上传费用明细")
  5924. userJSONBytes, _ := json.Marshal(dat)
  5925. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5926. utils.ErrorLog("解析失败:%v", err)
  5927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5928. return
  5929. }
  5930. res.InfRefmsgid = resFour10265.InfRefmsgid
  5931. res.Output = resFour10265.Output
  5932. res.ErrMsg = resFour10265.ErrMsg
  5933. res.Cainfo = resFour10265.Cainfo
  5934. res.WarnMsg = resFour10265.WarnMsg
  5935. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5936. res.Infcode = infocode
  5937. } else {
  5938. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  5939. var dat map[string]interface{}
  5940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5941. fmt.Println(dat)
  5942. } else {
  5943. fmt.Println(err)
  5944. }
  5945. saveLog(result, request_log, "2204", "上传费用明细")
  5946. userJSONBytes, _ := json.Marshal(dat)
  5947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5948. utils.ErrorLog("解析失败:%v", err)
  5949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5950. return
  5951. }
  5952. }
  5953. }
  5954. if res.Infcode == 0 {
  5955. order := &models.HisOrder{
  5956. UserOrgId: adminUser.CurrentOrgId,
  5957. HisPatientId: his.ID,
  5958. PatientId: his.PatientId,
  5959. SettleAccountsDate: recordDateTime,
  5960. MdtrtId: his.Number,
  5961. PsnNo: his.PsnNo,
  5962. MedType: strconv.FormatInt(reg_type, 10),
  5963. Ctime: time.Now().Unix(),
  5964. Mtime: time.Now().Unix(),
  5965. Status: 1,
  5966. Number: chrg_bchno,
  5967. Infcode: res.Infcode,
  5968. WarnMsg: res.WarnMsg,
  5969. Cainfo: res.Cainfo,
  5970. ErrMsg: res.ErrMsg,
  5971. RespondTime: res.RefmsgTime,
  5972. InfRefmsgid: res.InfRefmsgid,
  5973. OrderStatus: 1,
  5974. PayWay: pay_way,
  5975. PayPrice: pay_price,
  5976. PayCardNo: pay_card_no,
  5977. DiscountPrice: discount_price,
  5978. PreferentialPrice: preferential_price,
  5979. RealityPrice: reality_price,
  5980. FoundPrice: found_price,
  5981. MedicalInsurancePrice: medical_insurance_price,
  5982. PrivatePrice: private_price,
  5983. IsMedicineInsurance: 1,
  5984. SettleType: settle_accounts_type,
  5985. SettleStartTime: start_time,
  5986. SettleEndTime: end_time,
  5987. Creator: roles.AdminUserId,
  5988. Modify: roles.AdminUserId,
  5989. FaPiaoNumber: fapiao_number,
  5990. FaPiaoCode: fapiao_code,
  5991. PType: 2,
  5992. Diagnosis: diagnosis_id,
  5993. }
  5994. err = service.CreateOrder(order)
  5995. if err != nil {
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5997. return
  5998. }
  5999. for _, item := range res.Output.Result {
  6000. temp := strings.Split(item.FeedetlSn, "-")
  6001. var advice_id int64 = 0
  6002. var project_id int64 = 0
  6003. var types int64 = 0
  6004. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6005. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6006. if temp[1] == "1" {
  6007. advice_id = id
  6008. project_id = 0
  6009. } else if temp[1] == "2" {
  6010. advice_id = 0
  6011. project_id = id
  6012. }
  6013. info := &models.HisOrderInfo{
  6014. OrderNumber: order.Number,
  6015. FeedetlSn: item.FeedetlSn,
  6016. UploadDate: time.Now().Unix(),
  6017. AdviceId: advice_id,
  6018. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6019. Cnt: item.Cnt,
  6020. Pric: float64(item.Pric),
  6021. PatientId: his.PatientId,
  6022. PricUplmtAmt: item.PricUplmtAmt,
  6023. SelfpayProp: item.SelfpayProp,
  6024. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6025. OverlmtAmt: item.OverlmtAmt,
  6026. PreselfpayAmt: item.PreselfpayAmt,
  6027. BasMednFlag: item.BasMednFlag,
  6028. MedChrgitmType: item.MedChrgitmType,
  6029. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6030. Status: 1,
  6031. Memo: item.Memo,
  6032. Mtime: time.Now().Unix(),
  6033. InscpScpAmt: item.InscpScpAmt,
  6034. DrtReimFlag: item.DrtReimFlag,
  6035. Ctime: time.Now().Unix(),
  6036. ListSpItemFlag: item.ListSpItemFlag,
  6037. ChldMedcFlag: item.ChldMedcFlag,
  6038. LmtUsedFlag: item.LmtUsedFlag,
  6039. ChrgitmLv: item.ChrgitmLv,
  6040. UserOrgId: adminUser.CurrentOrgId,
  6041. HisPatientId: his.ID,
  6042. OrderId: order.ID,
  6043. ProjectId: project_id,
  6044. Type: types,
  6045. }
  6046. service.CreateOrderInfo(info)
  6047. }
  6048. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6049. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6050. var total float64
  6051. for _, item := range prescriptions {
  6052. if item.Type == 1 { //药品
  6053. for _, subItem := range item.HisDoctorAdviceInfo {
  6054. total = total + (subItem.Price * subItem.PrescribingNumber)
  6055. }
  6056. }
  6057. if item.Type == 2 { //项目
  6058. for _, subItem := range item.HisPrescriptionProject {
  6059. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6060. total = total + (subItem.Price * cnt)
  6061. }
  6062. }
  6063. }
  6064. for _, item := range prescriptions {
  6065. for _, subItem := range item.HisAdditionalCharge {
  6066. total = total + (subItem.Price * float64(subItem.Count))
  6067. }
  6068. }
  6069. var allTotal string
  6070. if adminUser.CurrentOrgId == 9919 {
  6071. allTotal = fmt.Sprintf("%.4f", total)
  6072. } else {
  6073. allTotal = fmt.Sprintf("%.4f", total)
  6074. }
  6075. if res.Infcode == 0 {
  6076. var rf []*ResultFive
  6077. json.Unmarshal([]byte(his.Iinfo), &rf)
  6078. chrg_bchno := chrg_bchno
  6079. cert_no := his.Certno
  6080. var insutypes []string
  6081. var insutype string
  6082. var is390 int = 0
  6083. var is310 int = 0
  6084. for _, item := range rf {
  6085. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6086. insutypes = append(insutypes, item.Insutype)
  6087. }
  6088. }
  6089. if len(insutypes) == 1 {
  6090. insutype = insutypes[0]
  6091. } else {
  6092. for _, i := range insutypes {
  6093. if i == "390" {
  6094. is390 = 1
  6095. }
  6096. if i == "310" {
  6097. is310 = 1
  6098. }
  6099. }
  6100. }
  6101. if is390 == 1 {
  6102. insutype = "390"
  6103. }
  6104. if is310 == 1 {
  6105. insutype = "310"
  6106. }
  6107. if len(insutypes) == 0 {
  6108. insutype = "310"
  6109. }
  6110. if len(insutypes) == 2 {
  6111. insutype = strconv.FormatInt(his.SocialType, 10)
  6112. }
  6113. insutype = strconv.FormatInt(his.SocialType, 10)
  6114. //insutype = "390"
  6115. if his.IdCardType == 1 {
  6116. // cert_no = his.MedicalInsuranceNumber
  6117. cert_no = his.Certno
  6118. } else {
  6119. cert_no = his.Certno
  6120. }
  6121. var res ResultSeven
  6122. var resSeven10265 ResultSeven10265
  6123. var src_resquest string
  6124. var result2 string
  6125. var acct_used_flag string
  6126. fmt.Println("pay_way")
  6127. fmt.Println(pay_way)
  6128. fmt.Println("pay_way")
  6129. if pay_way == 4 {
  6130. acct_used_flag = "1"
  6131. } else {
  6132. acct_used_flag = "0"
  6133. }
  6134. if miConfig.MdtrtareaAdmvs == "421300" {
  6135. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6136. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6137. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6139. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6140. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6141. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6142. resp, requestErr := http.Get(api)
  6143. if requestErr != nil {
  6144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6145. return
  6146. }
  6147. body, ioErr := ioutil.ReadAll(resp.Body)
  6148. if ioErr != nil {
  6149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6151. return
  6152. }
  6153. var respJSON map[string]interface{}
  6154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6157. return
  6158. }
  6159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6160. result, _ := json.Marshal(respJSON)
  6161. if miConfig.Code == "H15049901371" {
  6162. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6163. utils.ErrorLog("解析失败:%v", err)
  6164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6165. return
  6166. }
  6167. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6168. res.Output = resSeven10265.Output
  6169. res.ErrMsg = resSeven10265.ErrMsg
  6170. res.Cainfo = resSeven10265.Cainfo
  6171. res.WarnMsg = resSeven10265.WarnMsg
  6172. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6173. res.Infcode = infocode
  6174. } else {
  6175. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6176. utils.ErrorLog("解析失败:%v", err)
  6177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6178. return
  6179. }
  6180. }
  6181. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6182. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  6183. if result3101.Infcode == "0" {
  6184. if len(result3101.Output.Result) > 0 {
  6185. var errMsgs []string
  6186. for _, item := range result3101.Output.Result {
  6187. errMsgs = append(errMsgs, item.VolaCont)
  6188. }
  6189. c.ServeSuccessJSON(map[string]interface{}{
  6190. "failed_code": -10,
  6191. "msg": errMsgs,
  6192. })
  6193. return
  6194. } else {
  6195. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6196. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6197. bas := strings.Split(psn_info.CardInfo, "|")
  6198. if his.IdCardType == 1 {
  6199. cert_no = bas[2]
  6200. } else if his.IdCardType == 3 {
  6201. cert_no = his.Certno
  6202. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6203. } else if his.IdCardType == 4 {
  6204. cert_no = his.Certno
  6205. psn_info.VerifyNumber = token
  6206. }
  6207. var api string
  6208. if miConfig.MdtrtareaAdmvs == "320921" {
  6209. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6210. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6211. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6212. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6213. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6214. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6215. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  6216. } else {
  6217. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6218. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6219. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6220. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6221. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6222. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6223. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  6224. }
  6225. resp, requestErr := http.Get(api)
  6226. if requestErr != nil {
  6227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6228. return
  6229. }
  6230. body, ioErr := ioutil.ReadAll(resp.Body)
  6231. if ioErr != nil {
  6232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6234. return
  6235. }
  6236. var respJSON map[string]interface{}
  6237. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6240. return
  6241. }
  6242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6243. result, _ := json.Marshal(respJSON)
  6244. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6245. utils.ErrorLog("解析失败:%v", err)
  6246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6247. return
  6248. }
  6249. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6250. res.Output = resSeven10265.Output
  6251. res.ErrMsg = resSeven10265.ErrMsg
  6252. res.Cainfo = resSeven10265.Cainfo
  6253. res.WarnMsg = resSeven10265.WarnMsg
  6254. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6255. res.Infcode = infocode
  6256. }
  6257. }
  6258. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6259. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6260. var cert_no string
  6261. if his.IdCardType == 1 {
  6262. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6263. }
  6264. fmt.Println(cert_no)
  6265. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6266. //result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, acct_used_flag)
  6267. var dat map[string]interface{}
  6268. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6269. fmt.Println(dat)
  6270. } else {
  6271. fmt.Println(err)
  6272. }
  6273. saveLog(result2, src_resquest, "2207", "结算")
  6274. userJSONBytes, _ := json.Marshal(dat)
  6275. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6276. utils.ErrorLog("解析失败:%v", err)
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return
  6279. }
  6280. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6281. res.Output = resSeven10265.Output
  6282. res.ErrMsg = resSeven10265.ErrMsg
  6283. res.Cainfo = resSeven10265.Cainfo
  6284. res.WarnMsg = resSeven10265.WarnMsg
  6285. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6286. res.Infcode = infocode
  6287. } else {
  6288. if miConfig.Code == "H15049901371" {
  6289. //赤峰地区国家医保医疗类别
  6290. //职工透析:医疗类别选特殊情况门诊990502
  6291. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6292. var med_type string
  6293. if his.Insutype == "390" {
  6294. if reg_type == 14 {
  6295. med_type = "9933"
  6296. } else if reg_type == 11 {
  6297. med_type = "11"
  6298. }
  6299. } else if his.Insutype == "310" {
  6300. if reg_type == 14 {
  6301. med_type = "990502"
  6302. } else if reg_type == 11 {
  6303. med_type = "11"
  6304. }
  6305. }
  6306. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  6307. } else {
  6308. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  6309. }
  6310. //result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, acct_used_flag)
  6311. var dat map[string]interface{}
  6312. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6313. fmt.Println(dat)
  6314. } else {
  6315. fmt.Println(err)
  6316. }
  6317. saveLog(result2, src_resquest, "2207", "结算")
  6318. userJSONBytes, _ := json.Marshal(dat)
  6319. if miConfig.Code == "H15049901371" {
  6320. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6321. utils.ErrorLog("解析失败:%v", err)
  6322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6323. return
  6324. }
  6325. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6326. res.Output = resSeven10265.Output
  6327. res.ErrMsg = resSeven10265.ErrMsg
  6328. res.Cainfo = resSeven10265.Cainfo
  6329. res.WarnMsg = resSeven10265.WarnMsg
  6330. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6331. res.Infcode = infocode
  6332. } else {
  6333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6334. utils.ErrorLog("解析失败:%v", err)
  6335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6336. return
  6337. }
  6338. }
  6339. }
  6340. if res.Infcode != 0 {
  6341. errlog := &models.HisOrderError{
  6342. UserOrgId: adminUser.CurrentOrgId,
  6343. Ctime: time.Now().Unix(),
  6344. Mtime: time.Now().Unix(),
  6345. Number: chrg_bchno,
  6346. ErrMsg: res.ErrMsg,
  6347. Status: 1,
  6348. PatientId: id,
  6349. RecordTime: recordDateTime,
  6350. Stage: 6,
  6351. }
  6352. service.CreateErrMsgLog(errlog)
  6353. c.ServeSuccessJSON(map[string]interface{}{
  6354. "failed_code": -10,
  6355. "msg": res.ErrMsg,
  6356. })
  6357. return
  6358. } else {
  6359. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6360. order.OrderStatus = 2
  6361. order.Status = 1
  6362. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6363. order.SetlId = res.Output.Setlinfo.SetlID
  6364. order.PsnNo = res.Output.Setlinfo.PsnNo
  6365. order.PsnName = res.Output.Setlinfo.PsnName
  6366. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6367. order.Certno = res.Output.Setlinfo.Certno
  6368. order.Gend = res.Output.Setlinfo.Gend
  6369. order.Naty = res.Output.Setlinfo.Naty
  6370. order.Age = res.Output.Setlinfo.Age
  6371. order.Insutype = res.Output.Setlinfo.Insutype
  6372. order.PsnType = res.Output.Setlinfo.PsnType
  6373. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6374. order.SetlTime = res.Output.Setlinfo.SetlTime
  6375. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6376. if res.Output.Setlinfo.MedType == "140101" {
  6377. order.MedType = "14"
  6378. } else {
  6379. order.MedType = res.Output.Setlinfo.MedType
  6380. }
  6381. if reg_type == 1112 {
  6382. order.MedType = "1112"
  6383. }
  6384. if reg_type == 1111 {
  6385. order.MedType = "1111"
  6386. }
  6387. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6388. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6389. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6390. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6391. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6392. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6393. order.HifpPay = res.Output.Setlinfo.HifpPay
  6394. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6395. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6396. order.HifesPay = res.Output.Setlinfo.HifesPay
  6397. order.HifobPay = res.Output.Setlinfo.HifobPay
  6398. order.MafPay = res.Output.Setlinfo.MafPay
  6399. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6400. order.OthPay = res.Output.Setlinfo.OthPay
  6401. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6402. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6403. order.AcctPay = res.Output.Setlinfo.AcctPay
  6404. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6405. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6406. order.Balc = res.Output.Setlinfo.Balc
  6407. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6408. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6409. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6410. order.ClrType = res.Output.Setlinfo.ClrType
  6411. order.ClrWay = res.Output.Setlinfo.ClrWay
  6412. order.Creator = order.Creator
  6413. order.Modify = roles.AdminUserId
  6414. order.RequestLog = src_resquest
  6415. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6416. detailStr := string(setlDetail)
  6417. order.SetlDetail = detailStr
  6418. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6419. err = service.UpDateOrder(order)
  6420. if err == nil {
  6421. //判断是否使用了押金
  6422. if dec_way == "true" {
  6423. tmpstring := strconv.FormatInt(order.ID, 10)
  6424. order.Decimal = decimal
  6425. service.UpDateOrder(order)
  6426. //扣押金
  6427. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6428. if errmsg != nil {
  6429. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6430. return
  6431. }
  6432. }
  6433. c.ServeSuccessJSON(map[string]interface{}{
  6434. "msg": "结算成功",
  6435. })
  6436. } else {
  6437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6438. return
  6439. }
  6440. }
  6441. } else {
  6442. adminUser := c.GetAdminUserInfo()
  6443. errlog := &models.HisOrderError{
  6444. UserOrgId: adminUser.CurrentOrgId,
  6445. Ctime: time.Now().Unix(),
  6446. Mtime: time.Now().Unix(),
  6447. ErrMsg: res.ErrMsg,
  6448. Status: 1,
  6449. PatientId: id,
  6450. RecordTime: recordDateTime,
  6451. Stage: 4,
  6452. }
  6453. service.CreateErrMsgLog(errlog)
  6454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6455. return
  6456. }
  6457. } else {
  6458. adminUser := c.GetAdminUserInfo()
  6459. errlog := &models.HisOrderError{
  6460. UserOrgId: adminUser.CurrentOrgId,
  6461. Ctime: time.Now().Unix(),
  6462. Mtime: time.Now().Unix(),
  6463. ErrMsg: res.ErrMsg,
  6464. Status: 1,
  6465. PatientId: id,
  6466. RecordTime: recordDateTime,
  6467. Stage: 4,
  6468. }
  6469. service.CreateErrMsgLog(errlog)
  6470. c.ServeSuccessJSON(map[string]interface{}{
  6471. "failed_code": -10,
  6472. "msg": res.ErrMsg,
  6473. })
  6474. return
  6475. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6476. //return
  6477. }
  6478. }
  6479. }
  6480. } else if tempOrder.ID > 0 {
  6481. if tempOrder.IsPre == 1 {
  6482. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6483. var rf []*ResultFive
  6484. json.Unmarshal([]byte(his.Iinfo), &rf)
  6485. chrg_bchno := tempOrder.Number
  6486. cert_no := his.Certno
  6487. var insutypes []string
  6488. var insutype string
  6489. var is390 int = 0
  6490. var is310 int = 0
  6491. for _, item := range rf {
  6492. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6493. insutypes = append(insutypes, item.Insutype)
  6494. }
  6495. }
  6496. if len(insutypes) == 1 {
  6497. insutype = insutypes[0]
  6498. } else {
  6499. for _, i := range insutypes {
  6500. if i == "390" {
  6501. is390 = 1
  6502. }
  6503. if i == "310" {
  6504. is310 = 1
  6505. }
  6506. }
  6507. }
  6508. if is390 == 1 {
  6509. insutype = "390"
  6510. }
  6511. if is310 == 1 {
  6512. insutype = "310"
  6513. }
  6514. if len(insutypes) == 0 {
  6515. insutype = "310"
  6516. }
  6517. if len(insutypes) == 2 {
  6518. insutype = strconv.FormatInt(his.SocialType, 64)
  6519. }
  6520. //insutype = "390"
  6521. if his.IdCardType == 1 {
  6522. // cert_no = his.MedicalInsuranceNumber
  6523. cert_no = his.Certno
  6524. } else {
  6525. cert_no = his.Certno
  6526. }
  6527. var res ResultSeven
  6528. var resSeven10265 ResultSeven10265
  6529. var src_resquest string
  6530. var result2 string
  6531. var acct_used_flag string
  6532. fmt.Println("pay_way")
  6533. fmt.Println(pay_way)
  6534. fmt.Println("pay_way")
  6535. if pay_way == 4 {
  6536. acct_used_flag = "1"
  6537. } else {
  6538. acct_used_flag = "0"
  6539. }
  6540. if miConfig.MdtrtareaAdmvs == "421300" {
  6541. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6542. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6543. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6544. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6545. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6546. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6547. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6548. resp, requestErr := http.Get(api)
  6549. if requestErr != nil {
  6550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6551. return
  6552. }
  6553. body, ioErr := ioutil.ReadAll(resp.Body)
  6554. if ioErr != nil {
  6555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. return
  6558. }
  6559. var respJSON map[string]interface{}
  6560. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6563. return
  6564. }
  6565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6566. result, _ := json.Marshal(respJSON)
  6567. fmt.Println("log")
  6568. fmt.Println(string(result))
  6569. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6570. utils.ErrorLog("解析失败:%v", err)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. return
  6573. }
  6574. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6575. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  6576. if result3101.Infcode == "0" {
  6577. if len(result3101.Output.Result) > 0 {
  6578. var errMsgs []string
  6579. for _, item := range result3101.Output.Result {
  6580. errMsgs = append(errMsgs, item.VolaCont)
  6581. }
  6582. c.ServeSuccessJSON(map[string]interface{}{
  6583. "failed_code": -10,
  6584. "msg": errMsgs,
  6585. })
  6586. return
  6587. } else {
  6588. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6589. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6590. //psn_info, _ := service.GetPsnByPatientId(id)
  6591. bas := strings.Split(psn_info.CardInfo, "|")
  6592. if his.IdCardType == 1 {
  6593. cert_no = bas[2]
  6594. } else {
  6595. cert_no = bas[1]
  6596. }
  6597. //江苏地区国家医保医疗类别
  6598. //职工透析:医疗类别选特殊情况门诊9933
  6599. //居民血透门慢: 医疗类别选门诊慢病1402
  6600. //var med_type string
  6601. //if his.Insutype == "310" {
  6602. // if reg_type == 14 {
  6603. // med_type = "9933"
  6604. // } else if reg_type == 11 {
  6605. // med_type = "11"
  6606. //
  6607. // }
  6608. //} else if his.Insutype == "390" {
  6609. // if reg_type == 14 {
  6610. // med_type = "1402"
  6611. // } else if reg_type == 11 {
  6612. // med_type = "11"
  6613. // }
  6614. //}
  6615. var api string
  6616. if miConfig.MdtrtareaAdmvs == "320921" {
  6617. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6618. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6619. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6620. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6621. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6622. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6623. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  6624. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6625. } else {
  6626. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6627. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6628. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6629. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6630. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6631. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6632. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6633. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  6634. }
  6635. resp, requestErr := http.Get(api)
  6636. if requestErr != nil {
  6637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6638. return
  6639. }
  6640. body, ioErr := ioutil.ReadAll(resp.Body)
  6641. if ioErr != nil {
  6642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6644. return
  6645. }
  6646. var respJSON map[string]interface{}
  6647. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6650. return
  6651. }
  6652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6653. result, _ := json.Marshal(respJSON)
  6654. fmt.Println("log")
  6655. fmt.Println(string(result))
  6656. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6657. utils.ErrorLog("解析失败:%v", err)
  6658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6659. return
  6660. }
  6661. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6662. res.Output = resSeven10265.Output
  6663. res.ErrMsg = resSeven10265.ErrMsg
  6664. res.Cainfo = resSeven10265.Cainfo
  6665. res.WarnMsg = resSeven10265.WarnMsg
  6666. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6667. res.Infcode = infocode
  6668. }
  6669. }
  6670. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6671. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6672. var cert_no string
  6673. if his.IdCardType == 1 {
  6674. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6675. }
  6676. fmt.Println(cert_no)
  6677. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6678. var dat map[string]interface{}
  6679. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6680. fmt.Println(dat)
  6681. } else {
  6682. fmt.Println(err)
  6683. }
  6684. saveLog(result2, src_resquest, "2207", "结算")
  6685. userJSONBytes, _ := json.Marshal(dat)
  6686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6687. utils.ErrorLog("解析失败:%v", err)
  6688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6689. return
  6690. }
  6691. } else {
  6692. var src_resquest string
  6693. if miConfig.Code == "H15049901371" {
  6694. //赤峰地区国家医保医疗类别
  6695. //职工透析:医疗类别选特殊情况门诊990502
  6696. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6697. var med_type string
  6698. if his.Insutype == "390" {
  6699. if reg_type == 14 {
  6700. med_type = "9933"
  6701. } else if reg_type == 11 {
  6702. med_type = "11"
  6703. }
  6704. } else if his.Insutype == "310" {
  6705. if reg_type == 14 {
  6706. med_type = "990502"
  6707. } else if reg_type == 11 {
  6708. med_type = "11"
  6709. }
  6710. }
  6711. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  6712. } else {
  6713. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  6714. }
  6715. var dat map[string]interface{}
  6716. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6717. fmt.Println(dat)
  6718. } else {
  6719. fmt.Println(err)
  6720. }
  6721. saveLog(result2, src_resquest, "2207", "结算")
  6722. userJSONBytes, _ := json.Marshal(dat)
  6723. if miConfig.Code == "H15049901371" {
  6724. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6725. utils.ErrorLog("解析失败:%v", err)
  6726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6727. return
  6728. }
  6729. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6730. res.Output = resSeven10265.Output
  6731. res.ErrMsg = resSeven10265.ErrMsg
  6732. res.Cainfo = resSeven10265.Cainfo
  6733. res.WarnMsg = resSeven10265.WarnMsg
  6734. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6735. res.Infcode = infocode
  6736. } else {
  6737. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6738. utils.ErrorLog("解析失败:%v", err)
  6739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6740. return
  6741. }
  6742. }
  6743. }
  6744. if res.Infcode != 0 {
  6745. errlog := &models.HisOrderError{
  6746. UserOrgId: adminUser.CurrentOrgId,
  6747. Ctime: time.Now().Unix(),
  6748. Mtime: time.Now().Unix(),
  6749. Number: chrg_bchno,
  6750. ErrMsg: res.ErrMsg,
  6751. Status: 1,
  6752. PatientId: id,
  6753. RecordTime: recordDateTime,
  6754. Stage: 6,
  6755. }
  6756. service.CreateErrMsgLog(errlog)
  6757. c.ServeSuccessJSON(map[string]interface{}{
  6758. "failed_code": -10,
  6759. "msg": res.ErrMsg,
  6760. })
  6761. return
  6762. } else {
  6763. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6764. order.OrderStatus = 2
  6765. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6766. order.SetlId = res.Output.Setlinfo.SetlID
  6767. order.PsnNo = res.Output.Setlinfo.PsnNo
  6768. order.PsnName = res.Output.Setlinfo.PsnName
  6769. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6770. order.Certno = res.Output.Setlinfo.Certno
  6771. order.Gend = res.Output.Setlinfo.Gend
  6772. order.Naty = res.Output.Setlinfo.Naty
  6773. order.Age = res.Output.Setlinfo.Age
  6774. order.Insutype = res.Output.Setlinfo.Insutype
  6775. order.PsnType = res.Output.Setlinfo.PsnType
  6776. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6777. order.SetlTime = res.Output.Setlinfo.SetlTime
  6778. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6779. //order.MedType = res.Output.Setlinfo.MedType
  6780. if reg_type == 1112 {
  6781. order.MedType = "1112"
  6782. }
  6783. if reg_type == 1111 {
  6784. order.MedType = "1111"
  6785. }
  6786. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6787. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6788. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6789. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6790. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6791. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6792. order.HifpPay = res.Output.Setlinfo.HifpPay
  6793. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6794. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6795. order.HifesPay = res.Output.Setlinfo.HifesPay
  6796. order.HifobPay = res.Output.Setlinfo.HifobPay
  6797. order.MafPay = res.Output.Setlinfo.MafPay
  6798. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6799. order.OthPay = res.Output.Setlinfo.OthPay
  6800. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6801. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6802. order.AcctPay = res.Output.Setlinfo.AcctPay
  6803. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6804. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6805. order.Balc = res.Output.Setlinfo.Balc
  6806. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6807. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6808. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6809. order.ClrWay = res.Output.Setlinfo.ClrWay
  6810. order.Creator = order.Creator
  6811. order.Modify = roles.AdminUserId
  6812. order.RequestLog = src_resquest
  6813. order.Diagnosis = diagnosis_id
  6814. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6815. detailStr := string(setlDetail)
  6816. order.SetlDetail = detailStr
  6817. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6818. err = service.UpDateOrder(order)
  6819. if err == nil {
  6820. //判断是否使用了押金
  6821. if dec_way == "true" {
  6822. tmpstring := strconv.FormatInt(order.ID, 10)
  6823. //扣押金
  6824. order.Decimal = decimal
  6825. service.UpDateOrder(order)
  6826. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6827. if errmsg != nil {
  6828. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6829. return
  6830. }
  6831. }
  6832. c.ServeSuccessJSON(map[string]interface{}{
  6833. "msg": "结算成功",
  6834. })
  6835. } else {
  6836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6837. return
  6838. }
  6839. }
  6840. }
  6841. }
  6842. }
  6843. //func (c *HisApiController) GetPreUploadInfo() {
  6844. // id, _ := c.GetInt64("id")
  6845. // record_time := c.GetString("record_time")
  6846. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6847. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6848. //
  6849. // timeLayout := "2006-01-02"
  6850. // loc, _ := time.LoadLocation("Local")
  6851. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6852. // if err != nil {
  6853. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6854. // return
  6855. // }
  6856. // recordDateTime := theTime.Unix()
  6857. // adminUser := c.GetAdminUserInfo()
  6858. //
  6859. // var prescriptions []*models.HisPrescription
  6860. //
  6861. // var start_time int64
  6862. // var end_time int64
  6863. //
  6864. // data := make(map[string]interface{})
  6865. // if settle_accounts_type == 1 { //日结
  6866. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6867. // data["pre"] = prescriptions
  6868. //
  6869. // } else { //月结
  6870. // start_time_str := c.GetString("start_time")
  6871. // end_time_str := c.GetString("end_time")
  6872. // timeLayout := "2006-01-02"
  6873. // loc, _ := time.LoadLocation("Local")
  6874. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6875. // if err != nil {
  6876. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6877. // return
  6878. // }
  6879. // recordStartTime := theStartTime.Unix()
  6880. // start_time = recordStartTime
  6881. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6882. // if err != nil {
  6883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6884. // return
  6885. // }
  6886. // recordEndTime := theEndTime.Unix()
  6887. // end_time = recordEndTime
  6888. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6889. // data["pre"] = prescriptions
  6890. //
  6891. // }
  6892. //
  6893. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6894. //
  6895. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6896. // timestamp := time.Now().Unix()
  6897. // tempTime := time.Unix(timestamp, 0)
  6898. // timeFormat := tempTime.Format("20060102150405")
  6899. // chrgBchno := rand.Intn(100000) + 10000
  6900. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6901. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6902. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6903. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6904. // strconv.FormatInt(his.PatientId, 10)
  6905. // client := &http.Client{}
  6906. // data["psn_no"] = his.PsnNo
  6907. // data["mdtrt_id"] = his.Number
  6908. // data["chrg_bchno"] = chrg_bchno
  6909. // data["org_name"] = miConfig.OrgName
  6910. // data["doctor"] = roles.UserName
  6911. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6912. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6913. // data["fixmedins_code"] = miConfig.Code
  6914. // data["dept_code"] = department.Number
  6915. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6916. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6917. // data["secret_key"] = miConfig.SecretKey
  6918. // var ids []int64
  6919. //
  6920. // for _, item := range prescriptions {
  6921. // ids = append(ids, item.ID)
  6922. // }
  6923. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6924. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6925. // bytesData, _ := json.Marshal(data)
  6926. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6927. // resp, _ := client.Do(req)
  6928. // defer resp.Body.Close()
  6929. // body, ioErr := ioutil.ReadAll(resp.Body)
  6930. // if ioErr != nil {
  6931. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6933. // return
  6934. // }
  6935. // var respJSON map[string]interface{}
  6936. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6937. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6939. // return
  6940. // }
  6941. //
  6942. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6943. // userJSONBytes, _ := json.Marshal(respJSON)
  6944. // var res ResultFour
  6945. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6946. // utils.ErrorLog("解析失败:%v", err)
  6947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. // return
  6949. // }
  6950. //
  6951. // if res.Infcode == 0 {
  6952. // order := &models.HisOrder{
  6953. // UserOrgId: adminUser.CurrentOrgId,
  6954. // HisPatientId: his.ID,
  6955. // PatientId: his.PatientId,
  6956. // SettleAccountsDate: recordDateTime,
  6957. // Ctime: time.Now().Unix(),
  6958. // Mtime: time.Now().Unix(),
  6959. // Status: 1,
  6960. // Number: chrg_bchno,
  6961. // Infcode: res.Infcode,
  6962. // WarnMsg: res.WarnMsg,
  6963. // Cainfo: res.Cainfo,
  6964. // ErrMsg: res.ErrMsg,
  6965. // RespondTime: res.RefmsgTime,
  6966. // InfRefmsgid: res.InfRefmsgid,
  6967. // OrderStatus: 1,
  6968. // IsMedicineInsurance: 1,
  6969. // SettleType: settle_accounts_type,
  6970. // SettleStartTime: start_time,
  6971. // SettleEndTime: end_time,
  6972. // Creator: roles.ID,
  6973. // Modify: roles.ID,
  6974. // PType: 2,
  6975. // }
  6976. // err = service.CreateOrder(order)
  6977. // if err != nil {
  6978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6979. // return
  6980. // }
  6981. //
  6982. // for _, item := range res.Output.Result {
  6983. // temp := strings.Split(item.FeedetlSn, "-")
  6984. // var advice_id int64 = 0
  6985. // var project_id int64 = 0
  6986. // var types int64 = 0
  6987. //
  6988. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6989. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6990. //
  6991. // if temp[1] == "1" {
  6992. // advice_id = id
  6993. // project_id = 0
  6994. // } else if temp[1] == "2" {
  6995. // advice_id = 0
  6996. // project_id = id
  6997. // }
  6998. //
  6999. // info := &models.HisOrderInfo{
  7000. // OrderNumber: order.Number,
  7001. // FeedetlSn: item.FeedetlSn,
  7002. // UploadDate: time.Now().Unix(),
  7003. // AdviceId: advice_id,
  7004. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  7005. // Cnt: item.Cnt,
  7006. // Pric: float64(item.Pric),
  7007. // PatientId: his.PatientId,
  7008. // PricUplmtAmt: item.PricUplmtAmt,
  7009. // SelfpayProp: item.SelfpayProp,
  7010. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7011. // OverlmtAmt: item.OverlmtAmt,
  7012. // PreselfpayAmt: item.PreselfpayAmt,
  7013. // BasMednFlag: item.BasMednFlag,
  7014. // MedChrgitmType: item.MedChrgitmType,
  7015. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  7016. // Status: 1,
  7017. // Memo: item.Memo,
  7018. // Mtime: time.Now().Unix(),
  7019. // InscpScpAmt: item.InscpScpAmt,
  7020. // DrtReimFlag: item.DrtReimFlag,
  7021. // Ctime: time.Now().Unix(),
  7022. // ListSpItemFlag: item.ListSpItemFlag,
  7023. // ChldMedcFlag: item.ChldMedcFlag,
  7024. // LmtUsedFlag: item.LmtUsedFlag,
  7025. // ChrgitmLv: item.ChrgitmLv,
  7026. // UserOrgId: adminUser.CurrentOrgId,
  7027. // HisPatientId: his.ID,
  7028. // OrderId: order.ID,
  7029. // ProjectId: project_id,
  7030. // Type: types,
  7031. // }
  7032. // service.CreateOrderInfo(info)
  7033. //
  7034. // }
  7035. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7036. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7037. //
  7038. // var total float64
  7039. // for _, item := range prescriptions {
  7040. // if item.Type == 1 { //药品
  7041. // for _, subItem := range item.HisDoctorAdviceInfo {
  7042. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7043. // }
  7044. // }
  7045. // if item.Type == 2 { //项目
  7046. // for _, subItem := range item.HisPrescriptionProject {
  7047. // total = total + (subItem.Price * float64(subItem.Count))
  7048. // }
  7049. // }
  7050. // }
  7051. //
  7052. // for _, item := range prescriptions {
  7053. // for _, subItem := range item.HisAdditionalCharge {
  7054. // total = total + (subItem.Price * float64(subItem.Count))
  7055. // }
  7056. // }
  7057. //
  7058. // allTotal := fmt.Sprintf("%.2f", total)
  7059. // if res.Infcode == 0 {
  7060. // var rf []*ResultFive
  7061. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7062. // psn_no := his.PsnNo
  7063. // mdtrt_id := his.Number
  7064. // chrg_bchno := chrg_bchno
  7065. // cert_no := his.Certno
  7066. // insutype := rf[0].Insutype
  7067. //
  7068. // if his.IdCardType == 1 {
  7069. // cert_no = his.MedicalInsuranceNumber
  7070. //
  7071. // } else {
  7072. //
  7073. // cert_no = his.Certno
  7074. //
  7075. // }
  7076. //
  7077. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7078. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7079. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7080. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7081. // resp, requestErr := http.Get(api)
  7082. // if requestErr != nil {
  7083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7084. // return
  7085. // }
  7086. // defer resp.Body.Close()
  7087. // body, ioErr := ioutil.ReadAll(resp.Body)
  7088. // if ioErr != nil {
  7089. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. // return
  7092. // }
  7093. // var respJSON map[string]interface{}
  7094. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7095. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7097. // return
  7098. // }
  7099. // fmt.Println(respJSON)
  7100. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7101. // userJSONBytes, _ := json.Marshal(respJSON)
  7102. // var res ResultSeven
  7103. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7104. // utils.ErrorLog("解析失败:%v", err)
  7105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7106. // return
  7107. // }
  7108. // if res.Infcode != 0 {
  7109. // errlog := &models.HisOrderError{
  7110. // UserOrgId: adminUser.CurrentOrgId,
  7111. // Ctime: time.Now().Unix(),
  7112. // Mtime: time.Now().Unix(),
  7113. // Number: chrg_bchno,
  7114. // ErrMsg: res.ErrMsg,
  7115. // Status: 1,
  7116. // PatientId: id,
  7117. // RecordTime: recordDateTime,
  7118. // Stage: 7,
  7119. // }
  7120. // service.CreateErrMsgLog(errlog)
  7121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7122. // return
  7123. // } else {
  7124. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7125. // order.OrderStatus = 1
  7126. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7127. // order.SetlId = res.Output.Setlinfo.SetlID
  7128. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7129. // order.PsnName = res.Output.Setlinfo.PsnName
  7130. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7131. // order.Certno = res.Output.Setlinfo.Certno
  7132. // order.Gend = res.Output.Setlinfo.Gend
  7133. // order.Naty = res.Output.Setlinfo.Naty
  7134. // order.Age = res.Output.Setlinfo.Age
  7135. // order.Insutype = res.Output.Setlinfo.Insutype
  7136. // order.PsnType = res.Output.Setlinfo.PsnType
  7137. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7138. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7139. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7140. // order.MedType = res.Output.Setlinfo.MedType
  7141. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7142. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7143. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7144. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7145. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7146. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7147. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7148. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7149. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7150. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7151. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7152. // order.MafPay = res.Output.Setlinfo.MafPay
  7153. // order.OthPay = res.Output.Setlinfo.OthPay
  7154. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7155. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7156. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7157. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7158. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7159. // order.Balc = res.Output.Setlinfo.Balc
  7160. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7161. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7162. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7163. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7164. // order.Creator = order.Creator
  7165. // order.Modify = roles.ID
  7166. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7167. // detailStr := string(setlDetail)
  7168. // order.SetlDetail = detailStr
  7169. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7170. // err = service.UpDateOrder(order)
  7171. // if err == nil {
  7172. // c.ServeSuccessJSON(map[string]interface{}{
  7173. // "msg": "预结算成功",
  7174. // })
  7175. // } else {
  7176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7177. // return
  7178. // }
  7179. // }
  7180. // } else {
  7181. // adminUser := c.GetAdminUserInfo()
  7182. // errlog := &models.HisOrderError{
  7183. // UserOrgId: adminUser.CurrentOrgId,
  7184. // Ctime: time.Now().Unix(),
  7185. // Mtime: time.Now().Unix(),
  7186. // ErrMsg: res.ErrMsg,
  7187. // Status: 1,
  7188. // PatientId: id,
  7189. // RecordTime: recordDateTime,
  7190. // Stage: 4,
  7191. // }
  7192. // service.CreateErrMsgLog(errlog)
  7193. //
  7194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7195. // return
  7196. // }
  7197. // } else {
  7198. // adminUser := c.GetAdminUserInfo()
  7199. // errlog := &models.HisOrderError{
  7200. // UserOrgId: adminUser.CurrentOrgId,
  7201. // Ctime: time.Now().Unix(),
  7202. // Mtime: time.Now().Unix(),
  7203. // ErrMsg: res.ErrMsg,
  7204. // Status: 1,
  7205. // PatientId: id,
  7206. // RecordTime: recordDateTime,
  7207. // Stage: 4,
  7208. // }
  7209. // service.CreateErrMsgLog(errlog)
  7210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7211. // return
  7212. // }
  7213. //
  7214. // } else {
  7215. // var total float64
  7216. // for _, item := range prescriptions {
  7217. // if item.Type == 1 { //药品
  7218. // for _, subItem := range item.HisDoctorAdviceInfo {
  7219. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7220. // }
  7221. // }
  7222. // if item.Type == 2 { //项目
  7223. // for _, subItem := range item.HisPrescriptionProject {
  7224. // total = total + (subItem.Price * float64(subItem.Count))
  7225. // }
  7226. // }
  7227. //
  7228. // for _, subItem := range item.HisAdditionalCharge {
  7229. // total = total + (subItem.Price * float64(subItem.Count))
  7230. // }
  7231. // }
  7232. //
  7233. // allTotal := fmt.Sprintf("%.2f", total)
  7234. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7235. // order := &models.HisOrder{
  7236. // UserOrgId: adminUser.CurrentOrgId,
  7237. // HisPatientId: his.ID,
  7238. // PatientId: id,
  7239. // SettleAccountsDate: recordDateTime,
  7240. // Ctime: time.Now().Unix(),
  7241. // Mtime: time.Now().Unix(),
  7242. // Status: 1,
  7243. // OrderStatus: 2,
  7244. // Number: chrg_bchno,
  7245. // MedfeeSumamt: totals,
  7246. // }
  7247. // err = service.CreateOrder(order)
  7248. // if err != nil {
  7249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7250. // return
  7251. // }
  7252. //
  7253. // var customs []*Custom
  7254. // for _, item := range prescriptions {
  7255. //
  7256. // if item.Type == 1 { //药品
  7257. // for _, subItem := range item.HisDoctorAdviceInfo {
  7258. // cus := &Custom{
  7259. // AdviceId: subItem.ID,
  7260. // ProjectId: 0,
  7261. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7262. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7263. // FeedetlSn: subItem.FeedetlSn,
  7264. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7265. // MedListCodg: subItem.MedListCodg,
  7266. // Type: 1,
  7267. // }
  7268. // customs = append(customs, cus)
  7269. // }
  7270. // }
  7271. //
  7272. // if item.Type == 2 { //项目
  7273. // for _, subItem := range item.HisPrescriptionProject {
  7274. //
  7275. // cus := &Custom{
  7276. // AdviceId: 0,
  7277. // ProjectId: subItem.ID,
  7278. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7279. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7280. // FeedetlSn: subItem.FeedetlSn,
  7281. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7282. // MedListCodg: subItem.MedListCodg,
  7283. // Type: 2,
  7284. // }
  7285. //
  7286. // customs = append(customs, cus)
  7287. // }
  7288. // }
  7289. //
  7290. // for _, item := range item.HisAdditionalCharge {
  7291. // cus := &Custom{
  7292. // ItemId: item.ID,
  7293. // AdviceId: 0,
  7294. // ProjectId: 0,
  7295. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7296. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7297. // FeedetlSn: item.FeedetlSn,
  7298. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7299. // MedListCodg: item.XtHisAddtionConfig.Code,
  7300. // Type: 3,
  7301. // }
  7302. //
  7303. // customs = append(customs, cus)
  7304. // }
  7305. //
  7306. // }
  7307. //
  7308. // for _, item := range customs {
  7309. // var advice_id int64 = 0
  7310. // var project_id int64 = 0
  7311. // var item_id int64 = 0
  7312. //
  7313. // var types int64 = 0
  7314. //
  7315. // if item.Type == 1 {
  7316. // advice_id = item.AdviceId
  7317. // project_id = 0
  7318. // item_id = 0
  7319. // } else if item.Type == 2 {
  7320. // advice_id = 0
  7321. // item_id = 0
  7322. //
  7323. // project_id = item.ProjectId
  7324. // } else if item.Type == 3 {
  7325. // advice_id = 0
  7326. // item_id = item.ItemId
  7327. // project_id = 0
  7328. // }
  7329. //
  7330. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7331. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7332. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7333. //
  7334. // info := &models.HisOrderInfo{
  7335. // OrderNumber: order.Number,
  7336. // UploadDate: time.Now().Unix(),
  7337. // AdviceId: advice_id,
  7338. // DetItemFeeSumamt: detItemFeeSumamt,
  7339. // Cnt: cut,
  7340. // Pric: pric,
  7341. // PatientId: id,
  7342. // Status: 1,
  7343. // Mtime: time.Now().Unix(),
  7344. // Ctime: time.Now().Unix(),
  7345. // UserOrgId: adminUser.CurrentOrgId,
  7346. // HisPatientId: his.ID,
  7347. // OrderId: order.ID,
  7348. // ProjectId: project_id,
  7349. // Type: types,
  7350. // ItemId: item_id,
  7351. // }
  7352. // service.CreateOrderInfo(info)
  7353. // }
  7354. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7355. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7356. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7357. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7358. // if err == nil {
  7359. // c.ServeSuccessJSON(map[string]interface{}{
  7360. // "msg": "结算成功",
  7361. // })
  7362. // } else {
  7363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7364. // return
  7365. // }
  7366. // }
  7367. //}
  7368. //上传明细-预结算-
  7369. func (c *HisApiController) GetPreUploadInfo() {
  7370. id, _ := c.GetInt64("id")
  7371. record_time := c.GetString("record_time")
  7372. his_patient_id, _ := c.GetInt64("his_patient_id")
  7373. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7374. admin_user_id, _ := c.GetInt64("admin_user_id")
  7375. diagnosis_id := c.GetString("diagnosis")
  7376. sick_type, _ := c.GetInt64("sick_type")
  7377. reg_type, _ := c.GetInt64("p_type")
  7378. begin_time := c.GetString("begin_time")
  7379. id_str := c.GetString("ids")
  7380. ids_arr := strings.Split(id_str, ",")
  7381. timeLayout := "2006-01-02"
  7382. loc, _ := time.LoadLocation("Local")
  7383. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7384. if err != nil {
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7386. return
  7387. }
  7388. recordDateTime := theTime.Unix()
  7389. adminUser := c.GetAdminUserInfo()
  7390. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7391. var config []*models.HisXtDiagnoseConfig
  7392. for _, item := range diagnosis_ids {
  7393. id, _ := strconv.ParseInt(item, 10, 64)
  7394. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7395. config = append(config, &diagnosisConfig)
  7396. }
  7397. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7398. sickConfig, _ := service.FindSickById(sick_type)
  7399. var prescriptions []*models.HisPrescription
  7400. var start_time int64
  7401. var end_time int64
  7402. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7403. fmt.Println(his_patient_id)
  7404. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7405. timestamp := time.Now().Unix()
  7406. tempTime := time.Unix(timestamp, 0)
  7407. timeFormat := tempTime.Format("20060102150405")
  7408. chrgBchno := rand.Intn(100000) + 10000
  7409. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7410. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7411. var patientPrescription models.HisPrescriptionInfo
  7412. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7413. if patientPrescription.ID == 0 {
  7414. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7415. }
  7416. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7417. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7418. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7419. strconv.FormatInt(his.PatientId, 10)
  7420. var res2 ResultSix
  7421. var resSix10265 ResultSix10265
  7422. var time_stamp string
  7423. if miConfig.MdtrtareaAdmvs == "421300" {
  7424. data := make(map[string]interface{})
  7425. client := &http.Client{}
  7426. data["psn_no"] = his.PsnNo
  7427. data["mdtrt_id"] = his.Number
  7428. data["department"] = department.Name
  7429. data["org_name"] = miConfig.OrgName
  7430. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7431. data["doctor_id"] = doctor_info.DoctorNumber
  7432. data["doctor_name"] = roles.UserName
  7433. data["fixmedins_code"] = miConfig.Code
  7434. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7435. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7436. data["secret_key"] = miConfig.SecretKey
  7437. data["sick_code"] = sickConfig.CountryCode
  7438. data["sick_name"] = sickConfig.ClassName
  7439. data["begin_time"] = begin_time
  7440. data["dept"] = strconv.FormatInt(department.ID, 10)
  7441. data["config"] = config
  7442. data["opter"] = roles.UserName
  7443. fmt.Println(data)
  7444. bytesData, _ := json.Marshal(data)
  7445. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7446. resp, _ := client.Do(req)
  7447. defer resp.Body.Close()
  7448. body, ioErr := ioutil.ReadAll(resp.Body)
  7449. if ioErr != nil {
  7450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7452. return
  7453. }
  7454. var respJSON map[string]interface{}
  7455. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7458. return
  7459. }
  7460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7461. userJSONBytes, _ := json.Marshal(respJSON)
  7462. fmt.Println("log")
  7463. fmt.Println(string(userJSONBytes))
  7464. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7465. utils.ErrorLog("解析失败:%v", err)
  7466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7467. return
  7468. }
  7469. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7470. data := make(map[string]interface{})
  7471. client := &http.Client{}
  7472. data["psn_no"] = his.PsnNo
  7473. data["mdtrt_id"] = his.Number
  7474. data["doctor"] = roles.UserName
  7475. data["department"] = department.Name
  7476. data["org_name"] = miConfig.OrgName
  7477. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7478. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7479. data["fixmedins_code"] = miConfig.Code
  7480. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7481. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7482. data["secret_key"] = miConfig.SecretKey
  7483. data["sick_code"] = sickConfig.CountryCode
  7484. data["sick_name"] = sickConfig.ClassName
  7485. data["begin_time"] = begin_time
  7486. data["dept"] = strconv.FormatInt(department.ID, 10)
  7487. data["config"] = config
  7488. data["url"] = miConfig.Url
  7489. data["ak"] = miConfig.AccessKey
  7490. data["cainfo"] = miConfig.Cainfo
  7491. bytesData, _ := json.Marshal(data)
  7492. var req *http.Request
  7493. if miConfig.MdtrtareaAdmvs == "320921" {
  7494. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7495. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  7496. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7497. } else {
  7498. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7499. }
  7500. resp, _ := client.Do(req)
  7501. defer resp.Body.Close()
  7502. body, ioErr := ioutil.ReadAll(resp.Body)
  7503. if ioErr != nil {
  7504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7506. return
  7507. }
  7508. var respJSON map[string]interface{}
  7509. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7512. return
  7513. }
  7514. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7515. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7516. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7518. userJSONBytes, _ := json.Marshal(respJSON)
  7519. fmt.Println("log")
  7520. fmt.Println(string(userJSONBytes))
  7521. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7522. utils.ErrorLog("解析失败:%v", err)
  7523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7524. return
  7525. }
  7526. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7527. res2.Output = resSix10265.Output
  7528. res2.ErrMsg = resSix10265.ErrMsg
  7529. res2.Cainfo = resSix10265.Cainfo
  7530. res2.WarnMsg = resSix10265.WarnMsg
  7531. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7532. res2.Infcode = infocode
  7533. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7534. result, requestLog, _ := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7535. saveLog(result, requestLog, "2203", "上传就诊信息")
  7536. var respJSON2 map[string]interface{}
  7537. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. userJSONBytes2, _ := json.Marshal(respJSON2)
  7543. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7544. utils.ErrorLog("解析失败:%v", err)
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7546. return
  7547. }
  7548. } else {
  7549. var result string
  7550. var requestLog string
  7551. if miConfig.MdtrtareaAdmvs == "440781" { //
  7552. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  7553. } else {
  7554. if miConfig.Code == "H15049901371" {
  7555. //赤峰地区国家医保医疗类别
  7556. //职工透析:医疗类别选特殊情况门诊990502
  7557. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7558. var med_type string
  7559. if his.Insutype == "390" {
  7560. if reg_type == 14 {
  7561. med_type = "9933"
  7562. } else if reg_type == 11 {
  7563. med_type = "11"
  7564. }
  7565. } else if his.Insutype == "310" {
  7566. if reg_type == 14 {
  7567. med_type = "990502"
  7568. } else if reg_type == 11 {
  7569. med_type = "11"
  7570. }
  7571. }
  7572. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  7573. } else {
  7574. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  7575. }
  7576. saveLog(result, requestLog, "2203", "上传就诊信息")
  7577. var respJSON2 map[string]interface{}
  7578. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7581. return
  7582. }
  7583. userJSONBytes2, _ := json.Marshal(respJSON2)
  7584. if miConfig.Code == "H15049901371" {
  7585. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7586. utils.ErrorLog("解析失败:%v", err)
  7587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7588. return
  7589. }
  7590. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7591. res2.Output = resSix10265.Output
  7592. res2.ErrMsg = resSix10265.ErrMsg
  7593. res2.Cainfo = resSix10265.Cainfo
  7594. res2.WarnMsg = resSix10265.WarnMsg
  7595. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7596. res2.Infcode = infocode
  7597. } else {
  7598. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7599. utils.ErrorLog("解析失败:%v", err)
  7600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7601. return
  7602. }
  7603. }
  7604. }
  7605. }
  7606. if res2.Infcode != 0 {
  7607. adminUser := c.GetAdminUserInfo()
  7608. errlog := &models.HisOrderError{
  7609. UserOrgId: adminUser.CurrentOrgId,
  7610. Ctime: time.Now().Unix(),
  7611. Mtime: time.Now().Unix(),
  7612. ErrMsg: res2.ErrMsg,
  7613. Status: 1,
  7614. PatientId: id,
  7615. RecordTime: recordDateTime,
  7616. Stage: 3,
  7617. }
  7618. service.CreateErrMsgLog(errlog)
  7619. c.ServeSuccessJSON(map[string]interface{}{
  7620. "failed_code": -10,
  7621. "msg": res2.ErrMsg,
  7622. })
  7623. return
  7624. } else {
  7625. his.Diagnosis = diagnosis_id
  7626. his.SickType = sickConfig.ID
  7627. his.PType = fmt.Sprintf("%d", reg_type)
  7628. service.UpdateHisPatientThree(&his)
  7629. data := make(map[string]interface{})
  7630. if settle_accounts_type == 1 { //日结
  7631. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7632. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7633. } else {
  7634. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7635. }
  7636. data["pre"] = prescriptions
  7637. } else { //月结
  7638. start_time_str := c.GetString("start_time")
  7639. end_time_str := c.GetString("end_time")
  7640. timeLayout := "2006-01-02"
  7641. loc, _ := time.LoadLocation("Local")
  7642. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7643. if err != nil {
  7644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7645. return
  7646. }
  7647. recordStartTime := theStartTime.Unix()
  7648. start_time = recordStartTime
  7649. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7650. if err != nil {
  7651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7652. return
  7653. }
  7654. recordEndTime := theEndTime.Unix()
  7655. end_time = recordEndTime
  7656. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7657. data["pre"] = prescriptions
  7658. }
  7659. client := &http.Client{}
  7660. data["psn_no"] = his.PsnNo
  7661. data["mdtrt_id"] = his.Number
  7662. data["chrg_bchno"] = chrg_bchno
  7663. data["org_name"] = miConfig.OrgName
  7664. data["doctor"] = roles.UserName
  7665. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7666. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7667. data["fixmedins_code"] = miConfig.Code
  7668. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7669. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7670. data["dept_code"] = "15"
  7671. } else {
  7672. data["dept_code"] = department.Number
  7673. }
  7674. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7675. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7676. data["secret_key"] = miConfig.SecretKey
  7677. data["url"] = miConfig.Url
  7678. data["ak"] = miConfig.AccessKey
  7679. data["new_doctor_name"] = patientPrescription.Doctor
  7680. data["diag_code"] = sickConfig.CountryCode
  7681. data["time_stamp"] = time_stamp
  7682. data["cainfo"] = miConfig.Cainfo
  7683. var ids []int64
  7684. for _, item := range prescriptions {
  7685. ids = append(ids, item.ID)
  7686. }
  7687. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7688. if config.IsOpen == 1 { //对接了医保,走医保流程
  7689. var res ResultFour
  7690. var resFour10265 ResultFour10265
  7691. if miConfig.MdtrtareaAdmvs == "421300" {
  7692. bytesData, _ := json.Marshal(data)
  7693. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7694. resp, _ := client.Do(req)
  7695. defer resp.Body.Close()
  7696. body, ioErr := ioutil.ReadAll(resp.Body)
  7697. if ioErr != nil {
  7698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. var respJSON map[string]interface{}
  7703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7706. return
  7707. }
  7708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7709. userJSONBytes, _ := json.Marshal(respJSON)
  7710. fmt.Println("log")
  7711. fmt.Println(string(userJSONBytes))
  7712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7713. utils.ErrorLog("解析失败:%v", err)
  7714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7715. return
  7716. }
  7717. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7718. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7719. if result3101.Infcode == "0" {
  7720. if len(result3101.Output.Result) > 0 {
  7721. var errMsgs []string
  7722. for _, item := range result3101.Output.Result {
  7723. errMsgs = append(errMsgs, item.VolaCont)
  7724. }
  7725. c.ServeSuccessJSON(map[string]interface{}{
  7726. "failed_code": -10,
  7727. "msg": errMsgs,
  7728. })
  7729. return
  7730. } else {
  7731. bytesData, _ := json.Marshal(data)
  7732. var req *http.Request
  7733. if miConfig.MdtrtareaAdmvs == "320921" {
  7734. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7735. } else {
  7736. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7737. }
  7738. resp, _ := client.Do(req)
  7739. defer resp.Body.Close()
  7740. body, ioErr := ioutil.ReadAll(resp.Body)
  7741. if ioErr != nil {
  7742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. return
  7745. }
  7746. var respJSON map[string]interface{}
  7747. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7750. return
  7751. }
  7752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7753. userJSONBytes, _ := json.Marshal(respJSON)
  7754. fmt.Println("log")
  7755. fmt.Println(string(userJSONBytes))
  7756. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7757. utils.ErrorLog("解析失败:%v", err)
  7758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7759. return
  7760. }
  7761. res.InfRefmsgid = resFour10265.InfRefmsgid
  7762. res.Output = resFour10265.Output
  7763. res.ErrMsg = resFour10265.ErrMsg
  7764. res.Cainfo = resFour10265.Cainfo
  7765. res.WarnMsg = resFour10265.WarnMsg
  7766. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7767. res.Infcode = infocode
  7768. }
  7769. }
  7770. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7771. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  7772. var dat map[string]interface{}
  7773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7774. fmt.Println(dat)
  7775. } else {
  7776. fmt.Println(err)
  7777. }
  7778. saveLog(result, request_log, "2204", "上传费用明细")
  7779. userJSONBytes, _ := json.Marshal(dat)
  7780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7781. utils.ErrorLog("解析失败:%v", err)
  7782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7783. return
  7784. }
  7785. } else {
  7786. if miConfig.Code == "H15049901371" {
  7787. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  7788. var dat map[string]interface{}
  7789. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7790. fmt.Println(dat)
  7791. } else {
  7792. fmt.Println(err)
  7793. }
  7794. saveLog(result, request_log, "2204", "上传费用明细")
  7795. userJSONBytes, _ := json.Marshal(dat)
  7796. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7797. utils.ErrorLog("解析失败:%v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. res.InfRefmsgid = resFour10265.InfRefmsgid
  7802. res.Output = resFour10265.Output
  7803. res.ErrMsg = resFour10265.ErrMsg
  7804. res.Cainfo = resFour10265.Cainfo
  7805. res.WarnMsg = resFour10265.WarnMsg
  7806. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7807. res.Infcode = infocode
  7808. } else {
  7809. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  7810. var dat map[string]interface{}
  7811. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7812. fmt.Println(dat)
  7813. } else {
  7814. fmt.Println(err)
  7815. }
  7816. saveLog(result, request_log, "2204", "上传费用明细")
  7817. userJSONBytes, _ := json.Marshal(dat)
  7818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7819. utils.ErrorLog("解析失败:%v", err)
  7820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7821. return
  7822. }
  7823. }
  7824. }
  7825. if res.Infcode == 0 {
  7826. order := &models.HisOrder{
  7827. UserOrgId: adminUser.CurrentOrgId,
  7828. HisPatientId: his.ID,
  7829. PatientId: his.PatientId,
  7830. SettleAccountsDate: recordDateTime,
  7831. Ctime: time.Now().Unix(),
  7832. Mtime: time.Now().Unix(),
  7833. MdtrtId: his.Number,
  7834. PsnNo: his.PsnNo,
  7835. MedType: strconv.FormatInt(reg_type, 10),
  7836. Status: 1,
  7837. Number: chrg_bchno,
  7838. Infcode: res.Infcode,
  7839. WarnMsg: res.WarnMsg,
  7840. Cainfo: res.Cainfo,
  7841. ErrMsg: res.ErrMsg,
  7842. RespondTime: res.RefmsgTime,
  7843. InfRefmsgid: res.InfRefmsgid,
  7844. OrderStatus: 1,
  7845. IsMedicineInsurance: 1,
  7846. SettleType: settle_accounts_type,
  7847. SettleStartTime: start_time,
  7848. SettleEndTime: end_time,
  7849. Creator: roles.AdminUserId,
  7850. Modify: roles.AdminUserId,
  7851. PType: 2,
  7852. Diagnosis: diagnosis_id,
  7853. }
  7854. err = service.CreateOrder(order)
  7855. if err != nil {
  7856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7857. return
  7858. }
  7859. for _, item := range res.Output.Result {
  7860. temp := strings.Split(item.FeedetlSn, "-")
  7861. var advice_id int64 = 0
  7862. var project_id int64 = 0
  7863. var types int64 = 0
  7864. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7865. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7866. if temp[1] == "1" {
  7867. advice_id = id
  7868. project_id = 0
  7869. } else if temp[1] == "2" {
  7870. advice_id = 0
  7871. project_id = id
  7872. }
  7873. info := &models.HisOrderInfo{
  7874. OrderNumber: order.Number,
  7875. FeedetlSn: item.FeedetlSn,
  7876. UploadDate: time.Now().Unix(),
  7877. AdviceId: advice_id,
  7878. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7879. Cnt: item.Cnt,
  7880. Pric: float64(item.Pric),
  7881. PatientId: his.PatientId,
  7882. PricUplmtAmt: item.PricUplmtAmt,
  7883. SelfpayProp: item.SelfpayProp,
  7884. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7885. OverlmtAmt: item.OverlmtAmt,
  7886. PreselfpayAmt: item.PreselfpayAmt,
  7887. BasMednFlag: item.BasMednFlag,
  7888. MedChrgitmType: item.MedChrgitmType,
  7889. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7890. Status: 1,
  7891. Memo: item.Memo,
  7892. Mtime: time.Now().Unix(),
  7893. InscpScpAmt: item.InscpScpAmt,
  7894. DrtReimFlag: item.DrtReimFlag,
  7895. Ctime: time.Now().Unix(),
  7896. ListSpItemFlag: item.ListSpItemFlag,
  7897. ChldMedcFlag: item.ChldMedcFlag,
  7898. LmtUsedFlag: item.LmtUsedFlag,
  7899. ChrgitmLv: item.ChrgitmLv,
  7900. UserOrgId: adminUser.CurrentOrgId,
  7901. HisPatientId: his.ID,
  7902. OrderId: order.ID,
  7903. ProjectId: project_id,
  7904. Type: types,
  7905. }
  7906. service.CreateOrderInfo(info)
  7907. }
  7908. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7909. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7910. var total float64
  7911. for _, item := range prescriptions {
  7912. if item.Type == 1 { //药品
  7913. for _, subItem := range item.HisDoctorAdviceInfo {
  7914. total = total + (subItem.Price * subItem.PrescribingNumber)
  7915. }
  7916. }
  7917. if item.Type == 2 { //项目
  7918. for _, subItem := range item.HisPrescriptionProject {
  7919. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7920. total = total + (subItem.Price * cnt)
  7921. }
  7922. }
  7923. }
  7924. for _, item := range prescriptions {
  7925. for _, subItem := range item.HisAdditionalCharge {
  7926. total = total + (subItem.Price * float64(subItem.Count))
  7927. }
  7928. }
  7929. allTotal := fmt.Sprintf("%.4f", total)
  7930. if res.Infcode == 0 {
  7931. var rf []*ResultFive
  7932. json.Unmarshal([]byte(his.Iinfo), &rf)
  7933. chrg_bchno := chrg_bchno
  7934. cert_no := his.Certno
  7935. var insutypes []string
  7936. var insutype string
  7937. var is390 int = 0
  7938. var is310 int = 0
  7939. for _, item := range rf {
  7940. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7941. insutypes = append(insutypes, item.Insutype)
  7942. }
  7943. }
  7944. if len(insutypes) == 1 {
  7945. insutype = insutypes[0]
  7946. } else {
  7947. for _, i := range insutypes {
  7948. if i == "390" {
  7949. is390 = 1
  7950. }
  7951. if i == "310" {
  7952. is310 = 1
  7953. }
  7954. }
  7955. }
  7956. if is390 == 1 {
  7957. insutype = "390"
  7958. }
  7959. if is310 == 1 {
  7960. insutype = "310"
  7961. }
  7962. if len(insutypes) == 0 {
  7963. insutype = "310"
  7964. }
  7965. if len(insutypes) == 2 {
  7966. insutype = strconv.FormatInt(his.SocialType, 64)
  7967. }
  7968. //insutype = "390"
  7969. if his.IdCardType == 1 {
  7970. cert_no = his.MedicalInsuranceNumber
  7971. } else {
  7972. cert_no = his.Certno
  7973. }
  7974. var res ResultSeven
  7975. var resSeven10265 ResultSeven10265
  7976. if miConfig.MdtrtareaAdmvs == "421300" {
  7977. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7978. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7979. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7980. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7981. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7982. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7983. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7984. resp, requestErr := http.Get(api)
  7985. if requestErr != nil {
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7987. return
  7988. }
  7989. body, ioErr := ioutil.ReadAll(resp.Body)
  7990. if ioErr != nil {
  7991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7993. return
  7994. }
  7995. var respJSON map[string]interface{}
  7996. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7999. return
  8000. }
  8001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8002. result, _ := json.Marshal(respJSON)
  8003. fmt.Println("log")
  8004. fmt.Println(string(result))
  8005. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8006. utils.ErrorLog("解析失败:%v", err)
  8007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8008. return
  8009. }
  8010. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8011. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  8012. if result3101.Infcode == "0" {
  8013. if len(result3101.Output.Result) > 0 {
  8014. var errMsgs []string
  8015. for _, item := range result3101.Output.Result {
  8016. errMsgs = append(errMsgs, item.VolaCont)
  8017. }
  8018. c.ServeSuccessJSON(map[string]interface{}{
  8019. "failed_code": -10,
  8020. "msg": errMsgs,
  8021. })
  8022. return
  8023. } else {
  8024. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8025. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8026. bas := strings.Split(psn_info.CardInfo, "|")
  8027. if his.IdCardType == 1 {
  8028. cert_no = bas[2]
  8029. } else {
  8030. cert_no = bas[1]
  8031. }
  8032. //江苏地区国家医保医疗类别
  8033. //职工透析:医疗类别选特殊情况门诊9933
  8034. //居民血透门慢: 医疗类别选门诊慢病1402
  8035. //var med_type string
  8036. //if his.Insutype == "310" {
  8037. // if reg_type == 14 {
  8038. // med_type = "9933"
  8039. // } else if reg_type == 11 {
  8040. // med_type = "11"
  8041. //
  8042. // }
  8043. //} else if his.Insutype == "390" {
  8044. // if reg_type == 14 {
  8045. // med_type = "1402"
  8046. // } else if reg_type == 11 {
  8047. // med_type = "11"
  8048. // }
  8049. //}
  8050. var api string
  8051. if miConfig.MdtrtareaAdmvs == "320921" {
  8052. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8053. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8054. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8055. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8056. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8057. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8058. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8059. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8060. } else {
  8061. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8062. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8063. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8064. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8065. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8066. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8067. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8068. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8069. }
  8070. resp, requestErr := http.Get(api)
  8071. if requestErr != nil {
  8072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8073. return
  8074. }
  8075. body, ioErr := ioutil.ReadAll(resp.Body)
  8076. if ioErr != nil {
  8077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8079. return
  8080. }
  8081. var respJSON map[string]interface{}
  8082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8085. return
  8086. }
  8087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8088. result, _ := json.Marshal(respJSON)
  8089. fmt.Println("log")
  8090. fmt.Println(string(result))
  8091. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8092. utils.ErrorLog("解析失败:%v", err)
  8093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8094. return
  8095. }
  8096. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8097. res.Output = resSeven10265.Output
  8098. res.ErrMsg = resSeven10265.ErrMsg
  8099. res.Cainfo = resSeven10265.Cainfo
  8100. res.WarnMsg = resSeven10265.WarnMsg
  8101. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8102. res.Infcode = infocode
  8103. }
  8104. }
  8105. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8106. result, request_log, _ := service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8107. var dat map[string]interface{}
  8108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8109. fmt.Println(dat)
  8110. } else {
  8111. fmt.Println(err)
  8112. }
  8113. saveLog(result, request_log, "2206", "预结算")
  8114. userJSONBytes, _ := json.Marshal(dat)
  8115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8116. utils.ErrorLog("解析失败:%v", err)
  8117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8118. return
  8119. }
  8120. } else {
  8121. var result string
  8122. var request_log string
  8123. if miConfig.Code == "H15049901371" {
  8124. //赤峰地区国家医保医疗类别
  8125. //职工透析:医疗类别选特殊情况门诊990502
  8126. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8127. var med_type string
  8128. if his.Insutype == "390" {
  8129. if reg_type == 14 {
  8130. med_type = "9933"
  8131. } else if reg_type == 11 {
  8132. med_type = "11"
  8133. }
  8134. } else if his.Insutype == "310" {
  8135. if reg_type == 14 {
  8136. med_type = "990502"
  8137. } else if reg_type == 11 {
  8138. med_type = "11"
  8139. }
  8140. }
  8141. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  8142. } else {
  8143. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  8144. }
  8145. var dat map[string]interface{}
  8146. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8147. fmt.Println(dat)
  8148. } else {
  8149. fmt.Println(err)
  8150. }
  8151. saveLog(result, request_log, "2206", "预结算")
  8152. //userJSONBytes, _ := json.Marshal(dat)
  8153. //
  8154. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8155. // utils.ErrorLog("解析失败:%v", err)
  8156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8157. // return
  8158. //}
  8159. userJSONBytes, _ := json.Marshal(dat)
  8160. if miConfig.Code == "H15049901371" {
  8161. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8162. utils.ErrorLog("解析失败:%v", err)
  8163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8164. return
  8165. }
  8166. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8167. res.Output = resSeven10265.Output
  8168. res.ErrMsg = resSeven10265.ErrMsg
  8169. res.Cainfo = resSeven10265.Cainfo
  8170. res.WarnMsg = resSeven10265.WarnMsg
  8171. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8172. res.Infcode = infocode
  8173. } else {
  8174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8175. utils.ErrorLog("解析失败:%v", err)
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. return
  8178. }
  8179. }
  8180. }
  8181. if res.Infcode != 0 {
  8182. errlog := &models.HisOrderError{
  8183. UserOrgId: adminUser.CurrentOrgId,
  8184. Ctime: time.Now().Unix(),
  8185. Mtime: time.Now().Unix(),
  8186. Number: chrg_bchno,
  8187. ErrMsg: res.ErrMsg,
  8188. Status: 1,
  8189. PatientId: id,
  8190. RecordTime: recordDateTime,
  8191. Stage: 20,
  8192. }
  8193. service.CreateErrMsgLog(errlog)
  8194. c.ServeSuccessJSON(map[string]interface{}{
  8195. "failed_code": -10,
  8196. "msg": res.ErrMsg,
  8197. })
  8198. return
  8199. } else {
  8200. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8201. order.OrderStatus = 1
  8202. order.IsPre = 1
  8203. order.Status = 1
  8204. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8205. order.SetlId = res.Output.Setlinfo.SetlID
  8206. order.PsnNo = res.Output.Setlinfo.PsnNo
  8207. order.PsnName = res.Output.Setlinfo.PsnName
  8208. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8209. order.Certno = res.Output.Setlinfo.Certno
  8210. order.Gend = res.Output.Setlinfo.Gend
  8211. order.Naty = res.Output.Setlinfo.Naty
  8212. order.Age = res.Output.Setlinfo.Age
  8213. order.Insutype = res.Output.Setlinfo.Insutype
  8214. order.PsnType = res.Output.Setlinfo.PsnType
  8215. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8216. order.SetlTime = res.Output.Setlinfo.SetlTime
  8217. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8218. if res.Output.Setlinfo.MedType == "140101" {
  8219. order.MedType = "14"
  8220. } else {
  8221. order.MedType = res.Output.Setlinfo.MedType
  8222. }
  8223. if reg_type == 1112 {
  8224. order.MedType = "1112"
  8225. }
  8226. if reg_type == 1111 {
  8227. order.MedType = "1111"
  8228. }
  8229. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8230. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8231. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8232. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8233. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8234. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8235. order.HifpPay = res.Output.Setlinfo.HifpPay
  8236. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8237. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8238. order.HifesPay = res.Output.Setlinfo.HifesPay
  8239. order.HifobPay = res.Output.Setlinfo.HifobPay
  8240. order.MafPay = res.Output.Setlinfo.MafPay
  8241. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8242. order.OthPay = res.Output.Setlinfo.OthPay
  8243. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8244. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8245. order.AcctPay = res.Output.Setlinfo.AcctPay
  8246. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8247. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8248. order.Balc = res.Output.Setlinfo.Balc
  8249. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8250. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8251. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8252. order.ClrWay = res.Output.Setlinfo.ClrWay
  8253. order.Creator = order.Creator
  8254. order.Modify = roles.AdminUserId
  8255. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8256. detailStr := string(setlDetail)
  8257. order.SetlDetail = detailStr
  8258. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8259. err = service.UpDateOrder(order)
  8260. if err == nil {
  8261. c.ServeSuccessJSON(map[string]interface{}{
  8262. "msg": "预结算成功",
  8263. })
  8264. } else {
  8265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8266. return
  8267. }
  8268. }
  8269. } else {
  8270. adminUser := c.GetAdminUserInfo()
  8271. errlog := &models.HisOrderError{
  8272. UserOrgId: adminUser.CurrentOrgId,
  8273. Ctime: time.Now().Unix(),
  8274. Mtime: time.Now().Unix(),
  8275. ErrMsg: res.ErrMsg,
  8276. Status: 1,
  8277. PatientId: id,
  8278. RecordTime: recordDateTime,
  8279. Stage: 4,
  8280. }
  8281. service.CreateErrMsgLog(errlog)
  8282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8283. return
  8284. }
  8285. } else {
  8286. adminUser := c.GetAdminUserInfo()
  8287. errlog := &models.HisOrderError{
  8288. UserOrgId: adminUser.CurrentOrgId,
  8289. Ctime: time.Now().Unix(),
  8290. Mtime: time.Now().Unix(),
  8291. ErrMsg: res.ErrMsg,
  8292. Status: 1,
  8293. PatientId: id,
  8294. RecordTime: recordDateTime,
  8295. Stage: 4,
  8296. }
  8297. service.CreateErrMsgLog(errlog)
  8298. c.ServeSuccessJSON(map[string]interface{}{
  8299. "failed_code": -10,
  8300. "msg": res.ErrMsg,
  8301. })
  8302. return
  8303. }
  8304. }
  8305. }
  8306. }
  8307. //退款
  8308. func (c *HisApiController) Refund() {
  8309. order_id, _ := c.GetInt64("order_id")
  8310. admin_user_id, _ := c.GetInt64("admin_user_id")
  8311. adminUser := c.GetAdminUserInfo()
  8312. var order models.HisOrder
  8313. order, _ = service.GetHisOrderByID(order_id)
  8314. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8315. if order.ID == 0 {
  8316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8317. return
  8318. }
  8319. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8321. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8322. if config.IsOpen == 1 { //对接了医保,走医保流程
  8323. var res ResultSixteen
  8324. var resSixteen10265 ResultSixteen10265
  8325. var src_resquest string
  8326. var result string
  8327. if miConfig.MdtrtareaAdmvs == "421300" {
  8328. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8329. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8330. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8331. resp3, requestErr3 := http.Get(api3)
  8332. if requestErr3 != nil {
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8334. return
  8335. }
  8336. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8337. if ioErr3 != nil {
  8338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8340. return
  8341. }
  8342. var respJSON3 map[string]interface{}
  8343. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8346. return
  8347. }
  8348. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8349. userJSONBytes3, _ := json.Marshal(respJSON3)
  8350. fmt.Println("log")
  8351. fmt.Println(string(userJSONBytes3))
  8352. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8353. utils.ErrorLog("解析失败:%v", err)
  8354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8355. return
  8356. }
  8357. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8358. var api3 string
  8359. if miConfig.MdtrtareaAdmvs == "320921" {
  8360. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8361. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8362. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8363. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8364. } else {
  8365. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8366. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8367. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8368. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8369. }
  8370. resp3, requestErr3 := http.Get(api3)
  8371. if requestErr3 != nil {
  8372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8373. return
  8374. }
  8375. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8376. if ioErr3 != nil {
  8377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8379. return
  8380. }
  8381. var respJSON3 map[string]interface{}
  8382. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8388. userJSONBytes3, _ := json.Marshal(respJSON3)
  8389. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8390. utils.ErrorLog("解析失败:%v", err)
  8391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8392. return
  8393. }
  8394. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8395. res.Output = resSixteen10265.Output
  8396. res.ErrMsg = resSixteen10265.ErrMsg
  8397. res.Cainfo = resSixteen10265.Cainfo
  8398. res.WarnMsg = resSixteen10265.WarnMsg
  8399. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8400. res.Infcode = infocode
  8401. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8402. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8403. var dat map[string]interface{}
  8404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8405. fmt.Println(dat)
  8406. } else {
  8407. fmt.Println(err)
  8408. }
  8409. saveLog(result, src_resquest, "2208", "退费")
  8410. userJSONBytes, _ := json.Marshal(dat)
  8411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8412. utils.ErrorLog("解析失败:%v", err)
  8413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8414. return
  8415. }
  8416. } else {
  8417. if miConfig.Code == "H15049901371" {
  8418. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8419. var dat map[string]interface{}
  8420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8421. fmt.Println(dat)
  8422. } else {
  8423. fmt.Println(err)
  8424. }
  8425. saveLog(result, src_resquest, "2208", "退费")
  8426. userJSONBytes, _ := json.Marshal(dat)
  8427. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8428. utils.ErrorLog("解析失败:%v", err)
  8429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8430. return
  8431. }
  8432. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8433. res.Output = resSixteen10265.Output
  8434. res.ErrMsg = resSixteen10265.ErrMsg
  8435. res.Cainfo = resSixteen10265.Cainfo
  8436. res.WarnMsg = resSixteen10265.WarnMsg
  8437. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8438. res.Infcode = infocode
  8439. } else {
  8440. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8441. var dat map[string]interface{}
  8442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8443. fmt.Println(dat)
  8444. } else {
  8445. fmt.Println(err)
  8446. }
  8447. saveLog(result, src_resquest, "2208", "退费")
  8448. userJSONBytes, _ := json.Marshal(dat)
  8449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8450. utils.ErrorLog("解析失败:%v", err)
  8451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8452. return
  8453. }
  8454. }
  8455. }
  8456. if res.Infcode == 0 {
  8457. var res2 ResultSix
  8458. var resSix10265 ResultSix10265
  8459. if miConfig.MdtrtareaAdmvs == "421300" {
  8460. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8461. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8462. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8463. resp3, requestErr3 := http.Get(api3)
  8464. if requestErr3 != nil {
  8465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8466. return
  8467. }
  8468. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8469. if ioErr3 != nil {
  8470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8472. return
  8473. }
  8474. var respJSON3 map[string]interface{}
  8475. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8478. return
  8479. }
  8480. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8481. userJSONBytes3, _ := json.Marshal(respJSON3)
  8482. fmt.Println("log")
  8483. fmt.Println(string(userJSONBytes3))
  8484. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8485. utils.ErrorLog("解析失败:%v", err)
  8486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8487. return
  8488. }
  8489. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8490. var api3 string
  8491. if miConfig.MdtrtareaAdmvs == "320921" {
  8492. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8493. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8495. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8496. } else {
  8497. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8498. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8499. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8500. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8501. }
  8502. resp3, requestErr3 := http.Get(api3)
  8503. if requestErr3 != nil {
  8504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8505. return
  8506. }
  8507. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8508. if ioErr3 != nil {
  8509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8511. return
  8512. }
  8513. var respJSON3 map[string]interface{}
  8514. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8517. return
  8518. }
  8519. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8520. userJSONBytes3, _ := json.Marshal(respJSON3)
  8521. fmt.Println("log")
  8522. fmt.Println(string(userJSONBytes3))
  8523. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8524. utils.ErrorLog("解析失败:%v", err)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8529. res2.Output = resSix10265.Output
  8530. res2.ErrMsg = resSix10265.ErrMsg
  8531. res2.Cainfo = resSix10265.Cainfo
  8532. res2.WarnMsg = resSix10265.WarnMsg
  8533. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8534. res2.Infcode = infocode
  8535. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8536. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8537. var dat map[string]interface{}
  8538. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8539. fmt.Println(dat)
  8540. } else {
  8541. fmt.Println(err)
  8542. }
  8543. saveLog(result2, src_request, "2205", "撤销明细")
  8544. userJSONBytes, _ := json.Marshal(dat)
  8545. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8546. utils.ErrorLog("解析失败:%v", err)
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. } else {
  8551. if miConfig.Code == "H15049901371" {
  8552. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8553. var dat map[string]interface{}
  8554. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8555. fmt.Println(dat)
  8556. } else {
  8557. fmt.Println(err)
  8558. }
  8559. saveLog(result2, src_request, "2205", "撤销明细")
  8560. userJSONBytes, _ := json.Marshal(dat)
  8561. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8562. utils.ErrorLog("解析失败:%v", err)
  8563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8564. return
  8565. }
  8566. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8567. res2.Output = resSix10265.Output
  8568. res2.ErrMsg = resSix10265.ErrMsg
  8569. res2.Cainfo = resSix10265.Cainfo
  8570. res2.WarnMsg = resSix10265.WarnMsg
  8571. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8572. res2.Infcode = infocode
  8573. } else {
  8574. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8575. var dat map[string]interface{}
  8576. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8577. fmt.Println(dat)
  8578. } else {
  8579. fmt.Println(err)
  8580. }
  8581. saveLog(result2, src_request, "2205", "撤销明细")
  8582. userJSONBytes, _ := json.Marshal(dat)
  8583. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8584. utils.ErrorLog("解析失败:%v", err)
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8586. return
  8587. }
  8588. }
  8589. }
  8590. if res2.Infcode == 0 {
  8591. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8592. if err == nil {
  8593. //当押金不为零时产生退费记录
  8594. if order.Decimal != 0 {
  8595. tmp := strconv.FormatInt(order.ID, 10)
  8596. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8597. if err != nil {
  8598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8599. return
  8600. }
  8601. }
  8602. c.ServeSuccessJSON(map[string]interface{}{
  8603. "msg": "退费成功",
  8604. })
  8605. } else {
  8606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8607. return
  8608. }
  8609. } else {
  8610. c.ServeSuccessJSON(map[string]interface{}{
  8611. "code": -10,
  8612. "msg": res2.ErrMsg,
  8613. })
  8614. }
  8615. } else {
  8616. c.ServeSuccessJSON(map[string]interface{}{
  8617. "code": -10,
  8618. "msg": res.ErrMsg,
  8619. })
  8620. }
  8621. }
  8622. }
  8623. func (c *HisApiController) RefundNumber() {
  8624. record_time := c.GetString("record_time")
  8625. //patient_id, _ := c.GetInt64("patient_id")
  8626. admin_user_id, _ := c.GetInt64("admin_user_id")
  8627. his_patient_id, _ := c.GetInt64("id")
  8628. timeLayout := "2006-01-02"
  8629. loc, _ := time.LoadLocation("Local")
  8630. adminUser := c.GetAdminUserInfo()
  8631. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8632. fmt.Println(err)
  8633. if err != nil {
  8634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8635. return
  8636. }
  8637. recordDateTime := theTime.Unix()
  8638. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8639. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8640. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8641. //order, _ := service.GetHisOrderByID(order_id)
  8642. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8643. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8644. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8645. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8646. if count > 0 {
  8647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8648. return
  8649. }
  8650. if config.IsOpen == 1 { //对接了医保,走医保流程
  8651. var res2 ResultSix
  8652. var resSix10265 ResultSix10265
  8653. if miConfig.MdtrtareaAdmvs == "421300" {
  8654. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8655. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8656. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8657. resp3, requestErr3 := http.Get(api3)
  8658. if requestErr3 != nil {
  8659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8660. return
  8661. }
  8662. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8663. if ioErr3 != nil {
  8664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8666. return
  8667. }
  8668. var respJSON3 map[string]interface{}
  8669. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8672. return
  8673. }
  8674. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8675. userJSONBytes3, _ := json.Marshal(respJSON3)
  8676. fmt.Println("log")
  8677. fmt.Println(string(userJSONBytes3))
  8678. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8679. utils.ErrorLog("解析失败:%v", err)
  8680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8681. return
  8682. }
  8683. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8684. var api3 string
  8685. if miConfig.MdtrtareaAdmvs == "320921" {
  8686. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8687. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8688. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8689. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8690. } else {
  8691. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8692. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8693. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8694. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8695. }
  8696. resp3, requestErr3 := http.Get(api3)
  8697. if requestErr3 != nil {
  8698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8699. return
  8700. }
  8701. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8702. if ioErr3 != nil {
  8703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8705. return
  8706. }
  8707. var respJSON3 map[string]interface{}
  8708. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8711. return
  8712. }
  8713. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8714. userJSONBytes3, _ := json.Marshal(respJSON3)
  8715. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8716. utils.ErrorLog("解析失败:%v", err)
  8717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8718. return
  8719. }
  8720. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8721. res2.Output = resSix10265.Output
  8722. res2.ErrMsg = resSix10265.ErrMsg
  8723. res2.Cainfo = resSix10265.Cainfo
  8724. res2.WarnMsg = resSix10265.WarnMsg
  8725. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8726. res2.Infcode = infocode
  8727. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8728. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8729. var dat map[string]interface{}
  8730. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8731. fmt.Println(dat)
  8732. } else {
  8733. fmt.Println(err)
  8734. }
  8735. saveLog(result, request, "2202", "退号")
  8736. userJSONBytes, _ := json.Marshal(dat)
  8737. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8738. utils.ErrorLog("解析失败:%v", err)
  8739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8740. return
  8741. }
  8742. } else {
  8743. var api3 string
  8744. if miConfig.Code == "H15049901371" {
  8745. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8746. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8747. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8748. } else {
  8749. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8750. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8751. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8752. }
  8753. resp3, requestErr3 := http.Get(api3)
  8754. if requestErr3 != nil {
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return
  8757. }
  8758. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8759. if ioErr3 != nil {
  8760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8762. return
  8763. }
  8764. var respJSON3 map[string]interface{}
  8765. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8768. return
  8769. }
  8770. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8771. userJSONBytes3, _ := json.Marshal(respJSON3)
  8772. if miConfig.Code == "H15049901371" {
  8773. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8774. utils.ErrorLog("解析失败:%v", err)
  8775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8776. return
  8777. }
  8778. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8779. res2.Output = resSix10265.Output
  8780. res2.ErrMsg = resSix10265.ErrMsg
  8781. res2.Cainfo = resSix10265.Cainfo
  8782. res2.WarnMsg = resSix10265.WarnMsg
  8783. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8784. res2.Infcode = infocode
  8785. } else {
  8786. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8787. utils.ErrorLog("解析失败:%v", err)
  8788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8789. return
  8790. }
  8791. }
  8792. }
  8793. if res2.Infcode == 0 {
  8794. if err == nil {
  8795. c.ServeSuccessJSON(map[string]interface{}{
  8796. "msg": "退号成功",
  8797. })
  8798. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8799. } else {
  8800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8801. return
  8802. }
  8803. } else {
  8804. c.ServeSuccessJSON(map[string]interface{}{
  8805. "code": -10,
  8806. "msg": res2.ErrMsg,
  8807. })
  8808. }
  8809. } else {
  8810. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8811. //if err == nil {
  8812. // c.ServeSuccessJSON(map[string]interface{}{
  8813. // "msg": "退费成功",
  8814. // })
  8815. //} else {
  8816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8817. // return
  8818. //}
  8819. }
  8820. }
  8821. func (c *HisApiController) RefundDetail() {
  8822. order_id, _ := c.GetInt64("order_id")
  8823. admin_user_id, _ := c.GetInt64("admin_user_id")
  8824. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8825. number := c.GetString("number")
  8826. record_time := c.GetString("record_time")
  8827. patient_id, _ := c.GetInt64("patient_id")
  8828. //med_type, _ := c.GetInt64("med_type")
  8829. timeLayout := "2006-01-02"
  8830. loc, _ := time.LoadLocation("Local")
  8831. adminUser := c.GetAdminUserInfo()
  8832. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8833. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8834. fmt.Println(err)
  8835. if err != nil {
  8836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8837. return
  8838. }
  8839. recordDateTime := theTime.Unix()
  8840. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8841. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8842. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8843. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8844. var order models.HisOrder
  8845. order, _ = service.GetHisOrderByID(order_id)
  8846. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8847. if config.IsOpen == 1 { //对接了医保,走医保流程
  8848. var res2 ResultSix
  8849. if miConfig.MdtrtareaAdmvs == "421300" {
  8850. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8851. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8852. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8853. resp3, requestErr3 := http.Get(api3)
  8854. if requestErr3 != nil {
  8855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8856. return
  8857. }
  8858. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8859. if ioErr3 != nil {
  8860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8862. return
  8863. }
  8864. var respJSON3 map[string]interface{}
  8865. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. return
  8869. }
  8870. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8871. userJSONBytes3, _ := json.Marshal(respJSON3)
  8872. fmt.Println("log")
  8873. fmt.Println(string(userJSONBytes3))
  8874. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8875. utils.ErrorLog("解析失败:%v", err)
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8877. return
  8878. }
  8879. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8880. if err == nil {
  8881. c.ServeSuccessJSON(map[string]interface{}{
  8882. "msg": "撤销明细成功",
  8883. })
  8884. return
  8885. } else {
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8890. var resSix10265 ResultSix10265
  8891. var api3 string
  8892. if miConfig.MdtrtareaAdmvs == "320921" {
  8893. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8894. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8895. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8896. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8897. } else {
  8898. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8899. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8900. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8901. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8902. }
  8903. resp3, requestErr3 := http.Get(api3)
  8904. if requestErr3 != nil {
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. return
  8907. }
  8908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8909. if ioErr3 != nil {
  8910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8912. return
  8913. }
  8914. var respJSON3 map[string]interface{}
  8915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8918. return
  8919. }
  8920. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8921. userJSONBytes3, _ := json.Marshal(respJSON3)
  8922. fmt.Println("log")
  8923. fmt.Println(string(userJSONBytes3))
  8924. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8925. utils.ErrorLog("解析失败:%v", err)
  8926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8927. return
  8928. }
  8929. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8930. res2.Output = resSix10265.Output
  8931. res2.ErrMsg = resSix10265.ErrMsg
  8932. res2.Cainfo = resSix10265.Cainfo
  8933. res2.WarnMsg = resSix10265.WarnMsg
  8934. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8935. res2.Infcode = infocode
  8936. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8937. if err == nil {
  8938. c.ServeSuccessJSON(map[string]interface{}{
  8939. "msg": "撤销明细成功",
  8940. })
  8941. return
  8942. } else {
  8943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8944. return
  8945. }
  8946. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8947. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8948. var dat map[string]interface{}
  8949. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8950. fmt.Println(dat)
  8951. } else {
  8952. fmt.Println(err)
  8953. }
  8954. saveLog(result2, src_request, "2205", "撤销明细")
  8955. userJSONBytes, _ := json.Marshal(dat)
  8956. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8957. utils.ErrorLog("解析失败:%v", err)
  8958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8959. return
  8960. }
  8961. if res2.Infcode == 0 {
  8962. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8963. if err == nil {
  8964. c.ServeSuccessJSON(map[string]interface{}{
  8965. "msg": "撤销明细成功",
  8966. })
  8967. return
  8968. } else {
  8969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8970. return
  8971. }
  8972. } else {
  8973. c.ServeSuccessJSON(map[string]interface{}{
  8974. "code": -10,
  8975. "msg": res2.ErrMsg,
  8976. })
  8977. }
  8978. } else {
  8979. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8980. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8981. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8982. resp2, requestErr2 := http.Get(api2)
  8983. if requestErr2 != nil {
  8984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8985. return
  8986. }
  8987. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8988. if ioErr2 != nil {
  8989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8991. return
  8992. }
  8993. var respJSON2 map[string]interface{}
  8994. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8997. return
  8998. }
  8999. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9000. if err == nil {
  9001. c.ServeSuccessJSON(map[string]interface{}{
  9002. "msg": "撤销明细成功",
  9003. })
  9004. return
  9005. } else {
  9006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9007. return
  9008. }
  9009. }
  9010. } else {
  9011. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9012. if err == nil {
  9013. c.ServeSuccessJSON(map[string]interface{}{
  9014. "msg": "退费成功",
  9015. })
  9016. } else {
  9017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9018. return
  9019. }
  9020. }
  9021. }
  9022. //对账
  9023. func (c *HisApiController) GetCheckAccount() {
  9024. start_time := c.GetString("start_time")
  9025. end_time := c.GetString("end_time")
  9026. insutype := c.GetString("insutype")
  9027. clr_type := c.GetString("clr_type")
  9028. clr_org := c.GetString("clr_optins")
  9029. admin_user_id, _ := c.GetInt64("admin_user_id")
  9030. adminUser := c.GetAdminUserInfo()
  9031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9032. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9033. if len(clr_org) == 0 {
  9034. clr_org = miConfig.MdtrtareaAdmvs
  9035. }
  9036. timeLayout := "2006-01-02"
  9037. loc, _ := time.LoadLocation("Local")
  9038. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9039. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9040. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9041. fixmedins_setl_cnt := int64(len(orders))
  9042. var medfee_sumamt float64
  9043. var acct_pay float64
  9044. var fund_pay_sumamt float64
  9045. for _, item := range orders {
  9046. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9047. acct_pay = acct_pay + item.AcctPay
  9048. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9049. }
  9050. var user_name string
  9051. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9052. if role.ID == 0 {
  9053. user_name = "xxx"
  9054. } else {
  9055. user_name = role.UserName
  9056. }
  9057. var res ResultEight
  9058. var res10188 ResultEightFor10188
  9059. if config.IsOpen == 1 {
  9060. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9061. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9062. "insutype=" + insutype +
  9063. "&clr_type=" + clr_type +
  9064. "&setl_optins=" + clr_org +
  9065. "&stmt_begndate=" + start_time +
  9066. "&stm_enddate=" + end_time +
  9067. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9068. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9069. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9070. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9071. "&fixmedins_code=" + miConfig.Code +
  9072. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9073. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9074. "&secret_key=" + miConfig.SecretKey +
  9075. "&org_name=" + miConfig.OrgName +
  9076. "&doctor=" + user_name +
  9077. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9078. fmt.Println(api)
  9079. resp, requestErr := http.Get(api)
  9080. if requestErr != nil {
  9081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9082. return
  9083. }
  9084. body, ioErr := ioutil.ReadAll(resp.Body)
  9085. fmt.Println(body)
  9086. if ioErr != nil {
  9087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9089. return
  9090. }
  9091. var respJSON map[string]interface{}
  9092. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9095. return
  9096. }
  9097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9098. userJSONBytes, _ := json.Marshal(respJSON)
  9099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9100. utils.ErrorLog("解析失败:%v", err)
  9101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9102. return
  9103. }
  9104. res.InfRefmsgid = res10188.InfRefmsgid
  9105. res.Output = res10188.Output
  9106. res.ErrMsg = res10188.ErrMsg
  9107. res.Cainfo = res10188.Cainfo
  9108. res.WarnMsg = res10188.WarnMsg
  9109. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9110. res.Infcode = infocode
  9111. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9112. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9113. "insutype=" + insutype +
  9114. "&clr_type=" + clr_type +
  9115. "&setl_optins=" + clr_org +
  9116. "&stmt_begndate=" + start_time +
  9117. "&stm_enddate=" + end_time +
  9118. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9119. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9120. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9121. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9122. "&fixmedins_code=" + miConfig.Code +
  9123. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9124. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9125. "&secret_key=" + miConfig.SecretKey +
  9126. "&org_name=" + miConfig.OrgName +
  9127. "&doctor=" + user_name
  9128. resp, requestErr := http.Get(api)
  9129. if requestErr != nil {
  9130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9131. return
  9132. }
  9133. body, ioErr := ioutil.ReadAll(resp.Body)
  9134. if ioErr != nil {
  9135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9137. return
  9138. }
  9139. var respJSON map[string]interface{}
  9140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9143. return
  9144. }
  9145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9146. result, _ := json.Marshal(respJSON)
  9147. fmt.Println("log")
  9148. fmt.Println(string(result))
  9149. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  9150. utils.ErrorLog("解析失败:%v", err)
  9151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9152. return
  9153. }
  9154. res.InfRefmsgid = res10188.InfRefmsgid
  9155. res.Output = res10188.Output
  9156. res.ErrMsg = res10188.ErrMsg
  9157. res.Cainfo = res10188.Cainfo
  9158. res.WarnMsg = res10188.WarnMsg
  9159. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9160. res.Infcode = infocode
  9161. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9162. var baseParams models.BaseParams
  9163. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9164. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9165. baseParams.SecretKey = miConfig.SecretKey
  9166. baseParams.OrgName = miConfig.OrgName
  9167. baseParams.FixmedinsCode = miConfig.Code
  9168. baseParams.EncKey = miConfig.EncKey
  9169. baseParams.AppSecret = miConfig.AppSecret
  9170. baseParams.SignKey = miConfig.SignKey
  9171. baseParams.AppID = miConfig.Code
  9172. baseParams.Doctor = role.UserName
  9173. baseParams.RequestUrl = miConfig.Url
  9174. businessParams := models.BusinessParams{
  9175. Insutype: insutype,
  9176. ClrType: clr_type,
  9177. SetlOptins: clr_org,
  9178. StmtBegndate: start_time,
  9179. StmtEnddate: end_time,
  9180. MedfeeSumamt: medfee_sumamt,
  9181. FundPaySumamt: fund_pay_sumamt,
  9182. AcctPay: acct_pay,
  9183. FixmedinsSetlCnt: fixmedins_setl_cnt,
  9184. }
  9185. result, requestLog := service.FJyb3201(baseParams, businessParams)
  9186. fmt.Println(requestLog)
  9187. fmt.Println(result)
  9188. } else {
  9189. if len(clr_type) == 0 {
  9190. clr_type = "11"
  9191. }
  9192. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9193. "insutype=" + insutype +
  9194. "&clr_type=" + clr_type +
  9195. "&setl_optins=" + clr_org +
  9196. "&stmt_begndate=" + start_time +
  9197. "&stm_enddate=" + end_time +
  9198. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9199. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9200. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9201. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9202. "&fixmedins_code=" + miConfig.Code +
  9203. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9204. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9205. "&secret_key=" + miConfig.SecretKey +
  9206. "&org_name=" + miConfig.OrgName +
  9207. "&doctor=" + user_name
  9208. fmt.Println(api)
  9209. resp, requestErr := http.Get(api)
  9210. if requestErr != nil {
  9211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9212. return
  9213. }
  9214. body, ioErr := ioutil.ReadAll(resp.Body)
  9215. fmt.Println(body)
  9216. if ioErr != nil {
  9217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9219. return
  9220. }
  9221. var respJSON map[string]interface{}
  9222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9225. return
  9226. }
  9227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9228. userJSONBytes, _ := json.Marshal(respJSON)
  9229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9230. utils.ErrorLog("解析失败:%v", err)
  9231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9232. return
  9233. }
  9234. }
  9235. if res.Infcode == 0 {
  9236. if res.Output.Stmtinfo.StmtRslt == "0" {
  9237. micc := &models.MedicalInsuranceCostCompare{
  9238. StartTime: startime.Unix(),
  9239. EndTime: endtime.Unix(),
  9240. Insutype: insutype,
  9241. CheckType: 1,
  9242. Num: fixmedins_setl_cnt,
  9243. Mtime: time.Now().Unix(),
  9244. Status: 1,
  9245. UserOrgId: adminUser.CurrentOrgId,
  9246. CostTotal: medfee_sumamt,
  9247. FuncTotal: fund_pay_sumamt,
  9248. PsnPay: acct_pay,
  9249. Creator: admin_user_id,
  9250. Ctime: time.Now().Unix(),
  9251. ClrType: clr_type,
  9252. }
  9253. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9254. if err == nil {
  9255. c.ServeSuccessJSON(map[string]interface{}{
  9256. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9257. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9258. })
  9259. } else {
  9260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9261. }
  9262. } else {
  9263. c.ServeSuccessJSON(map[string]interface{}{
  9264. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9265. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9266. })
  9267. }
  9268. } else {
  9269. c.ServeSuccessJSON(map[string]interface{}{
  9270. "code": -10,
  9271. "msg": res.ErrMsg,
  9272. })
  9273. }
  9274. }
  9275. }
  9276. func (c *HisApiController) Check310() {
  9277. adminUser := c.GetAdminUserInfo()
  9278. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9279. var user_name string
  9280. user_name = "高慧裕"
  9281. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9282. "insutype=" + "310" +
  9283. "&clr_type=" + "" +
  9284. "&setl_optins=" + "441202" +
  9285. "&stmt_begndate=" + "2022-03-01" +
  9286. "&stm_enddate=" + "2022-03-31" +
  9287. "&medfee_sumamt=" + "194930.12" +
  9288. "&fund_pay_sumamt=" + "188741.46" +
  9289. "&acct_pay=" + "0" +
  9290. "&fixmedins_setl_cnt=" + "452" +
  9291. "&fixmedins_code=" + miConfig.Code +
  9292. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9293. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9294. "&secret_key=" + miConfig.SecretKey +
  9295. "&org_name=" + miConfig.OrgName +
  9296. "&doctor=" + user_name
  9297. fmt.Println(api)
  9298. resp, requestErr := http.Get(api)
  9299. if requestErr != nil {
  9300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9301. return
  9302. }
  9303. body, ioErr := ioutil.ReadAll(resp.Body)
  9304. fmt.Println(body)
  9305. if ioErr != nil {
  9306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9308. return
  9309. }
  9310. var respJSON map[string]interface{}
  9311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9314. return
  9315. }
  9316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9317. userJSONBytes, _ := json.Marshal(respJSON)
  9318. var res ResultEight
  9319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9320. utils.ErrorLog("解析失败:%v", err)
  9321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9322. return
  9323. }
  9324. }
  9325. func (c *HisApiController) Check390() {
  9326. adminUser := c.GetAdminUserInfo()
  9327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9328. var user_name string
  9329. user_name = "高慧裕"
  9330. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9331. "insutype=" + "390" +
  9332. "&clr_type=" + "" +
  9333. "&setl_optins=" + "441202" +
  9334. "&stmt_begndate=" + "2022-03-01" +
  9335. "&stm_enddate=" + "2022-03-31" +
  9336. "&medfee_sumamt=" + "1068448.89" +
  9337. "&fund_pay_sumamt=" + "1014677.62" +
  9338. "&acct_pay=" + "0" +
  9339. "&fixmedins_setl_cnt=" + "1950" +
  9340. "&fixmedins_code=" + miConfig.Code +
  9341. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9342. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9343. "&secret_key=" + miConfig.SecretKey +
  9344. "&org_name=" + miConfig.OrgName +
  9345. "&doctor=" + user_name
  9346. fmt.Println(api)
  9347. resp, requestErr := http.Get(api)
  9348. if requestErr != nil {
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. body, ioErr := ioutil.ReadAll(resp.Body)
  9353. fmt.Println(body)
  9354. if ioErr != nil {
  9355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9357. return
  9358. }
  9359. var respJSON map[string]interface{}
  9360. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9363. return
  9364. }
  9365. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9366. userJSONBytes, _ := json.Marshal(respJSON)
  9367. var res ResultEight
  9368. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9369. utils.ErrorLog("解析失败:%v", err)
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9371. return
  9372. }
  9373. }
  9374. //对账明细
  9375. func (c *HisApiController) GetCheckDetailAccount() {
  9376. start_time := c.GetString("start_time")
  9377. end_time := c.GetString("end_time")
  9378. admin_user_id, _ := c.GetInt64("admin_user_id")
  9379. adminUser := c.GetAdminUserInfo()
  9380. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9381. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9382. timeLayout := "2006-01-02"
  9383. loc, _ := time.LoadLocation("Local")
  9384. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9385. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9386. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9387. rand.Seed(time.Now().UnixNano())
  9388. num := rand.Intn(30000)
  9389. Mkdir(miConfig.OrgName)
  9390. file := strconv.FormatInt(int64(num), 10)
  9391. file_name := file + ".txt"
  9392. zip_name := file + ".zip"
  9393. zip_path := miConfig.OrgName + "/" + zip_name
  9394. file_path := miConfig.OrgName + "/" + file_name
  9395. decimal.DivisionPrecision = 2
  9396. var medfee_sumamt float64
  9397. var psn_cash_pay float64
  9398. var fund_pay_sumamt float64
  9399. fixmedins_setl_cnt := int64(len(orders))
  9400. for _, item := range orders {
  9401. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9402. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9403. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9404. }
  9405. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9406. defer f.Close()
  9407. if err != nil {
  9408. fmt.Println(err.Error())
  9409. } else {
  9410. for _, item := range orders {
  9411. var refd_setl_flag string
  9412. if item.OrderStatus == 2 {
  9413. refd_setl_flag = "0"
  9414. var str string
  9415. str = item.SetlId + " " +
  9416. item.MdtrtId + " " +
  9417. item.PsnNo + " " +
  9418. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9419. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9420. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9421. _, err = f.Write([]byte(str))
  9422. }
  9423. if item.OrderStatus == 3 {
  9424. var str string
  9425. str = item.SetlId + " " +
  9426. item.MdtrtId + " " +
  9427. item.PsnNo + " " +
  9428. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9429. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9430. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9431. _, err = f.Write([]byte(str))
  9432. var str2 string
  9433. str2 = item.SetlId + " " +
  9434. item.MdtrtId + " " +
  9435. item.PsnNo + " " +
  9436. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9437. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9438. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9439. _, err = f.Write([]byte(str2))
  9440. }
  9441. }
  9442. }
  9443. Zip(file_path, zip_path)
  9444. fmt.Println(ReadFile(zip_path))
  9445. fmt.Println(string(ReadFile(zip_path)))
  9446. if config.IsOpen == 1 {
  9447. var user_name string
  9448. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9449. if role.ID == 0 {
  9450. user_name = "管理员"
  9451. } else {
  9452. user_name = role.UserName
  9453. }
  9454. baseParams := models.BaseParams{
  9455. SecretKey: miConfig.SecretKey,
  9456. FixmedinsCode: miConfig.Code,
  9457. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9458. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9459. OrgName: miConfig.OrgName,
  9460. Doctor: user_name,
  9461. }
  9462. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9463. var dat map[string]interface{}
  9464. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9465. fmt.Println(dat)
  9466. } else {
  9467. fmt.Println(err)
  9468. }
  9469. userJSONBytes, _ := json.Marshal(dat)
  9470. var res ResultNine
  9471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9472. utils.ErrorLog("解析失败:%v", err)
  9473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9474. return
  9475. }
  9476. if res.Infcode == 0 {
  9477. fileNo := res.Output.FileQuryNo
  9478. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9479. "file_qury_no=" + fileNo +
  9480. "&setl_optins=" + "定点医保中心" +
  9481. "&stmt_begndate=" + start_time +
  9482. "&stm_enddate=" + end_time +
  9483. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9484. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9485. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9486. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9487. "&fixmedins_code=" + miConfig.Code +
  9488. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9489. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9490. "&secret_key=" + miConfig.SecretKey +
  9491. "&org_name=" + miConfig.OrgName +
  9492. "&doctor=" + user_name
  9493. resp, requestErr := http.Get(api)
  9494. if requestErr != nil {
  9495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9496. return
  9497. }
  9498. body, ioErr := ioutil.ReadAll(resp.Body)
  9499. if ioErr != nil {
  9500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9502. return
  9503. }
  9504. var respJSON map[string]interface{}
  9505. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9508. return
  9509. }
  9510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9511. userJSONBytes, _ := json.Marshal(respJSON)
  9512. var res ResultTen
  9513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9514. utils.ErrorLog("解析失败:%v", err)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return
  9517. }
  9518. if res.Infcode == 0 {
  9519. service.Gdyb9102(baseParams, zip_name, fileNo)
  9520. micc := &models.MedicalInsuranceCostCompare{
  9521. StartTime: startime.Unix(),
  9522. EndTime: endtime.Unix(),
  9523. Insutype: "0",
  9524. CheckType: 2,
  9525. Num: fixmedins_setl_cnt,
  9526. Mtime: time.Now().Unix(),
  9527. Status: 1,
  9528. UserOrgId: adminUser.CurrentOrgId,
  9529. CostTotal: medfee_sumamt,
  9530. FuncTotal: fund_pay_sumamt,
  9531. PsnPay: psn_cash_pay,
  9532. Creator: admin_user_id,
  9533. Ctime: time.Now().Unix(),
  9534. }
  9535. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9536. c.ServeSuccessJSON(map[string]interface{}{
  9537. "msg": "明细对账成功",
  9538. })
  9539. }
  9540. } else {
  9541. }
  9542. }
  9543. }
  9544. type CustomOrderInfo struct {
  9545. Name string
  9546. Spec string
  9547. Unit string
  9548. Count float64
  9549. Price float64
  9550. Total float64
  9551. }
  9552. func (c *HisApiController) GetSettleAccounts() {
  9553. //id, _ := c.GetInt64("id")
  9554. //record_time := c.GetString("record_time")
  9555. order_id, _ := c.GetInt64("order_id")
  9556. admin_user_id, _ := c.GetInt64("admin_user_id")
  9557. //timeLayout := "2006-01-02"
  9558. //loc, _ := time.LoadLocation("Local")
  9559. //
  9560. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9561. //if err != nil {
  9562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9563. // return
  9564. //}
  9565. //recordDateTime := theTime.Unix()
  9566. adminUser := c.GetAdminUserInfo()
  9567. order, _ := service.GetHisOrderByID(order_id)
  9568. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9569. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9570. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9571. orderInfos = append(orderInfos, orderInfos_two...)
  9572. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9573. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9574. var diagnosis_ids []string
  9575. if his.ID > 0 {
  9576. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9577. } else {
  9578. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9579. }
  9580. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9581. var dia_config []*models.HisXtDiagnoseConfig
  9582. var name string
  9583. for _, item := range diagnosis_ids {
  9584. id, _ := strconv.ParseInt(item, 10, 64)
  9585. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9586. dia_config = append(dia_config, &diagnosisConfig)
  9587. if len(name) == 0 {
  9588. name = diagnosisConfig.ClassName
  9589. } else {
  9590. name = name + "," + diagnosisConfig.ClassName
  9591. }
  9592. }
  9593. var bedCostTotal float64 = 0 //床位总费
  9594. var bedCostSelfTotal float64 = 0 //床位自费
  9595. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9596. var operationCostTotal float64 = 0 //手术费
  9597. var operationCostSelfTotal float64 = 0 //手术费
  9598. var operationCostPartSelfTotal float64 = 0 //手术费
  9599. var otherCostTotal float64 = 0 //其他费用
  9600. var otherCostSelfTotal float64 = 0 //其他费用
  9601. var otherCostPartSelfTotal float64 = 0 //其他费用
  9602. var materialCostTotal float64 = 0 //材料费
  9603. var materialCostSelfTotal float64 = 0 //材料费
  9604. var materialCostPartSelfTotal float64 = 0 //材料费
  9605. var westernMedicineCostTotal float64 = 0 //西药费
  9606. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9607. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9608. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9609. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9610. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9611. var checkCostTotal float64 = 0 //检查费
  9612. var checkCostSelfTotal float64 = 0 //检查费
  9613. var checkCostPartSelfTotal float64 = 0 //检查费
  9614. var laboratoryCostTotal float64 = 0 //化验费
  9615. var laboratoryCostSelfTotal float64 = 0 //化验费
  9616. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9617. var treatCostTotal float64 = 0 //治疗费用
  9618. var treatCostSelfTotal float64 = 0 //治疗费用
  9619. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9620. decimal.DivisionPrecision = 2
  9621. for _, item := range orderInfos {
  9622. if item.MedChrgitmType == "01" { //床位费
  9623. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9624. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9625. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9626. }
  9627. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9628. if item.MedChrgitmType == "03" { //检查费
  9629. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9630. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9631. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9632. }
  9633. } else {
  9634. if item.MedChrgitmType == "03" { //检查费
  9635. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9636. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9637. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9638. }
  9639. }
  9640. if item.MedChrgitmType == "04" { //化验费
  9641. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9642. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9643. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9644. }
  9645. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9646. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9647. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9648. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9649. }
  9650. if item.MedChrgitmType == "06" { //手术费
  9651. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9652. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9653. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9654. }
  9655. if item.MedChrgitmType == "08" { //材料费
  9656. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9657. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9658. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9659. }
  9660. if item.MedChrgitmType == "09" { //西药费
  9661. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9662. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9663. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9664. }
  9665. if item.MedChrgitmType == "11" { //中成费
  9666. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9667. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9668. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9669. }
  9670. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9671. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9672. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9673. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9674. }
  9675. }
  9676. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9677. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9678. var user_name string
  9679. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9680. if role.ID == 0 {
  9681. user_name = "管理员"
  9682. } else {
  9683. user_name = role.UserName
  9684. }
  9685. baseParams := models.BaseParams{
  9686. SecretKey: miConfig.SecretKey,
  9687. FixmedinsCode: miConfig.Code,
  9688. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9689. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9690. OrgName: miConfig.OrgName,
  9691. Doctor: user_name,
  9692. }
  9693. businessParams := models.BusinessParams{
  9694. PsnNo: order.PsnNo,
  9695. MdtrtId: order.MdtrtId,
  9696. SetlId: order.SetlId,
  9697. }
  9698. var res ResultEleven
  9699. var resEleven10265 ResultEleven10265
  9700. if config.IsOpen == 1 {
  9701. if miConfig.MdtrtareaAdmvs == "421300" {
  9702. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9703. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9704. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9705. resp, requestErr := http.Get(api)
  9706. if requestErr != nil {
  9707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9708. return
  9709. }
  9710. body, ioErr := ioutil.ReadAll(resp.Body)
  9711. if ioErr != nil {
  9712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9714. return
  9715. }
  9716. var respJSON map[string]interface{}
  9717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9720. return
  9721. }
  9722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9723. result, _ := json.Marshal(respJSON)
  9724. fmt.Println("log")
  9725. fmt.Println(string(result))
  9726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9727. utils.ErrorLog("解析失败:%v", err)
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9729. return
  9730. }
  9731. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9732. var api string
  9733. if miConfig.MdtrtareaAdmvs == "320921" {
  9734. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9735. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9736. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9737. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9738. } else {
  9739. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9740. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9741. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9742. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9743. }
  9744. resp, requestErr := http.Get(api)
  9745. if requestErr != nil {
  9746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9747. return
  9748. }
  9749. body, ioErr := ioutil.ReadAll(resp.Body)
  9750. if ioErr != nil {
  9751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9753. return
  9754. }
  9755. var respJSON map[string]interface{}
  9756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9759. return
  9760. }
  9761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9762. result, _ := json.Marshal(respJSON)
  9763. fmt.Println("log")
  9764. fmt.Println(string(result))
  9765. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9766. utils.ErrorLog("解析失败:%v", err)
  9767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9768. return
  9769. }
  9770. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9771. res.Output = resEleven10265.Output
  9772. res.ErrMsg = resEleven10265.ErrMsg
  9773. res.Cainfo = resEleven10265.Cainfo
  9774. res.WarnMsg = resEleven10265.WarnMsg
  9775. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9776. res.Infcode = infocode
  9777. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9778. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9779. saveLog(result, requestLog, "5203", "结算单")
  9780. var dat map[string]interface{}
  9781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9782. fmt.Println(dat)
  9783. } else {
  9784. fmt.Println(err)
  9785. }
  9786. userJSONBytes, _ := json.Marshal(dat)
  9787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9788. utils.ErrorLog("解析失败:%v", err)
  9789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9790. return
  9791. }
  9792. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9793. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9794. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9795. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9796. resp, requestErr := http.Get(api)
  9797. if requestErr != nil {
  9798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9799. return
  9800. }
  9801. body, ioErr := ioutil.ReadAll(resp.Body)
  9802. if ioErr != nil {
  9803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9805. return
  9806. }
  9807. var respJSON map[string]interface{}
  9808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9811. return
  9812. }
  9813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9814. result, _ := json.Marshal(respJSON)
  9815. fmt.Println("log")
  9816. fmt.Println(string(result))
  9817. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9818. utils.ErrorLog("解析失败:%v", err)
  9819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9820. return
  9821. }
  9822. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9823. res.Output = resEleven10265.Output
  9824. res.ErrMsg = resEleven10265.ErrMsg
  9825. res.Cainfo = resEleven10265.Cainfo
  9826. res.WarnMsg = resEleven10265.WarnMsg
  9827. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9828. res.Infcode = infocode
  9829. } else {
  9830. result := service.Gdyb5203(baseParams, businessParams)
  9831. //service.Gdyb5204(baseParams, businessParams)
  9832. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9833. var dat map[string]interface{}
  9834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9835. fmt.Println(dat)
  9836. } else {
  9837. fmt.Println(err)
  9838. }
  9839. userJSONBytes, _ := json.Marshal(dat)
  9840. if miConfig.Code == "H15049901371" {
  9841. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9842. utils.ErrorLog("解析失败:%v", err)
  9843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9844. return
  9845. }
  9846. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9847. res.Output = resEleven10265.Output
  9848. res.ErrMsg = resEleven10265.ErrMsg
  9849. res.Cainfo = resEleven10265.Cainfo
  9850. res.WarnMsg = resEleven10265.WarnMsg
  9851. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9852. res.Infcode = infocode
  9853. } else {
  9854. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9855. utils.ErrorLog("解析失败:%v", err)
  9856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9857. return
  9858. }
  9859. }
  9860. }
  9861. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9862. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9863. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9864. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9865. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9866. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9867. var doctor_name string
  9868. if roles.ID == 0 {
  9869. doctor_name = "管理员"
  9870. } else {
  9871. doctor_name = roles.UserName
  9872. }
  9873. yiliao_leibie := ""
  9874. switch order.MedType {
  9875. case "11":
  9876. yiliao_leibie = "普通门诊"
  9877. break
  9878. case "12":
  9879. yiliao_leibie = "门诊挂号"
  9880. break
  9881. case "13":
  9882. yiliao_leibie = "急诊"
  9883. break
  9884. case "14":
  9885. yiliao_leibie = "门诊特殊病"
  9886. break
  9887. case "15":
  9888. yiliao_leibie = "门诊统筹"
  9889. break
  9890. case "16":
  9891. yiliao_leibie = "门诊慢性病"
  9892. break
  9893. case "21":
  9894. yiliao_leibie = "普通住院"
  9895. break
  9896. }
  9897. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9898. if res.Infcode == 0 {
  9899. c.ServeSuccessJSON(map[string]interface{}{
  9900. "diagnosis": name,
  9901. "order_infos": orderInfos,
  9902. "number": order.MdtrtId,
  9903. "date": order.SettleAccountsDate,
  9904. "charge_admin": charge_admin,
  9905. "printor_admin": printor_admin,
  9906. "info": res.Output.Setlinfo,
  9907. "order": order,
  9908. "bedCostTotal": bedCostTotal,
  9909. "bedCostSelfTotal": bedCostSelfTotal,
  9910. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9911. "operationCostTotal": operationCostTotal,
  9912. "operationCostSelfTotal": operationCostSelfTotal,
  9913. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9914. "otherCostTotal": otherCostTotal,
  9915. "otherCostSelfTotal": otherCostSelfTotal,
  9916. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9917. "materialCostTotal": materialCostTotal,
  9918. "materialCostSelfTotal": materialCostSelfTotal,
  9919. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9920. "westernMedicineCostTotal": westernMedicineCostTotal,
  9921. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9922. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9923. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9924. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9925. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9926. "checkCostTotal": checkCostTotal,
  9927. "checkCostSelfTotal": checkCostSelfTotal,
  9928. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9929. "laboratoryCostTotal": laboratoryCostTotal,
  9930. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9931. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9932. "treatCostTotal": treatCostTotal,
  9933. "treatCostSelfTotal": treatCostSelfTotal,
  9934. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9935. "doctor_info": doctor_info,
  9936. "doctor_code": adminRole_two.DoctorCode,
  9937. "doctor_name": doctor_name,
  9938. "health_card_no": order.PsnNo,
  9939. "department": departments.Name,
  9940. "yiliao_leibie": yiliao_leibie,
  9941. "after_money": order.AccountPrice,
  9942. "patient": patient,
  9943. "org_name": miConfig.OrgName,
  9944. "org_code": miConfig.Code,
  9945. "order_number": order.Number,
  9946. "his_hospital": his_hospital,
  9947. "his": his,
  9948. "dia_config": dia_config,
  9949. //"check_order_info": cus_slice,
  9950. })
  9951. }
  9952. }
  9953. }
  9954. func (c *HisApiController) CheckTreatment() {
  9955. patient_id, _ := c.GetInt64("patient_id")
  9956. id_card_no := c.GetString("id_card_no")
  9957. insutype := c.GetString("insutype")
  9958. med_type := c.GetString("med_type")
  9959. admin_user_id, _ := c.GetInt64("admin_user_id")
  9960. adminUser := c.GetAdminUserInfo()
  9961. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9962. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9963. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9964. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9965. if miConfig.MdtrtareaAdmvs == "421300" {
  9966. var res ResultTwo
  9967. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9968. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9969. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(2, 10)
  9970. resp, requestErr := http.Get(api)
  9971. if requestErr != nil {
  9972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9973. return
  9974. }
  9975. body, ioErr := ioutil.ReadAll(resp.Body)
  9976. if ioErr != nil {
  9977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9979. return
  9980. }
  9981. var respJSON map[string]interface{}
  9982. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9985. return
  9986. }
  9987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9988. result, _ := json.Marshal(respJSON)
  9989. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9990. utils.ErrorLog("解析失败:%v", err)
  9991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9992. return
  9993. }
  9994. if res.Infcode == 0 {
  9995. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9996. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9997. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9998. resp, requestErr := http.Get(api)
  9999. if requestErr != nil {
  10000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10001. return
  10002. }
  10003. body, ioErr := ioutil.ReadAll(resp.Body)
  10004. if ioErr != nil {
  10005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10007. return
  10008. }
  10009. var respJSON map[string]interface{}
  10010. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10013. return
  10014. }
  10015. var res Result2001
  10016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10017. result2, _ := json.Marshal(respJSON)
  10018. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10019. utils.ErrorLog("解析失败:%v", err)
  10020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10021. return
  10022. }
  10023. if res.Infcode == 0 {
  10024. c.ServeSuccessJSON(map[string]interface{}{
  10025. "msg": res.Output.Trtinfo,
  10026. })
  10027. }
  10028. } else {
  10029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10030. return
  10031. }
  10032. } else {
  10033. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10034. var dat map[string]interface{}
  10035. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10036. fmt.Println(dat)
  10037. } else {
  10038. fmt.Println(err)
  10039. }
  10040. userJSONBytes, _ := json.Marshal(dat)
  10041. var res ResultTwo
  10042. var res10265 ResultTwo10265
  10043. if miConfig.Code == "H15049901371" {
  10044. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10045. utils.ErrorLog("解析失败:%v", err)
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10047. return
  10048. }
  10049. res.ErrMsg = res10265.ErrMsg
  10050. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10051. res.Infcode = infocode
  10052. res.Output = res10265.Output
  10053. res.InfRefmsgid = res10265.InfRefmsgid
  10054. } else {
  10055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10056. utils.ErrorLog("解析失败:%v", err)
  10057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10058. return
  10059. }
  10060. }
  10061. var user_name string
  10062. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10063. if role.ID == 0 {
  10064. user_name = "xxx"
  10065. } else {
  10066. user_name = role.UserName
  10067. }
  10068. baseParams := models.BaseParams{
  10069. SecretKey: miConfig.SecretKey,
  10070. FixmedinsCode: miConfig.Code,
  10071. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10072. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10073. OrgName: miConfig.OrgName,
  10074. Doctor: user_name,
  10075. }
  10076. if config.IsOpen == 1 {
  10077. if miConfig.Code == "H15049901371" {
  10078. if med_type == "14" {
  10079. if insutype == "390" {
  10080. med_type = "9933"
  10081. } else if insutype == "310" {
  10082. med_type = "990502"
  10083. }
  10084. } else if med_type == "11" {
  10085. med_type = "11"
  10086. }
  10087. }
  10088. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10089. var dat map[string]interface{}
  10090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10091. fmt.Println(dat)
  10092. } else {
  10093. fmt.Println(err)
  10094. }
  10095. var res Result2001
  10096. var res10265 Result2001Org10265
  10097. if miConfig.Code == "H15049901371" {
  10098. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10099. utils.ErrorLog("解析失败:%v", err)
  10100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10101. return
  10102. }
  10103. res.ErrMsg = res10265.ErrMsg
  10104. res.Output = res10265.Output
  10105. res.InfRefmsgid = res10265.InfRefmsgid
  10106. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10107. res.Infcode = infocode
  10108. } else {
  10109. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10110. utils.ErrorLog("解析失败:%v", err)
  10111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10112. return
  10113. }
  10114. }
  10115. if res.Infcode == 0 {
  10116. c.ServeSuccessJSON(map[string]interface{}{
  10117. "msg": res.Output.Trtinfo,
  10118. })
  10119. }
  10120. }
  10121. }
  10122. }
  10123. //func (c *HisApiController) PutRecord() {
  10124. // id, _ := c.GetInt64("id")
  10125. // record_time := c.GetString("record_time")
  10126. // timeLayout := "2006-01-02"
  10127. // loc, _ := time.LoadLocation("Local")
  10128. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10129. // if err != nil {
  10130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10131. // return
  10132. // }
  10133. // recordDateTime := theTime.Unix()
  10134. //
  10135. // adminInfo := c.GetAdminUserInfo()
  10136. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10137. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10138. //
  10139. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10140. //
  10141. // fmt.Println(miConfig.SecretKey)
  10142. //
  10143. // if patient == nil {
  10144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10145. // return
  10146. // }
  10147. // if len(patient.IdCardNo) == 0 {
  10148. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10149. // return
  10150. // }
  10151. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10152. // if config.IsOpen == 1 {
  10153. // api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10154. // resp, requestErr := http.Get(api)
  10155. // if requestErr != nil {
  10156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10157. // return
  10158. // }
  10159. // defer resp.Body.Close()
  10160. // body, ioErr := ioutil.ReadAll(resp.Body)
  10161. // if ioErr != nil {
  10162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. // return
  10165. // }
  10166. // var respJSON map[string]interface{}
  10167. //
  10168. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10169. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10171. // return
  10172. // }
  10173. //
  10174. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10175. // userJSONBytes, _ := json.Marshal(userJSON)
  10176. // var res ResultTwo
  10177. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10178. // utils.ErrorLog("解析失败:%v", err)
  10179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10180. // return
  10181. // }
  10182. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10183. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10184. // infoStr := string(Iinfos)
  10185. // idetinfoStr := string(Idetinfos)
  10186. //
  10187. // if res.Infcode == 0 {
  10188. // his := models.VMHisPatient{
  10189. // Status: 1,
  10190. // Ctime: time.Now().Unix(),
  10191. // Mtime: time.Now().Unix(),
  10192. // PsnNo: res.Output.Baseinfo.PsnNo,
  10193. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10194. // Certno: res.Output.Baseinfo.Certno,
  10195. // PsnName: res.Output.Baseinfo.PsnName,
  10196. // Gend: res.Output.Baseinfo.Gend,
  10197. // Naty: res.Output.Baseinfo.Naty,
  10198. // Brdy: res.Output.Baseinfo.Brdy,
  10199. // Age: res.Output.Baseinfo.Age,
  10200. // Iinfo: infoStr,
  10201. // Idetinfo: idetinfoStr,
  10202. // PatientId: patient.ID,
  10203. // RecordDate: theTime.Unix(),
  10204. // UserOrgId: adminInfo.CurrentOrgId,
  10205. // AdminUserId: adminInfo.AdminUser.Id,
  10206. // IsReturn: 1,
  10207. // }
  10208. //
  10209. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10210. // //result := service.Gdyb2503(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  10211. // //result2 := service.Gdyb5301(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  10212. //
  10213. // //var dat map[string]interface{}
  10214. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10215. // // fmt.Println(dat)
  10216. // //} else {
  10217. // // fmt.Println(err)
  10218. // //}
  10219. //
  10220. // var dat2 map[string]interface{}
  10221. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10222. // fmt.Println(dat2)
  10223. // } else {
  10224. // fmt.Println(err)
  10225. // }
  10226. //
  10227. // } else {
  10228. // adminUser := c.GetAdminUserInfo()
  10229. // errlog := &models.HisOrderError{
  10230. // UserOrgId: adminUser.CurrentOrgId,
  10231. // Ctime: time.Now().Unix(),
  10232. // Mtime: time.Now().Unix(),
  10233. // ErrMsg: res.ErrMsg,
  10234. // Status: 1,
  10235. // PatientId: id,
  10236. // RecordTime: recordDateTime,
  10237. // Stage: 1,
  10238. // }
  10239. // service.CreateErrMsgLog(errlog)
  10240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10241. // return
  10242. // }
  10243. // }
  10244. //
  10245. //}
  10246. //func (c *HisApiController) GetUploadDiag() {
  10247. // id, _ := c.GetInt64("id")
  10248. // record_time := c.GetString("record_time")
  10249. //
  10250. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10251. // sick_type, _ := c.GetInt64("sick_type")
  10252. // reg_type, _ := c.GetInt64("reg_type")
  10253. //
  10254. // timeLayout := "2006-01-02"
  10255. // loc, _ := time.LoadLocation("Local")
  10256. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10257. // if err != nil {
  10258. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10259. // return
  10260. // }
  10261. //
  10262. // var patientPrescription models.HisPrescriptionInfo
  10263. // recordDateTime := theTime.Unix()
  10264. // adminInfo := c.GetAdminUserInfo()
  10265. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10266. //
  10267. // if patientPrescription.ID == 0 {
  10268. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10269. // }
  10270. //
  10271. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10272. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10273. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10274. // sickConfig, _ := service.FindSickById(sick_type)
  10275. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10276. //
  10277. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10278. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10279. // "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
  10280. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10281. // resp2, requestErr2 := http.Get(api2)
  10282. // if requestErr2 != nil {
  10283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10284. // return
  10285. // }
  10286. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10287. // if ioErr2 != nil {
  10288. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10290. // return
  10291. // }
  10292. // var respJSON2 map[string]interface{}
  10293. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10294. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10295. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10296. // return
  10297. // }
  10298. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10299. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10300. //
  10301. // var res2 ResultSix
  10302. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10303. // utils.ErrorLog("解析失败:%v", err)
  10304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10305. // return
  10306. // }
  10307. // if res2.Infcode != 0 {
  10308. // adminUser := c.GetAdminUserInfo()
  10309. // errlog := &models.HisOrderError{
  10310. // UserOrgId: adminUser.CurrentOrgId,
  10311. // Ctime: time.Now().Unix(),
  10312. // Mtime: time.Now().Unix(),
  10313. // ErrMsg: res2.ErrMsg,
  10314. // Status: 1,
  10315. // PatientId: id,
  10316. // RecordTime: recordDateTime,
  10317. // Stage: 3,
  10318. // }
  10319. // service.CreateErrMsgLog(errlog)
  10320. //
  10321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10322. // return
  10323. // }
  10324. //
  10325. // c.ServeSuccessJSON(map[string]interface{}{
  10326. // "msg": "上传成功",
  10327. // })
  10328. //
  10329. //}
  10330. type QueryResult struct {
  10331. ID int64
  10332. Name string
  10333. Code string
  10334. List_type_code string
  10335. }
  10336. func (c *HisApiController) GetCheckCode() {
  10337. ids_str := c.GetString("ids")
  10338. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10339. ids_arr := strings.Split(ids_str, ",")
  10340. var queryResult []QueryResult
  10341. ids := make([]int64, 0)
  10342. for _, item := range ids_arr {
  10343. id, _ := strconv.ParseInt(item, 10, 64)
  10344. ids = append(ids, id)
  10345. }
  10346. if record_type == 1 {
  10347. drugs, _ := service.GetBatchDrugList(ids)
  10348. for _, item := range drugs {
  10349. result := QueryResult{
  10350. ID: item.ID,
  10351. Name: item.DrugName,
  10352. Code: item.MedicalInsuranceNumber,
  10353. List_type_code: "101",
  10354. }
  10355. queryResult = append(queryResult, result)
  10356. }
  10357. } else if record_type == 2 {
  10358. goods, _ := service.GetBatchGoodInformationList(ids)
  10359. for _, item := range goods {
  10360. result := QueryResult{
  10361. ID: item.ID,
  10362. Name: item.GoodName,
  10363. Code: item.MedicalInsuranceNumber,
  10364. List_type_code: "301",
  10365. }
  10366. queryResult = append(queryResult, result)
  10367. }
  10368. } else if record_type == 3 {
  10369. projects, _ := service.GetBathchMyPorjecgList(ids)
  10370. for _, item := range projects {
  10371. result := QueryResult{
  10372. ID: item.ID,
  10373. Name: item.ProjectName,
  10374. Code: item.MedicalCode,
  10375. List_type_code: "201",
  10376. }
  10377. queryResult = append(queryResult, result)
  10378. }
  10379. }
  10380. admin_user_id, _ := c.GetInt64("admin_user_id")
  10381. adminUser := c.GetAdminUserInfo()
  10382. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10383. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10384. var user_name string
  10385. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10386. if role.ID == 0 {
  10387. user_name = "xxx"
  10388. } else {
  10389. user_name = role.UserName
  10390. }
  10391. baseParams := &models.BaseParams{
  10392. SecretKey: miConfig.SecretKey,
  10393. FixmedinsCode: miConfig.Code,
  10394. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10395. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10396. OrgName: miConfig.OrgName,
  10397. Doctor: user_name,
  10398. }
  10399. if config.IsOpen == 1 {
  10400. for _, item := range queryResult {
  10401. var result string
  10402. if record_type == 1 {
  10403. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10404. } else if record_type == 2 {
  10405. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10406. } else if record_type == 3 {
  10407. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10408. }
  10409. var dat map[string]interface{}
  10410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10411. fmt.Println(dat)
  10412. } else {
  10413. fmt.Println(err)
  10414. }
  10415. userJSONBytes, _ := json.Marshal(dat)
  10416. var res ResultSix
  10417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10418. utils.ErrorLog("解析失败:%v", err)
  10419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10420. return
  10421. }
  10422. if res.Infcode == 0 {
  10423. if record_type == 1 {
  10424. service.UpdateBaseDrugById(item.ID)
  10425. } else if record_type == 2 {
  10426. service.UpdateGoodInformaitonByDetail(item.ID)
  10427. } else if record_type == 3 {
  10428. service.UpdateProjectById(item.ID)
  10429. }
  10430. c.ServeSuccessJSON(map[string]interface{}{
  10431. "failed_code": 0,
  10432. "msg": "目录对照成功",
  10433. })
  10434. } else {
  10435. c.ServeSuccessJSON(map[string]interface{}{
  10436. "failed_code": -10,
  10437. "msg": res.ErrMsg,
  10438. })
  10439. }
  10440. }
  10441. }
  10442. }
  10443. func (c *HisApiController) UnCheckCode() {
  10444. ids_str := c.GetString("ids")
  10445. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10446. admin_user_id, _ := c.GetInt64("admin_user_id")
  10447. ids_arr := strings.Split(ids_str, ",")
  10448. var queryResult []QueryResult
  10449. ids := make([]int64, 0)
  10450. for _, item := range ids_arr {
  10451. id, _ := strconv.ParseInt(item, 10, 64)
  10452. ids = append(ids, id)
  10453. }
  10454. if record_type == 1 {
  10455. drugs, _ := service.GetBatchDrugList(ids)
  10456. for _, item := range drugs {
  10457. result := QueryResult{
  10458. ID: item.ID,
  10459. Name: item.DrugName,
  10460. Code: item.MedicalInsuranceNumber,
  10461. List_type_code: "101",
  10462. }
  10463. queryResult = append(queryResult, result)
  10464. }
  10465. } else if record_type == 2 {
  10466. goods, _ := service.GetBatchGoodInformationList(ids)
  10467. for _, item := range goods {
  10468. result := QueryResult{
  10469. ID: item.ID,
  10470. Name: item.GoodName,
  10471. Code: item.MedicalInsuranceNumber,
  10472. List_type_code: "301",
  10473. }
  10474. queryResult = append(queryResult, result)
  10475. }
  10476. } else if record_type == 3 {
  10477. projects, _ := service.GetBathchMyPorjecgList(ids)
  10478. for _, item := range projects {
  10479. result := QueryResult{
  10480. ID: item.ID,
  10481. Name: item.ProjectName,
  10482. Code: item.MedicalCode,
  10483. List_type_code: "201",
  10484. }
  10485. queryResult = append(queryResult, result)
  10486. }
  10487. }
  10488. adminUser := c.GetAdminUserInfo()
  10489. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10490. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10491. var user_name string
  10492. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10493. if role.ID == 0 {
  10494. user_name = "xxx"
  10495. } else {
  10496. user_name = role.UserName
  10497. }
  10498. baseParams := &models.BaseParams{
  10499. SecretKey: miConfig.SecretKey,
  10500. FixmedinsCode: miConfig.Code,
  10501. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10502. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10503. OrgName: miConfig.OrgName,
  10504. Doctor: user_name,
  10505. }
  10506. if config.IsOpen == 1 {
  10507. for _, item := range queryResult {
  10508. var result string
  10509. if record_type == 1 {
  10510. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10511. } else if record_type == 2 {
  10512. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10513. } else if record_type == 3 {
  10514. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10515. }
  10516. var dat2 map[string]interface{}
  10517. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10518. fmt.Println(dat2)
  10519. } else {
  10520. fmt.Println(err)
  10521. }
  10522. userJSONBytes, _ := json.Marshal(dat2)
  10523. var res ResultSix
  10524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10525. utils.ErrorLog("解析失败:%v", err)
  10526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10527. return
  10528. }
  10529. if res.Infcode == 0 {
  10530. if record_type == 1 {
  10531. service.UpdateDrugByIdDetail(item.ID)
  10532. } else if record_type == 2 {
  10533. service.UpdateGoodInfoById(item.ID)
  10534. } else if record_type == 3 {
  10535. service.UpdateMyProjectById(item.ID)
  10536. }
  10537. c.ServeSuccessJSON(map[string]interface{}{
  10538. "failed_code": 0,
  10539. "msg": "撤销目录对照成功",
  10540. })
  10541. } else {
  10542. c.ServeSuccessJSON(map[string]interface{}{
  10543. "failed_code": -10,
  10544. "msg": res.ErrMsg,
  10545. })
  10546. }
  10547. }
  10548. }
  10549. }
  10550. func (c *HisApiController) GetPatientInfo() {
  10551. id_card_no := c.GetString("id_card_no")
  10552. admin_user_id, _ := c.GetInt64("admin_user_id")
  10553. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10554. if patient.ID == 0 {
  10555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10556. return
  10557. }
  10558. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10559. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10560. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10561. if config.IsOpen == 1 {
  10562. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10563. var dat map[string]interface{}
  10564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10565. fmt.Println(dat)
  10566. } else {
  10567. fmt.Println(err)
  10568. }
  10569. userJSONBytes, _ := json.Marshal(dat)
  10570. var res ResultTwo
  10571. var res10265 ResultTwo10265
  10572. if miConfig.Code == "H15049901371" {
  10573. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10574. utils.ErrorLog("解析失败:%v", err)
  10575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10576. return
  10577. }
  10578. res.ErrMsg = res10265.ErrMsg
  10579. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10580. res.Infcode = infocode
  10581. res.Output = res10265.Output
  10582. res.InfRefmsgid = res10265.InfRefmsgid
  10583. } else {
  10584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10585. utils.ErrorLog("解析失败:%v", err)
  10586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10587. return
  10588. }
  10589. }
  10590. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10591. // utils.ErrorLog("解析失败:%v", err)
  10592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10593. // return
  10594. //}
  10595. if res.Infcode != 0 {
  10596. c.ServeSuccessJSON(map[string]interface{}{
  10597. "failed_code": -10,
  10598. "msg": res.ErrMsg,
  10599. })
  10600. } else {
  10601. c.ServeSuccessJSON(map[string]interface{}{
  10602. "failed_code": 0,
  10603. "info": res,
  10604. })
  10605. }
  10606. }
  10607. }
  10608. func (c *HisApiController) PsnPutOnRecord() {
  10609. record_type, _ := c.GetInt64("type")
  10610. patient_id, _ := c.GetInt64("patient_id")
  10611. admin_user_id, _ := c.GetInt64("admin_user_id")
  10612. start_time := c.GetString("start_time")
  10613. end_time := c.GetString("end_time")
  10614. adminUser := c.GetAdminUserInfo()
  10615. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10616. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10617. var patients []*models.Patients
  10618. if record_type == 1 { //全部备案
  10619. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10620. patients = append(patients, patient...)
  10621. } else { //单个备案
  10622. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10623. patients = append(patients, patient)
  10624. }
  10625. var user_name string
  10626. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10627. if role.ID == 0 {
  10628. user_name = "xxx"
  10629. } else {
  10630. user_name = role.UserName
  10631. }
  10632. if config.IsOpen == 1 {
  10633. for _, item := range patients {
  10634. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + item.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + user_name + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10635. resp, requestErr := http.Get(api)
  10636. if requestErr != nil {
  10637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10638. return
  10639. }
  10640. defer resp.Body.Close()
  10641. body, ioErr := ioutil.ReadAll(resp.Body)
  10642. if ioErr != nil {
  10643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10645. return
  10646. }
  10647. var respJSON map[string]interface{}
  10648. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10651. return
  10652. }
  10653. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10654. userJSONBytes, _ := json.Marshal(userJSON)
  10655. var res ResultTwo
  10656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10657. utils.ErrorLog("解析失败:%v", err)
  10658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10659. return
  10660. }
  10661. if res.Infcode == 0 {
  10662. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10663. var dat map[string]interface{}
  10664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10665. fmt.Println(dat)
  10666. } else {
  10667. fmt.Println(err)
  10668. }
  10669. userJSONBytes, _ := json.Marshal(dat)
  10670. var res2 ResultThirteen
  10671. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10672. utils.ErrorLog("解析失败:%v", err)
  10673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10674. return
  10675. }
  10676. if res2.Infcode == 0 {
  10677. psnResult := &models.GdybPsnRecord{
  10678. UserOrgId: adminUser.CurrentOrgId,
  10679. PatientId: item.ID,
  10680. PsnNo: res.Output.Baseinfo.PsnNo,
  10681. Ctime: time.Now().Unix(),
  10682. Mtime: time.Now().Unix(),
  10683. Status: 1,
  10684. IsCancel: 1,
  10685. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10686. }
  10687. service.CreatePsnRecord(psnResult)
  10688. } else {
  10689. c.ServeSuccessJSON(map[string]interface{}{
  10690. "failed_code": -10,
  10691. "msg": res2.ErrMsg,
  10692. })
  10693. return
  10694. }
  10695. }
  10696. }
  10697. }
  10698. }
  10699. func (c *HisApiController) PsnUnPutOnRecord() {
  10700. id, _ := c.GetInt64("id")
  10701. //record_type, _ := c.GetInt64("type")
  10702. admin_user_id, _ := c.GetInt64("admin_user_id")
  10703. adminUser := c.GetAdminUserInfo()
  10704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10705. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10706. var user_name string
  10707. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10708. if role.ID == 0 {
  10709. user_name = "xxx"
  10710. } else {
  10711. user_name = role.UserName
  10712. }
  10713. psn_record, _ := service.GetPsnRecordById(id)
  10714. if psn_record.ID == 0 {
  10715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10716. return
  10717. }
  10718. if config.IsOpen == 1 {
  10719. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10720. var dat map[string]interface{}
  10721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10722. fmt.Println(dat)
  10723. } else {
  10724. fmt.Println(err)
  10725. }
  10726. userJSONBytes, _ := json.Marshal(dat)
  10727. var res ResultFourteen
  10728. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10729. utils.ErrorLog("解析失败:%v", err)
  10730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10731. return
  10732. }
  10733. if res.Infcode == 0 {
  10734. psn_record.IsCancel = 2
  10735. service.CreatePsnRecord(&psn_record)
  10736. } else {
  10737. c.ServeSuccessJSON(map[string]interface{}{
  10738. "failed_code": -10,
  10739. "msg": res.ErrMsg,
  10740. })
  10741. return
  10742. }
  10743. }
  10744. }
  10745. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10746. patient_id, _ := c.GetInt64("patient_id")
  10747. insutype_two := c.GetString("insutype")
  10748. psn_no := c.GetString("psn_no")
  10749. doctor_id, _ := c.GetInt64("doctor_id")
  10750. sick_id, _ := c.GetInt64("sick_id")
  10751. department_id, _ := c.GetInt64("department_id")
  10752. start_time := c.GetString("start_time")
  10753. end_time := c.GetString("end_time")
  10754. check_time := c.GetString("check_time")
  10755. adminUser := c.GetAdminUserInfo()
  10756. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10757. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10758. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10759. sick, _ := service.FindSickById(sick_id)
  10760. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10761. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10762. var res ResultTwo
  10763. var res10265 ResultTwo10265
  10764. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10765. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10766. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10767. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10768. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  10769. resp, requestErr := http.Get(api)
  10770. if requestErr != nil {
  10771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10772. return
  10773. }
  10774. body, ioErr := ioutil.ReadAll(resp.Body)
  10775. if ioErr != nil {
  10776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10778. return
  10779. }
  10780. var respJSON map[string]interface{}
  10781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10784. return
  10785. }
  10786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10787. result, _ := json.Marshal(respJSON)
  10788. fmt.Println("log")
  10789. fmt.Println(string(result))
  10790. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10791. utils.ErrorLog("解析失败:%v", err)
  10792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10793. return
  10794. }
  10795. res.ErrMsg = res10265.ErrMsg
  10796. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10797. res.Infcode = infocode
  10798. res.Output = res10265.Output
  10799. res.InfRefmsgid = res10265.InfRefmsgid
  10800. } else {
  10801. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10802. if miConfig.Code == "H15049901371" {
  10803. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10804. utils.ErrorLog("解析失败:%v", err)
  10805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10806. return
  10807. }
  10808. res.ErrMsg = res10265.ErrMsg
  10809. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10810. res.Infcode = infocode
  10811. res.Output = res10265.Output
  10812. res.InfRefmsgid = res10265.InfRefmsgid
  10813. } else {
  10814. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10815. utils.ErrorLog("解析失败:%v", err)
  10816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10817. return
  10818. }
  10819. }
  10820. }
  10821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10822. infoStr := string(Iinfos)
  10823. var rf []*ResultFive
  10824. json.Unmarshal([]byte(infoStr), &rf)
  10825. var insuplc_admdvs string
  10826. var insutype string
  10827. var is390 int = 0
  10828. var is310 int = 0
  10829. var insutypes []*ResultFive
  10830. for _, item := range rf {
  10831. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10832. insutypes = append(insutypes, item)
  10833. }
  10834. }
  10835. if len(insutypes) == 1 {
  10836. insutype = insutypes[0].Insutype
  10837. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10838. } else {
  10839. for _, i := range insutypes {
  10840. if i.Insutype == "390" {
  10841. is390 = 1
  10842. }
  10843. if i.Insutype == "310" {
  10844. is310 = 1
  10845. }
  10846. }
  10847. }
  10848. if is390 == 1 {
  10849. insutype = "390"
  10850. }
  10851. if is310 == 1 {
  10852. insutype = "310"
  10853. }
  10854. if len(insutypes) == 2 {
  10855. insutype = insutype_two
  10856. }
  10857. if len(insutypes) == 0 {
  10858. insutype = "310"
  10859. }
  10860. insutype = insutype_two
  10861. fmt.Println(insutype)
  10862. for _, item := range rf {
  10863. fmt.Println(item.Insutype)
  10864. fmt.Println(insutype)
  10865. if item.Insutype == insutype {
  10866. fmt.Println(item.Insutype)
  10867. fmt.Println(insutype)
  10868. insuplc_admdvs = item.InsuplcAdmdvs
  10869. }
  10870. }
  10871. fmt.Println(insuplc_admdvs)
  10872. var res2 ResultThirteen
  10873. var res10265_2 ResultThirteen10265
  10874. if config.IsOpen == 1 {
  10875. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10876. } else {
  10877. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  10878. var dat map[string]interface{}
  10879. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10880. fmt.Println(dat)
  10881. } else {
  10882. fmt.Println(err)
  10883. }
  10884. userJSONBytes, _ := json.Marshal(dat)
  10885. if miConfig.Code == "H15049901371" {
  10886. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10887. utils.ErrorLog("解析失败:%v", err)
  10888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10889. return
  10890. }
  10891. res2.ErrMsg = res10265_2.ErrMsg
  10892. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10893. res2.Infcode = infocode
  10894. res2.Output = res10265_2.Output
  10895. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10896. } else {
  10897. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10898. utils.ErrorLog("解析失败:%v", err)
  10899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10900. return
  10901. }
  10902. }
  10903. }
  10904. if res2.Infcode == 0 {
  10905. psnResult := &models.GdybPsnNcdsRecord{
  10906. UserOrgId: adminUser.CurrentOrgId,
  10907. PatientId: patient.ID,
  10908. PsnNo: psn_no,
  10909. DoctorId: doctor.AdminUserId,
  10910. DepartmentId: department_id,
  10911. SickType: sick_id,
  10912. Insutype: insutype,
  10913. Ctime: time.Now().Unix(),
  10914. Mtime: time.Now().Unix(),
  10915. Status: 1,
  10916. IsCancel: 1,
  10917. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10918. }
  10919. service.CreatePsnNCDSRecord(psnResult)
  10920. c.ServeSuccessJSON(map[string]interface{}{
  10921. "failed_code": 0,
  10922. "msg": "备案成功",
  10923. "result": psnResult,
  10924. })
  10925. } else {
  10926. c.ServeSuccessJSON(map[string]interface{}{
  10927. "failed_code": -10,
  10928. "msg": res2.ErrMsg,
  10929. })
  10930. return
  10931. }
  10932. }
  10933. }
  10934. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10935. id, _ := c.GetInt64("id")
  10936. admin_user_id, _ := c.GetInt64("admin_user_id")
  10937. adminUser := c.GetAdminUserInfo()
  10938. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10939. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10940. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10941. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10942. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10943. //var user_name string
  10944. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10945. //if role.ID == 0 {
  10946. // user_name = "xxx"
  10947. //} else {
  10948. // user_name = role.UserName
  10949. //}
  10950. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10951. if psn_record.ID == 0 {
  10952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10953. return
  10954. }
  10955. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10956. var res ResultTwo
  10957. var res10265 ResultTwo10265
  10958. if miConfig.Code == "H15049901371" {
  10959. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10960. utils.ErrorLog("解析失败:%v", err)
  10961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10962. return
  10963. }
  10964. res.ErrMsg = res10265.ErrMsg
  10965. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10966. res.Infcode = infocode
  10967. res.Output = res10265.Output
  10968. res.InfRefmsgid = res10265.InfRefmsgid
  10969. } else {
  10970. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10971. utils.ErrorLog("解析失败:%v", err)
  10972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10973. return
  10974. }
  10975. }
  10976. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10977. infoStr := string(Iinfos)
  10978. var rf []*ResultFive
  10979. json.Unmarshal([]byte(infoStr), &rf)
  10980. var insuplc_admdvs string
  10981. var insutype string
  10982. var is390 int = 0
  10983. var is310 int = 0
  10984. var insutypes []*ResultFive
  10985. for _, item := range rf {
  10986. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10987. insutypes = append(insutypes, item)
  10988. }
  10989. }
  10990. if len(insutypes) == 1 {
  10991. insutype = insutypes[0].Insutype
  10992. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10993. } else {
  10994. for _, i := range insutypes {
  10995. if i.Insutype == "390" {
  10996. is390 = 1
  10997. }
  10998. if i.Insutype == "310" {
  10999. is310 = 1
  11000. }
  11001. }
  11002. }
  11003. if is390 == 1 {
  11004. insutype = "390"
  11005. }
  11006. if is310 == 1 {
  11007. insutype = "310"
  11008. }
  11009. if len(insutypes) == 0 {
  11010. insutype = "310"
  11011. }
  11012. insutype = psn_record.Insutype
  11013. for _, item := range rf {
  11014. if item.Insutype == insutype {
  11015. insuplc_admdvs = item.InsuplcAdmdvs
  11016. }
  11017. }
  11018. if config.IsOpen == 1 {
  11019. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11020. var dat map[string]interface{}
  11021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11022. fmt.Println(dat)
  11023. } else {
  11024. fmt.Println(err)
  11025. }
  11026. userJSONBytes, _ := json.Marshal(dat)
  11027. var res ResultFourteen
  11028. var res10265 ResultFourteen10265
  11029. if miConfig.Code == "H15049901371" {
  11030. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11031. utils.ErrorLog("解析失败:%v", err)
  11032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11033. return
  11034. }
  11035. res.ErrMsg = res10265.ErrMsg
  11036. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11037. res.Infcode = infocode
  11038. res.Output = res10265.Output
  11039. res.InfRefmsgid = res10265.InfRefmsgid
  11040. } else {
  11041. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11042. utils.ErrorLog("解析失败:%v", err)
  11043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11044. return
  11045. }
  11046. }
  11047. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11048. // utils.ErrorLog("解析失败:%v", err)
  11049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11050. // return
  11051. //}
  11052. if res.Infcode == 0 {
  11053. psn_record.IsCancel = 2
  11054. service.CreatePsnNCDSRecord(&psn_record)
  11055. c.ServeSuccessJSON(map[string]interface{}{
  11056. "failed_code": 0,
  11057. "msg": "撤销备案成功",
  11058. })
  11059. } else {
  11060. c.ServeSuccessJSON(map[string]interface{}{
  11061. "failed_code": -10,
  11062. "msg": res.ErrMsg,
  11063. })
  11064. return
  11065. }
  11066. }
  11067. }
  11068. func (c *HisApiController) TestTest() {
  11069. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11070. fmt.Println(patient.Iinfo)
  11071. }
  11072. type CustomData struct {
  11073. MsgId string
  11074. PsnNo string
  11075. Info string
  11076. }
  11077. func (c *HisApiController) ReversalData() {
  11078. var customData []*CustomData
  11079. custom := &CustomData{
  11080. MsgId: "H44022900158202103301714472004",
  11081. PsnNo: "44020000001101329945",
  11082. Info: "2207",
  11083. }
  11084. customData = append(customData, custom)
  11085. custom1 := &CustomData{
  11086. MsgId: "H4402290015820210330172057803",
  11087. PsnNo: "44020000001101161813",
  11088. Info: "2207",
  11089. }
  11090. customData = append(customData, custom1)
  11091. custom2 := &CustomData{
  11092. MsgId: "H44022900158202103301705198813",
  11093. PsnNo: "44190000133097375417",
  11094. Info: "2207",
  11095. }
  11096. customData = append(customData, custom2)
  11097. custom3 := &CustomData{
  11098. MsgId: "H44022900158202103301715524756",
  11099. PsnNo: "44020000001100187221",
  11100. Info: "2207",
  11101. }
  11102. customData = append(customData, custom3)
  11103. custom4 := &CustomData{
  11104. MsgId: "H44022900158202103301730376224",
  11105. PsnNo: "44020000001101959155",
  11106. Info: "2207",
  11107. }
  11108. customData = append(customData, custom4)
  11109. custom5 := &CustomData{
  11110. MsgId: "H44022900158202103301748008725",
  11111. PsnNo: "44020000001104246641",
  11112. Info: "2207",
  11113. }
  11114. customData = append(customData, custom5)
  11115. custom6 := &CustomData{
  11116. MsgId: "H44022900158202103301718096755",
  11117. PsnNo: "44020000001102211860",
  11118. Info: "2207",
  11119. }
  11120. customData = append(customData, custom6)
  11121. custom7 := &CustomData{
  11122. MsgId: "H44022900158202103301736551640",
  11123. PsnNo: "44020000001102687718",
  11124. Info: "2207",
  11125. }
  11126. customData = append(customData, custom7)
  11127. custom8 := &CustomData{
  11128. MsgId: "H44022900158202103301743097676",
  11129. PsnNo: "44020000001102127785",
  11130. Info: "2207",
  11131. }
  11132. customData = append(customData, custom8)
  11133. custom9 := &CustomData{
  11134. MsgId: "H44022900158202103301712304203",
  11135. PsnNo: "44020000001101518097",
  11136. Info: "2207",
  11137. }
  11138. customData = append(customData, custom9)
  11139. custom10 := &CustomData{
  11140. MsgId: "H44022900158202103301738448785",
  11141. PsnNo: "44020000001100500813",
  11142. Info: "2207",
  11143. }
  11144. customData = append(customData, custom10)
  11145. custom11 := &CustomData{
  11146. MsgId: "H44022900158202103301732455843",
  11147. PsnNo: "44020000001102690557",
  11148. Info: "2207",
  11149. }
  11150. customData = append(customData, custom11)
  11151. custom12 := &CustomData{
  11152. MsgId: "H44022900158202103301745421708",
  11153. PsnNo: "44020000001102211928",
  11154. Info: "2207",
  11155. }
  11156. customData = append(customData, custom12)
  11157. custom1212 := &CustomData{
  11158. MsgId: "H440229001582021033017351627",
  11159. PsnNo: "44020000001102481733",
  11160. Info: "2207",
  11161. }
  11162. customData = append(customData, custom1212)
  11163. custom13 := &CustomData{
  11164. MsgId: "H44022900158202103301740327951",
  11165. PsnNo: "44020000001103174866",
  11166. Info: "2207",
  11167. }
  11168. customData = append(customData, custom13)
  11169. custom14 := &CustomData{
  11170. MsgId: "H4402290015820210330174922668",
  11171. PsnNo: "44020000001102927272",
  11172. Info: "2207",
  11173. }
  11174. customData = append(customData, custom14)
  11175. custom15 := &CustomData{
  11176. MsgId: "H44022900158202103301752362273",
  11177. PsnNo: "44020000001102942890",
  11178. Info: "2207",
  11179. }
  11180. customData = append(customData, custom15)
  11181. custom16 := &CustomData{
  11182. MsgId: "H44022900158202103301751082917",
  11183. PsnNo: "44020000001101662162",
  11184. Info: "2207",
  11185. }
  11186. customData = append(customData, custom16)
  11187. custom17 := &CustomData{
  11188. MsgId: "H44022900158202103301754147728",
  11189. PsnNo: "44020000000229014511",
  11190. Info: "2207",
  11191. }
  11192. customData = append(customData, custom17)
  11193. adminUser := c.GetAdminUserInfo()
  11194. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11195. for _, item := range customData {
  11196. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11197. fmt.Println(result)
  11198. }
  11199. }
  11200. //func (c *HisApiController) GetAllopatry() {
  11201. // year := c.GetString("year")
  11202. // month := c.GetString("month")
  11203. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11204. // adminUser := c.GetAdminUserInfo()
  11205. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11206. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11207. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11208. //
  11209. // var dat map[string]interface{}
  11210. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11211. // fmt.Println(dat)
  11212. // } else {
  11213. // fmt.Println(err)
  11214. // }
  11215. // userJSONBytes, _ := json.Marshal(dat)
  11216. // var res models.Result9001
  11217. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11218. // utils.ErrorLog("解析失败:%v", err)
  11219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11220. // return
  11221. // }
  11222. //
  11223. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11224. // var dat2 map[string]interface{}
  11225. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11226. // fmt.Println(dat)
  11227. // } else {
  11228. // fmt.Println(err)
  11229. // }
  11230. // userJSONBytes2, _ := json.Marshal(dat2)
  11231. // var res2 models.Result3260
  11232. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11233. // utils.ErrorLog("解析失败:%v", err)
  11234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11235. // return
  11236. // }
  11237. // if res2.Infcode == 0 {
  11238. // c.ServeSuccessJSON(map[string]interface{}{
  11239. // "list": res2.Output.Data,
  11240. // })
  11241. // return
  11242. // } else {
  11243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11244. // return
  11245. // }
  11246. //
  11247. //}
  11248. //func (c *HisApiController) ComfirmAllopatry() {
  11249. // year := c.GetString("year")
  11250. // month := c.GetString("month")
  11251. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11252. // adminUser := c.GetAdminUserInfo()
  11253. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11254. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11255. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11256. // var dat map[string]interface{}
  11257. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11258. // fmt.Println(dat)
  11259. // } else {
  11260. // fmt.Println(err)
  11261. // }
  11262. // userJSONBytes, _ := json.Marshal(dat)
  11263. // var res models.Result9001
  11264. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11265. // utils.ErrorLog("解析失败:%v", err)
  11266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11267. // return
  11268. // }
  11269. //
  11270. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11271. // var dat2 map[string]interface{}
  11272. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11273. // fmt.Println(dat)
  11274. // } else {
  11275. // fmt.Println(err)
  11276. // }
  11277. // userJSONBytes2, _ := json.Marshal(dat2)
  11278. // var res2 models.Result3260
  11279. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11280. // utils.ErrorLog("解析失败:%v", err)
  11281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11282. // return
  11283. // }
  11284. //
  11285. // if res2.Infcode == 0 {
  11286. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11287. // var dat map[string]interface{}
  11288. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11289. // fmt.Println(dat)
  11290. // } else {
  11291. // fmt.Println(err)
  11292. // }
  11293. // userJSONBytes, _ := json.Marshal(dat)
  11294. // var res3 models.Result3261
  11295. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11296. // utils.ErrorLog("解析失败:%v", err)
  11297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11298. // return
  11299. // }
  11300. //
  11301. // if res3.Infcode == 0 {
  11302. // record := &models.HisYidiClearRecord{
  11303. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11304. // Ctime: time.Now().Unix(),
  11305. // Mtime: time.Now().Unix(),
  11306. // Status: 1,
  11307. // MsgId: msgId,
  11308. // }
  11309. // service.SaveClearRecord(record)
  11310. // c.ServeSuccessJSON(map[string]interface{}{
  11311. // "msg": "提取成功",
  11312. // })
  11313. // }
  11314. // }
  11315. //}
  11316. func (c *HisApiController) RefundAllopatry() {
  11317. year := c.GetString("year")
  11318. month := c.GetString("month")
  11319. id, _ := c.GetInt64("id")
  11320. admin_user_id, _ := c.GetInt64("admin_user_id")
  11321. adminUser := c.GetAdminUserInfo()
  11322. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11323. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11324. record, _ := service.GetClearRecordById(id)
  11325. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11326. var dat map[string]interface{}
  11327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11328. fmt.Println(dat)
  11329. } else {
  11330. fmt.Println(err)
  11331. }
  11332. userJSONBytes, _ := json.Marshal(dat)
  11333. var empty ResultFourteen
  11334. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11335. utils.ErrorLog("解析失败:%v", err)
  11336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11337. return
  11338. }
  11339. if empty.Infcode == 0 {
  11340. c.ServeSuccessJSON(map[string]interface{}{
  11341. "msg": "撤销成功",
  11342. })
  11343. return
  11344. }
  11345. }
  11346. func (c *HisApiController) ReversalOtherData() {
  11347. var customData []*CustomData
  11348. custom := &CustomData{
  11349. MsgId: "H44022900158202103301714472004",
  11350. PsnNo: "44020000001101329945",
  11351. Info: "2208",
  11352. }
  11353. customData = append(customData, custom)
  11354. custom1 := &CustomData{
  11355. MsgId: "H4402290015820210330172057803",
  11356. PsnNo: "44020000001101161813",
  11357. Info: "2208",
  11358. }
  11359. customData = append(customData, custom1)
  11360. custom2 := &CustomData{
  11361. MsgId: "H44022900158202103301705198813",
  11362. PsnNo: "44190000133097375417",
  11363. Info: "2208",
  11364. }
  11365. customData = append(customData, custom2)
  11366. custom3 := &CustomData{
  11367. MsgId: "H44022900158202103301715524756",
  11368. PsnNo: "44020000001100187221",
  11369. Info: "2208",
  11370. }
  11371. customData = append(customData, custom3)
  11372. custom4 := &CustomData{
  11373. MsgId: "H44022900158202103301730376224",
  11374. PsnNo: "44020000001101959155",
  11375. Info: "2208",
  11376. }
  11377. customData = append(customData, custom4)
  11378. custom5 := &CustomData{
  11379. MsgId: "H44022900158202103301748008725",
  11380. PsnNo: "44020000001104246641",
  11381. Info: "2208",
  11382. }
  11383. customData = append(customData, custom5)
  11384. custom6 := &CustomData{
  11385. MsgId: "H44022900158202103301718096755",
  11386. PsnNo: "44020000001102211860",
  11387. Info: "2208",
  11388. }
  11389. customData = append(customData, custom6)
  11390. custom7 := &CustomData{
  11391. MsgId: "H44022900158202103301736551640",
  11392. PsnNo: "44020000001102687718",
  11393. Info: "2208",
  11394. }
  11395. customData = append(customData, custom7)
  11396. custom8 := &CustomData{
  11397. MsgId: "H44022900158202103301743097676",
  11398. PsnNo: "44020000001102127785",
  11399. Info: "2208",
  11400. }
  11401. customData = append(customData, custom8)
  11402. custom9 := &CustomData{
  11403. MsgId: "H44022900158202103301712304203",
  11404. PsnNo: "44020000001101518097",
  11405. Info: "2208",
  11406. }
  11407. customData = append(customData, custom9)
  11408. custom10 := &CustomData{
  11409. MsgId: "H44022900158202103301738448785",
  11410. PsnNo: "44020000001100500813",
  11411. Info: "2208",
  11412. }
  11413. customData = append(customData, custom10)
  11414. custom11 := &CustomData{
  11415. MsgId: "H44022900158202103301732455843",
  11416. PsnNo: "44020000001102690557",
  11417. Info: "2208",
  11418. }
  11419. customData = append(customData, custom11)
  11420. custom12 := &CustomData{
  11421. MsgId: "H44022900158202103301745421708",
  11422. PsnNo: "44020000001102211928",
  11423. Info: "2208",
  11424. }
  11425. customData = append(customData, custom12)
  11426. custom1212 := &CustomData{
  11427. MsgId: "H440229001582021033017351627",
  11428. PsnNo: "44020000001102481733",
  11429. Info: "2208",
  11430. }
  11431. customData = append(customData, custom1212)
  11432. custom13 := &CustomData{
  11433. MsgId: "H44022900158202103301740327951",
  11434. PsnNo: "44020000001103174866",
  11435. Info: "2208",
  11436. }
  11437. customData = append(customData, custom13)
  11438. custom14 := &CustomData{
  11439. MsgId: "H4402290015820210330174922668",
  11440. PsnNo: "44020000001102927272",
  11441. Info: "2208",
  11442. }
  11443. customData = append(customData, custom14)
  11444. custom15 := &CustomData{
  11445. MsgId: "H44022900158202103301752362273",
  11446. PsnNo: "44020000001102942890",
  11447. Info: "2208",
  11448. }
  11449. customData = append(customData, custom15)
  11450. custom16 := &CustomData{
  11451. MsgId: "H44022900158202103301751082917",
  11452. PsnNo: "44020000001101662162",
  11453. Info: "2208",
  11454. }
  11455. customData = append(customData, custom16)
  11456. custom17 := &CustomData{
  11457. MsgId: "H44022900158202103301754147728",
  11458. PsnNo: "44020000000229014511",
  11459. Info: "2208",
  11460. }
  11461. customData = append(customData, custom17)
  11462. adminUser := c.GetAdminUserInfo()
  11463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11464. for _, item := range customData {
  11465. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11466. fmt.Println(result)
  11467. }
  11468. }
  11469. func PathExists(path string) (bool, error) {
  11470. _, err := os.Stat(path)
  11471. if err == nil {
  11472. return true, nil
  11473. }
  11474. if os.IsNotExist(err) {
  11475. return false, nil
  11476. }
  11477. return false, err
  11478. }
  11479. //创建文件夹
  11480. func Mkdir(dir string) {
  11481. // 创建文件夹
  11482. exist, err := PathExists(dir)
  11483. if err != nil {
  11484. fmt.Println(err.Error())
  11485. } else {
  11486. if exist {
  11487. fmt.Println(dir + "文件夹已存在!")
  11488. } else {
  11489. // 文件夹名称,权限
  11490. err := os.Mkdir(dir, os.ModePerm)
  11491. if err != nil {
  11492. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11493. } else {
  11494. fmt.Println(dir + "文件夹创建成功!")
  11495. }
  11496. }
  11497. }
  11498. }
  11499. //压缩文件
  11500. func Zip(srcFile string, destZip string) error {
  11501. zipfile, err := os.Create(destZip)
  11502. if err != nil {
  11503. return err
  11504. }
  11505. defer zipfile.Close()
  11506. archive := zip.NewWriter(zipfile)
  11507. defer archive.Close()
  11508. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11509. if err != nil {
  11510. return err
  11511. }
  11512. header, err := zip.FileInfoHeader(info)
  11513. if err != nil {
  11514. return err
  11515. }
  11516. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11517. // header.Name = path
  11518. if info.IsDir() {
  11519. header.Name += "/"
  11520. } else {
  11521. header.Method = zip.Deflate
  11522. }
  11523. writer, err := archive.CreateHeader(header)
  11524. if err != nil {
  11525. return err
  11526. }
  11527. if !info.IsDir() {
  11528. file, err := os.Open(path)
  11529. if err != nil {
  11530. return err
  11531. }
  11532. defer file.Close()
  11533. _, err = io.Copy(writer, file)
  11534. }
  11535. return err
  11536. })
  11537. return err
  11538. }
  11539. func ReadFile(filePath string) []byte {
  11540. f, err := os.Open(filePath)
  11541. if err != nil {
  11542. fmt.Println("read file fail", err)
  11543. return nil
  11544. }
  11545. defer f.Close()
  11546. fd, err := ioutil.ReadAll(f)
  11547. if err != nil {
  11548. fmt.Println("read to fd fail", err)
  11549. return nil
  11550. }
  11551. return fd
  11552. }
  11553. func saveLog(result string, request string, infno string, desc string) {
  11554. org_id, _ := beego.AppConfig.Int64("org_id")
  11555. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11556. dir := miConfig.OrgName + "日志"
  11557. utils.Mkdir(dir)
  11558. month := time.Unix(1557042972, 0).Format("1")
  11559. year := time.Now().Format("2006")
  11560. month = time.Now().Format("01")
  11561. day := time.Now().Format("02")
  11562. hour := time.Now().Format("15")
  11563. min := time.Now().Format("04")
  11564. sec := time.Now().Format("05")
  11565. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11566. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11567. file_name := file + ".txt"
  11568. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11569. exist, _ := utils.PathExists(file_path)
  11570. if exist { //存在
  11571. fmt.Println("存在")
  11572. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11573. if err != nil {
  11574. fmt.Println("read fail")
  11575. }
  11576. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11577. n, _ := f.Seek(0, 2)
  11578. _, err = f.WriteAt([]byte(content), n)
  11579. } else { //不存在
  11580. fmt.Println("文件不存在,创建文件")
  11581. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11582. defer f.Close()
  11583. if err != nil {
  11584. } else {
  11585. _, err = f.Write([]byte("记录日志"))
  11586. }
  11587. }
  11588. }
  11589. type Charset string
  11590. const (
  11591. UTF8 = Charset("UTF-8")
  11592. GB18030 = Charset("GB18030")
  11593. )
  11594. func ConvertToString(src string, srcCode string, tagCode string) string {
  11595. srcCoder := mahonia.NewDecoder(srcCode)
  11596. srcResult := srcCoder.ConvertString(src)
  11597. tagCoder := mahonia.NewDecoder(tagCode)
  11598. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11599. result := string(cdata)
  11600. return result
  11601. }
  11602. func (c *HisApiController) ReadEleCard() {
  11603. id_card_type, _ := c.GetInt64("id_card_type")
  11604. admin_user_id, _ := c.GetInt64("admin_user_id")
  11605. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11606. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11607. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11608. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11609. var api string
  11610. if miConfig.MdtrtareaAdmvs == "320921" {
  11611. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11612. "&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
  11613. fmt.Println(api)
  11614. } else {
  11615. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11616. "&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
  11617. }
  11618. resp, requestErr := http.Get(api)
  11619. if requestErr != nil {
  11620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11621. return
  11622. }
  11623. body, ioErr := ioutil.ReadAll(resp.Body)
  11624. if ioErr != nil {
  11625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11627. return
  11628. }
  11629. var respJSON map[string]interface{}
  11630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11633. return
  11634. }
  11635. var status string
  11636. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11637. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11638. var token string
  11639. var res ResultTwo //1101结果
  11640. var res10265 ResultTwo10265 //1101结果
  11641. if status == "0" { //读卡成功
  11642. var card_info string //卡信息
  11643. var busi_card_info string
  11644. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11645. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11646. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11647. fmt.Println(card_info)
  11648. fmt.Println(busi_card_info)
  11649. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11650. result, _ := json.Marshal(respJSON)
  11651. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11652. utils.ErrorLog("解析失败:%v", err)
  11653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11654. return
  11655. }
  11656. res.ErrMsg = res10265.ErrMsg
  11657. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11658. res.Infcode = infocode
  11659. res.Output = res10265.Output
  11660. res.InfRefmsgid = res10265.InfRefmsgid
  11661. if res.Infcode == 0 {
  11662. c.ServeSuccessJSON(map[string]interface{}{
  11663. "number": token,
  11664. })
  11665. }
  11666. } else {
  11667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11668. return
  11669. }
  11670. } else { //读卡失败
  11671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11672. return
  11673. }
  11674. }
  11675. func DeleteExtraSpaceTwo(s string) string {
  11676. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11677. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11678. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11679. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11680. s2 := make([]byte, len(s1)) //定义字符数组切片
  11681. copy(s2, s1) //将字符串复制到切片
  11682. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11683. for len(spc_index) > 0 { //找到适配项
  11684. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11685. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11686. }
  11687. return string(s2)
  11688. }
  11689. func Remove0000(s string) string {
  11690. str := make([]rune, 0, len(s))
  11691. for _, v := range []rune(s) {
  11692. if v == 0 {
  11693. continue
  11694. }
  11695. str = append(str, v)
  11696. }
  11697. return string(str)
  11698. }
  11699. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11700. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11701. readCard := DllDef.MustFindProc("EcQuery")
  11702. pCardInfo := make([]byte, 8192)
  11703. pBusiCardInfo := make([]byte, 8192)
  11704. data := make(map[string]interface{})
  11705. //pData := make(map[string]interface{})
  11706. inputData := make(map[string]interface{})
  11707. inputData["orgId"] = code
  11708. inputData["businessType"] = "01101"
  11709. inputData["operatorId"] = operator_id
  11710. inputData["operatorName"] = operator_name
  11711. inputData["officeId"] = "001"
  11712. inputData["officeName"] = "血透室"
  11713. //
  11714. data["data"] = inputData
  11715. data["transType"] = "ec.query"
  11716. data["orgId"] = code
  11717. bytesData, _ := json.Marshal(data)
  11718. pCardInfo = bytesData
  11719. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11720. fmt.Println(ret2)
  11721. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11722. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11723. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11724. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11725. if ret2 != 0 {
  11726. return "", ""
  11727. }
  11728. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11729. }
  11730. func DeleteExtraSpace(s string) string {
  11731. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11732. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11733. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11734. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11735. s2 := make([]byte, len(s1)) //定义字符数组切片
  11736. copy(s2, s1) //将字符串复制到切片
  11737. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11738. for len(spc_index) > 0 { //找到适配项
  11739. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11740. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11741. }
  11742. return string(s2)
  11743. }
  11744. //对账
  11745. func (c *HisApiController) Post3202() {
  11746. start_time := c.GetString("start_time")
  11747. end_time := c.GetString("end_time")
  11748. insutype := c.GetString("insutype")
  11749. clr_type := c.GetString("clr_type")
  11750. clr_org := c.GetString("clr_optins")
  11751. admin_user_id, _ := c.GetInt64("admin_user_id")
  11752. adminUser := c.GetAdminUserInfo()
  11753. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11754. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11755. if len(clr_org) == 0 {
  11756. clr_org = miConfig.MdtrtareaAdmvs
  11757. }
  11758. timeLayout := "2006-01-02"
  11759. loc, _ := time.LoadLocation("Local")
  11760. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11761. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11762. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11763. fixmedins_setl_cnt := int64(len(orders))
  11764. var medfee_sumamt float64
  11765. var acct_pay float64
  11766. var fund_pay_sumamt float64
  11767. for _, item := range orders {
  11768. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11769. acct_pay = acct_pay + item.AcctPay
  11770. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11771. }
  11772. var user_name string
  11773. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11774. if role.ID == 0 {
  11775. user_name = "xxx"
  11776. } else {
  11777. user_name = role.UserName
  11778. }
  11779. var res ResultSix
  11780. if config.IsOpen == 1 {
  11781. if miConfig.MdtrtareaAdmvs == "421300" {
  11782. api := "http://192.168.124.4:9532/" + "hbyb/3202?" +
  11783. "insutype=" + insutype +
  11784. "&clr_type=" + clr_type +
  11785. "&setl_optins=" + clr_org +
  11786. "&stmt_begndate=" + start_time +
  11787. "&stm_enddate=" + end_time +
  11788. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11789. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11790. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11791. "&fixmedins_code=" + miConfig.Code +
  11792. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11793. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11794. "&secret_key=" + miConfig.SecretKey +
  11795. "&org_name=" + miConfig.OrgName +
  11796. "&doctor=" + user_name
  11797. resp, requestErr := http.Get(api)
  11798. if requestErr != nil {
  11799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11800. return
  11801. }
  11802. body, ioErr := ioutil.ReadAll(resp.Body)
  11803. if ioErr != nil {
  11804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11806. return
  11807. }
  11808. var respJSON map[string]interface{}
  11809. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11812. return
  11813. }
  11814. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11815. result, _ := json.Marshal(respJSON)
  11816. fmt.Println("log")
  11817. fmt.Println(string(result))
  11818. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11819. utils.ErrorLog("解析失败:%v", err)
  11820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11821. return
  11822. }
  11823. }
  11824. if res.Infcode == 0 {
  11825. c.ServeSuccessJSON(map[string]interface{}{
  11826. "msg": "发起成功",
  11827. })
  11828. } else {
  11829. c.ServeSuccessJSON(map[string]interface{}{
  11830. "code": -10,
  11831. "msg": res.ErrMsg,
  11832. })
  11833. }
  11834. }
  11835. }