his_api_controller.go 483KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226
  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. struct4101.BillCode = order.Number
  2627. struct4101.BillNo = order.SetlId
  2628. var resOther ResultSeventeenOther
  2629. var pp models.PublicParams
  2630. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2631. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2632. pp.FixmedinsName = miConfig.OrgName
  2633. pp.FixmedinsCode = miConfig.Code
  2634. pp.RequestUrl = miConfig.Url
  2635. pp.Cainfo = miConfig.Cainfo
  2636. pp.SecretKey = miConfig.SecretKey
  2637. pp.AccessKey = miConfig.AccessKey
  2638. pp.OpterName = curRoles.UserName
  2639. client := &http.Client{}
  2640. var req *http.Request
  2641. data := make(map[string]interface{})
  2642. data["struct4101"] = struct4101
  2643. data["pp"] = pp
  2644. bytesData, _ := json.Marshal(data)
  2645. if miConfig.MdtrtareaAdmvs == "320921" {
  2646. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2647. } else {
  2648. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2649. }
  2650. resp, _ := client.Do(req)
  2651. defer resp.Body.Close()
  2652. body, ioErr := ioutil.ReadAll(resp.Body)
  2653. if ioErr != nil {
  2654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2656. return
  2657. }
  2658. var respJSON map[string]interface{}
  2659. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2662. return
  2663. }
  2664. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2665. userJSONBytes, _ := json.Marshal(respJSON)
  2666. fmt.Println("log")
  2667. fmt.Println(string(userJSONBytes))
  2668. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2669. utils.ErrorLog("解析失败:%v", err)
  2670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2671. return
  2672. }
  2673. res.InfRefmsgid = resOther.InfRefmsgid
  2674. res.Output = resOther.Output
  2675. res.ErrMsg = resOther.ErrMsg
  2676. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2677. res.Infcode = infocode
  2678. } else {
  2679. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2680. var dat map[string]interface{}
  2681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2682. fmt.Println(dat)
  2683. } else {
  2684. fmt.Println(err)
  2685. }
  2686. userJSONBytes, _ := json.Marshal(dat)
  2687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2688. utils.ErrorLog("解析失败:%v", err)
  2689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. return
  2691. }
  2692. }
  2693. if res.Infcode != 0 {
  2694. c.ServeSuccessJSON(map[string]interface{}{
  2695. "failed_code": -10,
  2696. "msg": res.ErrMsg,
  2697. })
  2698. return
  2699. } else {
  2700. order.FaPiaoNumber = zero
  2701. order.FaPiaoCode = last_order.FaPiaoCode
  2702. service.UpdateOrder(order)
  2703. hisFundSettleListResult := &models.HisFundSettleListResult{
  2704. Number: res.Output.SetlListId,
  2705. Status: 1,
  2706. Ctime: time.Now().Unix(),
  2707. Mtime: time.Now().Unix(),
  2708. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2709. IsUpload: 1,
  2710. OrderId: order_id,
  2711. }
  2712. service.CreateUploadRecord(hisFundSettleListResult)
  2713. c.ServeSuccessJSON(map[string]interface{}{
  2714. "msg": "上传成功",
  2715. "result": hisFundSettleListResult,
  2716. })
  2717. return
  2718. }
  2719. }
  2720. func (c *HisApiController) GetSettleListHospital() {
  2721. order_id, _ := c.GetInt64("order_id")
  2722. admin_user_id, _ := c.GetInt64("admin_user_id")
  2723. order, _ := service.GetHisOrderByIDTwo(order_id)
  2724. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2725. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2726. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2727. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2728. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2729. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2730. if order.ID == 0 {
  2731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2732. return
  2733. }
  2734. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2735. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2736. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2737. fmt.Println(count)
  2738. var zero string
  2739. number := count + 1
  2740. if number >= 1000 {
  2741. zero = "0000" + strconv.FormatInt(number, 10)
  2742. } else if number >= 10000 {
  2743. zero = "000" + strconv.FormatInt(number, 10)
  2744. } else if number >= 100000 {
  2745. zero = "00" + strconv.FormatInt(number, 10)
  2746. } else if number >= 1000000 {
  2747. zero = "0" + strconv.FormatInt(number, 10)
  2748. } else {
  2749. zero = strconv.FormatInt(number, 10)
  2750. }
  2751. fmt.Println(zero)
  2752. struct4101 := service.Struct4101{
  2753. PsnNo: order.PsnNo,
  2754. MdtrtId: order.MdtrtId,
  2755. SetlId: order.SetlId,
  2756. PsnName: order.PsnName,
  2757. Gend: order.Gend,
  2758. Brdy: his.Brdy,
  2759. Age: int64(order.Age),
  2760. Naty: order.Naty,
  2761. PatnCertType: "01",
  2762. Certno: order.Certno,
  2763. Prfs: "90",
  2764. ConerName: roles[0].UserName,
  2765. PatnRlts: "99",
  2766. ConerAddr: miConfig.OrgName,
  2767. ConerTel: admin.Mobile,
  2768. HiType: order.Insutype,
  2769. Insuplc: miConfig.InsuplcAdmdvs,
  2770. MaindiagFlag: "1",
  2771. BillCode: last_order.FaPiaoCode,
  2772. BillNo: zero,
  2773. BizSn: order.Number,
  2774. PsnSelfPay: order.PsnPartAmt,
  2775. PsnOwnPay: order.PsnPartAmt,
  2776. AcctPay: order.AcctPay,
  2777. PsnCashpay: order.PsnCashPay,
  2778. HiPaymtd: "1",
  2779. Hsorg: miConfig.InsuplcAdmdvs,
  2780. HsorgOpter: miConfig.InsuplcAdmdvs,
  2781. MedinsFillPsn: curRoles.UserName,
  2782. MedinsFillDept: depart.Name,
  2783. IptMedType: "2",
  2784. AdmTime: his.InHosptialTime,
  2785. AdmEndTime: his.OutHosptialTime,
  2786. }
  2787. struct4101.SetlBegnDate = order.SetlTime
  2788. struct4101.SetlEndDate = order.SetlTime
  2789. var rf []CustomFundPay
  2790. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2791. var tempFunPays []service.CustomStruct
  2792. for _, item := range rf {
  2793. var tempFunPay service.CustomStruct
  2794. tempFunPay.FundPayamt = item.FundPayamt
  2795. tempFunPay.FundPayType = item.FundPayType
  2796. tempFunPays = append(tempFunPays, tempFunPay)
  2797. }
  2798. struct4101.CustomStruct = tempFunPays
  2799. var tempDiaginfos []service.DiaginfoStructTwo
  2800. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2801. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2802. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2803. var config []*models.HisXtDiagnoseConfig
  2804. for _, item := range diagnosis_ids {
  2805. id, _ := strconv.ParseInt(item, 10, 64)
  2806. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2807. config = append(config, &diagnosisConfig)
  2808. }
  2809. for index, item := range config {
  2810. if index == 0 {
  2811. var tempDiaginfo service.DiaginfoStructTwo
  2812. tempDiaginfo.DiagCode = item.CountryCode
  2813. tempDiaginfo.DiagName = item.CountryContentName
  2814. tempDiaginfo.DiagType = "1"
  2815. tempDiaginfo.MaindiagFlag = "1"
  2816. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2817. } else {
  2818. var tempDiaginfo service.DiaginfoStructTwo
  2819. tempDiaginfo.DiagCode = item.CountryCode
  2820. tempDiaginfo.DiagName = item.CountryContentName
  2821. tempDiaginfo.DiagType = "2"
  2822. tempDiaginfo.MaindiagFlag = "0"
  2823. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2824. }
  2825. }
  2826. struct4101.Diseinfo = tempDiaginfos
  2827. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2828. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2829. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2830. tempOpspdiseinfo2.OprnOprtCode = ""
  2831. tempOpspdiseinfo2.OprnOprtName = ""
  2832. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2833. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2834. var iteminfo service.IteminfoStruct
  2835. var bedCostTotal float64 = 0 //床位总费
  2836. var bedCostSelfTotal float64 = 0 //床位自费
  2837. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2838. var operationCostTotal float64 = 0 //手术费
  2839. var operationCostSelfTotal float64 = 0 //手术费
  2840. var operationCostPartSelfTotal float64 = 0 //手术费
  2841. var otherCostTotal float64 = 0 //其他费用
  2842. var otherCostSelfTotal float64 = 0 //其他费用
  2843. var otherCostPartSelfTotal float64 = 0 //其他费用
  2844. var materialCostTotal float64 = 0 //材料费
  2845. var materialCostSelfTotal float64 = 0 //材料费
  2846. var materialCostPartSelfTotal float64 = 0 //材料费
  2847. var westernMedicineCostTotal float64 = 0 //西药费
  2848. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2849. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2850. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2851. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2852. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2853. var checkCostTotal float64 = 0 //检查费
  2854. var checkCostSelfTotal float64 = 0 //检查费
  2855. var checkCostPartSelfTotal float64 = 0 //检查费
  2856. var laboratoryCostTotal float64 = 0 //化验费
  2857. var laboratoryCostSelfTotal float64 = 0 //化验费
  2858. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2859. var treatCostTotal float64 = 0 //治疗费用
  2860. var treatCostSelfTotal float64 = 0 //治疗费用
  2861. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2862. decimal.DivisionPrecision = 2
  2863. var bed_fulamt_ownpay_amt float64 = 0
  2864. var operation_fulamt_ownpay_amt float64 = 0
  2865. var other_fulamt_ownpay_amt float64 = 0
  2866. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2867. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2868. var check_fulamt_ownpay_amt float64 = 0
  2869. var material_fulamt_ownpay_amt float64 = 0
  2870. var laboratory_fulamt_ownpay_amt float64 = 0
  2871. var treat_fulamt_ownpay_amt float64 = 0
  2872. var bed_claa_sunmfee float64 = 0
  2873. var bed_clab_amt float64 = 0
  2874. var bed_other_amt float64 = 0
  2875. var operation_claa_sunmfee float64 = 0
  2876. var operation_clab_amt float64 = 0
  2877. var operation_other_amt float64 = 0
  2878. var other_claa_sunmfee float64 = 0
  2879. var other_clab_amt float64 = 0
  2880. var other_other_amt float64 = 0
  2881. var westernMedicine_claa_sunmfee float64 = 0
  2882. var westernMedicine_clab_amt float64 = 0
  2883. var westernMedicine_other_amt float64 = 0
  2884. var chineseTraditional_claa_sunmfee float64 = 0
  2885. var chineseTraditional_clab_amt float64 = 0
  2886. var chineseTraditional_other_amt float64 = 0
  2887. var check_claa_sunmfee float64 = 0
  2888. var check_clab_amt float64 = 0
  2889. var check_other_amt float64 = 0
  2890. var material_claa_sunmfee float64 = 0
  2891. var material_clab_amt float64 = 0
  2892. var material_other_amt float64 = 0
  2893. var laboratory_claa_sunmfee float64 = 0
  2894. var laboratory_clab_amt float64 = 0
  2895. var laboratory_other_amt float64 = 0
  2896. var treat_claa_sunmfee float64 = 0
  2897. var treat_clab_amt float64 = 0
  2898. var treat_other_amt float64 = 0
  2899. for _, item := range order.HisOrderInfo {
  2900. if item.MedChrgitmType == "01" { //床位费
  2901. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2902. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2903. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2904. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2905. if item.ChrgitmLv == "1" {
  2906. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2907. }
  2908. if item.ChrgitmLv == "2" {
  2909. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2910. }
  2911. if item.ChrgitmLv == "3" {
  2912. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2913. }
  2914. }
  2915. if item.MedChrgitmType == "03" { //检查费
  2916. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2917. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2918. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2919. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2920. if item.ChrgitmLv == "1" {
  2921. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2922. }
  2923. if item.ChrgitmLv == "2" {
  2924. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2925. }
  2926. if item.ChrgitmLv == "3" {
  2927. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2928. }
  2929. }
  2930. if item.MedChrgitmType == "04" { //化验费
  2931. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2932. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2933. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2934. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2935. if item.ChrgitmLv == "1" {
  2936. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2937. }
  2938. if item.ChrgitmLv == "2" {
  2939. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2940. }
  2941. if item.ChrgitmLv == "3" {
  2942. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2943. }
  2944. }
  2945. if item.MedChrgitmType == "05" { //治疗费
  2946. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2947. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2948. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2949. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2950. if item.ChrgitmLv == "1" {
  2951. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2952. }
  2953. if item.ChrgitmLv == "2" {
  2954. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2955. }
  2956. if item.ChrgitmLv == "3" {
  2957. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2958. }
  2959. }
  2960. if item.MedChrgitmType == "06" { //手术费
  2961. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2962. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2963. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2964. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2965. if item.ChrgitmLv == "1" {
  2966. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2967. }
  2968. if item.ChrgitmLv == "2" {
  2969. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2970. }
  2971. if item.ChrgitmLv == "3" {
  2972. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2973. }
  2974. }
  2975. if item.MedChrgitmType == "08" { //材料费
  2976. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2977. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2978. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2979. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2980. if item.ChrgitmLv == "1" {
  2981. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2982. }
  2983. if item.ChrgitmLv == "2" {
  2984. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2985. }
  2986. if item.ChrgitmLv == "3" {
  2987. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2988. }
  2989. }
  2990. if item.MedChrgitmType == "09" { //西药费
  2991. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2992. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2993. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2994. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2995. if item.ChrgitmLv == "1" {
  2996. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2997. }
  2998. if item.ChrgitmLv == "2" {
  2999. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3000. }
  3001. if item.ChrgitmLv == "3" {
  3002. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3003. }
  3004. }
  3005. if item.MedChrgitmType == "11" { //中成费
  3006. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3007. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3008. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3009. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3010. if item.ChrgitmLv == "1" {
  3011. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3012. }
  3013. if item.ChrgitmLv == "2" {
  3014. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3015. }
  3016. if item.ChrgitmLv == "3" {
  3017. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3018. }
  3019. }
  3020. if item.MedChrgitmType == "14" { //其他费
  3021. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3022. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3023. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3024. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3025. if item.ChrgitmLv == "1" {
  3026. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3027. }
  3028. if item.ChrgitmLv == "2" {
  3029. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3030. }
  3031. if item.ChrgitmLv == "3" {
  3032. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3033. }
  3034. }
  3035. }
  3036. var iteminfoStructs []service.IteminfoStruct
  3037. if bedCostTotal != 0 {
  3038. iteminfo.MedChrgitm = "01"
  3039. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3040. iteminfo.Amt = bedCostTotal
  3041. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3042. iteminfo.ClabAmt = bed_clab_amt
  3043. iteminfo.OthAmt = bed_other_amt
  3044. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3045. }
  3046. if checkCostTotal != 0 {
  3047. iteminfo.MedChrgitm = "03"
  3048. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3049. iteminfo.Amt = checkCostTotal
  3050. iteminfo.ClaaSumfee = check_claa_sunmfee
  3051. iteminfo.ClabAmt = check_clab_amt
  3052. iteminfo.OthAmt = check_other_amt
  3053. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3054. }
  3055. if laboratoryCostTotal != 0 {
  3056. iteminfo.MedChrgitm = "04"
  3057. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3058. iteminfo.Amt = laboratoryCostTotal
  3059. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3060. iteminfo.ClabAmt = laboratory_clab_amt
  3061. iteminfo.OthAmt = laboratory_other_amt
  3062. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3063. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3064. }
  3065. if treatCostTotal != 0 {
  3066. iteminfo.MedChrgitm = "05"
  3067. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3068. iteminfo.Amt = treatCostTotal
  3069. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3070. iteminfo.ClabAmt = treat_clab_amt
  3071. iteminfo.OthAmt = treat_other_amt
  3072. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3073. //(struct4101.IteminfoStruct, iteminfo)
  3074. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3075. }
  3076. if operationCostTotal != 0 {
  3077. iteminfo.MedChrgitm = "06"
  3078. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3079. iteminfo.Amt = operationCostTotal
  3080. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3081. iteminfo.ClabAmt = operation_clab_amt
  3082. iteminfo.OthAmt = operation_other_amt
  3083. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3084. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3085. }
  3086. if materialCostTotal != 0 {
  3087. iteminfo.MedChrgitm = "08"
  3088. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3089. iteminfo.Amt = materialCostTotal
  3090. iteminfo.ClaaSumfee = material_claa_sunmfee
  3091. iteminfo.ClabAmt = material_clab_amt
  3092. iteminfo.OthAmt = material_other_amt
  3093. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3094. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3095. }
  3096. if westernMedicineCostTotal != 0 {
  3097. iteminfo.MedChrgitm = "09"
  3098. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3099. iteminfo.Amt = westernMedicineCostTotal
  3100. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3101. iteminfo.ClabAmt = westernMedicine_clab_amt
  3102. iteminfo.OthAmt = westernMedicine_other_amt
  3103. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3104. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3105. }
  3106. if chineseTraditionalMedicineCostTotal != 0 {
  3107. iteminfo.MedChrgitm = "11"
  3108. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3109. iteminfo.Amt = westernMedicineCostTotal
  3110. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3111. iteminfo.ClabAmt = westernMedicine_clab_amt
  3112. iteminfo.OthAmt = westernMedicine_other_amt
  3113. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3114. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3115. }
  3116. if otherCostTotal != 0 {
  3117. iteminfo.MedChrgitm = "14"
  3118. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3119. iteminfo.Amt = otherCostTotal
  3120. iteminfo.ClaaSumfee = other_claa_sunmfee
  3121. iteminfo.ClabAmt = other_clab_amt
  3122. iteminfo.OthAmt = other_other_amt
  3123. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3124. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3125. }
  3126. struct4101.IteminfoStruct = iteminfoStructs
  3127. struct4101.Ntly = "中国"
  3128. struct4101.AdmCaty = "A03.06"
  3129. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3130. fmt.Println(result)
  3131. var dat map[string]interface{}
  3132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3133. fmt.Println(dat)
  3134. } else {
  3135. fmt.Println(err)
  3136. }
  3137. userJSONBytes, _ := json.Marshal(dat)
  3138. var res ResultSeventeen
  3139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3140. utils.ErrorLog("解析失败:%v", err)
  3141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3142. return
  3143. }
  3144. if res.Infcode != 0 {
  3145. c.ServeSuccessJSON(map[string]interface{}{
  3146. "failed_code": -10,
  3147. "msg": res.ErrMsg,
  3148. })
  3149. return
  3150. } else {
  3151. order.FaPiaoNumber = zero
  3152. order.FaPiaoCode = last_order.FaPiaoCode
  3153. service.UpdateOrder(order)
  3154. hisFundSettleListResult := &models.HisFundSettleListResult{
  3155. Number: res.Output.SetlListId,
  3156. Status: 1,
  3157. Ctime: time.Now().Unix(),
  3158. Mtime: time.Now().Unix(),
  3159. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3160. IsUpload: 1,
  3161. OrderId: order_id,
  3162. }
  3163. service.CreateUploadRecord(hisFundSettleListResult)
  3164. c.ServeSuccessJSON(map[string]interface{}{
  3165. "msg": "上传成功",
  3166. "result": hisFundSettleListResult,
  3167. })
  3168. return
  3169. }
  3170. }
  3171. func (c *HisApiController) GetBatchSettleList() {
  3172. orders, _ := service.GetAllHisOrder(10106)
  3173. for _, item := range orders {
  3174. order_id := item.ID
  3175. order, _ := service.GetHisOrderByIDTwo(order_id)
  3176. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3177. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3178. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3179. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  3180. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3181. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3182. if order.ID == 0 {
  3183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3184. return
  3185. }
  3186. if his.BalanceAccountsType == 2 {
  3187. continue
  3188. }
  3189. struct4101 := service.Struct4101{
  3190. PsnNo: order.PsnNo,
  3191. MdtrtId: order.MdtrtId,
  3192. SetlId: order.SetlId,
  3193. PsnName: order.PsnName,
  3194. Gend: order.Gend,
  3195. Brdy: his.Brdy,
  3196. Age: his.Age,
  3197. Naty: order.Naty,
  3198. PatnCertType: "01",
  3199. Certno: order.Certno,
  3200. Prfs: "90",
  3201. ConerName: roles[0].UserName,
  3202. PatnRlts: "99",
  3203. ConerAddr: miConfig.OrgName,
  3204. ConerTel: admin.Mobile,
  3205. HiType: order.Insutype,
  3206. Insuplc: his.InsuplcAdmdvs,
  3207. MaindiagFlag: "1",
  3208. BillCode: order.FaPiaoCode,
  3209. BillNo: order.FaPiaoNumber,
  3210. BizSn: order.Number,
  3211. PsnSelfPay: order.PsnPartAmt,
  3212. PsnOwnPay: order.PsnPartAmt,
  3213. AcctPay: order.AcctPay,
  3214. PsnCashpay: order.PsnCashPay,
  3215. HiPaymtd: "1",
  3216. Hsorg: his.InsuplcAdmdvs,
  3217. HsorgOpter: his.InsuplcAdmdvs,
  3218. MedinsFillPsn: curRoles.UserName,
  3219. MedinsFillDept: depart.Name,
  3220. IptMedType: "2",
  3221. }
  3222. struct4101.SetlBegnDate = order.SetlTime
  3223. struct4101.SetlEndDate = order.SetlTime
  3224. //if order.SettleType == 1 {
  3225. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3226. // dateStr := t.Format("2006-01-02")
  3227. // struct4101.SetlBegnDate = dateStr
  3228. // struct4101.SetlEndDate = dateStr
  3229. //} else {
  3230. // t := time.Unix(int64(order.SettleStartTime), 0)
  3231. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3232. // dateStartStr := t.Format("2006-01-02")
  3233. // dateEndStr := t2.Format("2006-01-02")
  3234. // struct4101.SetlBegnDate = dateStartStr
  3235. // struct4101.SetlEndDate = dateEndStr
  3236. //}
  3237. var rf []CustomFundPay
  3238. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3239. var tempFunPays []service.CustomStruct
  3240. var tempFunPay610100 service.CustomStruct
  3241. for _, item := range rf {
  3242. if item.FundPayType == "610100" {
  3243. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3244. tempFunPay610100.FundPayType = item.FundPayType
  3245. } else {
  3246. var tempFunPay service.CustomStruct
  3247. tempFunPay.FundPayamt = item.FundPayamt
  3248. tempFunPay.FundPayType = item.FundPayType
  3249. tempFunPays = append(tempFunPays, tempFunPay)
  3250. }
  3251. }
  3252. tempFunPays = append(tempFunPays, tempFunPay610100)
  3253. struct4101.CustomStruct = tempFunPays
  3254. var tempDiaginfos []service.DiaginfoStructTwo
  3255. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3256. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3257. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3258. var config []*models.HisXtDiagnoseConfig
  3259. for _, item := range diagnosis_ids {
  3260. id, _ := strconv.ParseInt(item, 10, 64)
  3261. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3262. config = append(config, &diagnosisConfig)
  3263. }
  3264. for index, item := range config {
  3265. if index == 0 {
  3266. var tempDiaginfo service.DiaginfoStructTwo
  3267. tempDiaginfo.DiagCode = item.CountryCode
  3268. tempDiaginfo.DiagName = item.CountryContentName
  3269. tempDiaginfo.DiagType = "1"
  3270. tempDiaginfo.MaindiagFlag = "1"
  3271. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3272. } else {
  3273. var tempDiaginfo service.DiaginfoStructTwo
  3274. tempDiaginfo.DiagCode = item.CountryCode
  3275. tempDiaginfo.DiagName = item.CountryContentName
  3276. tempDiaginfo.DiagType = "2"
  3277. tempDiaginfo.MaindiagFlag = "0"
  3278. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3279. }
  3280. }
  3281. struct4101.Diseinfo = tempDiaginfos
  3282. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3283. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3284. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3285. tempOpspdiseinfo2.OprnOprtCode = ""
  3286. tempOpspdiseinfo2.OprnOprtName = ""
  3287. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3288. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3289. var iteminfo service.IteminfoStruct
  3290. var bedCostTotal float64 = 0 //床位总费
  3291. var bedCostSelfTotal float64 = 0 //床位自费
  3292. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3293. var examineCostTotal float64 = 0 //诊查总费
  3294. var examineCostSelfTotal float64 = 0 //诊查自费
  3295. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3296. var nursingCostTotal float64 = 0 //护理总费
  3297. var nursingCostSelfTotal float64 = 0 //护理自费
  3298. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3299. var chineseMedicineCostTotal float64 = 0 //中成药
  3300. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3301. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3302. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3303. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3304. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3305. var registerCostTotal float64 = 0 //一般诊疗费
  3306. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3307. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3308. var operationCostTotal float64 = 0 //手术费
  3309. var operationCostSelfTotal float64 = 0 //手术费
  3310. var operationCostPartSelfTotal float64 = 0 //手术费
  3311. var otherCostTotal float64 = 0 //其他费用
  3312. var otherCostSelfTotal float64 = 0 //其他费用
  3313. var otherCostPartSelfTotal float64 = 0 //其他费用
  3314. var materialCostTotal float64 = 0 //材料费
  3315. var materialCostSelfTotal float64 = 0 //材料费
  3316. var materialCostPartSelfTotal float64 = 0 //材料费
  3317. var westernMedicineCostTotal float64 = 0 //西药费
  3318. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3319. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3320. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3321. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3322. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3323. var checkCostTotal float64 = 0 //检查费
  3324. var checkCostSelfTotal float64 = 0 //检查费
  3325. var checkCostPartSelfTotal float64 = 0 //检查费
  3326. var laboratoryCostTotal float64 = 0 //化验费
  3327. var laboratoryCostSelfTotal float64 = 0 //化验费
  3328. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3329. var treatCostTotal float64 = 0 //治疗费用
  3330. var treatCostSelfTotal float64 = 0 //治疗费用
  3331. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3332. decimal.DivisionPrecision = 2
  3333. var bed_fulamt_ownpay_amt float64 = 0
  3334. var examine_fulamt_ownpay_amt float64 = 0
  3335. var nursing_fulamt_ownpay_amt float64 = 0
  3336. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3337. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3338. var register_fulamt_ownpay_amt float64 = 0
  3339. var operation_fulamt_ownpay_amt float64 = 0
  3340. var other_fulamt_ownpay_amt float64 = 0
  3341. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3342. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3343. var check_fulamt_ownpay_amt float64 = 0
  3344. var material_fulamt_ownpay_amt float64 = 0
  3345. var laboratory_fulamt_ownpay_amt float64 = 0
  3346. var treat_fulamt_ownpay_amt float64 = 0
  3347. var bed_claa_sunmfee float64 = 0
  3348. var bed_clab_amt float64 = 0
  3349. var bed_other_amt float64 = 0
  3350. var examine_claa_sunmfee float64 = 0
  3351. var examine_clab_amt float64 = 0
  3352. var examine_other_amt float64 = 0
  3353. var nursing_claa_sunmfee float64 = 0
  3354. var nursing_clab_amt float64 = 0
  3355. var nursing_other_amt float64 = 0
  3356. var chinese_medicine_claa_sunmfee float64 = 0
  3357. var chinese_medicine_clab_amt float64 = 0
  3358. var chinese_medicine_other_amt float64 = 0
  3359. var commonly_treatment_claa_sunmfee float64 = 0
  3360. var commonly_treatment_clab_amt float64 = 0
  3361. var commonly_treatment_other_amt float64 = 0
  3362. var operation_claa_sunmfee float64 = 0
  3363. var operation_clab_amt float64 = 0
  3364. var operation_other_amt float64 = 0
  3365. var other_claa_sunmfee float64 = 0
  3366. var other_clab_amt float64 = 0
  3367. var other_other_amt float64 = 0
  3368. var westernMedicine_claa_sunmfee float64 = 0
  3369. var westernMedicine_clab_amt float64 = 0
  3370. var westernMedicine_other_amt float64 = 0
  3371. var chineseTraditional_claa_sunmfee float64 = 0
  3372. var chineseTraditional_clab_amt float64 = 0
  3373. var chineseTraditional_other_amt float64 = 0
  3374. var check_claa_sunmfee float64 = 0
  3375. var check_clab_amt float64 = 0
  3376. var check_other_amt float64 = 0
  3377. var material_claa_sunmfee float64 = 0
  3378. var material_clab_amt float64 = 0
  3379. var material_other_amt float64 = 0
  3380. var laboratory_claa_sunmfee float64 = 0
  3381. var laboratory_clab_amt float64 = 0
  3382. var laboratory_other_amt float64 = 0
  3383. var treat_claa_sunmfee float64 = 0
  3384. var treat_clab_amt float64 = 0
  3385. var treat_other_amt float64 = 0
  3386. var register_claa_sunmfee float64 = 0
  3387. var register_clab_amt float64 = 0
  3388. var register_other_amt float64 = 0
  3389. for _, item := range order.HisOrderInfo {
  3390. if item.MedChrgitmType == "01" { //床位费
  3391. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3392. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3393. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3394. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3395. if item.ChrgitmLv == "1" {
  3396. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3397. }
  3398. if item.ChrgitmLv == "2" {
  3399. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3400. }
  3401. if item.ChrgitmLv == "3" {
  3402. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3403. }
  3404. }
  3405. if item.MedChrgitmType == "02" { //诊查
  3406. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3407. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3408. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3409. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3410. if item.ChrgitmLv == "1" {
  3411. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3412. }
  3413. if item.ChrgitmLv == "2" {
  3414. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3415. }
  3416. if item.ChrgitmLv == "3" {
  3417. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3418. }
  3419. }
  3420. if item.MedChrgitmType == "03" { //检查费
  3421. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3422. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3423. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3424. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3425. if item.ChrgitmLv == "1" {
  3426. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3427. }
  3428. if item.ChrgitmLv == "2" {
  3429. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3430. }
  3431. if item.ChrgitmLv == "3" {
  3432. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3433. }
  3434. }
  3435. if item.MedChrgitmType == "04" { //化验费
  3436. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3437. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3438. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3439. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3440. if item.ChrgitmLv == "1" {
  3441. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3442. }
  3443. if item.ChrgitmLv == "2" {
  3444. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3445. }
  3446. if item.ChrgitmLv == "3" {
  3447. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3448. }
  3449. }
  3450. if item.MedChrgitmType == "05" { //治疗费
  3451. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3452. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3453. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3454. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3455. if item.ChrgitmLv == "1" {
  3456. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3457. }
  3458. if item.ChrgitmLv == "2" {
  3459. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3460. }
  3461. if item.ChrgitmLv == "3" {
  3462. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3463. }
  3464. }
  3465. if item.MedChrgitmType == "06" { //手术费
  3466. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3467. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3468. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3469. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3470. if item.ChrgitmLv == "1" {
  3471. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3472. }
  3473. if item.ChrgitmLv == "2" {
  3474. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3475. }
  3476. if item.ChrgitmLv == "3" {
  3477. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3478. }
  3479. }
  3480. if item.MedChrgitmType == "07" { //手术费
  3481. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3482. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3483. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3484. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3485. if item.ChrgitmLv == "1" {
  3486. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3487. }
  3488. if item.ChrgitmLv == "2" {
  3489. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3490. }
  3491. if item.ChrgitmLv == "3" {
  3492. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3493. }
  3494. }
  3495. if item.MedChrgitmType == "08" { //材料费
  3496. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3497. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3498. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3499. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3500. if item.ChrgitmLv == "1" {
  3501. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3502. }
  3503. if item.ChrgitmLv == "2" {
  3504. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3505. }
  3506. if item.ChrgitmLv == "3" {
  3507. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3508. }
  3509. }
  3510. if item.MedChrgitmType == "09" { //西药费
  3511. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3512. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3513. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3514. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3515. if item.ChrgitmLv == "1" {
  3516. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3517. }
  3518. if item.ChrgitmLv == "2" {
  3519. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3520. }
  3521. if item.ChrgitmLv == "3" {
  3522. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3523. }
  3524. }
  3525. if item.MedChrgitmType == "10" { //中药饮片
  3526. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3527. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3528. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3529. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3530. if item.ChrgitmLv == "1" {
  3531. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3532. }
  3533. if item.ChrgitmLv == "2" {
  3534. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3535. }
  3536. if item.ChrgitmLv == "3" {
  3537. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3538. }
  3539. }
  3540. if item.MedChrgitmType == "11" { //中成费
  3541. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3542. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3543. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3544. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3545. if item.ChrgitmLv == "1" {
  3546. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3547. }
  3548. if item.ChrgitmLv == "2" {
  3549. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3550. }
  3551. if item.ChrgitmLv == "3" {
  3552. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3553. }
  3554. }
  3555. if item.MedChrgitmType == "12" { //中成费
  3556. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3557. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3558. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3559. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3560. if item.ChrgitmLv == "1" {
  3561. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3562. }
  3563. if item.ChrgitmLv == "2" {
  3564. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3565. }
  3566. if item.ChrgitmLv == "3" {
  3567. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3568. }
  3569. }
  3570. if item.MedChrgitmType == "13" { //中成费
  3571. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3572. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3573. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3574. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3575. if item.ChrgitmLv == "1" {
  3576. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3577. }
  3578. if item.ChrgitmLv == "2" {
  3579. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3580. }
  3581. if item.ChrgitmLv == "3" {
  3582. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3583. }
  3584. }
  3585. if item.MedChrgitmType == "14" { //其他费
  3586. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3587. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3588. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3589. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3590. if item.ChrgitmLv == "1" {
  3591. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3592. }
  3593. if item.ChrgitmLv == "2" {
  3594. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3595. }
  3596. if item.ChrgitmLv == "3" {
  3597. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3598. }
  3599. }
  3600. }
  3601. var iteminfoStructs []service.IteminfoStruct
  3602. if bedCostTotal != 0 {
  3603. iteminfo.MedChrgitm = "01"
  3604. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3605. iteminfo.Amt = bedCostTotal
  3606. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3607. iteminfo.ClabAmt = bed_clab_amt
  3608. iteminfo.OthAmt = bed_other_amt
  3609. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3610. }
  3611. if examineCostTotal != 0 {
  3612. iteminfo.MedChrgitm = "02"
  3613. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3614. iteminfo.Amt = examineCostTotal
  3615. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3616. iteminfo.ClabAmt = examine_clab_amt
  3617. iteminfo.OthAmt = examine_other_amt
  3618. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3619. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3620. }
  3621. if checkCostTotal != 0 {
  3622. iteminfo.MedChrgitm = "03"
  3623. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3624. iteminfo.Amt = checkCostTotal
  3625. iteminfo.ClaaSumfee = check_claa_sunmfee
  3626. iteminfo.ClabAmt = check_clab_amt
  3627. iteminfo.OthAmt = check_other_amt
  3628. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3629. }
  3630. if laboratoryCostTotal != 0 {
  3631. iteminfo.MedChrgitm = "04"
  3632. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3633. iteminfo.Amt = laboratoryCostTotal
  3634. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3635. iteminfo.ClabAmt = laboratory_clab_amt
  3636. iteminfo.OthAmt = laboratory_other_amt
  3637. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3638. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3639. }
  3640. if treatCostTotal != 0 {
  3641. iteminfo.MedChrgitm = "05"
  3642. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3643. iteminfo.Amt = treatCostTotal
  3644. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3645. iteminfo.ClabAmt = treat_clab_amt
  3646. iteminfo.OthAmt = treat_other_amt
  3647. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3648. //(struct4101.IteminfoStruct, iteminfo)
  3649. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3650. }
  3651. if operationCostTotal != 0 {
  3652. iteminfo.MedChrgitm = "06"
  3653. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3654. iteminfo.Amt = operationCostTotal
  3655. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3656. iteminfo.ClabAmt = operation_clab_amt
  3657. iteminfo.OthAmt = operation_other_amt
  3658. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3659. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3660. }
  3661. if nursingCostTotal != 0 {
  3662. iteminfo.MedChrgitm = "07"
  3663. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3664. iteminfo.Amt = nursingCostTotal
  3665. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3666. iteminfo.ClabAmt = nursing_clab_amt
  3667. iteminfo.OthAmt = nursing_other_amt
  3668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3669. }
  3670. if materialCostTotal != 0 {
  3671. iteminfo.MedChrgitm = "08"
  3672. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3673. iteminfo.Amt = materialCostTotal
  3674. iteminfo.ClaaSumfee = material_claa_sunmfee
  3675. iteminfo.ClabAmt = material_clab_amt
  3676. iteminfo.OthAmt = material_other_amt
  3677. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3678. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3679. }
  3680. if westernMedicineCostTotal != 0 {
  3681. iteminfo.MedChrgitm = "09"
  3682. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3683. iteminfo.Amt = westernMedicineCostTotal
  3684. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3685. iteminfo.ClabAmt = westernMedicine_clab_amt
  3686. iteminfo.OthAmt = westernMedicine_other_amt
  3687. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3688. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3689. }
  3690. if chineseMedicineCostTotal != 0 {
  3691. iteminfo.MedChrgitm = "10"
  3692. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3693. iteminfo.Amt = chineseMedicineCostTotal
  3694. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3695. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3696. iteminfo.OthAmt = chinese_medicine_other_amt
  3697. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3698. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3699. }
  3700. if chineseTraditionalMedicineCostTotal != 0 {
  3701. iteminfo.MedChrgitm = "11"
  3702. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3703. iteminfo.Amt = westernMedicineCostTotal
  3704. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3705. iteminfo.ClabAmt = westernMedicine_clab_amt
  3706. iteminfo.OthAmt = westernMedicine_other_amt
  3707. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3708. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3709. }
  3710. if commonlyTreatmentCostTotal != 0 {
  3711. iteminfo.MedChrgitm = "12"
  3712. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3713. iteminfo.Amt = commonlyTreatmentCostTotal
  3714. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3715. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3716. iteminfo.OthAmt = commonly_treatment_other_amt
  3717. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3718. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3719. }
  3720. if registerCostTotal != 0 {
  3721. iteminfo.MedChrgitm = "13"
  3722. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3723. iteminfo.Amt = registerCostTotal
  3724. iteminfo.ClaaSumfee = register_claa_sunmfee
  3725. iteminfo.ClabAmt = register_clab_amt
  3726. iteminfo.OthAmt = register_other_amt
  3727. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3728. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3729. }
  3730. if otherCostTotal != 0 {
  3731. iteminfo.MedChrgitm = "14"
  3732. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3733. iteminfo.Amt = otherCostTotal
  3734. iteminfo.ClaaSumfee = other_claa_sunmfee
  3735. iteminfo.ClabAmt = other_clab_amt
  3736. iteminfo.OthAmt = other_other_amt
  3737. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3738. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3739. }
  3740. struct4101.IteminfoStruct = iteminfoStructs
  3741. struct4101.Ntly = "中国"
  3742. struct4101.AdmCaty = "A03.06"
  3743. var res ResultSeventeen
  3744. if miConfig.MdtrtareaAdmvs == "421300" {
  3745. data := make(map[string]interface{})
  3746. data["struct4101"] = struct4101
  3747. data["secret_key"] = miConfig.SecretKey
  3748. data["org_name"] = miConfig.OrgName
  3749. data["opera"] = curRoles.UserName
  3750. data["code"] = miConfig.Code
  3751. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3752. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3753. client := &http.Client{}
  3754. bytesData, _ := json.Marshal(data)
  3755. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3756. resp, _ := client.Do(req)
  3757. defer resp.Body.Close()
  3758. body, ioErr := ioutil.ReadAll(resp.Body)
  3759. if ioErr != nil {
  3760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. return
  3763. }
  3764. var respJSON map[string]interface{}
  3765. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3768. return
  3769. }
  3770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3771. userJSONBytes, _ := json.Marshal(respJSON)
  3772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3773. utils.ErrorLog("解析失败:%v", err)
  3774. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3775. adminUser := c.GetAdminUserInfo()
  3776. errlog := &models.HisOrderError{
  3777. UserOrgId: adminUser.CurrentOrgId,
  3778. Ctime: time.Now().Unix(),
  3779. Mtime: time.Now().Unix(),
  3780. ErrMsg: res.ErrMsg + "解析失败",
  3781. Status: 1,
  3782. PatientId: order_id,
  3783. Stage: 10088,
  3784. }
  3785. service.CreateErrMsgLog(errlog)
  3786. continue
  3787. }
  3788. } else {
  3789. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3790. fmt.Println(result)
  3791. var dat map[string]interface{}
  3792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3793. fmt.Println(dat)
  3794. } else {
  3795. fmt.Println(err)
  3796. }
  3797. userJSONBytes, _ := json.Marshal(dat)
  3798. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3799. utils.ErrorLog("解析失败:%v", err)
  3800. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3801. adminUser := c.GetAdminUserInfo()
  3802. errlog := &models.HisOrderError{
  3803. UserOrgId: adminUser.CurrentOrgId,
  3804. Ctime: time.Now().Unix(),
  3805. Mtime: time.Now().Unix(),
  3806. ErrMsg: res.ErrMsg + "解析失败",
  3807. Status: 1,
  3808. PatientId: order_id,
  3809. Stage: 10106,
  3810. }
  3811. service.CreateErrMsgLog(errlog)
  3812. continue
  3813. }
  3814. }
  3815. if res.Infcode != 0 {
  3816. adminUser := c.GetAdminUserInfo()
  3817. errlog := &models.HisOrderError{
  3818. UserOrgId: adminUser.CurrentOrgId,
  3819. Ctime: time.Now().Unix(),
  3820. Mtime: time.Now().Unix(),
  3821. ErrMsg: res.ErrMsg,
  3822. Status: 1,
  3823. PatientId: order_id,
  3824. Stage: 10106,
  3825. }
  3826. service.CreateErrMsgLog(errlog)
  3827. continue
  3828. } else {
  3829. hisFundSettleListResult := &models.HisFundSettleListResult{
  3830. Number: res.Output.SetlListId,
  3831. Status: 1,
  3832. Ctime: time.Now().Unix(),
  3833. Mtime: time.Now().Unix(),
  3834. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3835. IsUpload: 1,
  3836. OrderId: order_id,
  3837. }
  3838. service.CreateUploadRecord(hisFundSettleListResult)
  3839. continue
  3840. }
  3841. }
  3842. }
  3843. func (c *HisApiController) GetOrgInfo() {
  3844. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3845. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3846. }
  3847. func (c *HisApiController) GetHisPatientInfo() {
  3848. medical_insurance_card := c.GetString("medical_insurance_card")
  3849. id_card_type, _ := c.GetInt64("id_card_type")
  3850. id_card := c.GetString("id_card")
  3851. adminInfo := c.GetAdminUserInfo()
  3852. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3853. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3854. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3855. IdCardNo := ""
  3856. if id_card_type == 1 {
  3857. IdCardNo = medical_insurance_card
  3858. } else if id_card_type == 2 {
  3859. IdCardNo = id_card
  3860. }
  3861. if config.IsOpen == 1 {
  3862. 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
  3863. resp, requestErr := http.Get(api)
  3864. if requestErr != nil {
  3865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. return
  3867. }
  3868. defer resp.Body.Close()
  3869. body, ioErr := ioutil.ReadAll(resp.Body)
  3870. if ioErr != nil {
  3871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3873. return
  3874. }
  3875. var respJSON map[string]interface{}
  3876. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3879. return
  3880. }
  3881. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3882. userJSONBytes, _ := json.Marshal(userJSON)
  3883. var res ResultTwo
  3884. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3885. utils.ErrorLog("解析失败:%v", err)
  3886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3887. return
  3888. }
  3889. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3890. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3891. infoStr := string(Iinfos)
  3892. idetinfoStr := string(Idetinfos)
  3893. if res.Infcode == 0 {
  3894. his := models.VMHisPatient{
  3895. Status: 1,
  3896. Ctime: time.Now().Unix(),
  3897. Mtime: time.Now().Unix(),
  3898. PsnNo: res.Output.Baseinfo.PsnNo,
  3899. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3900. Certno: res.Output.Baseinfo.Certno,
  3901. PsnName: res.Output.Baseinfo.PsnName,
  3902. Gend: res.Output.Baseinfo.Gend,
  3903. Naty: res.Output.Baseinfo.Naty,
  3904. Brdy: res.Output.Baseinfo.Brdy,
  3905. Age: res.Output.Baseinfo.Age,
  3906. Iinfo: infoStr,
  3907. Idetinfo: idetinfoStr,
  3908. UserOrgId: adminInfo.CurrentOrgId,
  3909. IsReturn: 1,
  3910. IdCardType: id_card_type,
  3911. }
  3912. c.ServeSuccessJSON(map[string]interface{}{
  3913. "info": his,
  3914. })
  3915. } else {
  3916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3917. return
  3918. }
  3919. }
  3920. }
  3921. //func GetBasBaseInfo() (jsonStr string, err error) {
  3922. //
  3923. // handle := syscall.NewLazyDLL("SSCard.dll")
  3924. // add := handle.NewProc("ReadCardBas")
  3925. // str := make([]byte, 1024)
  3926. // str1 := make([]byte, 1024)
  3927. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3928. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3929. //
  3930. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3931. //
  3932. // fmt.Println("> Add(4,5)的结果为:", ret)
  3933. // handle.Release()
  3934. //
  3935. // return "", nil
  3936. //
  3937. //}
  3938. //func GetQRBaseInfo() (jsonStr string, err error) {
  3939. // handle := syscall.LoadDLL("SSCard.dll")
  3940. // ReadCardBas := handle.FindProc("GetQRBase")
  3941. //
  3942. // str := make([]byte, 256)
  3943. // str1 := make([]byte, 256)
  3944. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3945. //
  3946. // fmt.Println(string(str))
  3947. // fmt.Println(r)
  3948. // return string(str), nil
  3949. //}
  3950. //func CardInit() int {
  3951. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3952. // add := DllTestDef.MustFindProc("Init")
  3953. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3954. // if err != nil {
  3955. // fmt.Println("SSCard的运算结果为:", ret)
  3956. // }
  3957. // result := int(ret)
  3958. // return result
  3959. //}
  3960. //func CardInit() int {
  3961. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3962. // if err != nil {
  3963. // fmt.Println("SSCard的运算结果为:", ret)
  3964. // }
  3965. // fmt.Println(err)
  3966. // result := int(ret)
  3967. // return result
  3968. //}
  3969. func IntPtr(n int) uintptr {
  3970. return uintptr(n)
  3971. }
  3972. func StrPtr(s string) uintptr {
  3973. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3974. }
  3975. type Result2001 struct {
  3976. Cainfo interface{} `json:"cainfo"`
  3977. ErrMsg string `json:"err_msg"`
  3978. InfRefmsgid string `json:"inf_refmsgid"`
  3979. Infcode int64 `json:"infcode"`
  3980. Output struct {
  3981. Trtinfo struct {
  3982. PsnNo string `json:"psn_no"`
  3983. TrtChkType string `json:"trt_chk_type"`
  3984. FundPayType string `json:"fund_pay_type"`
  3985. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3986. Begndate string `json:"begndate"`
  3987. Enddate string `json:"enddate"`
  3988. TrtChkRslt string `json:"trt_chk_rslt"`
  3989. } `json:"trtinfo"`
  3990. } `json:"output"`
  3991. RefmsgTime string `json:"refmsg_time"`
  3992. RespondTime string `json:"respond_time"`
  3993. Signtype interface{} `json:"signtype"`
  3994. WarnMsg interface{} `json:"warn_msg"`
  3995. }
  3996. type Result2001Org10265 struct {
  3997. Cainfo interface{} `json:"cainfo"`
  3998. ErrMsg string `json:"err_msg"`
  3999. InfRefmsgid string `json:"inf_refmsgid"`
  4000. Infcode string `json:"infcode"`
  4001. Output struct {
  4002. Trtinfo struct {
  4003. PsnNo string `json:"psn_no"`
  4004. TrtChkType string `json:"trt_chk_type"`
  4005. FundPayType string `json:"fund_pay_type"`
  4006. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4007. Begndate string `json:"begndate"`
  4008. Enddate string `json:"enddate"`
  4009. TrtChkRslt string `json:"trt_chk_rslt"`
  4010. } `json:"trtinfo"`
  4011. } `json:"output"`
  4012. RefmsgTime string `json:"refmsg_time"`
  4013. RespondTime string `json:"respond_time"`
  4014. Signtype interface{} `json:"signtype"`
  4015. WarnMsg interface{} `json:"warn_msg"`
  4016. }
  4017. type ResultTwo struct {
  4018. ErrMsg string `json:"err_msg"`
  4019. InfRefmsgid string `json:"inf_refmsgid"`
  4020. Infcode int64 `json:"infcode"`
  4021. Output struct {
  4022. Baseinfo struct {
  4023. Age float64 `json:"age"`
  4024. Brdy string `json:"brdy"`
  4025. Certno string `json:"certno"`
  4026. Gend string `json:"gend"`
  4027. Naty string `json:"naty"`
  4028. PsnCertType string `json:"psn_cert_type"`
  4029. PsnName string `json:"psn_name"`
  4030. PsnNo string `json:"psn_no"`
  4031. } `json:"baseinfo"`
  4032. Idetinfo []interface{} `json:"idetinfo"`
  4033. Iinfo []struct {
  4034. Balc float64 `json:"balc"`
  4035. CvlservFlag string `json:"cvlserv_flag"`
  4036. EmpName string `json:"emp_name"`
  4037. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4038. Insutype string `json:"insutype"`
  4039. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4040. PausInsuDate string `json:"paus_insu_date"`
  4041. PsnInsuDate string `json:"psn_insu_date"`
  4042. PsnInsuStas string `json:"psn_insu_stas"`
  4043. PsnType string `json:"psn_type"`
  4044. } `json:"insuinfo"`
  4045. } `json:"output"`
  4046. RefmsgTime string `json:"refmsg_time"`
  4047. RespondTime string `json:"respond_time"`
  4048. Signtype interface{} `json:"signtype"`
  4049. WarnInfo interface{} `json:"warn_info"`
  4050. }
  4051. type ResultTwo10265 struct {
  4052. ErrMsg string `json:"err_msg"`
  4053. InfRefmsgid string `json:"inf_refmsgid"`
  4054. Infcode string `json:"infcode"`
  4055. Output struct {
  4056. Baseinfo struct {
  4057. Age float64 `json:"age"`
  4058. Brdy string `json:"brdy"`
  4059. Certno string `json:"certno"`
  4060. Gend string `json:"gend"`
  4061. Naty string `json:"naty"`
  4062. PsnCertType string `json:"psn_cert_type"`
  4063. PsnName string `json:"psn_name"`
  4064. PsnNo string `json:"psn_no"`
  4065. } `json:"baseinfo"`
  4066. Idetinfo []interface{} `json:"idetinfo"`
  4067. Iinfo []struct {
  4068. Balc float64 `json:"balc"`
  4069. CvlservFlag string `json:"cvlserv_flag"`
  4070. EmpName string `json:"emp_name"`
  4071. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4072. Insutype string `json:"insutype"`
  4073. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4074. PausInsuDate string `json:"paus_insu_date"`
  4075. PsnInsuDate string `json:"psn_insu_date"`
  4076. PsnInsuStas string `json:"psn_insu_stas"`
  4077. PsnType string `json:"psn_type"`
  4078. } `json:"insuinfo"`
  4079. } `json:"output"`
  4080. RefmsgTime string `json:"refmsg_time"`
  4081. RespondTime string `json:"respond_time"`
  4082. Signtype interface{} `json:"signtype"`
  4083. WarnInfo interface{} `json:"warn_info"`
  4084. }
  4085. type ResultThree struct {
  4086. Cainfo interface{} `json:"cainfo"`
  4087. ErrMsg string `json:"err_msg"`
  4088. InfRefmsgid string `json:"inf_refmsgid"`
  4089. Infcode int64 `json:"infcode"`
  4090. Output struct {
  4091. Data struct {
  4092. IptOtpNo string `json:"ipt_otp_no"`
  4093. MdtrtID string `json:"mdtrt_id"`
  4094. PsnNo string `json:"psn_no"`
  4095. } `json:"data"`
  4096. } `json:"output"`
  4097. RefmsgTime string `json:"refmsg_time"`
  4098. RespondTime string `json:"respond_time"`
  4099. Signtype interface{} `json:"signtype"`
  4100. WarnMsg interface{} `json:"warn_msg"`
  4101. }
  4102. type ResultThree10265 struct {
  4103. Cainfo interface{} `json:"cainfo"`
  4104. ErrMsg string `json:"err_msg"`
  4105. InfRefmsgid string `json:"inf_refmsgid"`
  4106. Infcode string `json:"infcode"`
  4107. Output struct {
  4108. Data struct {
  4109. IptOtpNo string `json:"ipt_otp_no"`
  4110. MdtrtID string `json:"mdtrt_id"`
  4111. PsnNo string `json:"psn_no"`
  4112. } `json:"data"`
  4113. } `json:"output"`
  4114. RefmsgTime string `json:"refmsg_time"`
  4115. RespondTime string `json:"respond_time"`
  4116. Signtype interface{} `json:"signtype"`
  4117. WarnMsg interface{} `json:"warn_msg"`
  4118. }
  4119. type ResultFour struct {
  4120. Cainfo string `json:"cainfo"`
  4121. ErrMsg string `json:"err_msg"`
  4122. InfRefmsgid string `json:"inf_refmsgid"`
  4123. Infcode int64 `json:"infcode"`
  4124. Output struct {
  4125. Result []struct {
  4126. BasMednFlag string `json:"bas_medn_flag"`
  4127. ChldMedcFlag string `json:"chld_medc_flag"`
  4128. ChrgitmLv string `json:"chrgitm_lv"`
  4129. Cnt float64 `json:"cnt"`
  4130. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4131. DrtReimFlag string `json:"drt_reim_flag"`
  4132. FeedetlSn string `json:"feedetl_sn"`
  4133. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4134. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4135. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4136. ListSpItemFlag string `json:"list_sp_item_flag"`
  4137. LmtUsedFlag string `json:"lmt_used_flag"`
  4138. MedChrgitmType string `json:"med_chrgitm_type"`
  4139. Memo string `json:"memo"`
  4140. OverlmtAmt float64 `json:"overlmt_amt"`
  4141. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4142. Pric float64 `json:"pric"`
  4143. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4144. SelfpayProp float64 `json:"selfpay_prop"`
  4145. } `json:"result"`
  4146. } `json:"output"`
  4147. RefmsgTime string `json:"refmsg_time"`
  4148. RespondTime string `json:"respond_time"`
  4149. Signtype string `json:"signtype"`
  4150. WarnMsg string `json:"warn_msg"`
  4151. }
  4152. type ResultFour10265 struct {
  4153. Cainfo string `json:"cainfo"`
  4154. ErrMsg string `json:"err_msg"`
  4155. InfRefmsgid string `json:"inf_refmsgid"`
  4156. Infcode string `json:"infcode"`
  4157. Output struct {
  4158. Result []struct {
  4159. BasMednFlag string `json:"bas_medn_flag"`
  4160. ChldMedcFlag string `json:"chld_medc_flag"`
  4161. ChrgitmLv string `json:"chrgitm_lv"`
  4162. Cnt float64 `json:"cnt"`
  4163. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4164. DrtReimFlag string `json:"drt_reim_flag"`
  4165. FeedetlSn string `json:"feedetl_sn"`
  4166. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4167. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4168. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4169. ListSpItemFlag string `json:"list_sp_item_flag"`
  4170. LmtUsedFlag string `json:"lmt_used_flag"`
  4171. MedChrgitmType string `json:"med_chrgitm_type"`
  4172. Memo string `json:"memo"`
  4173. OverlmtAmt float64 `json:"overlmt_amt"`
  4174. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4175. Pric float64 `json:"pric"`
  4176. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4177. SelfpayProp float64 `json:"selfpay_prop"`
  4178. } `json:"result"`
  4179. } `json:"output"`
  4180. RefmsgTime string `json:"refmsg_time"`
  4181. RespondTime string `json:"respond_time"`
  4182. Signtype string `json:"signtype"`
  4183. WarnMsg string `json:"warn_msg"`
  4184. }
  4185. type ResultFive struct {
  4186. Balc float64 `json:"balc"`
  4187. CvlservFlag string `json:"cvlserv_flag"`
  4188. EmpName string `json:"emp_name"`
  4189. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4190. Insutype string `json:"insutype"`
  4191. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4192. PausInsuDate string `json:"paus_insu_date"`
  4193. PsnInsuDate string `json:"psn_insu_date"`
  4194. PsnInsuStas string `json:"psn_insu_stas"`
  4195. PsnType string `json:"psn_type"`
  4196. }
  4197. type ResultSix struct {
  4198. Cainfo interface{} `json:"cainfo"`
  4199. ErrMsg string `json:"err_msg"`
  4200. InfRefmsgid string `json:"inf_refmsgid"`
  4201. Infcode int64 `json:"infcode"`
  4202. Output struct {
  4203. } `json:"output"`
  4204. RefmsgTime string `json:"refmsg_time"`
  4205. RespondTime string `json:"respond_time"`
  4206. Signtype interface{} `json:"signtype"`
  4207. WarnMsg interface{} `json:"warn_msg"`
  4208. }
  4209. type ResultSix10265 struct {
  4210. Cainfo interface{} `json:"cainfo"`
  4211. ErrMsg string `json:"err_msg"`
  4212. InfRefmsgid string `json:"inf_refmsgid"`
  4213. Infcode string `json:"infcode"`
  4214. Output struct {
  4215. } `json:"output"`
  4216. RefmsgTime string `json:"refmsg_time"`
  4217. RespondTime string `json:"respond_time"`
  4218. Signtype interface{} `json:"signtype"`
  4219. WarnMsg interface{} `json:"warn_msg"`
  4220. }
  4221. type ResultSeven struct {
  4222. Cainfo string `json:"cainfo"`
  4223. ErrMsg string `json:"err_msg"`
  4224. InfRefmsgid string `json:"inf_refmsgid"`
  4225. Infcode int64 `json:"infcode"`
  4226. Output struct {
  4227. Setldetail []interface{} `json:"setldetail"`
  4228. Setlinfo struct {
  4229. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4230. AcctPay float64 `json:"acct_pay"`
  4231. ActPayDedc float64 `json:"act_pay_dedc"`
  4232. Age float64 `json:"age"`
  4233. Balc float64 `json:"balc"`
  4234. Brdy string `json:"brdy"`
  4235. Certno string `json:"certno"`
  4236. ClrOptins string `json:"clr_optins"`
  4237. ClrType string `json:"clr_type"`
  4238. ClrWay string `json:"clr_way"`
  4239. CvlservFlag string `json:"cvlserv_flag"`
  4240. CvlservPay float64 `json:"cvlserv_pay"`
  4241. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4242. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4243. Gend string `json:"gend"`
  4244. HifesPay float64 `json:"hifes_pay"`
  4245. HifmiPay float64 `json:"hifmi_pay"`
  4246. HifpPay float64 `json:"hifp_pay"`
  4247. HospPartAmt float64 `json:"hosp_part_amt"`
  4248. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4249. Insutype string `json:"insutype"`
  4250. MafPay float64 `json:"maf_pay"`
  4251. MdtrtCertType string `json:"mdtrt_cert_type"`
  4252. HifobPay float64 `json:"hifob_pay"`
  4253. MdtrtID string `json:"mdtrt_id"`
  4254. MedType string `json:"med_type"`
  4255. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4256. MedinsSetlID string `json:"medins_setl_id"`
  4257. Naty string `json:"naty"`
  4258. OthPay float64 `json:"oth_pay"`
  4259. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4260. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4261. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4262. PsnCashPay float64 `json:"psn_cash_pay"`
  4263. PsnCertType string `json:"psn_cert_type"`
  4264. PsnName string `json:"psn_name"`
  4265. PsnNo string `json:"psn_no"`
  4266. PsnPartAmt float64 `json:"psn_part_amt"`
  4267. PsnType string `json:"psn_type"`
  4268. SetlID string `json:"setl_id"`
  4269. SetlTime string `json:"setl_time"`
  4270. } `json:"setlinfo"`
  4271. } `json:"output"`
  4272. RefmsgTime string `json:"refmsg_time"`
  4273. RespondTime string `json:"respond_time"`
  4274. Signtype interface{} `json:"signtype"`
  4275. WarnMsg interface{} `json:"warn_msg"`
  4276. }
  4277. type ResultSeven10265 struct {
  4278. Cainfo string `json:"cainfo"`
  4279. ErrMsg string `json:"err_msg"`
  4280. InfRefmsgid string `json:"inf_refmsgid"`
  4281. Infcode string `json:"infcode"`
  4282. Output struct {
  4283. Setldetail []interface{} `json:"setldetail"`
  4284. Setlinfo struct {
  4285. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4286. AcctPay float64 `json:"acct_pay"`
  4287. ActPayDedc float64 `json:"act_pay_dedc"`
  4288. Age float64 `json:"age"`
  4289. Balc float64 `json:"balc"`
  4290. Brdy string `json:"brdy"`
  4291. Certno string `json:"certno"`
  4292. ClrOptins string `json:"clr_optins"`
  4293. ClrType string `json:"clr_type"`
  4294. ClrWay string `json:"clr_way"`
  4295. CvlservFlag string `json:"cvlserv_flag"`
  4296. CvlservPay float64 `json:"cvlserv_pay"`
  4297. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4298. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4299. Gend string `json:"gend"`
  4300. HifesPay float64 `json:"hifes_pay"`
  4301. HifmiPay float64 `json:"hifmi_pay"`
  4302. HifpPay float64 `json:"hifp_pay"`
  4303. HospPartAmt float64 `json:"hosp_part_amt"`
  4304. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4305. Insutype string `json:"insutype"`
  4306. MafPay float64 `json:"maf_pay"`
  4307. MdtrtCertType string `json:"mdtrt_cert_type"`
  4308. HifobPay float64 `json:"hifob_pay"`
  4309. MdtrtID string `json:"mdtrt_id"`
  4310. MedType string `json:"med_type"`
  4311. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4312. MedinsSetlID string `json:"medins_setl_id"`
  4313. Naty string `json:"naty"`
  4314. OthPay float64 `json:"oth_pay"`
  4315. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4316. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4317. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4318. PsnCashPay float64 `json:"psn_cash_pay"`
  4319. PsnCertType string `json:"psn_cert_type"`
  4320. PsnName string `json:"psn_name"`
  4321. PsnNo string `json:"psn_no"`
  4322. PsnPartAmt float64 `json:"psn_part_amt"`
  4323. PsnType string `json:"psn_type"`
  4324. SetlID string `json:"setl_id"`
  4325. SetlTime string `json:"setl_time"`
  4326. } `json:"setlinfo"`
  4327. } `json:"output"`
  4328. RefmsgTime string `json:"refmsg_time"`
  4329. RespondTime string `json:"respond_time"`
  4330. Signtype interface{} `json:"signtype"`
  4331. WarnMsg interface{} `json:"warn_msg"`
  4332. }
  4333. type ResultEight struct {
  4334. Cainfo string `json:"cainfo"`
  4335. ErrMsg string `json:"err_msg"`
  4336. InfRefmsgid string `json:"inf_refmsgid"`
  4337. Infcode int64 `json:"infcode"`
  4338. Output struct {
  4339. Stmtinfo struct {
  4340. SetlOptins string `json:"setl_optins"`
  4341. StmtRslt string `json:"stmt_rslt"`
  4342. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4343. } `json:"stmtinfo"`
  4344. } `json:"output"`
  4345. RefmsgTime string `json:"refmsg_time"`
  4346. RespondTime string `json:"respond_time"`
  4347. Signtype interface{} `json:"signtype"`
  4348. WarnMsg interface{} `json:"warn_msg"`
  4349. }
  4350. type ResultEightFor10188 struct {
  4351. Cainfo string `json:"cainfo"`
  4352. ErrMsg string `json:"err_msg"`
  4353. InfRefmsgid string `json:"inf_refmsgid"`
  4354. Infcode string `json:"infcode"`
  4355. Output struct {
  4356. Stmtinfo struct {
  4357. SetlOptins string `json:"setl_optins"`
  4358. StmtRslt string `json:"stmt_rslt"`
  4359. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4360. } `json:"stmtinfo"`
  4361. } `json:"output"`
  4362. RefmsgTime string `json:"refmsg_time"`
  4363. RespondTime string `json:"respond_time"`
  4364. Signtype interface{} `json:"signtype"`
  4365. WarnMsg interface{} `json:"warn_msg"`
  4366. }
  4367. type ResultNine struct {
  4368. Cainfo string `json:"cainfo"`
  4369. ErrMsg string `json:"err_msg"`
  4370. InfRefmsgid string `json:"inf_refmsgid"`
  4371. Infcode int64 `json:"infcode"`
  4372. Output struct {
  4373. FileQuryNo string `json:"file_qury_no"`
  4374. } `json:"output"`
  4375. RefmsgTime string `json:"refmsg_time"`
  4376. RespondTime string `json:"respond_time"`
  4377. Signtype interface{} `json:"signtype"`
  4378. WarnMsg interface{} `json:"warn_msg"`
  4379. }
  4380. type ResultTen struct {
  4381. Cainfo string `json:"cainfo"`
  4382. ErrMsg string `json:"err_msg"`
  4383. InfRefmsgid string `json:"inf_refmsgid"`
  4384. Infcode int64 `json:"infcode"`
  4385. Output struct {
  4386. DldEndtime string `json:"dld_endtime"`
  4387. FileQuryNo string `json:"file_qury_no"`
  4388. Filename string `json:"filename"`
  4389. } `json:"output"`
  4390. RefmsgTime string `json:"refmsg_time"`
  4391. RespondTime string `json:"respond_time"`
  4392. Signtype interface{} `json:"signtype"`
  4393. WarnMsg interface{} `json:"warn_msg"`
  4394. }
  4395. //type Autogenerated struct {
  4396. // Output struct {
  4397. // Setlinfo struct {
  4398. // SetlTime string `json:"setl_time"`
  4399. // CvlservPay float64 `json:"cvlserv_pay"`
  4400. // Year string `json:"year"`
  4401. // MedType string `json:"med_type"`
  4402. // PsnPay float64 `json:"psn_pay"`
  4403. // OpterID string `json:"opter_id"`
  4404. // Begndate string `json:"begndate"`
  4405. // FlxempeFlag string `json:"flxempe_flag"`
  4406. // HifmiPay float64 `json:"hifmi_pay"`
  4407. // PsnNo string `json:"psn_no"`
  4408. // ActPayDedc float64 `json:"act_pay_dedc"`
  4409. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4410. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4411. // ClrWay string `json:"clr_way"`
  4412. // OthPay float64 `json:"oth_pay"`
  4413. // Gend string `json:"gend"`
  4414. // MdtrtID string `json:"mdtrt_id"`
  4415. // AcctPay float64 `json:"acct_pay"`
  4416. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4417. // Insutype string `json:"insutype"`
  4418. // Invono interface{} `json:"invono"`
  4419. // Enddate string `json:"enddate"`
  4420. // CashPayamt float64 `json:"cash_payamt"`
  4421. // PsnType string `json:"psn_type"`
  4422. // FixmedinsName string `json:"fixmedins_name"`
  4423. // HifpPay float64 `json:"hifp_pay"`
  4424. // NewFlag interface{} `json:"new_flag"`
  4425. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4426. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4427. // PayLoc string `json:"pay_loc"`
  4428. // ClrType string `json:"clr_type"`
  4429. // RefdSetlFlag string `json:"refd_setl_flag"`
  4430. // CvlservFlag string `json:"cvlserv_flag"`
  4431. // EmpName string `json:"emp_name"`
  4432. // Brdy string `json:"brdy"`
  4433. // Naty string `json:"naty"`
  4434. // Certno string `json:"certno"`
  4435. // DiseCode string `json:"dise_code"`
  4436. // FixmedinsCode string `json:"fixmedins_code"`
  4437. // DedcHospLv string `json:"dedc_hosp_lv"`
  4438. // OpterName string `json:"opter_name"`
  4439. // Balc float64 `json:"balc"`
  4440. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4441. // PsnCertType string `json:"psn_cert_type"`
  4442. // HifobPay float64 `json:"hifob_pay"`
  4443. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4444. // HifesPay float64 `json:"hifes_pay"`
  4445. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4446. // OptTime string `json:"opt_time"`
  4447. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4448. // SetlID string `json:"setl_id"`
  4449. // MafPay float64 `json:"maf_pay"`
  4450. // PsnName string `json:"psn_name"`
  4451. // InsuOptins interface{} `json:"insu_optins"`
  4452. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4453. // ClrOptins string `json:"clr_optins"`
  4454. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4455. // DiseName string `json:"dise_name"`
  4456. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4457. // Age float64 `json:"age"`
  4458. // DtrtCertType string `json:"dtrt_cert_type"`
  4459. // HospLv string `json:"hosp_lv"`
  4460. // } `json:"setlinfo"`
  4461. // Setldetail []struct {
  4462. // FundPayType string `json:"fund_pay_type"`
  4463. // FundPayamt float64 `json:"fund_payamt"`
  4464. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4465. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4466. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4467. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4468. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4469. // } `json:"setldetail"`
  4470. // } `json:"output"`
  4471. // Infcode int `json:"infcode"`
  4472. // WarnMsg interface{} `json:"warn_msg"`
  4473. // Cainfo interface{} `json:"cainfo"`
  4474. // ErrMsg interface{} `json:"err_msg"`
  4475. // RefmsgTime string `json:"refmsg_time"`
  4476. // Signtype interface{} `json:"signtype"`
  4477. // RespondTime string `json:"respond_time"`
  4478. // InfRefmsgid string `json:"inf_refmsgid"`
  4479. //}
  4480. type ResultEleven struct {
  4481. Cainfo string `json:"cainfo"`
  4482. ErrMsg string `json:"err_msg"`
  4483. InfRefmsgid string `json:"inf_refmsgid"`
  4484. Infcode int64 `json:"infcode"`
  4485. Output struct {
  4486. Setlinfo struct {
  4487. SetlTime string `json:"setl_time"`
  4488. CvlservPay float64 `json:"cvlserv_pay"`
  4489. Year string `json:"year"`
  4490. MedType string `json:"med_type"`
  4491. PsnPay float64 `json:"psn_pay"`
  4492. OpterID string `json:"opter_id"`
  4493. Begndate string `json:"begndate"`
  4494. FlxempeFlag string `json:"flxempe_flag"`
  4495. HifmiPay float64 `json:"hifmi_pay"`
  4496. PsnNo string `json:"psn_no"`
  4497. ActPayDedc float64 `json:"act_pay_dedc"`
  4498. MedinsSetlID interface{} `json:"medins_setl_id"`
  4499. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4500. ClrWay string `json:"clr_way"`
  4501. OthPay float64 `json:"oth_pay"`
  4502. Gend string `json:"gend"`
  4503. MdtrtID string `json:"mdtrt_id"`
  4504. AcctPay float64 `json:"acct_pay"`
  4505. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4506. Insutype string `json:"insutype"`
  4507. Invono interface{} `json:"invono"`
  4508. Enddate string `json:"enddate"`
  4509. CashPayamt float64 `json:"cash_payamt"`
  4510. PsnType string `json:"psn_type"`
  4511. FixmedinsName string `json:"fixmedins_name"`
  4512. HifpPay float64 `json:"hifp_pay"`
  4513. NewFlag interface{} `json:"new_flag"`
  4514. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4515. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4516. PayLoc string `json:"pay_loc"`
  4517. ClrType string `json:"clr_type"`
  4518. RefdSetlFlag string `json:"refd_setl_flag"`
  4519. CvlservFlag string `json:"cvlserv_flag"`
  4520. EmpName string `json:"emp_name"`
  4521. Brdy string `json:"brdy"`
  4522. Naty string `json:"naty"`
  4523. Certno string `json:"certno"`
  4524. DiseCode string `json:"dise_code"`
  4525. FixmedinsCode string `json:"fixmedins_code"`
  4526. DedcHospLv string `json:"dedc_hosp_lv"`
  4527. OpterName string `json:"opter_name"`
  4528. Balc float64 `json:"balc"`
  4529. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4530. PsnCertType string `json:"psn_cert_type"`
  4531. HifobPay float64 `json:"hifob_pay"`
  4532. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4533. HifesPay float64 `json:"hifes_pay"`
  4534. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4535. OptTime string `json:"opt_time"`
  4536. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4537. SetlID string `json:"setl_id"`
  4538. MafPay float64 `json:"maf_pay"`
  4539. PsnName string `json:"psn_name"`
  4540. InsuOptins interface{} `json:"insu_optins"`
  4541. PrefFundPay interface{} `json:"pref_fund_pay"`
  4542. ClrOptins string `json:"clr_optins"`
  4543. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4544. DiseName string `json:"dise_name"`
  4545. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4546. Age float64 `json:"age"`
  4547. DtrtCertType string `json:"dtrt_cert_type"`
  4548. HospLv string `json:"hosp_lv"`
  4549. } `json:"setlinfo"`
  4550. } `json:"output"`
  4551. RefmsgTime string `json:"refmsg_time"`
  4552. RespondTime string `json:"respond_time"`
  4553. Signtype interface{} `json:"signtype"`
  4554. WarnMsg interface{} `json:"warn_msg"`
  4555. }
  4556. type ResultEleven10265 struct {
  4557. Cainfo string `json:"cainfo"`
  4558. ErrMsg string `json:"err_msg"`
  4559. InfRefmsgid string `json:"inf_refmsgid"`
  4560. Infcode string `json:"infcode"`
  4561. Output struct {
  4562. Setlinfo struct {
  4563. SetlTime string `json:"setl_time"`
  4564. CvlservPay float64 `json:"cvlserv_pay"`
  4565. Year string `json:"year"`
  4566. MedType string `json:"med_type"`
  4567. PsnPay float64 `json:"psn_pay"`
  4568. OpterID string `json:"opter_id"`
  4569. Begndate string `json:"begndate"`
  4570. FlxempeFlag string `json:"flxempe_flag"`
  4571. HifmiPay float64 `json:"hifmi_pay"`
  4572. PsnNo string `json:"psn_no"`
  4573. ActPayDedc float64 `json:"act_pay_dedc"`
  4574. MedinsSetlID interface{} `json:"medins_setl_id"`
  4575. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4576. ClrWay string `json:"clr_way"`
  4577. OthPay float64 `json:"oth_pay"`
  4578. Gend string `json:"gend"`
  4579. MdtrtID string `json:"mdtrt_id"`
  4580. AcctPay float64 `json:"acct_pay"`
  4581. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4582. Insutype string `json:"insutype"`
  4583. Invono interface{} `json:"invono"`
  4584. Enddate string `json:"enddate"`
  4585. CashPayamt float64 `json:"cash_payamt"`
  4586. PsnType string `json:"psn_type"`
  4587. FixmedinsName string `json:"fixmedins_name"`
  4588. HifpPay float64 `json:"hifp_pay"`
  4589. NewFlag interface{} `json:"new_flag"`
  4590. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4591. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4592. PayLoc string `json:"pay_loc"`
  4593. ClrType string `json:"clr_type"`
  4594. RefdSetlFlag string `json:"refd_setl_flag"`
  4595. CvlservFlag string `json:"cvlserv_flag"`
  4596. EmpName string `json:"emp_name"`
  4597. Brdy string `json:"brdy"`
  4598. Naty string `json:"naty"`
  4599. Certno string `json:"certno"`
  4600. DiseCode string `json:"dise_code"`
  4601. FixmedinsCode string `json:"fixmedins_code"`
  4602. DedcHospLv string `json:"dedc_hosp_lv"`
  4603. OpterName string `json:"opter_name"`
  4604. Balc float64 `json:"balc"`
  4605. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4606. PsnCertType string `json:"psn_cert_type"`
  4607. HifobPay float64 `json:"hifob_pay"`
  4608. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4609. HifesPay float64 `json:"hifes_pay"`
  4610. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4611. OptTime string `json:"opt_time"`
  4612. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4613. SetlID string `json:"setl_id"`
  4614. MafPay float64 `json:"maf_pay"`
  4615. PsnName string `json:"psn_name"`
  4616. InsuOptins interface{} `json:"insu_optins"`
  4617. PrefFundPay interface{} `json:"pref_fund_pay"`
  4618. ClrOptins string `json:"clr_optins"`
  4619. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4620. DiseName string `json:"dise_name"`
  4621. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4622. Age float64 `json:"age"`
  4623. DtrtCertType string `json:"dtrt_cert_type"`
  4624. HospLv string `json:"hosp_lv"`
  4625. } `json:"setlinfo"`
  4626. } `json:"output"`
  4627. RefmsgTime string `json:"refmsg_time"`
  4628. RespondTime string `json:"respond_time"`
  4629. Signtype interface{} `json:"signtype"`
  4630. WarnMsg interface{} `json:"warn_msg"`
  4631. }
  4632. type ResultTwelve struct {
  4633. Cainfo string `json:"cainfo"`
  4634. ErrMsg string `json:"err_msg"`
  4635. InfRefmsgid string `json:"inf_refmsgid"`
  4636. Infcode int64 `json:"infcode"`
  4637. Output struct {
  4638. MdtrtId string `json:"mdtrt_id"`
  4639. ChrgBchno string `json:"chrg_bchno"`
  4640. PsnNo string `json:"psn_no"`
  4641. } `json:"output"`
  4642. RefmsgTime string `json:"refmsg_time"`
  4643. RespondTime string `json:"respond_time"`
  4644. Signtype interface{} `json:"signtype"`
  4645. WarnMsg interface{} `json:"warn_msg"`
  4646. }
  4647. type ResultThirteen struct {
  4648. ErrMsg string `json:"err_msg"`
  4649. InfRefmsgid string `json:"inf_refmsgid"`
  4650. Infcode int64 `json:"infcode"`
  4651. Output struct {
  4652. Result struct {
  4653. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4654. } `json:"result"`
  4655. } `json:"output"`
  4656. RefmsgTime string `json:"refmsg_time"`
  4657. RespondTime string `json:"respond_time"`
  4658. Signtype interface{} `json:"signtype"`
  4659. WarnInfo interface{} `json:"warn_info"`
  4660. }
  4661. type ResultThirteen10265 struct {
  4662. ErrMsg string `json:"err_msg"`
  4663. InfRefmsgid string `json:"inf_refmsgid"`
  4664. Infcode string `json:"infcode"`
  4665. Output struct {
  4666. Result struct {
  4667. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4668. } `json:"result"`
  4669. } `json:"output"`
  4670. RefmsgTime string `json:"refmsg_time"`
  4671. RespondTime string `json:"respond_time"`
  4672. Signtype interface{} `json:"signtype"`
  4673. WarnInfo interface{} `json:"warn_info"`
  4674. }
  4675. type ResultFourteen struct {
  4676. ErrMsg string `json:"err_msg"`
  4677. InfRefmsgid string `json:"inf_refmsgid"`
  4678. Infcode int64 `json:"infcode"`
  4679. Output struct {
  4680. } `json:"output"`
  4681. RefmsgTime string `json:"refmsg_time"`
  4682. RespondTime string `json:"respond_time"`
  4683. Signtype interface{} `json:"signtype"`
  4684. WarnInfo interface{} `json:"warn_info"`
  4685. }
  4686. type ResultFourteen10265 struct {
  4687. ErrMsg string `json:"err_msg"`
  4688. InfRefmsgid string `json:"inf_refmsgid"`
  4689. Infcode string `json:"infcode"`
  4690. Output struct {
  4691. } `json:"output"`
  4692. RefmsgTime string `json:"refmsg_time"`
  4693. RespondTime string `json:"respond_time"`
  4694. Signtype interface{} `json:"signtype"`
  4695. WarnInfo interface{} `json:"warn_info"`
  4696. }
  4697. type ResultSixteen struct {
  4698. Cainfo string `json:"cainfo"`
  4699. ErrMsg string `json:"err_msg"`
  4700. InfRefmsgid string `json:"inf_refmsgid"`
  4701. Infcode int64 `json:"infcode"`
  4702. Output struct {
  4703. Setldetail []interface{} `json:"setldetail"`
  4704. Setlinfo struct {
  4705. MdtrtID string `json:"mdtrt_id"`
  4706. SetlID string `json:"setl_id"`
  4707. ClrOptins string `json:"clr_optins"`
  4708. SetlTime string `json:"setl_time"`
  4709. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4710. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4711. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4712. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4713. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4714. ActPayDedc float64 `json:"act_pay_dedc"`
  4715. HifpPay float64 `json:"hifp_pay"`
  4716. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4717. Lfpay float64 `json:"selfpay"`
  4718. CvlservPay float64 `json:"cvlserv_pay"`
  4719. HifesPay float64 `json:"hifes_pay"`
  4720. HifmiPay float64 `json:"hifmi_pay"`
  4721. HifobPay float64 `json:"hifob_pay"`
  4722. MafPay float64 `json:"maf_pay"`
  4723. OthPay float64 `json:"oth_pay"`
  4724. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4725. PsnPartAmt float64 `json:"psn_part_amt"`
  4726. AcctPay float64 `json:"acct_pay"`
  4727. Balc float64 `json:"balc"`
  4728. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4729. HospPartAmt float64 `json:"hosp_part_amt"`
  4730. MedinsSetlID string `json:"medins_setl_id"`
  4731. PdnCashPay string `json:"pdn_cash_pay"`
  4732. } `json:"setlinfo"`
  4733. } `json:"output"`
  4734. RefmsgTime string `json:"refmsg_time"`
  4735. RespondTime string `json:"respond_time"`
  4736. Signtype interface{} `json:"signtype"`
  4737. WarnMsg interface{} `json:"warn_msg"`
  4738. }
  4739. type ResultSixteen10265 struct {
  4740. Cainfo string `json:"cainfo"`
  4741. ErrMsg string `json:"err_msg"`
  4742. InfRefmsgid string `json:"inf_refmsgid"`
  4743. Infcode string `json:"infcode"`
  4744. Output struct {
  4745. Setldetail []interface{} `json:"setldetail"`
  4746. Setlinfo struct {
  4747. MdtrtID string `json:"mdtrt_id"`
  4748. SetlID string `json:"setl_id"`
  4749. ClrOptins string `json:"clr_optins"`
  4750. SetlTime string `json:"setl_time"`
  4751. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4752. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4753. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4754. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4755. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4756. ActPayDedc float64 `json:"act_pay_dedc"`
  4757. HifpPay float64 `json:"hifp_pay"`
  4758. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4759. Lfpay float64 `json:"selfpay"`
  4760. CvlservPay float64 `json:"cvlserv_pay"`
  4761. HifesPay float64 `json:"hifes_pay"`
  4762. HifmiPay float64 `json:"hifmi_pay"`
  4763. HifobPay float64 `json:"hifob_pay"`
  4764. MafPay float64 `json:"maf_pay"`
  4765. OthPay float64 `json:"oth_pay"`
  4766. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4767. PsnPartAmt float64 `json:"psn_part_amt"`
  4768. AcctPay float64 `json:"acct_pay"`
  4769. Balc float64 `json:"balc"`
  4770. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4771. HospPartAmt float64 `json:"hosp_part_amt"`
  4772. MedinsSetlID string `json:"medins_setl_id"`
  4773. PdnCashPay string `json:"pdn_cash_pay"`
  4774. } `json:"setlinfo"`
  4775. } `json:"output"`
  4776. RefmsgTime string `json:"refmsg_time"`
  4777. RespondTime string `json:"respond_time"`
  4778. Signtype interface{} `json:"signtype"`
  4779. WarnMsg interface{} `json:"warn_msg"`
  4780. }
  4781. type ResultSeventeen struct {
  4782. ErrMsg string `json:"err_msg"`
  4783. InfRefmsgid string `json:"inf_refmsgid"`
  4784. Infcode int64 `json:"infcode"`
  4785. Output struct {
  4786. SetlListId string `json:"setl_list_id"`
  4787. } `json:"output"`
  4788. RefmsgTime string `json:"refmsg_time"`
  4789. RespondTime string `json:"respond_time"`
  4790. Signtype string `json:"signtype"`
  4791. WarnInfo string `json:"warn_info"`
  4792. }
  4793. type ResultSeventeenOther struct {
  4794. ErrMsg string `json:"err_msg"`
  4795. InfRefmsgid string `json:"inf_refmsgid"`
  4796. Infcode string `json:"infcode"`
  4797. Output struct {
  4798. SetlListId string `json:"setl_list_id"`
  4799. } `json:"output"`
  4800. RefmsgTime string `json:"refmsg_time"`
  4801. RespondTime string `json:"respond_time"`
  4802. Signtype string `json:"signtype"`
  4803. WarnInfo string `json:"warn_info"`
  4804. }
  4805. type Result90991 struct {
  4806. ErrMsg string `json:"err_msg"`
  4807. InfRefmsgid string `json:"inf_refmsgid"`
  4808. Infcode int64 `json:"infcode"`
  4809. Output struct {
  4810. Result struct {
  4811. PsnNo string `json:"psn_no"`
  4812. CardStat string `json:"card_stat"`
  4813. Certno string `json:"certno"`
  4814. PsnName string `json:"psn_name"`
  4815. CheckStat string `json:"check_stat"`
  4816. SscnoCheckStat string `json:"sscno_check_stat"`
  4817. } `json:"result"`
  4818. } `json:"output"`
  4819. RefmsgTime string `json:"refmsg_time"`
  4820. RespondTime string `json:"respond_time"`
  4821. Signtype interface{} `json:"signtype"`
  4822. WarnInfo interface{} `json:"warn_info"`
  4823. }
  4824. type Result90100 struct {
  4825. ErrMsg string `json:"err_msg"`
  4826. InfRefmsgid string `json:"inf_refmsgid"`
  4827. Infcode int64 `json:"infcode"`
  4828. Output struct {
  4829. PoolareaNo string `json:"poolarea_no"`
  4830. PoolareaNoName string `json:"poolarea_no_name"`
  4831. Insutype string `json:"insutype"`
  4832. InsutypeName string `json:"insutype_name"`
  4833. ClctType string `json:"clct_type"`
  4834. ClctTypeName string `json:"clct_type_name"`
  4835. ClctFlag string `json:"clct_flag"`
  4836. ClctFlagName string `json:"clct_flag_name"`
  4837. AccrymBegn string `json:"accrym_begn"`
  4838. AccrymEnd string `json:"accrym_end"`
  4839. ClctTime string `json:"clct_time"`
  4840. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4841. } `json:"output"`
  4842. RefmsgTime string `json:"refmsg_time"`
  4843. RespondTime string `json:"respond_time"`
  4844. Signtype interface{} `json:"signtype"`
  4845. WarnInfo interface{} `json:"warn_info"`
  4846. }
  4847. type Custom struct {
  4848. DetItemFeeSumamt string
  4849. Cut string
  4850. FeedetlSn string
  4851. Price string
  4852. MedListCodg string
  4853. Type int64
  4854. AdviceId int64
  4855. ProjectId int64
  4856. ItemId int64
  4857. }
  4858. type Result5301 struct {
  4859. ErrMsg string `json:"err_msg"`
  4860. InfRefmsgid string `json:"inf_refmsgid"`
  4861. Infcode int64 `json:"infcode"`
  4862. Output struct {
  4863. Result []struct {
  4864. OpspDiseCode string `json:"opsp_dise_code"`
  4865. OpspDiseName string `json:"opsp_dise_name"`
  4866. Begndate string `json:"begndate"`
  4867. Enddate string `json:"enddate"`
  4868. } `json:"feedetail"`
  4869. } `json:"output"`
  4870. RefmsgTime string `json:"refmsg_time"`
  4871. RespondTime string `json:"respond_time"`
  4872. Signtype interface{} `json:"signtype"`
  4873. WarnInfo interface{} `json:"warn_info"`
  4874. }
  4875. type Result5301For10265 struct {
  4876. ErrMsg string `json:"err_msg"`
  4877. InfRefmsgid string `json:"inf_refmsgid"`
  4878. Infcode string `json:"infcode"`
  4879. Output struct {
  4880. Result []struct {
  4881. OpspDiseCode string `json:"opsp_dise_code"`
  4882. OpspDiseName string `json:"opsp_dise_name"`
  4883. Begndate string `json:"begndate"`
  4884. Enddate string `json:"enddate"`
  4885. } `json:"feedetail"`
  4886. } `json:"output"`
  4887. RefmsgTime string `json:"refmsg_time"`
  4888. RespondTime string `json:"respond_time"`
  4889. Signtype interface{} `json:"signtype"`
  4890. WarnInfo interface{} `json:"warn_info"`
  4891. }
  4892. //获取个人信息----挂号-----上传就诊信息
  4893. func (c *HisApiController) GetRegisterInfo() {
  4894. id, _ := c.GetInt64("id")
  4895. record_time := c.GetString("record_time")
  4896. settlementValue, _ := c.GetInt64("settlement_value")
  4897. medical_insurance_card := c.GetString("medical_insurance_card")
  4898. name := c.GetString("name")
  4899. id_card_type, _ := c.GetInt64("id_card_type")
  4900. certificates, _ := c.GetInt64("certificates")
  4901. medical_care, _ := c.GetInt64("medical_care")
  4902. birthday := c.GetString("birthday")
  4903. id_card := c.GetString("id_card")
  4904. register_type, _ := c.GetInt64("register")
  4905. doctor, _ := c.GetInt64("doctor")
  4906. department, _ := c.GetInt64("department")
  4907. gender, _ := c.GetInt64("sex")
  4908. registration_fee, _ := c.GetFloat("registration_fee")
  4909. medical_expenses, _ := c.GetFloat("medical_expenses")
  4910. social_type, _ := c.GetInt64("social_type")
  4911. med_type := c.GetString("social_type")
  4912. admin_user_id, _ := c.GetInt64("admin_user_id")
  4913. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4914. timeLayout := "2006-01-02"
  4915. loc, _ := time.LoadLocation("Local")
  4916. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4917. birthUnix := birthdays.Unix()
  4918. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4919. if err != nil {
  4920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4921. return
  4922. }
  4923. recordDateTime := theTime.Unix()
  4924. adminInfo := c.GetAdminUserInfo()
  4925. var patient service.Patients
  4926. if id == 0 {
  4927. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4928. } else {
  4929. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4930. }
  4931. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4932. if patientPrescription.ID == 0 {
  4933. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4934. }
  4935. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4936. if patient.ID == 0 {
  4937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4938. return
  4939. }
  4940. if len(patient.IdCardNo) == 0 {
  4941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4942. return
  4943. }
  4944. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4945. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4946. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4947. //就诊结算未完成,不能进行二次挂号
  4948. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4949. if len(his) >= 1 {
  4950. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4951. if len(his) >= 1 && order.ID == 0 {
  4952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4953. return
  4954. }
  4955. }
  4956. //var register_log string
  4957. if config.IsOpen == 1 {
  4958. var res ResultTwo
  4959. var res10265 ResultTwo10265
  4960. var PsnNo string
  4961. var PsnCertType string
  4962. var Certno string
  4963. var PsnName string
  4964. var Gend string
  4965. var Naty string
  4966. var Brdy string
  4967. var Age float64
  4968. var infoStr string
  4969. var idetinfoStr string
  4970. var infocode int64
  4971. var verify_number string
  4972. fmt.Println(verify_number)
  4973. if miConfig.MdtrtareaAdmvs == "421300" {
  4974. psn_info, _ := service.GetPsnByPatientId(id)
  4975. PsnNo = psn_info.PsnNo
  4976. PsnCertType = psn_info.PsnCertType
  4977. Certno = psn_info.Certno
  4978. PsnName = psn_info.PsnName
  4979. Gend = psn_info.Gend
  4980. Naty = psn_info.Naty
  4981. Brdy = psn_info.Brdy
  4982. Age = psn_info.Age
  4983. infoStr = psn_info.Insuinfo
  4984. idetinfoStr = psn_info.Idetinfo
  4985. infocode = 0
  4986. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4987. psn_info, _ := service.GetPsnByPatientId(id)
  4988. PsnNo = psn_info.PsnNo
  4989. PsnCertType = psn_info.PsnCertType
  4990. Certno = psn_info.Certno
  4991. PsnName = psn_info.PsnName
  4992. Gend = psn_info.Gend
  4993. Naty = psn_info.Naty
  4994. Brdy = psn_info.Brdy
  4995. Age = psn_info.Age
  4996. infoStr = psn_info.Insuinfo
  4997. idetinfoStr = psn_info.Idetinfo
  4998. infocode = 0
  4999. verify_number = psn_info.VerifyNumber
  5000. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5001. if id_card_type == 1 {
  5002. psn_info, _ := service.GetPsnByPatientId(id)
  5003. PsnNo = psn_info.PsnNo
  5004. PsnCertType = psn_info.PsnCertType
  5005. Certno = psn_info.Certno
  5006. PsnName = psn_info.PsnName
  5007. Gend = psn_info.Gend
  5008. Naty = psn_info.Naty
  5009. Brdy = psn_info.Brdy
  5010. Age = psn_info.Age
  5011. infoStr = psn_info.Insuinfo
  5012. idetinfoStr = psn_info.Idetinfo
  5013. infocode = 0
  5014. verify_number = psn_info.VerifyNumber
  5015. } else if id_card_type == 2 {
  5016. 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)
  5017. fmt.Println(errMsgLog)
  5018. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5019. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5020. utils.ErrorLog("解析失败:%v", err)
  5021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5022. return
  5023. }
  5024. PsnNo = res.Output.Baseinfo.PsnNo
  5025. PsnCertType = res.Output.Baseinfo.PsnCertType
  5026. Certno = res.Output.Baseinfo.Certno
  5027. PsnName = res.Output.Baseinfo.PsnName
  5028. Gend = res.Output.Baseinfo.Gend
  5029. Naty = res.Output.Baseinfo.Naty
  5030. Brdy = res.Output.Baseinfo.Brdy
  5031. Age = res.Output.Baseinfo.Age
  5032. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5033. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5034. infoStr = string(Iinfos)
  5035. idetinfoStr = string(Idetinfos)
  5036. infocode = res.Infcode
  5037. }
  5038. } else {
  5039. var result string
  5040. var requestLog string
  5041. if miConfig.UserOrgId == 10138 {
  5042. if id_card_type == 4 {
  5043. psn_info, _ := service.GetPsnByPatientId(id)
  5044. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5045. } else {
  5046. 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)
  5047. }
  5048. } else {
  5049. 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)
  5050. }
  5051. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5052. if miConfig.Code == "H15049901371" {
  5053. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5054. utils.ErrorLog("解析失败:%v", err)
  5055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5056. return
  5057. }
  5058. res.ErrMsg = res10265.ErrMsg
  5059. res.Output = res10265.Output
  5060. res.InfRefmsgid = res10265.InfRefmsgid
  5061. } else {
  5062. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5063. utils.ErrorLog("解析失败:%v", err)
  5064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5065. return
  5066. }
  5067. }
  5068. PsnNo = res.Output.Baseinfo.PsnNo
  5069. PsnCertType = res.Output.Baseinfo.PsnCertType
  5070. Certno = res.Output.Baseinfo.Certno
  5071. PsnName = res.Output.Baseinfo.PsnName
  5072. Gend = res.Output.Baseinfo.Gend
  5073. Naty = res.Output.Baseinfo.Naty
  5074. Brdy = res.Output.Baseinfo.Brdy
  5075. Age = res.Output.Baseinfo.Age
  5076. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5077. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5078. infoStr = string(Iinfos)
  5079. idetinfoStr = string(Idetinfos)
  5080. if miConfig.Code == "H15049901371" {
  5081. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5082. } else {
  5083. infocode = res.Infcode
  5084. }
  5085. }
  5086. if infocode == 0 {
  5087. his := models.VMHisPatient{
  5088. Name: name,
  5089. Gender: gender,
  5090. Birthday: birthUnix,
  5091. MedicalTreatmentType: medical_care,
  5092. IdType: certificates,
  5093. IdCardNo: id_card,
  5094. BalanceAccountsType: settlementValue,
  5095. SocialType: social_type,
  5096. MedicalInsuranceNumber: medical_insurance_card,
  5097. RegisterType: register_type,
  5098. RegisterCost: registration_fee,
  5099. TreatmentCost: medical_expenses,
  5100. Status: 1,
  5101. Ctime: time.Now().Unix(),
  5102. Mtime: time.Now().Unix(),
  5103. PsnNo: PsnNo,
  5104. PsnCertType: PsnCertType,
  5105. Certno: Certno,
  5106. PsnName: PsnName,
  5107. Gend: Gend,
  5108. Naty: Naty,
  5109. Brdy: Brdy,
  5110. Age: Age,
  5111. Iinfo: infoStr,
  5112. Idetinfo: idetinfoStr,
  5113. PatientId: patient.ID,
  5114. RecordDate: theTime.Unix(),
  5115. UserOrgId: adminInfo.CurrentOrgId,
  5116. AdminUserId: admin_user_id,
  5117. IsReturn: 1,
  5118. IdCardType: id_card_type,
  5119. Doctor: doctor,
  5120. Departments: department,
  5121. }
  5122. timestamp := time.Now().Unix()
  5123. tempTime := time.Unix(timestamp, 0)
  5124. timeFormat := tempTime.Format("20060102150405")
  5125. chrgBchno := rand.Intn(100000) + 10000
  5126. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5127. his.Number = ipt_otp_no
  5128. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5129. department, _ := service.GetDepartMentDetail(department)
  5130. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5131. IdCardNo := ""
  5132. if id_card_type == 1 {
  5133. // IdCardNo = medical_insurance_card
  5134. IdCardNo = patient.IdCardNo
  5135. } else {
  5136. IdCardNo = patient.IdCardNo
  5137. }
  5138. var rf []*ResultFive
  5139. json.Unmarshal([]byte(his.Iinfo), &rf)
  5140. var insutypes []*ResultFive
  5141. var insutype string
  5142. var insuplc_admdvs_temp string
  5143. var is390 int = 0
  5144. var is310 int = 0
  5145. for _, item := range rf {
  5146. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5147. insutypes = append(insutypes, item)
  5148. }
  5149. }
  5150. if len(insutypes) == 1 {
  5151. insutype = insutypes[0].Insutype
  5152. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5153. } else {
  5154. for _, i := range insutypes {
  5155. if i.Insutype == "390" {
  5156. is390 = 1
  5157. }
  5158. if i.Insutype == "310" {
  5159. is310 = 1
  5160. }
  5161. }
  5162. }
  5163. if is390 == 1 {
  5164. insutype = "390"
  5165. }
  5166. if is310 == 1 {
  5167. insutype = "310"
  5168. }
  5169. if len(insutypes) == 0 {
  5170. insutype = "310"
  5171. }
  5172. if len(insutypes) == 2 {
  5173. insutype = med_type
  5174. }
  5175. if len(med_type) > 0 {
  5176. insutype = med_type
  5177. }
  5178. var infocode int64
  5179. var resThree ResultThree
  5180. var resThree10265 ResultThree10265
  5181. if len(insuplc_admdvs) == 0 {
  5182. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5183. } else {
  5184. insuplc_admdvs_temp = insuplc_admdvs
  5185. }
  5186. if miConfig.MdtrtareaAdmvs == "421300" {
  5187. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5188. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5189. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5190. "&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
  5191. resp, requestErr := http.Get(api)
  5192. if requestErr != nil {
  5193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5194. return
  5195. }
  5196. body, ioErr := ioutil.ReadAll(resp.Body)
  5197. if ioErr != nil {
  5198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5200. return
  5201. }
  5202. var respJSON map[string]interface{}
  5203. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5206. return
  5207. }
  5208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5209. result, _ := json.Marshal(respJSON)
  5210. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5211. utils.ErrorLog("解析失败:%v", err)
  5212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5213. return
  5214. }
  5215. infocode = resThree.Infcode
  5216. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5217. psn_info, _ := service.GetPsnByPatientId(id)
  5218. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5219. var cert_no string
  5220. if id_card_type == 3 {
  5221. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5222. cert_no = IdCardNo
  5223. } else if id_card_type == 4 {
  5224. cert_no = IdCardNo
  5225. psn_info.VerifyNumber = psn_info.VerifyNumber
  5226. } else {
  5227. bas := strings.Split(psn_info.CardInfo, "|")
  5228. cert_no = bas[2]
  5229. }
  5230. var hisPrescription []*models.HisPrescription
  5231. for _, item := range rf {
  5232. if item.Insutype == insutype {
  5233. //insuplc_admdvs = item.InsuplcAdmdvs
  5234. his.InsuplcAdmdvs = insuplc_admdvs
  5235. }
  5236. }
  5237. his.Insutype = insutype
  5238. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5239. fmt.Println(res3101)
  5240. fmt.Println(res3101.Infcode)
  5241. if res3101.Infcode == "0" {
  5242. fmt.Println("33333333")
  5243. if len(res3101.Output.Result) > 0 {
  5244. fmt.Println("222222")
  5245. for _, item := range res3101.Output.Result {
  5246. if len(res3101.ErrMsg) == 0 {
  5247. res3101.ErrMsg = item.VolaCont
  5248. } else {
  5249. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5250. }
  5251. }
  5252. c.ServeSuccessJSON(map[string]interface{}{
  5253. "failed_code": -10,
  5254. "msg": res3101.ErrMsg,
  5255. })
  5256. return
  5257. } else {
  5258. fmt.Println("11111")
  5259. var api string
  5260. if miConfig.MdtrtareaAdmvs == "320921" {
  5261. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5262. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5263. "&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
  5264. } else {
  5265. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5266. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5267. "&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
  5268. }
  5269. resp, requestErr := http.Get(api)
  5270. if requestErr != nil {
  5271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5272. return
  5273. }
  5274. body, ioErr := ioutil.ReadAll(resp.Body)
  5275. if ioErr != nil {
  5276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5278. return
  5279. }
  5280. var respJSON map[string]interface{}
  5281. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5284. return
  5285. }
  5286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5287. result, _ := json.Marshal(respJSON)
  5288. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5289. utils.ErrorLog("解析失败:%v", err)
  5290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5291. return
  5292. }
  5293. resThree.ErrMsg = resThree10265.ErrMsg
  5294. resThree.Output = resThree10265.Output
  5295. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5296. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5297. }
  5298. } else if res3101.Infcode != "0" {
  5299. c.ServeSuccessJSON(map[string]interface{}{
  5300. "failed_code": -10,
  5301. "msg": res3101.ErrMsg,
  5302. })
  5303. return
  5304. }
  5305. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5306. psn_info, _ := service.GetPsnByPatientId(id)
  5307. var cert_no string
  5308. if id_card_type == 1 {
  5309. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5310. } else {
  5311. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5312. }
  5313. fmt.Println(cert_no)
  5314. 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)
  5315. saveLog(result, requestLog, "2201", "挂号")
  5316. if miConfig.Code == "H15049901371" {
  5317. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5318. utils.ErrorLog("解析失败:%v", err)
  5319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5320. return
  5321. }
  5322. resThree.ErrMsg = resThree10265.ErrMsg
  5323. resThree.Output = resThree10265.Output
  5324. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5325. } else {
  5326. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5327. utils.ErrorLog("解析失败:%v", err)
  5328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5329. return
  5330. }
  5331. }
  5332. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5333. } else {
  5334. psn_info, _ := service.GetPsnByPatientId(id)
  5335. 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)
  5336. saveLog(result, requestLog, "2201A", "挂号")
  5337. if miConfig.Code == "H15049901371" {
  5338. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5339. utils.ErrorLog("解析失败:%v", err)
  5340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5341. return
  5342. }
  5343. resThree.ErrMsg = resThree10265.ErrMsg
  5344. resThree.Output = resThree10265.Output
  5345. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5346. } else {
  5347. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5348. utils.ErrorLog("解析失败:%v", err)
  5349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5350. return
  5351. }
  5352. }
  5353. if miConfig.Code == "H15049901371" {
  5354. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5355. } else {
  5356. infocode = resThree.Infcode
  5357. }
  5358. }
  5359. if infocode != 0 {
  5360. adminUser := c.GetAdminUserInfo()
  5361. errlog := &models.HisOrderError{
  5362. UserOrgId: adminUser.CurrentOrgId,
  5363. Ctime: time.Now().Unix(),
  5364. Mtime: time.Now().Unix(),
  5365. ErrMsg: resThree.ErrMsg,
  5366. Status: 1,
  5367. PatientId: id,
  5368. RecordTime: recordDateTime,
  5369. Stage: 2,
  5370. }
  5371. service.CreateErrMsgLog(errlog)
  5372. c.ServeSuccessJSON(map[string]interface{}{
  5373. "failed_code": -10,
  5374. "msg": resThree.ErrMsg,
  5375. })
  5376. return
  5377. }
  5378. his.Number = resThree.Output.Data.MdtrtID
  5379. his.PsnNo = resThree.Output.Data.PsnNo
  5380. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5381. his.IdCardNo = patient.IdCardNo
  5382. his.PhoneNumber = patient.Phone
  5383. his.UserOrgId = adminInfo.CurrentOrgId
  5384. his.Insutype = insutype
  5385. his.Ctime = time.Now().Unix()
  5386. his.Mtime = time.Now().Unix()
  5387. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5388. his.Status = 1
  5389. service.UpdateHisPatientStatus(&his)
  5390. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5391. c.ServeSuccessJSON(map[string]interface{}{
  5392. "his_info": his,
  5393. })
  5394. } else {
  5395. adminUser := c.GetAdminUserInfo()
  5396. errlog := &models.HisOrderError{
  5397. UserOrgId: adminUser.CurrentOrgId,
  5398. Ctime: time.Now().Unix(),
  5399. Mtime: time.Now().Unix(),
  5400. ErrMsg: res.ErrMsg,
  5401. Status: 1,
  5402. PatientId: id,
  5403. RecordTime: recordDateTime,
  5404. Stage: 1,
  5405. }
  5406. service.CreateErrMsgLog(errlog)
  5407. c.ServeSuccessJSON(map[string]interface{}{
  5408. "failed_code": -10,
  5409. "msg": res.ErrMsg,
  5410. })
  5411. return
  5412. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5413. }
  5414. }
  5415. }
  5416. //上传明细----预结算----确认订单
  5417. func (c *HisApiController) GetUploadInfo() {
  5418. id, _ := c.GetInt64("id")
  5419. record_time := c.GetString("record_time")
  5420. his_patient_id, _ := c.GetInt64("his_patient_id")
  5421. order_id, _ := c.GetInt64("order_id")
  5422. pay_way, _ := c.GetInt64("pay_way")
  5423. pay_price, _ := c.GetFloat("pay_price")
  5424. pay_card_no := c.GetString("pay_card_no")
  5425. token := c.GetString("token")
  5426. discount_price, _ := c.GetFloat("discount_price")
  5427. preferential_price, _ := c.GetFloat("preferential_price")
  5428. reality_price, _ := c.GetFloat("reality_price")
  5429. found_price, _ := c.GetFloat("found_price")
  5430. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5431. private_price, _ := c.GetFloat("private_price")
  5432. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5433. admin_user_id, _ := c.GetInt64("admin_user_id")
  5434. fapiao_code := c.GetString("fapiao_code")
  5435. fapiao_number := c.GetString("fapiao_number")
  5436. diagnosis_id := c.GetString("diagnosis")
  5437. sick_type, _ := c.GetInt64("sick_type")
  5438. reg_type, _ := c.GetInt64("p_type")
  5439. begin_time := c.GetString("begin_time")
  5440. id_str := c.GetString("ids")
  5441. ids_arr := strings.Split(id_str, ",")
  5442. timeLayout := "2006-01-02"
  5443. loc, _ := time.LoadLocation("Local")
  5444. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5445. if err != nil {
  5446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5447. return
  5448. }
  5449. recordDateTime := theTime.Unix()
  5450. adminUser := c.GetAdminUserInfo()
  5451. var tempOrder models.HisOrder
  5452. tempOrder, _ = service.GetHisOrderByID(order_id)
  5453. var prescriptions []*models.HisPrescription
  5454. var start_time int64
  5455. var end_time int64
  5456. //押金模块
  5457. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5458. tmp_decimal := c.GetString("tmp_decimal")
  5459. var decimal float64 //本次使用的押金
  5460. var errmsg error
  5461. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5462. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5463. return
  5464. }
  5465. if len(tmp_decimal) > 0 {
  5466. if tmp_decimal[0] == 45 {
  5467. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5468. return
  5469. }
  5470. }
  5471. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5472. fmt.Println(errs)
  5473. decimal = tt
  5474. //if adminUser.CurrentOrgId == 10106{
  5475. // if len(fapiao_code) == 0{
  5476. // fapiao_code = "144072080589"
  5477. // }
  5478. // if len(fapiao_number) == 0{
  5479. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5480. // if order.ID == 0{
  5481. // fapiao_number = "00001520"
  5482. // }else{
  5483. // //fapiao_code = "00001520"
  5484. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5485. // var zero string
  5486. // if fpNumber >= 1000{
  5487. // zero = "0000" + strconv.Itoa(fpNumber)
  5488. // }else if fpNumber >= 10000{
  5489. // zero = "000" + strconv.Itoa(fpNumber)
  5490. // } else if fpNumber >= 100000{
  5491. // zero = "00" + strconv.Itoa(fpNumber)
  5492. // } else if fpNumber >= 1000000{
  5493. // zero = "0" + strconv.Itoa(fpNumber)
  5494. // }else {
  5495. // zero = strconv.Itoa(fpNumber)
  5496. // }
  5497. // fapiao_number = zero
  5498. // }
  5499. // }
  5500. //}
  5501. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5502. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5503. var patientPrescription models.HisPrescriptionInfo
  5504. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5505. if patientPrescription.ID == 0 {
  5506. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5507. }
  5508. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5509. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5510. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5511. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5512. var config []*models.HisXtDiagnoseConfig
  5513. for _, item := range diagnosis_ids {
  5514. id, _ := strconv.ParseInt(item, 10, 64)
  5515. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5516. config = append(config, &diagnosisConfig)
  5517. }
  5518. sickConfig, _ := service.FindSickById(sick_type)
  5519. //if tempOrder.ID == 0 {
  5520. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5521. //}
  5522. if tempOrder.ID == 0 {
  5523. var result string
  5524. var requestLog string
  5525. var res2 ResultSix
  5526. var ressix10265 ResultSix10265
  5527. if miConfig.MdtrtareaAdmvs == "421300" {
  5528. data := make(map[string]interface{})
  5529. client := &http.Client{}
  5530. data["psn_no"] = his.PsnNo
  5531. data["mdtrt_id"] = his.Number
  5532. data["opter"] = roles.UserName
  5533. data["org_name"] = miConfig.OrgName
  5534. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5535. data["doctor_id"] = doctor_info.DoctorNumber
  5536. data["doctor_name"] = doctor_info.UserName
  5537. data["department"] = department.Name
  5538. data["fixmedins_code"] = miConfig.Code
  5539. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5540. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5541. data["secret_key"] = miConfig.SecretKey
  5542. data["sick_code"] = sickConfig.CountryCode
  5543. data["sick_name"] = sickConfig.ClassName
  5544. data["dept"] = strconv.FormatInt(department.ID, 10)
  5545. data["config"] = config
  5546. data["begin_time"] = begin_time
  5547. bytesData, _ := json.Marshal(data)
  5548. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5549. resp, _ := client.Do(req)
  5550. defer resp.Body.Close()
  5551. body, ioErr := ioutil.ReadAll(resp.Body)
  5552. if ioErr != nil {
  5553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5555. return
  5556. }
  5557. var respJSON map[string]interface{}
  5558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5561. return
  5562. }
  5563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5564. userJSONBytes, _ := json.Marshal(respJSON)
  5565. fmt.Println("log")
  5566. fmt.Println(string(userJSONBytes))
  5567. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5568. utils.ErrorLog("解析失败:%v", err)
  5569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5570. return
  5571. }
  5572. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5573. //江苏地区国家医保医疗类别
  5574. //职工透析:医疗类别选特殊情况门诊9933
  5575. //居民血透门慢: 医疗类别选门诊慢病1402
  5576. //var med_type string
  5577. //if his.Insutype == "310" {
  5578. // if reg_type == 14 {
  5579. // med_type = "9933"
  5580. // } else if reg_type == 11 {
  5581. // med_type = "11"
  5582. //
  5583. // }
  5584. //} else if his.Insutype == "390" {
  5585. // if reg_type == 14 {
  5586. // med_type = "1402"
  5587. // } else if reg_type == 11 {
  5588. // med_type = "11"
  5589. // }
  5590. //}
  5591. data := make(map[string]interface{})
  5592. client := &http.Client{}
  5593. data["psn_no"] = his.PsnNo
  5594. data["mdtrt_id"] = his.Number
  5595. data["doctor"] = roles.UserName
  5596. data["department"] = department.Name
  5597. data["org_name"] = miConfig.OrgName
  5598. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5599. data["doctor_id"] = doctor_info.DoctorNumber
  5600. data["new_doctor_name"] = doctor_info.UserName
  5601. data["fixmedins_code"] = miConfig.Code
  5602. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5603. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5604. data["secret_key"] = miConfig.SecretKey
  5605. data["sick_code"] = sickConfig.CountryCode
  5606. data["sick_name"] = sickConfig.ClassName
  5607. data["url"] = miConfig.Url
  5608. data["ak"] = miConfig.AccessKey
  5609. data["begin_time"] = begin_time
  5610. data["cainfo"] = miConfig.Cainfo
  5611. data["dept"] = strconv.FormatInt(department.ID, 10)
  5612. data["config"] = config
  5613. bytesData, _ := json.Marshal(data)
  5614. var req *http.Request
  5615. if miConfig.MdtrtareaAdmvs == "320921" {
  5616. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5617. //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 +
  5618. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5619. } else {
  5620. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5621. }
  5622. resp, _ := client.Do(req)
  5623. defer resp.Body.Close()
  5624. body, ioErr := ioutil.ReadAll(resp.Body)
  5625. if ioErr != nil {
  5626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5628. return
  5629. }
  5630. var respJSON map[string]interface{}
  5631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5634. return
  5635. }
  5636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5637. userJSONBytes, _ := json.Marshal(respJSON)
  5638. fmt.Println("log")
  5639. fmt.Println(string(userJSONBytes))
  5640. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5641. utils.ErrorLog("解析失败:%v", err)
  5642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5643. return
  5644. }
  5645. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5646. res2.Output = ressix10265.Output
  5647. res2.ErrMsg = ressix10265.ErrMsg
  5648. res2.Cainfo = ressix10265.Cainfo
  5649. res2.WarnMsg = ressix10265.WarnMsg
  5650. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5651. res2.Infcode = infocode
  5652. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5653. 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)
  5654. saveLog(result, requestLog, "2203", "上传就诊信息")
  5655. var respJSON2 map[string]interface{}
  5656. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5659. return
  5660. }
  5661. userJSONBytes2, _ := json.Marshal(respJSON2)
  5662. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5663. utils.ErrorLog("解析失败:%v", err)
  5664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5665. return
  5666. }
  5667. } else {
  5668. if miConfig.MdtrtareaAdmvs == "440781" { //
  5669. 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)
  5670. } else {
  5671. if miConfig.Code == "H15049901371" {
  5672. //赤峰地区国家医保医疗类别
  5673. //职工透析:医疗类别选特殊情况门诊990502
  5674. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5675. var med_type string
  5676. if his.Insutype == "390" {
  5677. if reg_type == 14 {
  5678. med_type = "9933"
  5679. } else if reg_type == 11 {
  5680. med_type = "11"
  5681. }
  5682. } else if his.Insutype == "310" {
  5683. if reg_type == 14 {
  5684. med_type = "990502"
  5685. } else if reg_type == 11 {
  5686. med_type = "11"
  5687. }
  5688. }
  5689. 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)
  5690. } else {
  5691. 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)
  5692. }
  5693. }
  5694. saveLog(result, requestLog, "2203", "上传就诊信息")
  5695. var respJSON2 map[string]interface{}
  5696. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5699. return
  5700. }
  5701. userJSONBytes2, _ := json.Marshal(respJSON2)
  5702. if miConfig.Code == "H15049901371" {
  5703. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5704. utils.ErrorLog("解析失败:%v", err)
  5705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5706. return
  5707. }
  5708. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5709. res2.Output = ressix10265.Output
  5710. res2.ErrMsg = ressix10265.ErrMsg
  5711. res2.Cainfo = ressix10265.Cainfo
  5712. res2.WarnMsg = ressix10265.WarnMsg
  5713. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5714. res2.Infcode = infocode
  5715. } else {
  5716. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5717. utils.ErrorLog("解析失败:%v", err)
  5718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5719. return
  5720. }
  5721. }
  5722. }
  5723. if res2.Infcode != 0 {
  5724. adminUser := c.GetAdminUserInfo()
  5725. errlog := &models.HisOrderError{
  5726. UserOrgId: adminUser.CurrentOrgId,
  5727. Ctime: time.Now().Unix(),
  5728. Mtime: time.Now().Unix(),
  5729. ErrMsg: res2.ErrMsg,
  5730. Status: 1,
  5731. PatientId: id,
  5732. RecordTime: recordDateTime,
  5733. Stage: 3,
  5734. }
  5735. service.CreateErrMsgLog(errlog)
  5736. c.ServeSuccessJSON(map[string]interface{}{
  5737. "failed_code": -10,
  5738. "msg": res2.ErrMsg,
  5739. })
  5740. return
  5741. } else {
  5742. his.Diagnosis = diagnosis_id
  5743. his.SickType = sickConfig.ID
  5744. //var p_type int64
  5745. //if reg_type == 1111 || reg_type == 1112 {
  5746. // p_type = 11
  5747. //
  5748. //}
  5749. his.PType = fmt.Sprintf("%d", reg_type)
  5750. service.UpdateHisPatientThree(&his)
  5751. data := make(map[string]interface{})
  5752. if settle_accounts_type == 1 { //日结
  5753. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5754. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5755. } else {
  5756. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5757. }
  5758. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5759. data["pre"] = prescriptions
  5760. } else { //月结
  5761. start_time_str := c.GetString("start_time")
  5762. end_time_str := c.GetString("end_time")
  5763. timeLayout := "2006-01-02"
  5764. loc, _ := time.LoadLocation("Local")
  5765. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5766. if err != nil {
  5767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5768. return
  5769. }
  5770. recordStartTime := theStartTime.Unix()
  5771. start_time = recordStartTime
  5772. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5773. if err != nil {
  5774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5775. return
  5776. }
  5777. recordEndTime := theEndTime.Unix()
  5778. end_time = recordEndTime
  5779. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5780. data["pre"] = prescriptions
  5781. }
  5782. timestamp := time.Now().Unix()
  5783. tempTime := time.Unix(timestamp, 0)
  5784. timeFormat := tempTime.Format("20060102150405")
  5785. chrgBchno := rand.Intn(100000) + 10000
  5786. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5787. strconv.FormatInt(his.PatientId, 10)
  5788. client := &http.Client{}
  5789. data["psn_no"] = his.PsnNo
  5790. data["mdtrt_id"] = his.Number
  5791. data["chrg_bchno"] = chrg_bchno
  5792. data["org_name"] = miConfig.OrgName
  5793. data["doctor"] = doctor_info.UserName
  5794. data["doctor_id"] = doctor_info.DoctorNumber
  5795. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5796. data["fixmedins_code"] = miConfig.Code
  5797. data["opter"] = roles.UserName
  5798. data["dept_code"] = department.Number
  5799. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5800. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5801. data["secret_key"] = miConfig.SecretKey
  5802. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5803. data["url"] = miConfig.Url
  5804. data["ak"] = miConfig.AccessKey
  5805. data["new_doctor_name"] = patientPrescription.Doctor
  5806. data["diag_code"] = sickConfig.CountryCode
  5807. data["cainfo"] = miConfig.Cainfo
  5808. var ids []int64
  5809. for _, item := range prescriptions {
  5810. ids = append(ids, item.ID)
  5811. }
  5812. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5813. if config.IsOpen == 1 { //对接了医保,走医保流程
  5814. var res ResultFour
  5815. var resFour10265 ResultFour10265
  5816. if miConfig.MdtrtareaAdmvs == "421300" {
  5817. bytesData, _ := json.Marshal(data)
  5818. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5819. resp, _ := client.Do(req)
  5820. defer resp.Body.Close()
  5821. body, ioErr := ioutil.ReadAll(resp.Body)
  5822. if ioErr != nil {
  5823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5825. return
  5826. }
  5827. var respJSON map[string]interface{}
  5828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5831. return
  5832. }
  5833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5834. userJSONBytes, _ := json.Marshal(respJSON)
  5835. fmt.Println("log")
  5836. fmt.Println(string(userJSONBytes))
  5837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5838. utils.ErrorLog("解析失败:%v", err)
  5839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5840. return
  5841. }
  5842. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5843. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5844. if result3101.Infcode == "0" {
  5845. if len(result3101.Output.Result) > 0 {
  5846. var errMsgs []string
  5847. for _, item := range result3101.Output.Result {
  5848. errMsgs = append(errMsgs, item.VolaCont)
  5849. }
  5850. c.ServeSuccessJSON(map[string]interface{}{
  5851. "failed_code": -10,
  5852. "msg": errMsgs,
  5853. })
  5854. return
  5855. }
  5856. }
  5857. bytesData, _ := json.Marshal(data)
  5858. var req *http.Request
  5859. if miConfig.MdtrtareaAdmvs == "320921" {
  5860. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5861. } else {
  5862. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5863. }
  5864. resp, _ := client.Do(req)
  5865. defer resp.Body.Close()
  5866. body, ioErr := ioutil.ReadAll(resp.Body)
  5867. if ioErr != nil {
  5868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5870. return
  5871. }
  5872. var respJSON map[string]interface{}
  5873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5876. return
  5877. }
  5878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5879. userJSONBytes, _ := json.Marshal(respJSON)
  5880. fmt.Println("log")
  5881. fmt.Println(string(userJSONBytes))
  5882. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5883. utils.ErrorLog("解析失败:%v", err)
  5884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5885. return
  5886. }
  5887. res.InfRefmsgid = resFour10265.InfRefmsgid
  5888. res.Output = resFour10265.Output
  5889. res.ErrMsg = resFour10265.ErrMsg
  5890. res.Cainfo = resFour10265.Cainfo
  5891. res.WarnMsg = resFour10265.WarnMsg
  5892. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5893. res.Infcode = infocode
  5894. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5895. 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)
  5896. var dat map[string]interface{}
  5897. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5898. fmt.Println(dat)
  5899. } else {
  5900. fmt.Println(err)
  5901. }
  5902. saveLog(result, request_log, "2204", "上传费用明细")
  5903. userJSONBytes, _ := json.Marshal(dat)
  5904. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5905. utils.ErrorLog("解析失败:%v", err)
  5906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5907. return
  5908. }
  5909. res.InfRefmsgid = resFour10265.InfRefmsgid
  5910. res.Output = resFour10265.Output
  5911. res.ErrMsg = resFour10265.ErrMsg
  5912. res.Cainfo = resFour10265.Cainfo
  5913. res.WarnMsg = resFour10265.WarnMsg
  5914. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5915. res.Infcode = infocode
  5916. } else {
  5917. if miConfig.Code == "H15049901371" {
  5918. 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)
  5919. var dat map[string]interface{}
  5920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5921. fmt.Println(dat)
  5922. } else {
  5923. fmt.Println(err)
  5924. }
  5925. saveLog(result, request_log, "2204", "上传费用明细")
  5926. userJSONBytes, _ := json.Marshal(dat)
  5927. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5928. utils.ErrorLog("解析失败:%v", err)
  5929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5930. return
  5931. }
  5932. res.InfRefmsgid = resFour10265.InfRefmsgid
  5933. res.Output = resFour10265.Output
  5934. res.ErrMsg = resFour10265.ErrMsg
  5935. res.Cainfo = resFour10265.Cainfo
  5936. res.WarnMsg = resFour10265.WarnMsg
  5937. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5938. res.Infcode = infocode
  5939. } else {
  5940. 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)
  5941. var dat map[string]interface{}
  5942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5943. fmt.Println(dat)
  5944. } else {
  5945. fmt.Println(err)
  5946. }
  5947. saveLog(result, request_log, "2204", "上传费用明细")
  5948. userJSONBytes, _ := json.Marshal(dat)
  5949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5950. utils.ErrorLog("解析失败:%v", err)
  5951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5952. return
  5953. }
  5954. }
  5955. }
  5956. if res.Infcode == 0 {
  5957. order := &models.HisOrder{
  5958. UserOrgId: adminUser.CurrentOrgId,
  5959. HisPatientId: his.ID,
  5960. PatientId: his.PatientId,
  5961. SettleAccountsDate: recordDateTime,
  5962. MdtrtId: his.Number,
  5963. PsnNo: his.PsnNo,
  5964. MedType: strconv.FormatInt(reg_type, 10),
  5965. Ctime: time.Now().Unix(),
  5966. Mtime: time.Now().Unix(),
  5967. Status: 1,
  5968. Number: chrg_bchno,
  5969. Infcode: res.Infcode,
  5970. WarnMsg: res.WarnMsg,
  5971. Cainfo: res.Cainfo,
  5972. ErrMsg: res.ErrMsg,
  5973. RespondTime: res.RefmsgTime,
  5974. InfRefmsgid: res.InfRefmsgid,
  5975. OrderStatus: 1,
  5976. PayWay: pay_way,
  5977. PayPrice: pay_price,
  5978. PayCardNo: pay_card_no,
  5979. DiscountPrice: discount_price,
  5980. PreferentialPrice: preferential_price,
  5981. RealityPrice: reality_price,
  5982. FoundPrice: found_price,
  5983. MedicalInsurancePrice: medical_insurance_price,
  5984. PrivatePrice: private_price,
  5985. IsMedicineInsurance: 1,
  5986. SettleType: settle_accounts_type,
  5987. SettleStartTime: start_time,
  5988. SettleEndTime: end_time,
  5989. Creator: roles.AdminUserId,
  5990. Modify: roles.AdminUserId,
  5991. FaPiaoNumber: fapiao_number,
  5992. FaPiaoCode: fapiao_code,
  5993. PType: 2,
  5994. Diagnosis: diagnosis_id,
  5995. }
  5996. err = service.CreateOrder(order)
  5997. if err != nil {
  5998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5999. return
  6000. }
  6001. for _, item := range res.Output.Result {
  6002. temp := strings.Split(item.FeedetlSn, "-")
  6003. var advice_id int64 = 0
  6004. var project_id int64 = 0
  6005. var types int64 = 0
  6006. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6007. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6008. if temp[1] == "1" {
  6009. advice_id = id
  6010. project_id = 0
  6011. } else if temp[1] == "2" {
  6012. advice_id = 0
  6013. project_id = id
  6014. }
  6015. info := &models.HisOrderInfo{
  6016. OrderNumber: order.Number,
  6017. FeedetlSn: item.FeedetlSn,
  6018. UploadDate: time.Now().Unix(),
  6019. AdviceId: advice_id,
  6020. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6021. Cnt: item.Cnt,
  6022. Pric: float64(item.Pric),
  6023. PatientId: his.PatientId,
  6024. PricUplmtAmt: item.PricUplmtAmt,
  6025. SelfpayProp: item.SelfpayProp,
  6026. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6027. OverlmtAmt: item.OverlmtAmt,
  6028. PreselfpayAmt: item.PreselfpayAmt,
  6029. BasMednFlag: item.BasMednFlag,
  6030. MedChrgitmType: item.MedChrgitmType,
  6031. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6032. Status: 1,
  6033. Memo: item.Memo,
  6034. Mtime: time.Now().Unix(),
  6035. InscpScpAmt: item.InscpScpAmt,
  6036. DrtReimFlag: item.DrtReimFlag,
  6037. Ctime: time.Now().Unix(),
  6038. ListSpItemFlag: item.ListSpItemFlag,
  6039. ChldMedcFlag: item.ChldMedcFlag,
  6040. LmtUsedFlag: item.LmtUsedFlag,
  6041. ChrgitmLv: item.ChrgitmLv,
  6042. UserOrgId: adminUser.CurrentOrgId,
  6043. HisPatientId: his.ID,
  6044. OrderId: order.ID,
  6045. ProjectId: project_id,
  6046. Type: types,
  6047. }
  6048. service.CreateOrderInfo(info)
  6049. }
  6050. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6051. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6052. var total float64
  6053. for _, item := range prescriptions {
  6054. if item.Type == 1 { //药品
  6055. for _, subItem := range item.HisDoctorAdviceInfo {
  6056. total = total + (subItem.Price * subItem.PrescribingNumber)
  6057. }
  6058. }
  6059. if item.Type == 2 { //项目
  6060. for _, subItem := range item.HisPrescriptionProject {
  6061. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6062. total = total + (subItem.Price * cnt)
  6063. }
  6064. }
  6065. }
  6066. for _, item := range prescriptions {
  6067. for _, subItem := range item.HisAdditionalCharge {
  6068. total = total + (subItem.Price * float64(subItem.Count))
  6069. }
  6070. }
  6071. var allTotal string
  6072. if adminUser.CurrentOrgId == 9919 {
  6073. allTotal = fmt.Sprintf("%.4f", total)
  6074. } else {
  6075. allTotal = fmt.Sprintf("%.4f", total)
  6076. }
  6077. if res.Infcode == 0 {
  6078. var rf []*ResultFive
  6079. json.Unmarshal([]byte(his.Iinfo), &rf)
  6080. chrg_bchno := chrg_bchno
  6081. cert_no := his.Certno
  6082. var insutypes []string
  6083. var insutype string
  6084. var is390 int = 0
  6085. var is310 int = 0
  6086. for _, item := range rf {
  6087. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6088. insutypes = append(insutypes, item.Insutype)
  6089. }
  6090. }
  6091. if len(insutypes) == 1 {
  6092. insutype = insutypes[0]
  6093. } else {
  6094. for _, i := range insutypes {
  6095. if i == "390" {
  6096. is390 = 1
  6097. }
  6098. if i == "310" {
  6099. is310 = 1
  6100. }
  6101. }
  6102. }
  6103. if is390 == 1 {
  6104. insutype = "390"
  6105. }
  6106. if is310 == 1 {
  6107. insutype = "310"
  6108. }
  6109. if len(insutypes) == 0 {
  6110. insutype = "310"
  6111. }
  6112. if len(insutypes) == 2 {
  6113. insutype = strconv.FormatInt(his.SocialType, 10)
  6114. }
  6115. insutype = strconv.FormatInt(his.SocialType, 10)
  6116. //insutype = "390"
  6117. if his.IdCardType == 1 {
  6118. // cert_no = his.MedicalInsuranceNumber
  6119. cert_no = his.Certno
  6120. } else {
  6121. cert_no = his.Certno
  6122. }
  6123. var res ResultSeven
  6124. var resSeven10265 ResultSeven10265
  6125. var src_resquest string
  6126. var result2 string
  6127. var acct_used_flag string
  6128. fmt.Println("pay_way")
  6129. fmt.Println(pay_way)
  6130. fmt.Println("pay_way")
  6131. if pay_way == 4 {
  6132. acct_used_flag = "1"
  6133. } else {
  6134. acct_used_flag = "0"
  6135. }
  6136. if miConfig.MdtrtareaAdmvs == "421300" {
  6137. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6138. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6139. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6140. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6141. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6142. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6143. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6144. resp, requestErr := http.Get(api)
  6145. if requestErr != nil {
  6146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6147. return
  6148. }
  6149. body, ioErr := ioutil.ReadAll(resp.Body)
  6150. if ioErr != nil {
  6151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6153. return
  6154. }
  6155. var respJSON map[string]interface{}
  6156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6159. return
  6160. }
  6161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6162. result, _ := json.Marshal(respJSON)
  6163. if miConfig.Code == "H15049901371" {
  6164. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6165. utils.ErrorLog("解析失败:%v", err)
  6166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6167. return
  6168. }
  6169. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6170. res.Output = resSeven10265.Output
  6171. res.ErrMsg = resSeven10265.ErrMsg
  6172. res.Cainfo = resSeven10265.Cainfo
  6173. res.WarnMsg = resSeven10265.WarnMsg
  6174. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6175. res.Infcode = infocode
  6176. } else {
  6177. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6178. utils.ErrorLog("解析失败:%v", err)
  6179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6180. return
  6181. }
  6182. }
  6183. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6184. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  6185. if result3101.Infcode == "0" {
  6186. if len(result3101.Output.Result) > 0 {
  6187. var errMsgs []string
  6188. for _, item := range result3101.Output.Result {
  6189. errMsgs = append(errMsgs, item.VolaCont)
  6190. }
  6191. c.ServeSuccessJSON(map[string]interface{}{
  6192. "failed_code": -10,
  6193. "msg": errMsgs,
  6194. })
  6195. return
  6196. } else {
  6197. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6198. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6199. bas := strings.Split(psn_info.CardInfo, "|")
  6200. if his.IdCardType == 1 {
  6201. cert_no = bas[2]
  6202. } else if his.IdCardType == 3 {
  6203. cert_no = his.Certno
  6204. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6205. } else if his.IdCardType == 4 {
  6206. cert_no = his.Certno
  6207. psn_info.VerifyNumber = token
  6208. }
  6209. var api string
  6210. if miConfig.MdtrtareaAdmvs == "320921" {
  6211. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6212. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6213. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6214. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6215. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6216. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6217. "&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
  6218. } else {
  6219. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6220. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6221. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6223. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6224. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6225. "&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
  6226. }
  6227. resp, requestErr := http.Get(api)
  6228. if requestErr != nil {
  6229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6230. return
  6231. }
  6232. body, ioErr := ioutil.ReadAll(resp.Body)
  6233. if ioErr != nil {
  6234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6236. return
  6237. }
  6238. var respJSON map[string]interface{}
  6239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6242. return
  6243. }
  6244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6245. result, _ := json.Marshal(respJSON)
  6246. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6247. utils.ErrorLog("解析失败:%v", err)
  6248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6249. return
  6250. }
  6251. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6252. res.Output = resSeven10265.Output
  6253. res.ErrMsg = resSeven10265.ErrMsg
  6254. res.Cainfo = resSeven10265.Cainfo
  6255. res.WarnMsg = resSeven10265.WarnMsg
  6256. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6257. res.Infcode = infocode
  6258. }
  6259. }
  6260. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6261. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6262. var cert_no string
  6263. if his.IdCardType == 1 {
  6264. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6265. }
  6266. fmt.Println(cert_no)
  6267. 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)
  6268. //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)
  6269. var dat map[string]interface{}
  6270. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6271. fmt.Println(dat)
  6272. } else {
  6273. fmt.Println(err)
  6274. }
  6275. saveLog(result2, src_resquest, "2207", "结算")
  6276. userJSONBytes, _ := json.Marshal(dat)
  6277. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6278. utils.ErrorLog("解析失败:%v", err)
  6279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6280. return
  6281. }
  6282. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6283. res.Output = resSeven10265.Output
  6284. res.ErrMsg = resSeven10265.ErrMsg
  6285. res.Cainfo = resSeven10265.Cainfo
  6286. res.WarnMsg = resSeven10265.WarnMsg
  6287. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6288. res.Infcode = infocode
  6289. } else {
  6290. if miConfig.Code == "H15049901371" {
  6291. //赤峰地区国家医保医疗类别
  6292. //职工透析:医疗类别选特殊情况门诊990502
  6293. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6294. var med_type string
  6295. if his.Insutype == "390" {
  6296. if reg_type == 14 {
  6297. med_type = "9933"
  6298. } else if reg_type == 11 {
  6299. med_type = "11"
  6300. }
  6301. } else if his.Insutype == "310" {
  6302. if reg_type == 14 {
  6303. med_type = "990502"
  6304. } else if reg_type == 11 {
  6305. med_type = "11"
  6306. }
  6307. }
  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, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  6309. } else {
  6310. 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)
  6311. }
  6312. //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)
  6313. var dat map[string]interface{}
  6314. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6315. fmt.Println(dat)
  6316. } else {
  6317. fmt.Println(err)
  6318. }
  6319. saveLog(result2, src_resquest, "2207", "结算")
  6320. userJSONBytes, _ := json.Marshal(dat)
  6321. if miConfig.Code == "H15049901371" {
  6322. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6323. utils.ErrorLog("解析失败:%v", err)
  6324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6325. return
  6326. }
  6327. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6328. res.Output = resSeven10265.Output
  6329. res.ErrMsg = resSeven10265.ErrMsg
  6330. res.Cainfo = resSeven10265.Cainfo
  6331. res.WarnMsg = resSeven10265.WarnMsg
  6332. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6333. res.Infcode = infocode
  6334. } else {
  6335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6336. utils.ErrorLog("解析失败:%v", err)
  6337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6338. return
  6339. }
  6340. }
  6341. }
  6342. if res.Infcode != 0 {
  6343. errlog := &models.HisOrderError{
  6344. UserOrgId: adminUser.CurrentOrgId,
  6345. Ctime: time.Now().Unix(),
  6346. Mtime: time.Now().Unix(),
  6347. Number: chrg_bchno,
  6348. ErrMsg: res.ErrMsg,
  6349. Status: 1,
  6350. PatientId: id,
  6351. RecordTime: recordDateTime,
  6352. Stage: 6,
  6353. }
  6354. service.CreateErrMsgLog(errlog)
  6355. c.ServeSuccessJSON(map[string]interface{}{
  6356. "failed_code": -10,
  6357. "msg": res.ErrMsg,
  6358. })
  6359. return
  6360. } else {
  6361. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6362. order.OrderStatus = 2
  6363. order.Status = 1
  6364. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6365. order.SetlId = res.Output.Setlinfo.SetlID
  6366. order.PsnNo = res.Output.Setlinfo.PsnNo
  6367. order.PsnName = res.Output.Setlinfo.PsnName
  6368. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6369. order.Certno = res.Output.Setlinfo.Certno
  6370. order.Gend = res.Output.Setlinfo.Gend
  6371. order.Naty = res.Output.Setlinfo.Naty
  6372. order.Age = res.Output.Setlinfo.Age
  6373. order.Insutype = res.Output.Setlinfo.Insutype
  6374. order.PsnType = res.Output.Setlinfo.PsnType
  6375. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6376. order.SetlTime = res.Output.Setlinfo.SetlTime
  6377. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6378. if res.Output.Setlinfo.MedType == "140101" {
  6379. order.MedType = "14"
  6380. } else {
  6381. order.MedType = res.Output.Setlinfo.MedType
  6382. }
  6383. if reg_type == 1112 {
  6384. order.MedType = "1112"
  6385. }
  6386. if reg_type == 1111 {
  6387. order.MedType = "1111"
  6388. }
  6389. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6390. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6391. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6392. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6393. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6394. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6395. order.HifpPay = res.Output.Setlinfo.HifpPay
  6396. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6397. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6398. order.HifesPay = res.Output.Setlinfo.HifesPay
  6399. order.HifobPay = res.Output.Setlinfo.HifobPay
  6400. order.MafPay = res.Output.Setlinfo.MafPay
  6401. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6402. order.OthPay = res.Output.Setlinfo.OthPay
  6403. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6404. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6405. order.AcctPay = res.Output.Setlinfo.AcctPay
  6406. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6407. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6408. order.Balc = res.Output.Setlinfo.Balc
  6409. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6410. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6411. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6412. order.ClrType = res.Output.Setlinfo.ClrType
  6413. order.ClrWay = res.Output.Setlinfo.ClrWay
  6414. order.Creator = order.Creator
  6415. order.Modify = roles.AdminUserId
  6416. order.RequestLog = src_resquest
  6417. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6418. detailStr := string(setlDetail)
  6419. order.SetlDetail = detailStr
  6420. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6421. err = service.UpDateOrder(order)
  6422. if err == nil {
  6423. //判断是否使用了押金
  6424. if dec_way == "true" {
  6425. tmpstring := strconv.FormatInt(order.ID, 10)
  6426. order.Decimal = decimal
  6427. service.UpDateOrder(order)
  6428. //扣押金
  6429. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6430. if errmsg != nil {
  6431. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6432. return
  6433. }
  6434. }
  6435. c.ServeSuccessJSON(map[string]interface{}{
  6436. "msg": "结算成功",
  6437. })
  6438. } else {
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6440. return
  6441. }
  6442. }
  6443. } else {
  6444. adminUser := c.GetAdminUserInfo()
  6445. errlog := &models.HisOrderError{
  6446. UserOrgId: adminUser.CurrentOrgId,
  6447. Ctime: time.Now().Unix(),
  6448. Mtime: time.Now().Unix(),
  6449. ErrMsg: res.ErrMsg,
  6450. Status: 1,
  6451. PatientId: id,
  6452. RecordTime: recordDateTime,
  6453. Stage: 4,
  6454. }
  6455. service.CreateErrMsgLog(errlog)
  6456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6457. return
  6458. }
  6459. } else {
  6460. adminUser := c.GetAdminUserInfo()
  6461. errlog := &models.HisOrderError{
  6462. UserOrgId: adminUser.CurrentOrgId,
  6463. Ctime: time.Now().Unix(),
  6464. Mtime: time.Now().Unix(),
  6465. ErrMsg: res.ErrMsg,
  6466. Status: 1,
  6467. PatientId: id,
  6468. RecordTime: recordDateTime,
  6469. Stage: 4,
  6470. }
  6471. service.CreateErrMsgLog(errlog)
  6472. c.ServeSuccessJSON(map[string]interface{}{
  6473. "failed_code": -10,
  6474. "msg": res.ErrMsg,
  6475. })
  6476. return
  6477. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6478. //return
  6479. }
  6480. }
  6481. }
  6482. } else if tempOrder.ID > 0 {
  6483. if tempOrder.IsPre == 1 {
  6484. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6485. var rf []*ResultFive
  6486. json.Unmarshal([]byte(his.Iinfo), &rf)
  6487. chrg_bchno := tempOrder.Number
  6488. cert_no := his.Certno
  6489. var insutypes []string
  6490. var insutype string
  6491. var is390 int = 0
  6492. var is310 int = 0
  6493. for _, item := range rf {
  6494. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6495. insutypes = append(insutypes, item.Insutype)
  6496. }
  6497. }
  6498. if len(insutypes) == 1 {
  6499. insutype = insutypes[0]
  6500. } else {
  6501. for _, i := range insutypes {
  6502. if i == "390" {
  6503. is390 = 1
  6504. }
  6505. if i == "310" {
  6506. is310 = 1
  6507. }
  6508. }
  6509. }
  6510. if is390 == 1 {
  6511. insutype = "390"
  6512. }
  6513. if is310 == 1 {
  6514. insutype = "310"
  6515. }
  6516. if len(insutypes) == 0 {
  6517. insutype = "310"
  6518. }
  6519. if len(insutypes) == 2 {
  6520. insutype = strconv.FormatInt(his.SocialType, 64)
  6521. }
  6522. //insutype = "390"
  6523. if his.IdCardType == 1 {
  6524. // cert_no = his.MedicalInsuranceNumber
  6525. cert_no = his.Certno
  6526. } else {
  6527. cert_no = his.Certno
  6528. }
  6529. var res ResultSeven
  6530. var resSeven10265 ResultSeven10265
  6531. var src_resquest string
  6532. var result2 string
  6533. var acct_used_flag string
  6534. fmt.Println("pay_way")
  6535. fmt.Println(pay_way)
  6536. fmt.Println("pay_way")
  6537. if pay_way == 4 {
  6538. acct_used_flag = "1"
  6539. } else {
  6540. acct_used_flag = "0"
  6541. }
  6542. if miConfig.MdtrtareaAdmvs == "421300" {
  6543. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6544. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6545. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6547. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6548. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6549. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6550. resp, requestErr := http.Get(api)
  6551. if requestErr != nil {
  6552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. return
  6554. }
  6555. body, ioErr := ioutil.ReadAll(resp.Body)
  6556. if ioErr != nil {
  6557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6559. return
  6560. }
  6561. var respJSON map[string]interface{}
  6562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6565. return
  6566. }
  6567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6568. result, _ := json.Marshal(respJSON)
  6569. fmt.Println("log")
  6570. fmt.Println(string(result))
  6571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6572. utils.ErrorLog("解析失败:%v", err)
  6573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6574. return
  6575. }
  6576. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6577. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  6578. if result3101.Infcode == "0" {
  6579. if len(result3101.Output.Result) > 0 {
  6580. var errMsgs []string
  6581. for _, item := range result3101.Output.Result {
  6582. errMsgs = append(errMsgs, item.VolaCont)
  6583. }
  6584. c.ServeSuccessJSON(map[string]interface{}{
  6585. "failed_code": -10,
  6586. "msg": errMsgs,
  6587. })
  6588. return
  6589. } else {
  6590. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6591. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6592. //psn_info, _ := service.GetPsnByPatientId(id)
  6593. bas := strings.Split(psn_info.CardInfo, "|")
  6594. if his.IdCardType == 1 {
  6595. cert_no = bas[2]
  6596. } else {
  6597. cert_no = bas[1]
  6598. }
  6599. //江苏地区国家医保医疗类别
  6600. //职工透析:医疗类别选特殊情况门诊9933
  6601. //居民血透门慢: 医疗类别选门诊慢病1402
  6602. //var med_type string
  6603. //if his.Insutype == "310" {
  6604. // if reg_type == 14 {
  6605. // med_type = "9933"
  6606. // } else if reg_type == 11 {
  6607. // med_type = "11"
  6608. //
  6609. // }
  6610. //} else if his.Insutype == "390" {
  6611. // if reg_type == 14 {
  6612. // med_type = "1402"
  6613. // } else if reg_type == 11 {
  6614. // med_type = "11"
  6615. // }
  6616. //}
  6617. var api string
  6618. if miConfig.MdtrtareaAdmvs == "320921" {
  6619. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6620. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6621. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6622. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6623. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6624. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6625. "&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
  6626. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6627. } else {
  6628. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6629. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6630. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6631. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6632. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6633. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6634. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6635. "&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
  6636. }
  6637. resp, requestErr := http.Get(api)
  6638. if requestErr != nil {
  6639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6640. return
  6641. }
  6642. body, ioErr := ioutil.ReadAll(resp.Body)
  6643. if ioErr != nil {
  6644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6646. return
  6647. }
  6648. var respJSON map[string]interface{}
  6649. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6652. return
  6653. }
  6654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6655. result, _ := json.Marshal(respJSON)
  6656. fmt.Println("log")
  6657. fmt.Println(string(result))
  6658. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6659. utils.ErrorLog("解析失败:%v", err)
  6660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6661. return
  6662. }
  6663. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6664. res.Output = resSeven10265.Output
  6665. res.ErrMsg = resSeven10265.ErrMsg
  6666. res.Cainfo = resSeven10265.Cainfo
  6667. res.WarnMsg = resSeven10265.WarnMsg
  6668. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6669. res.Infcode = infocode
  6670. }
  6671. }
  6672. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6673. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6674. var cert_no string
  6675. if his.IdCardType == 1 {
  6676. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6677. }
  6678. fmt.Println(cert_no)
  6679. 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)
  6680. var dat map[string]interface{}
  6681. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6682. fmt.Println(dat)
  6683. } else {
  6684. fmt.Println(err)
  6685. }
  6686. saveLog(result2, src_resquest, "2207", "结算")
  6687. userJSONBytes, _ := json.Marshal(dat)
  6688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6689. utils.ErrorLog("解析失败:%v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. return
  6692. }
  6693. } else {
  6694. var src_resquest string
  6695. if miConfig.Code == "H15049901371" {
  6696. //赤峰地区国家医保医疗类别
  6697. //职工透析:医疗类别选特殊情况门诊990502
  6698. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6699. var med_type string
  6700. if his.Insutype == "390" {
  6701. if reg_type == 14 {
  6702. med_type = "9933"
  6703. } else if reg_type == 11 {
  6704. med_type = "11"
  6705. }
  6706. } else if his.Insutype == "310" {
  6707. if reg_type == 14 {
  6708. med_type = "990502"
  6709. } else if reg_type == 11 {
  6710. med_type = "11"
  6711. }
  6712. }
  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, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  6714. } else {
  6715. 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)
  6716. }
  6717. var dat map[string]interface{}
  6718. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6719. fmt.Println(dat)
  6720. } else {
  6721. fmt.Println(err)
  6722. }
  6723. saveLog(result2, src_resquest, "2207", "结算")
  6724. userJSONBytes, _ := json.Marshal(dat)
  6725. if miConfig.Code == "H15049901371" {
  6726. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6727. utils.ErrorLog("解析失败:%v", err)
  6728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6729. return
  6730. }
  6731. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6732. res.Output = resSeven10265.Output
  6733. res.ErrMsg = resSeven10265.ErrMsg
  6734. res.Cainfo = resSeven10265.Cainfo
  6735. res.WarnMsg = resSeven10265.WarnMsg
  6736. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6737. res.Infcode = infocode
  6738. } else {
  6739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6740. utils.ErrorLog("解析失败:%v", err)
  6741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6742. return
  6743. }
  6744. }
  6745. }
  6746. if res.Infcode != 0 {
  6747. errlog := &models.HisOrderError{
  6748. UserOrgId: adminUser.CurrentOrgId,
  6749. Ctime: time.Now().Unix(),
  6750. Mtime: time.Now().Unix(),
  6751. Number: chrg_bchno,
  6752. ErrMsg: res.ErrMsg,
  6753. Status: 1,
  6754. PatientId: id,
  6755. RecordTime: recordDateTime,
  6756. Stage: 6,
  6757. }
  6758. service.CreateErrMsgLog(errlog)
  6759. c.ServeSuccessJSON(map[string]interface{}{
  6760. "failed_code": -10,
  6761. "msg": res.ErrMsg,
  6762. })
  6763. return
  6764. } else {
  6765. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6766. order.OrderStatus = 2
  6767. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6768. order.SetlId = res.Output.Setlinfo.SetlID
  6769. order.PsnNo = res.Output.Setlinfo.PsnNo
  6770. order.PsnName = res.Output.Setlinfo.PsnName
  6771. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6772. order.Certno = res.Output.Setlinfo.Certno
  6773. order.Gend = res.Output.Setlinfo.Gend
  6774. order.Naty = res.Output.Setlinfo.Naty
  6775. order.Age = res.Output.Setlinfo.Age
  6776. order.Insutype = res.Output.Setlinfo.Insutype
  6777. order.PsnType = res.Output.Setlinfo.PsnType
  6778. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6779. order.SetlTime = res.Output.Setlinfo.SetlTime
  6780. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6781. //order.MedType = res.Output.Setlinfo.MedType
  6782. if reg_type == 1112 {
  6783. order.MedType = "1112"
  6784. }
  6785. if reg_type == 1111 {
  6786. order.MedType = "1111"
  6787. }
  6788. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6789. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6790. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6791. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6792. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6793. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6794. order.HifpPay = res.Output.Setlinfo.HifpPay
  6795. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6796. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6797. order.HifesPay = res.Output.Setlinfo.HifesPay
  6798. order.HifobPay = res.Output.Setlinfo.HifobPay
  6799. order.MafPay = res.Output.Setlinfo.MafPay
  6800. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6801. order.OthPay = res.Output.Setlinfo.OthPay
  6802. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6803. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6804. order.AcctPay = res.Output.Setlinfo.AcctPay
  6805. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6806. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6807. order.Balc = res.Output.Setlinfo.Balc
  6808. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6809. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6810. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6811. order.ClrWay = res.Output.Setlinfo.ClrWay
  6812. order.Creator = order.Creator
  6813. order.Modify = roles.AdminUserId
  6814. order.RequestLog = src_resquest
  6815. order.Diagnosis = diagnosis_id
  6816. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6817. detailStr := string(setlDetail)
  6818. order.SetlDetail = detailStr
  6819. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6820. err = service.UpDateOrder(order)
  6821. if err == nil {
  6822. //判断是否使用了押金
  6823. if dec_way == "true" {
  6824. tmpstring := strconv.FormatInt(order.ID, 10)
  6825. //扣押金
  6826. order.Decimal = decimal
  6827. service.UpDateOrder(order)
  6828. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6829. if errmsg != nil {
  6830. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6831. return
  6832. }
  6833. }
  6834. c.ServeSuccessJSON(map[string]interface{}{
  6835. "msg": "结算成功",
  6836. })
  6837. } else {
  6838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6839. return
  6840. }
  6841. }
  6842. }
  6843. }
  6844. }
  6845. //func (c *HisApiController) GetPreUploadInfo() {
  6846. // id, _ := c.GetInt64("id")
  6847. // record_time := c.GetString("record_time")
  6848. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6849. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6850. //
  6851. // timeLayout := "2006-01-02"
  6852. // loc, _ := time.LoadLocation("Local")
  6853. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6854. // if err != nil {
  6855. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6856. // return
  6857. // }
  6858. // recordDateTime := theTime.Unix()
  6859. // adminUser := c.GetAdminUserInfo()
  6860. //
  6861. // var prescriptions []*models.HisPrescription
  6862. //
  6863. // var start_time int64
  6864. // var end_time int64
  6865. //
  6866. // data := make(map[string]interface{})
  6867. // if settle_accounts_type == 1 { //日结
  6868. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6869. // data["pre"] = prescriptions
  6870. //
  6871. // } else { //月结
  6872. // start_time_str := c.GetString("start_time")
  6873. // end_time_str := c.GetString("end_time")
  6874. // timeLayout := "2006-01-02"
  6875. // loc, _ := time.LoadLocation("Local")
  6876. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6877. // if err != nil {
  6878. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6879. // return
  6880. // }
  6881. // recordStartTime := theStartTime.Unix()
  6882. // start_time = recordStartTime
  6883. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6884. // if err != nil {
  6885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6886. // return
  6887. // }
  6888. // recordEndTime := theEndTime.Unix()
  6889. // end_time = recordEndTime
  6890. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6891. // data["pre"] = prescriptions
  6892. //
  6893. // }
  6894. //
  6895. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6896. //
  6897. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6898. // timestamp := time.Now().Unix()
  6899. // tempTime := time.Unix(timestamp, 0)
  6900. // timeFormat := tempTime.Format("20060102150405")
  6901. // chrgBchno := rand.Intn(100000) + 10000
  6902. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6903. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6904. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6905. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6906. // strconv.FormatInt(his.PatientId, 10)
  6907. // client := &http.Client{}
  6908. // data["psn_no"] = his.PsnNo
  6909. // data["mdtrt_id"] = his.Number
  6910. // data["chrg_bchno"] = chrg_bchno
  6911. // data["org_name"] = miConfig.OrgName
  6912. // data["doctor"] = roles.UserName
  6913. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6914. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6915. // data["fixmedins_code"] = miConfig.Code
  6916. // data["dept_code"] = department.Number
  6917. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6918. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6919. // data["secret_key"] = miConfig.SecretKey
  6920. // var ids []int64
  6921. //
  6922. // for _, item := range prescriptions {
  6923. // ids = append(ids, item.ID)
  6924. // }
  6925. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6926. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6927. // bytesData, _ := json.Marshal(data)
  6928. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6929. // resp, _ := client.Do(req)
  6930. // defer resp.Body.Close()
  6931. // body, ioErr := ioutil.ReadAll(resp.Body)
  6932. // if ioErr != nil {
  6933. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6935. // return
  6936. // }
  6937. // var respJSON map[string]interface{}
  6938. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6939. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6941. // return
  6942. // }
  6943. //
  6944. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6945. // userJSONBytes, _ := json.Marshal(respJSON)
  6946. // var res ResultFour
  6947. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6948. // utils.ErrorLog("解析失败:%v", err)
  6949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6950. // return
  6951. // }
  6952. //
  6953. // if res.Infcode == 0 {
  6954. // order := &models.HisOrder{
  6955. // UserOrgId: adminUser.CurrentOrgId,
  6956. // HisPatientId: his.ID,
  6957. // PatientId: his.PatientId,
  6958. // SettleAccountsDate: recordDateTime,
  6959. // Ctime: time.Now().Unix(),
  6960. // Mtime: time.Now().Unix(),
  6961. // Status: 1,
  6962. // Number: chrg_bchno,
  6963. // Infcode: res.Infcode,
  6964. // WarnMsg: res.WarnMsg,
  6965. // Cainfo: res.Cainfo,
  6966. // ErrMsg: res.ErrMsg,
  6967. // RespondTime: res.RefmsgTime,
  6968. // InfRefmsgid: res.InfRefmsgid,
  6969. // OrderStatus: 1,
  6970. // IsMedicineInsurance: 1,
  6971. // SettleType: settle_accounts_type,
  6972. // SettleStartTime: start_time,
  6973. // SettleEndTime: end_time,
  6974. // Creator: roles.ID,
  6975. // Modify: roles.ID,
  6976. // PType: 2,
  6977. // }
  6978. // err = service.CreateOrder(order)
  6979. // if err != nil {
  6980. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6981. // return
  6982. // }
  6983. //
  6984. // for _, item := range res.Output.Result {
  6985. // temp := strings.Split(item.FeedetlSn, "-")
  6986. // var advice_id int64 = 0
  6987. // var project_id int64 = 0
  6988. // var types int64 = 0
  6989. //
  6990. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6991. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6992. //
  6993. // if temp[1] == "1" {
  6994. // advice_id = id
  6995. // project_id = 0
  6996. // } else if temp[1] == "2" {
  6997. // advice_id = 0
  6998. // project_id = id
  6999. // }
  7000. //
  7001. // info := &models.HisOrderInfo{
  7002. // OrderNumber: order.Number,
  7003. // FeedetlSn: item.FeedetlSn,
  7004. // UploadDate: time.Now().Unix(),
  7005. // AdviceId: advice_id,
  7006. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  7007. // Cnt: item.Cnt,
  7008. // Pric: float64(item.Pric),
  7009. // PatientId: his.PatientId,
  7010. // PricUplmtAmt: item.PricUplmtAmt,
  7011. // SelfpayProp: item.SelfpayProp,
  7012. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7013. // OverlmtAmt: item.OverlmtAmt,
  7014. // PreselfpayAmt: item.PreselfpayAmt,
  7015. // BasMednFlag: item.BasMednFlag,
  7016. // MedChrgitmType: item.MedChrgitmType,
  7017. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  7018. // Status: 1,
  7019. // Memo: item.Memo,
  7020. // Mtime: time.Now().Unix(),
  7021. // InscpScpAmt: item.InscpScpAmt,
  7022. // DrtReimFlag: item.DrtReimFlag,
  7023. // Ctime: time.Now().Unix(),
  7024. // ListSpItemFlag: item.ListSpItemFlag,
  7025. // ChldMedcFlag: item.ChldMedcFlag,
  7026. // LmtUsedFlag: item.LmtUsedFlag,
  7027. // ChrgitmLv: item.ChrgitmLv,
  7028. // UserOrgId: adminUser.CurrentOrgId,
  7029. // HisPatientId: his.ID,
  7030. // OrderId: order.ID,
  7031. // ProjectId: project_id,
  7032. // Type: types,
  7033. // }
  7034. // service.CreateOrderInfo(info)
  7035. //
  7036. // }
  7037. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7038. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7039. //
  7040. // var total float64
  7041. // for _, item := range prescriptions {
  7042. // if item.Type == 1 { //药品
  7043. // for _, subItem := range item.HisDoctorAdviceInfo {
  7044. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7045. // }
  7046. // }
  7047. // if item.Type == 2 { //项目
  7048. // for _, subItem := range item.HisPrescriptionProject {
  7049. // total = total + (subItem.Price * float64(subItem.Count))
  7050. // }
  7051. // }
  7052. // }
  7053. //
  7054. // for _, item := range prescriptions {
  7055. // for _, subItem := range item.HisAdditionalCharge {
  7056. // total = total + (subItem.Price * float64(subItem.Count))
  7057. // }
  7058. // }
  7059. //
  7060. // allTotal := fmt.Sprintf("%.2f", total)
  7061. // if res.Infcode == 0 {
  7062. // var rf []*ResultFive
  7063. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7064. // psn_no := his.PsnNo
  7065. // mdtrt_id := his.Number
  7066. // chrg_bchno := chrg_bchno
  7067. // cert_no := his.Certno
  7068. // insutype := rf[0].Insutype
  7069. //
  7070. // if his.IdCardType == 1 {
  7071. // cert_no = his.MedicalInsuranceNumber
  7072. //
  7073. // } else {
  7074. //
  7075. // cert_no = his.Certno
  7076. //
  7077. // }
  7078. //
  7079. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7080. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7081. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7082. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7083. // resp, requestErr := http.Get(api)
  7084. // if requestErr != nil {
  7085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7086. // return
  7087. // }
  7088. // defer resp.Body.Close()
  7089. // body, ioErr := ioutil.ReadAll(resp.Body)
  7090. // if ioErr != nil {
  7091. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. // return
  7094. // }
  7095. // var respJSON map[string]interface{}
  7096. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7097. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7099. // return
  7100. // }
  7101. // fmt.Println(respJSON)
  7102. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7103. // userJSONBytes, _ := json.Marshal(respJSON)
  7104. // var res ResultSeven
  7105. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7106. // utils.ErrorLog("解析失败:%v", err)
  7107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7108. // return
  7109. // }
  7110. // if res.Infcode != 0 {
  7111. // errlog := &models.HisOrderError{
  7112. // UserOrgId: adminUser.CurrentOrgId,
  7113. // Ctime: time.Now().Unix(),
  7114. // Mtime: time.Now().Unix(),
  7115. // Number: chrg_bchno,
  7116. // ErrMsg: res.ErrMsg,
  7117. // Status: 1,
  7118. // PatientId: id,
  7119. // RecordTime: recordDateTime,
  7120. // Stage: 7,
  7121. // }
  7122. // service.CreateErrMsgLog(errlog)
  7123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7124. // return
  7125. // } else {
  7126. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7127. // order.OrderStatus = 1
  7128. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7129. // order.SetlId = res.Output.Setlinfo.SetlID
  7130. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7131. // order.PsnName = res.Output.Setlinfo.PsnName
  7132. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7133. // order.Certno = res.Output.Setlinfo.Certno
  7134. // order.Gend = res.Output.Setlinfo.Gend
  7135. // order.Naty = res.Output.Setlinfo.Naty
  7136. // order.Age = res.Output.Setlinfo.Age
  7137. // order.Insutype = res.Output.Setlinfo.Insutype
  7138. // order.PsnType = res.Output.Setlinfo.PsnType
  7139. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7140. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7141. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7142. // order.MedType = res.Output.Setlinfo.MedType
  7143. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7144. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7145. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7146. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7147. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7148. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7149. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7150. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7151. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7152. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7153. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7154. // order.MafPay = res.Output.Setlinfo.MafPay
  7155. // order.OthPay = res.Output.Setlinfo.OthPay
  7156. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7157. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7158. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7159. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7160. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7161. // order.Balc = res.Output.Setlinfo.Balc
  7162. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7163. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7164. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7165. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7166. // order.Creator = order.Creator
  7167. // order.Modify = roles.ID
  7168. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7169. // detailStr := string(setlDetail)
  7170. // order.SetlDetail = detailStr
  7171. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7172. // err = service.UpDateOrder(order)
  7173. // if err == nil {
  7174. // c.ServeSuccessJSON(map[string]interface{}{
  7175. // "msg": "预结算成功",
  7176. // })
  7177. // } else {
  7178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7179. // return
  7180. // }
  7181. // }
  7182. // } else {
  7183. // adminUser := c.GetAdminUserInfo()
  7184. // errlog := &models.HisOrderError{
  7185. // UserOrgId: adminUser.CurrentOrgId,
  7186. // Ctime: time.Now().Unix(),
  7187. // Mtime: time.Now().Unix(),
  7188. // ErrMsg: res.ErrMsg,
  7189. // Status: 1,
  7190. // PatientId: id,
  7191. // RecordTime: recordDateTime,
  7192. // Stage: 4,
  7193. // }
  7194. // service.CreateErrMsgLog(errlog)
  7195. //
  7196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7197. // return
  7198. // }
  7199. // } else {
  7200. // adminUser := c.GetAdminUserInfo()
  7201. // errlog := &models.HisOrderError{
  7202. // UserOrgId: adminUser.CurrentOrgId,
  7203. // Ctime: time.Now().Unix(),
  7204. // Mtime: time.Now().Unix(),
  7205. // ErrMsg: res.ErrMsg,
  7206. // Status: 1,
  7207. // PatientId: id,
  7208. // RecordTime: recordDateTime,
  7209. // Stage: 4,
  7210. // }
  7211. // service.CreateErrMsgLog(errlog)
  7212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7213. // return
  7214. // }
  7215. //
  7216. // } else {
  7217. // var total float64
  7218. // for _, item := range prescriptions {
  7219. // if item.Type == 1 { //药品
  7220. // for _, subItem := range item.HisDoctorAdviceInfo {
  7221. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7222. // }
  7223. // }
  7224. // if item.Type == 2 { //项目
  7225. // for _, subItem := range item.HisPrescriptionProject {
  7226. // total = total + (subItem.Price * float64(subItem.Count))
  7227. // }
  7228. // }
  7229. //
  7230. // for _, subItem := range item.HisAdditionalCharge {
  7231. // total = total + (subItem.Price * float64(subItem.Count))
  7232. // }
  7233. // }
  7234. //
  7235. // allTotal := fmt.Sprintf("%.2f", total)
  7236. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7237. // order := &models.HisOrder{
  7238. // UserOrgId: adminUser.CurrentOrgId,
  7239. // HisPatientId: his.ID,
  7240. // PatientId: id,
  7241. // SettleAccountsDate: recordDateTime,
  7242. // Ctime: time.Now().Unix(),
  7243. // Mtime: time.Now().Unix(),
  7244. // Status: 1,
  7245. // OrderStatus: 2,
  7246. // Number: chrg_bchno,
  7247. // MedfeeSumamt: totals,
  7248. // }
  7249. // err = service.CreateOrder(order)
  7250. // if err != nil {
  7251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7252. // return
  7253. // }
  7254. //
  7255. // var customs []*Custom
  7256. // for _, item := range prescriptions {
  7257. //
  7258. // if item.Type == 1 { //药品
  7259. // for _, subItem := range item.HisDoctorAdviceInfo {
  7260. // cus := &Custom{
  7261. // AdviceId: subItem.ID,
  7262. // ProjectId: 0,
  7263. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7264. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7265. // FeedetlSn: subItem.FeedetlSn,
  7266. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7267. // MedListCodg: subItem.MedListCodg,
  7268. // Type: 1,
  7269. // }
  7270. // customs = append(customs, cus)
  7271. // }
  7272. // }
  7273. //
  7274. // if item.Type == 2 { //项目
  7275. // for _, subItem := range item.HisPrescriptionProject {
  7276. //
  7277. // cus := &Custom{
  7278. // AdviceId: 0,
  7279. // ProjectId: subItem.ID,
  7280. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7281. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7282. // FeedetlSn: subItem.FeedetlSn,
  7283. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7284. // MedListCodg: subItem.MedListCodg,
  7285. // Type: 2,
  7286. // }
  7287. //
  7288. // customs = append(customs, cus)
  7289. // }
  7290. // }
  7291. //
  7292. // for _, item := range item.HisAdditionalCharge {
  7293. // cus := &Custom{
  7294. // ItemId: item.ID,
  7295. // AdviceId: 0,
  7296. // ProjectId: 0,
  7297. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7298. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7299. // FeedetlSn: item.FeedetlSn,
  7300. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7301. // MedListCodg: item.XtHisAddtionConfig.Code,
  7302. // Type: 3,
  7303. // }
  7304. //
  7305. // customs = append(customs, cus)
  7306. // }
  7307. //
  7308. // }
  7309. //
  7310. // for _, item := range customs {
  7311. // var advice_id int64 = 0
  7312. // var project_id int64 = 0
  7313. // var item_id int64 = 0
  7314. //
  7315. // var types int64 = 0
  7316. //
  7317. // if item.Type == 1 {
  7318. // advice_id = item.AdviceId
  7319. // project_id = 0
  7320. // item_id = 0
  7321. // } else if item.Type == 2 {
  7322. // advice_id = 0
  7323. // item_id = 0
  7324. //
  7325. // project_id = item.ProjectId
  7326. // } else if item.Type == 3 {
  7327. // advice_id = 0
  7328. // item_id = item.ItemId
  7329. // project_id = 0
  7330. // }
  7331. //
  7332. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7333. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7334. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7335. //
  7336. // info := &models.HisOrderInfo{
  7337. // OrderNumber: order.Number,
  7338. // UploadDate: time.Now().Unix(),
  7339. // AdviceId: advice_id,
  7340. // DetItemFeeSumamt: detItemFeeSumamt,
  7341. // Cnt: cut,
  7342. // Pric: pric,
  7343. // PatientId: id,
  7344. // Status: 1,
  7345. // Mtime: time.Now().Unix(),
  7346. // Ctime: time.Now().Unix(),
  7347. // UserOrgId: adminUser.CurrentOrgId,
  7348. // HisPatientId: his.ID,
  7349. // OrderId: order.ID,
  7350. // ProjectId: project_id,
  7351. // Type: types,
  7352. // ItemId: item_id,
  7353. // }
  7354. // service.CreateOrderInfo(info)
  7355. // }
  7356. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7357. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7358. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7359. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7360. // if err == nil {
  7361. // c.ServeSuccessJSON(map[string]interface{}{
  7362. // "msg": "结算成功",
  7363. // })
  7364. // } else {
  7365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7366. // return
  7367. // }
  7368. // }
  7369. //}
  7370. //上传明细-预结算-
  7371. func (c *HisApiController) GetPreUploadInfo() {
  7372. id, _ := c.GetInt64("id")
  7373. record_time := c.GetString("record_time")
  7374. his_patient_id, _ := c.GetInt64("his_patient_id")
  7375. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7376. admin_user_id, _ := c.GetInt64("admin_user_id")
  7377. diagnosis_id := c.GetString("diagnosis")
  7378. sick_type, _ := c.GetInt64("sick_type")
  7379. reg_type, _ := c.GetInt64("p_type")
  7380. begin_time := c.GetString("begin_time")
  7381. id_str := c.GetString("ids")
  7382. ids_arr := strings.Split(id_str, ",")
  7383. timeLayout := "2006-01-02"
  7384. loc, _ := time.LoadLocation("Local")
  7385. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7386. if err != nil {
  7387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7388. return
  7389. }
  7390. recordDateTime := theTime.Unix()
  7391. adminUser := c.GetAdminUserInfo()
  7392. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7393. var config []*models.HisXtDiagnoseConfig
  7394. for _, item := range diagnosis_ids {
  7395. id, _ := strconv.ParseInt(item, 10, 64)
  7396. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7397. config = append(config, &diagnosisConfig)
  7398. }
  7399. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7400. sickConfig, _ := service.FindSickById(sick_type)
  7401. var prescriptions []*models.HisPrescription
  7402. var start_time int64
  7403. var end_time int64
  7404. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7405. fmt.Println(his_patient_id)
  7406. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7407. timestamp := time.Now().Unix()
  7408. tempTime := time.Unix(timestamp, 0)
  7409. timeFormat := tempTime.Format("20060102150405")
  7410. chrgBchno := rand.Intn(100000) + 10000
  7411. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7413. var patientPrescription models.HisPrescriptionInfo
  7414. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7415. if patientPrescription.ID == 0 {
  7416. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7417. }
  7418. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7419. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7420. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7421. strconv.FormatInt(his.PatientId, 10)
  7422. var res2 ResultSix
  7423. var resSix10265 ResultSix10265
  7424. var time_stamp string
  7425. if miConfig.MdtrtareaAdmvs == "421300" {
  7426. data := make(map[string]interface{})
  7427. client := &http.Client{}
  7428. data["psn_no"] = his.PsnNo
  7429. data["mdtrt_id"] = his.Number
  7430. data["department"] = department.Name
  7431. data["org_name"] = miConfig.OrgName
  7432. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7433. data["doctor_id"] = doctor_info.DoctorNumber
  7434. data["doctor_name"] = roles.UserName
  7435. data["fixmedins_code"] = miConfig.Code
  7436. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7437. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7438. data["secret_key"] = miConfig.SecretKey
  7439. data["sick_code"] = sickConfig.CountryCode
  7440. data["sick_name"] = sickConfig.ClassName
  7441. data["begin_time"] = begin_time
  7442. data["dept"] = strconv.FormatInt(department.ID, 10)
  7443. data["config"] = config
  7444. data["opter"] = roles.UserName
  7445. fmt.Println(data)
  7446. bytesData, _ := json.Marshal(data)
  7447. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7448. resp, _ := client.Do(req)
  7449. defer resp.Body.Close()
  7450. body, ioErr := ioutil.ReadAll(resp.Body)
  7451. if ioErr != nil {
  7452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7454. return
  7455. }
  7456. var respJSON map[string]interface{}
  7457. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7460. return
  7461. }
  7462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7463. userJSONBytes, _ := json.Marshal(respJSON)
  7464. fmt.Println("log")
  7465. fmt.Println(string(userJSONBytes))
  7466. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7467. utils.ErrorLog("解析失败:%v", err)
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7472. data := make(map[string]interface{})
  7473. client := &http.Client{}
  7474. data["psn_no"] = his.PsnNo
  7475. data["mdtrt_id"] = his.Number
  7476. data["doctor"] = roles.UserName
  7477. data["department"] = department.Name
  7478. data["org_name"] = miConfig.OrgName
  7479. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7480. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7481. data["fixmedins_code"] = miConfig.Code
  7482. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7483. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7484. data["secret_key"] = miConfig.SecretKey
  7485. data["sick_code"] = sickConfig.CountryCode
  7486. data["sick_name"] = sickConfig.ClassName
  7487. data["begin_time"] = begin_time
  7488. data["dept"] = strconv.FormatInt(department.ID, 10)
  7489. data["config"] = config
  7490. data["url"] = miConfig.Url
  7491. data["ak"] = miConfig.AccessKey
  7492. data["cainfo"] = miConfig.Cainfo
  7493. bytesData, _ := json.Marshal(data)
  7494. var req *http.Request
  7495. if miConfig.MdtrtareaAdmvs == "320921" {
  7496. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7497. //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 +
  7498. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7499. } else {
  7500. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7501. }
  7502. resp, _ := client.Do(req)
  7503. defer resp.Body.Close()
  7504. body, ioErr := ioutil.ReadAll(resp.Body)
  7505. if ioErr != nil {
  7506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7508. return
  7509. }
  7510. var respJSON map[string]interface{}
  7511. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7514. return
  7515. }
  7516. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7517. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7518. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7520. userJSONBytes, _ := json.Marshal(respJSON)
  7521. fmt.Println("log")
  7522. fmt.Println(string(userJSONBytes))
  7523. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7524. utils.ErrorLog("解析失败:%v", err)
  7525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7526. return
  7527. }
  7528. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7529. res2.Output = resSix10265.Output
  7530. res2.ErrMsg = resSix10265.ErrMsg
  7531. res2.Cainfo = resSix10265.Cainfo
  7532. res2.WarnMsg = resSix10265.WarnMsg
  7533. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7534. res2.Infcode = infocode
  7535. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7536. 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)
  7537. saveLog(result, requestLog, "2203", "上传就诊信息")
  7538. var respJSON2 map[string]interface{}
  7539. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. return
  7543. }
  7544. userJSONBytes2, _ := json.Marshal(respJSON2)
  7545. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7546. utils.ErrorLog("解析失败:%v", err)
  7547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7548. return
  7549. }
  7550. } else {
  7551. var result string
  7552. var requestLog string
  7553. if miConfig.MdtrtareaAdmvs == "440781" { //
  7554. 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)
  7555. } else {
  7556. if miConfig.Code == "H15049901371" {
  7557. //赤峰地区国家医保医疗类别
  7558. //职工透析:医疗类别选特殊情况门诊990502
  7559. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7560. var med_type string
  7561. if his.Insutype == "390" {
  7562. if reg_type == 14 {
  7563. med_type = "9933"
  7564. } else if reg_type == 11 {
  7565. med_type = "11"
  7566. }
  7567. } else if his.Insutype == "310" {
  7568. if reg_type == 14 {
  7569. med_type = "990502"
  7570. } else if reg_type == 11 {
  7571. med_type = "11"
  7572. }
  7573. }
  7574. 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)
  7575. } else {
  7576. 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)
  7577. }
  7578. saveLog(result, requestLog, "2203", "上传就诊信息")
  7579. var respJSON2 map[string]interface{}
  7580. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7583. return
  7584. }
  7585. userJSONBytes2, _ := json.Marshal(respJSON2)
  7586. if miConfig.Code == "H15049901371" {
  7587. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7588. utils.ErrorLog("解析失败:%v", err)
  7589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7590. return
  7591. }
  7592. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7593. res2.Output = resSix10265.Output
  7594. res2.ErrMsg = resSix10265.ErrMsg
  7595. res2.Cainfo = resSix10265.Cainfo
  7596. res2.WarnMsg = resSix10265.WarnMsg
  7597. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7598. res2.Infcode = infocode
  7599. } else {
  7600. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7601. utils.ErrorLog("解析失败:%v", err)
  7602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7603. return
  7604. }
  7605. }
  7606. }
  7607. }
  7608. if res2.Infcode != 0 {
  7609. adminUser := c.GetAdminUserInfo()
  7610. errlog := &models.HisOrderError{
  7611. UserOrgId: adminUser.CurrentOrgId,
  7612. Ctime: time.Now().Unix(),
  7613. Mtime: time.Now().Unix(),
  7614. ErrMsg: res2.ErrMsg,
  7615. Status: 1,
  7616. PatientId: id,
  7617. RecordTime: recordDateTime,
  7618. Stage: 3,
  7619. }
  7620. service.CreateErrMsgLog(errlog)
  7621. c.ServeSuccessJSON(map[string]interface{}{
  7622. "failed_code": -10,
  7623. "msg": res2.ErrMsg,
  7624. })
  7625. return
  7626. } else {
  7627. his.Diagnosis = diagnosis_id
  7628. his.SickType = sickConfig.ID
  7629. his.PType = fmt.Sprintf("%d", reg_type)
  7630. service.UpdateHisPatientThree(&his)
  7631. data := make(map[string]interface{})
  7632. if settle_accounts_type == 1 { //日结
  7633. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7634. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7635. } else {
  7636. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7637. }
  7638. data["pre"] = prescriptions
  7639. } else { //月结
  7640. start_time_str := c.GetString("start_time")
  7641. end_time_str := c.GetString("end_time")
  7642. timeLayout := "2006-01-02"
  7643. loc, _ := time.LoadLocation("Local")
  7644. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7645. if err != nil {
  7646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7647. return
  7648. }
  7649. recordStartTime := theStartTime.Unix()
  7650. start_time = recordStartTime
  7651. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7652. if err != nil {
  7653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7654. return
  7655. }
  7656. recordEndTime := theEndTime.Unix()
  7657. end_time = recordEndTime
  7658. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7659. data["pre"] = prescriptions
  7660. }
  7661. client := &http.Client{}
  7662. data["psn_no"] = his.PsnNo
  7663. data["mdtrt_id"] = his.Number
  7664. data["chrg_bchno"] = chrg_bchno
  7665. data["org_name"] = miConfig.OrgName
  7666. data["doctor"] = roles.UserName
  7667. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7668. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7669. data["fixmedins_code"] = miConfig.Code
  7670. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7671. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7672. data["dept_code"] = "15"
  7673. } else {
  7674. data["dept_code"] = department.Number
  7675. }
  7676. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7677. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7678. data["secret_key"] = miConfig.SecretKey
  7679. data["url"] = miConfig.Url
  7680. data["ak"] = miConfig.AccessKey
  7681. data["new_doctor_name"] = patientPrescription.Doctor
  7682. data["diag_code"] = sickConfig.CountryCode
  7683. data["time_stamp"] = time_stamp
  7684. data["cainfo"] = miConfig.Cainfo
  7685. var ids []int64
  7686. for _, item := range prescriptions {
  7687. ids = append(ids, item.ID)
  7688. }
  7689. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7690. if config.IsOpen == 1 { //对接了医保,走医保流程
  7691. var res ResultFour
  7692. var resFour10265 ResultFour10265
  7693. if miConfig.MdtrtareaAdmvs == "421300" {
  7694. bytesData, _ := json.Marshal(data)
  7695. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7696. resp, _ := client.Do(req)
  7697. defer resp.Body.Close()
  7698. body, ioErr := ioutil.ReadAll(resp.Body)
  7699. if ioErr != nil {
  7700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7702. return
  7703. }
  7704. var respJSON map[string]interface{}
  7705. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7708. return
  7709. }
  7710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7711. userJSONBytes, _ := json.Marshal(respJSON)
  7712. fmt.Println("log")
  7713. fmt.Println(string(userJSONBytes))
  7714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7715. utils.ErrorLog("解析失败:%v", err)
  7716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7717. return
  7718. }
  7719. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7720. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7721. if result3101.Infcode == "0" {
  7722. if len(result3101.Output.Result) > 0 {
  7723. var errMsgs []string
  7724. for _, item := range result3101.Output.Result {
  7725. errMsgs = append(errMsgs, item.VolaCont)
  7726. }
  7727. c.ServeSuccessJSON(map[string]interface{}{
  7728. "failed_code": -10,
  7729. "msg": errMsgs,
  7730. })
  7731. return
  7732. } else {
  7733. bytesData, _ := json.Marshal(data)
  7734. var req *http.Request
  7735. if miConfig.MdtrtareaAdmvs == "320921" {
  7736. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7737. } else {
  7738. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7739. }
  7740. resp, _ := client.Do(req)
  7741. defer resp.Body.Close()
  7742. body, ioErr := ioutil.ReadAll(resp.Body)
  7743. if ioErr != nil {
  7744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7746. return
  7747. }
  7748. var respJSON map[string]interface{}
  7749. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. return
  7753. }
  7754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7755. userJSONBytes, _ := json.Marshal(respJSON)
  7756. fmt.Println("log")
  7757. fmt.Println(string(userJSONBytes))
  7758. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7759. utils.ErrorLog("解析失败:%v", err)
  7760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7761. return
  7762. }
  7763. res.InfRefmsgid = resFour10265.InfRefmsgid
  7764. res.Output = resFour10265.Output
  7765. res.ErrMsg = resFour10265.ErrMsg
  7766. res.Cainfo = resFour10265.Cainfo
  7767. res.WarnMsg = resFour10265.WarnMsg
  7768. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7769. res.Infcode = infocode
  7770. }
  7771. }
  7772. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7773. 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)
  7774. var dat map[string]interface{}
  7775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7776. fmt.Println(dat)
  7777. } else {
  7778. fmt.Println(err)
  7779. }
  7780. saveLog(result, request_log, "2204", "上传费用明细")
  7781. userJSONBytes, _ := json.Marshal(dat)
  7782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7783. utils.ErrorLog("解析失败:%v", err)
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. return
  7786. }
  7787. } else {
  7788. if miConfig.Code == "H15049901371" {
  7789. 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)
  7790. var dat map[string]interface{}
  7791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7792. fmt.Println(dat)
  7793. } else {
  7794. fmt.Println(err)
  7795. }
  7796. saveLog(result, request_log, "2204", "上传费用明细")
  7797. userJSONBytes, _ := json.Marshal(dat)
  7798. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7799. utils.ErrorLog("解析失败:%v", err)
  7800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7801. return
  7802. }
  7803. res.InfRefmsgid = resFour10265.InfRefmsgid
  7804. res.Output = resFour10265.Output
  7805. res.ErrMsg = resFour10265.ErrMsg
  7806. res.Cainfo = resFour10265.Cainfo
  7807. res.WarnMsg = resFour10265.WarnMsg
  7808. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7809. res.Infcode = infocode
  7810. } else {
  7811. 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)
  7812. var dat map[string]interface{}
  7813. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7814. fmt.Println(dat)
  7815. } else {
  7816. fmt.Println(err)
  7817. }
  7818. saveLog(result, request_log, "2204", "上传费用明细")
  7819. userJSONBytes, _ := json.Marshal(dat)
  7820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7821. utils.ErrorLog("解析失败:%v", err)
  7822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7823. return
  7824. }
  7825. }
  7826. }
  7827. if res.Infcode == 0 {
  7828. order := &models.HisOrder{
  7829. UserOrgId: adminUser.CurrentOrgId,
  7830. HisPatientId: his.ID,
  7831. PatientId: his.PatientId,
  7832. SettleAccountsDate: recordDateTime,
  7833. Ctime: time.Now().Unix(),
  7834. Mtime: time.Now().Unix(),
  7835. MdtrtId: his.Number,
  7836. PsnNo: his.PsnNo,
  7837. MedType: strconv.FormatInt(reg_type, 10),
  7838. Status: 1,
  7839. Number: chrg_bchno,
  7840. Infcode: res.Infcode,
  7841. WarnMsg: res.WarnMsg,
  7842. Cainfo: res.Cainfo,
  7843. ErrMsg: res.ErrMsg,
  7844. RespondTime: res.RefmsgTime,
  7845. InfRefmsgid: res.InfRefmsgid,
  7846. OrderStatus: 1,
  7847. IsMedicineInsurance: 1,
  7848. SettleType: settle_accounts_type,
  7849. SettleStartTime: start_time,
  7850. SettleEndTime: end_time,
  7851. Creator: roles.AdminUserId,
  7852. Modify: roles.AdminUserId,
  7853. PType: 2,
  7854. Diagnosis: diagnosis_id,
  7855. }
  7856. err = service.CreateOrder(order)
  7857. if err != nil {
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7859. return
  7860. }
  7861. for _, item := range res.Output.Result {
  7862. temp := strings.Split(item.FeedetlSn, "-")
  7863. var advice_id int64 = 0
  7864. var project_id int64 = 0
  7865. var types int64 = 0
  7866. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7867. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7868. if temp[1] == "1" {
  7869. advice_id = id
  7870. project_id = 0
  7871. } else if temp[1] == "2" {
  7872. advice_id = 0
  7873. project_id = id
  7874. }
  7875. info := &models.HisOrderInfo{
  7876. OrderNumber: order.Number,
  7877. FeedetlSn: item.FeedetlSn,
  7878. UploadDate: time.Now().Unix(),
  7879. AdviceId: advice_id,
  7880. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7881. Cnt: item.Cnt,
  7882. Pric: float64(item.Pric),
  7883. PatientId: his.PatientId,
  7884. PricUplmtAmt: item.PricUplmtAmt,
  7885. SelfpayProp: item.SelfpayProp,
  7886. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7887. OverlmtAmt: item.OverlmtAmt,
  7888. PreselfpayAmt: item.PreselfpayAmt,
  7889. BasMednFlag: item.BasMednFlag,
  7890. MedChrgitmType: item.MedChrgitmType,
  7891. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7892. Status: 1,
  7893. Memo: item.Memo,
  7894. Mtime: time.Now().Unix(),
  7895. InscpScpAmt: item.InscpScpAmt,
  7896. DrtReimFlag: item.DrtReimFlag,
  7897. Ctime: time.Now().Unix(),
  7898. ListSpItemFlag: item.ListSpItemFlag,
  7899. ChldMedcFlag: item.ChldMedcFlag,
  7900. LmtUsedFlag: item.LmtUsedFlag,
  7901. ChrgitmLv: item.ChrgitmLv,
  7902. UserOrgId: adminUser.CurrentOrgId,
  7903. HisPatientId: his.ID,
  7904. OrderId: order.ID,
  7905. ProjectId: project_id,
  7906. Type: types,
  7907. }
  7908. service.CreateOrderInfo(info)
  7909. }
  7910. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7911. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7912. var total float64
  7913. for _, item := range prescriptions {
  7914. if item.Type == 1 { //药品
  7915. for _, subItem := range item.HisDoctorAdviceInfo {
  7916. total = total + (subItem.Price * subItem.PrescribingNumber)
  7917. }
  7918. }
  7919. if item.Type == 2 { //项目
  7920. for _, subItem := range item.HisPrescriptionProject {
  7921. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7922. total = total + (subItem.Price * cnt)
  7923. }
  7924. }
  7925. }
  7926. for _, item := range prescriptions {
  7927. for _, subItem := range item.HisAdditionalCharge {
  7928. total = total + (subItem.Price * float64(subItem.Count))
  7929. }
  7930. }
  7931. allTotal := fmt.Sprintf("%.4f", total)
  7932. if res.Infcode == 0 {
  7933. var rf []*ResultFive
  7934. json.Unmarshal([]byte(his.Iinfo), &rf)
  7935. chrg_bchno := chrg_bchno
  7936. cert_no := his.Certno
  7937. var insutypes []string
  7938. var insutype string
  7939. var is390 int = 0
  7940. var is310 int = 0
  7941. for _, item := range rf {
  7942. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7943. insutypes = append(insutypes, item.Insutype)
  7944. }
  7945. }
  7946. if len(insutypes) == 1 {
  7947. insutype = insutypes[0]
  7948. } else {
  7949. for _, i := range insutypes {
  7950. if i == "390" {
  7951. is390 = 1
  7952. }
  7953. if i == "310" {
  7954. is310 = 1
  7955. }
  7956. }
  7957. }
  7958. if is390 == 1 {
  7959. insutype = "390"
  7960. }
  7961. if is310 == 1 {
  7962. insutype = "310"
  7963. }
  7964. if len(insutypes) == 0 {
  7965. insutype = "310"
  7966. }
  7967. if len(insutypes) == 2 {
  7968. insutype = strconv.FormatInt(his.SocialType, 64)
  7969. }
  7970. //insutype = "390"
  7971. if his.IdCardType == 1 {
  7972. cert_no = his.MedicalInsuranceNumber
  7973. } else {
  7974. cert_no = his.Certno
  7975. }
  7976. var res ResultSeven
  7977. var resSeven10265 ResultSeven10265
  7978. if miConfig.MdtrtareaAdmvs == "421300" {
  7979. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7980. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7981. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7983. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7984. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7985. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7986. resp, requestErr := http.Get(api)
  7987. if requestErr != nil {
  7988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7989. return
  7990. }
  7991. body, ioErr := ioutil.ReadAll(resp.Body)
  7992. if ioErr != nil {
  7993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7995. return
  7996. }
  7997. var respJSON map[string]interface{}
  7998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. return
  8002. }
  8003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8004. result, _ := json.Marshal(respJSON)
  8005. fmt.Println("log")
  8006. fmt.Println(string(result))
  8007. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8008. utils.ErrorLog("解析失败:%v", err)
  8009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8010. return
  8011. }
  8012. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8013. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  8014. if result3101.Infcode == "0" {
  8015. if len(result3101.Output.Result) > 0 {
  8016. var errMsgs []string
  8017. for _, item := range result3101.Output.Result {
  8018. errMsgs = append(errMsgs, item.VolaCont)
  8019. }
  8020. c.ServeSuccessJSON(map[string]interface{}{
  8021. "failed_code": -10,
  8022. "msg": errMsgs,
  8023. })
  8024. return
  8025. } else {
  8026. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8027. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8028. bas := strings.Split(psn_info.CardInfo, "|")
  8029. if his.IdCardType == 1 {
  8030. cert_no = bas[2]
  8031. } else {
  8032. cert_no = bas[1]
  8033. }
  8034. //江苏地区国家医保医疗类别
  8035. //职工透析:医疗类别选特殊情况门诊9933
  8036. //居民血透门慢: 医疗类别选门诊慢病1402
  8037. //var med_type string
  8038. //if his.Insutype == "310" {
  8039. // if reg_type == 14 {
  8040. // med_type = "9933"
  8041. // } else if reg_type == 11 {
  8042. // med_type = "11"
  8043. //
  8044. // }
  8045. //} else if his.Insutype == "390" {
  8046. // if reg_type == 14 {
  8047. // med_type = "1402"
  8048. // } else if reg_type == 11 {
  8049. // med_type = "11"
  8050. // }
  8051. //}
  8052. var api string
  8053. if miConfig.MdtrtareaAdmvs == "320921" {
  8054. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8055. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8056. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8057. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8058. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8059. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8060. "&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
  8061. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8062. } else {
  8063. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8064. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8065. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8066. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8067. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8068. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8069. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8070. "&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
  8071. }
  8072. resp, requestErr := http.Get(api)
  8073. if requestErr != nil {
  8074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. return
  8076. }
  8077. body, ioErr := ioutil.ReadAll(resp.Body)
  8078. if ioErr != nil {
  8079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. return
  8082. }
  8083. var respJSON map[string]interface{}
  8084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8090. result, _ := json.Marshal(respJSON)
  8091. fmt.Println("log")
  8092. fmt.Println(string(result))
  8093. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8094. utils.ErrorLog("解析失败:%v", err)
  8095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8096. return
  8097. }
  8098. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8099. res.Output = resSeven10265.Output
  8100. res.ErrMsg = resSeven10265.ErrMsg
  8101. res.Cainfo = resSeven10265.Cainfo
  8102. res.WarnMsg = resSeven10265.WarnMsg
  8103. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8104. res.Infcode = infocode
  8105. }
  8106. }
  8107. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8108. 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)
  8109. var dat map[string]interface{}
  8110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8111. fmt.Println(dat)
  8112. } else {
  8113. fmt.Println(err)
  8114. }
  8115. saveLog(result, request_log, "2206", "预结算")
  8116. userJSONBytes, _ := json.Marshal(dat)
  8117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8118. utils.ErrorLog("解析失败:%v", err)
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8120. return
  8121. }
  8122. } else {
  8123. var result string
  8124. var request_log string
  8125. if miConfig.Code == "H15049901371" {
  8126. //赤峰地区国家医保医疗类别
  8127. //职工透析:医疗类别选特殊情况门诊990502
  8128. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8129. var med_type string
  8130. if his.Insutype == "390" {
  8131. if reg_type == 14 {
  8132. med_type = "9933"
  8133. } else if reg_type == 11 {
  8134. med_type = "11"
  8135. }
  8136. } else if his.Insutype == "310" {
  8137. if reg_type == 14 {
  8138. med_type = "990502"
  8139. } else if reg_type == 11 {
  8140. med_type = "11"
  8141. }
  8142. }
  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, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  8144. } else {
  8145. 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)
  8146. }
  8147. var dat map[string]interface{}
  8148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8149. fmt.Println(dat)
  8150. } else {
  8151. fmt.Println(err)
  8152. }
  8153. saveLog(result, request_log, "2206", "预结算")
  8154. //userJSONBytes, _ := json.Marshal(dat)
  8155. //
  8156. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8157. // utils.ErrorLog("解析失败:%v", err)
  8158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8159. // return
  8160. //}
  8161. userJSONBytes, _ := json.Marshal(dat)
  8162. if miConfig.Code == "H15049901371" {
  8163. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8164. utils.ErrorLog("解析失败:%v", err)
  8165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8166. return
  8167. }
  8168. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8169. res.Output = resSeven10265.Output
  8170. res.ErrMsg = resSeven10265.ErrMsg
  8171. res.Cainfo = resSeven10265.Cainfo
  8172. res.WarnMsg = resSeven10265.WarnMsg
  8173. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8174. res.Infcode = infocode
  8175. } else {
  8176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8177. utils.ErrorLog("解析失败:%v", err)
  8178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8179. return
  8180. }
  8181. }
  8182. }
  8183. if res.Infcode != 0 {
  8184. errlog := &models.HisOrderError{
  8185. UserOrgId: adminUser.CurrentOrgId,
  8186. Ctime: time.Now().Unix(),
  8187. Mtime: time.Now().Unix(),
  8188. Number: chrg_bchno,
  8189. ErrMsg: res.ErrMsg,
  8190. Status: 1,
  8191. PatientId: id,
  8192. RecordTime: recordDateTime,
  8193. Stage: 20,
  8194. }
  8195. service.CreateErrMsgLog(errlog)
  8196. c.ServeSuccessJSON(map[string]interface{}{
  8197. "failed_code": -10,
  8198. "msg": res.ErrMsg,
  8199. })
  8200. return
  8201. } else {
  8202. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8203. order.OrderStatus = 1
  8204. order.IsPre = 1
  8205. order.Status = 1
  8206. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8207. order.SetlId = res.Output.Setlinfo.SetlID
  8208. order.PsnNo = res.Output.Setlinfo.PsnNo
  8209. order.PsnName = res.Output.Setlinfo.PsnName
  8210. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8211. order.Certno = res.Output.Setlinfo.Certno
  8212. order.Gend = res.Output.Setlinfo.Gend
  8213. order.Naty = res.Output.Setlinfo.Naty
  8214. order.Age = res.Output.Setlinfo.Age
  8215. order.Insutype = res.Output.Setlinfo.Insutype
  8216. order.PsnType = res.Output.Setlinfo.PsnType
  8217. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8218. order.SetlTime = res.Output.Setlinfo.SetlTime
  8219. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8220. if res.Output.Setlinfo.MedType == "140101" {
  8221. order.MedType = "14"
  8222. } else {
  8223. order.MedType = res.Output.Setlinfo.MedType
  8224. }
  8225. if reg_type == 1112 {
  8226. order.MedType = "1112"
  8227. }
  8228. if reg_type == 1111 {
  8229. order.MedType = "1111"
  8230. }
  8231. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8232. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8233. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8234. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8235. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8236. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8237. order.HifpPay = res.Output.Setlinfo.HifpPay
  8238. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8239. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8240. order.HifesPay = res.Output.Setlinfo.HifesPay
  8241. order.HifobPay = res.Output.Setlinfo.HifobPay
  8242. order.MafPay = res.Output.Setlinfo.MafPay
  8243. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8244. order.OthPay = res.Output.Setlinfo.OthPay
  8245. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8246. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8247. order.AcctPay = res.Output.Setlinfo.AcctPay
  8248. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8249. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8250. order.Balc = res.Output.Setlinfo.Balc
  8251. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8252. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8253. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8254. order.ClrWay = res.Output.Setlinfo.ClrWay
  8255. order.Creator = order.Creator
  8256. order.Modify = roles.AdminUserId
  8257. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8258. detailStr := string(setlDetail)
  8259. order.SetlDetail = detailStr
  8260. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8261. err = service.UpDateOrder(order)
  8262. if err == nil {
  8263. c.ServeSuccessJSON(map[string]interface{}{
  8264. "msg": "预结算成功",
  8265. })
  8266. } else {
  8267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8268. return
  8269. }
  8270. }
  8271. } else {
  8272. adminUser := c.GetAdminUserInfo()
  8273. errlog := &models.HisOrderError{
  8274. UserOrgId: adminUser.CurrentOrgId,
  8275. Ctime: time.Now().Unix(),
  8276. Mtime: time.Now().Unix(),
  8277. ErrMsg: res.ErrMsg,
  8278. Status: 1,
  8279. PatientId: id,
  8280. RecordTime: recordDateTime,
  8281. Stage: 4,
  8282. }
  8283. service.CreateErrMsgLog(errlog)
  8284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8285. return
  8286. }
  8287. } else {
  8288. adminUser := c.GetAdminUserInfo()
  8289. errlog := &models.HisOrderError{
  8290. UserOrgId: adminUser.CurrentOrgId,
  8291. Ctime: time.Now().Unix(),
  8292. Mtime: time.Now().Unix(),
  8293. ErrMsg: res.ErrMsg,
  8294. Status: 1,
  8295. PatientId: id,
  8296. RecordTime: recordDateTime,
  8297. Stage: 4,
  8298. }
  8299. service.CreateErrMsgLog(errlog)
  8300. c.ServeSuccessJSON(map[string]interface{}{
  8301. "failed_code": -10,
  8302. "msg": res.ErrMsg,
  8303. })
  8304. return
  8305. }
  8306. }
  8307. }
  8308. }
  8309. //退款
  8310. func (c *HisApiController) Refund() {
  8311. order_id, _ := c.GetInt64("order_id")
  8312. admin_user_id, _ := c.GetInt64("admin_user_id")
  8313. adminUser := c.GetAdminUserInfo()
  8314. var order models.HisOrder
  8315. order, _ = service.GetHisOrderByID(order_id)
  8316. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8317. if order.ID == 0 {
  8318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8319. return
  8320. }
  8321. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8322. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8323. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8324. if config.IsOpen == 1 { //对接了医保,走医保流程
  8325. var res ResultSixteen
  8326. var resSixteen10265 ResultSixteen10265
  8327. var src_resquest string
  8328. var result string
  8329. if miConfig.MdtrtareaAdmvs == "421300" {
  8330. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8331. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8332. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8333. resp3, requestErr3 := http.Get(api3)
  8334. if requestErr3 != nil {
  8335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8336. return
  8337. }
  8338. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8339. if ioErr3 != nil {
  8340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8342. return
  8343. }
  8344. var respJSON3 map[string]interface{}
  8345. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8348. return
  8349. }
  8350. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8351. userJSONBytes3, _ := json.Marshal(respJSON3)
  8352. fmt.Println("log")
  8353. fmt.Println(string(userJSONBytes3))
  8354. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8355. utils.ErrorLog("解析失败:%v", err)
  8356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8357. return
  8358. }
  8359. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8360. var api3 string
  8361. if miConfig.MdtrtareaAdmvs == "320921" {
  8362. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8363. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8364. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8365. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8366. } else {
  8367. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8368. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8369. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8370. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8371. }
  8372. resp3, requestErr3 := http.Get(api3)
  8373. if requestErr3 != nil {
  8374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8375. return
  8376. }
  8377. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8378. if ioErr3 != nil {
  8379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8381. return
  8382. }
  8383. var respJSON3 map[string]interface{}
  8384. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8387. return
  8388. }
  8389. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8390. userJSONBytes3, _ := json.Marshal(respJSON3)
  8391. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8392. utils.ErrorLog("解析失败:%v", err)
  8393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8394. return
  8395. }
  8396. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8397. res.Output = resSixteen10265.Output
  8398. res.ErrMsg = resSixteen10265.ErrMsg
  8399. res.Cainfo = resSixteen10265.Cainfo
  8400. res.WarnMsg = resSixteen10265.WarnMsg
  8401. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8402. res.Infcode = infocode
  8403. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8404. 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)
  8405. var dat map[string]interface{}
  8406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8407. fmt.Println(dat)
  8408. } else {
  8409. fmt.Println(err)
  8410. }
  8411. saveLog(result, src_resquest, "2208", "退费")
  8412. userJSONBytes, _ := json.Marshal(dat)
  8413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8414. utils.ErrorLog("解析失败:%v", err)
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. } else {
  8419. if miConfig.Code == "H15049901371" {
  8420. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8421. var dat map[string]interface{}
  8422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8423. fmt.Println(dat)
  8424. } else {
  8425. fmt.Println(err)
  8426. }
  8427. saveLog(result, src_resquest, "2208", "退费")
  8428. userJSONBytes, _ := json.Marshal(dat)
  8429. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8430. utils.ErrorLog("解析失败:%v", err)
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8435. res.Output = resSixteen10265.Output
  8436. res.ErrMsg = resSixteen10265.ErrMsg
  8437. res.Cainfo = resSixteen10265.Cainfo
  8438. res.WarnMsg = resSixteen10265.WarnMsg
  8439. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8440. res.Infcode = infocode
  8441. } else {
  8442. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8443. var dat map[string]interface{}
  8444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8445. fmt.Println(dat)
  8446. } else {
  8447. fmt.Println(err)
  8448. }
  8449. saveLog(result, src_resquest, "2208", "退费")
  8450. userJSONBytes, _ := json.Marshal(dat)
  8451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8452. utils.ErrorLog("解析失败:%v", err)
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8454. return
  8455. }
  8456. }
  8457. }
  8458. if res.Infcode == 0 {
  8459. var res2 ResultSix
  8460. var resSix10265 ResultSix10265
  8461. if miConfig.MdtrtareaAdmvs == "421300" {
  8462. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8463. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8464. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8465. resp3, requestErr3 := http.Get(api3)
  8466. if requestErr3 != nil {
  8467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8468. return
  8469. }
  8470. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8471. if ioErr3 != nil {
  8472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8474. return
  8475. }
  8476. var respJSON3 map[string]interface{}
  8477. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8480. return
  8481. }
  8482. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8483. userJSONBytes3, _ := json.Marshal(respJSON3)
  8484. fmt.Println("log")
  8485. fmt.Println(string(userJSONBytes3))
  8486. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8487. utils.ErrorLog("解析失败:%v", err)
  8488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8489. return
  8490. }
  8491. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8492. var api3 string
  8493. if miConfig.MdtrtareaAdmvs == "320921" {
  8494. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8495. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8496. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8497. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8498. } else {
  8499. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8500. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8501. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8503. }
  8504. resp3, requestErr3 := http.Get(api3)
  8505. if requestErr3 != nil {
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8507. return
  8508. }
  8509. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8510. if ioErr3 != nil {
  8511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8513. return
  8514. }
  8515. var respJSON3 map[string]interface{}
  8516. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8522. userJSONBytes3, _ := json.Marshal(respJSON3)
  8523. fmt.Println("log")
  8524. fmt.Println(string(userJSONBytes3))
  8525. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8526. utils.ErrorLog("解析失败:%v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8531. res2.Output = resSix10265.Output
  8532. res2.ErrMsg = resSix10265.ErrMsg
  8533. res2.Cainfo = resSix10265.Cainfo
  8534. res2.WarnMsg = resSix10265.WarnMsg
  8535. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8536. res2.Infcode = infocode
  8537. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8538. 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)
  8539. var dat map[string]interface{}
  8540. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8541. fmt.Println(dat)
  8542. } else {
  8543. fmt.Println(err)
  8544. }
  8545. saveLog(result2, src_request, "2205", "撤销明细")
  8546. userJSONBytes, _ := json.Marshal(dat)
  8547. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8548. utils.ErrorLog("解析失败:%v", err)
  8549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8550. return
  8551. }
  8552. } else {
  8553. if miConfig.Code == "H15049901371" {
  8554. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8555. var dat map[string]interface{}
  8556. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8557. fmt.Println(dat)
  8558. } else {
  8559. fmt.Println(err)
  8560. }
  8561. saveLog(result2, src_request, "2205", "撤销明细")
  8562. userJSONBytes, _ := json.Marshal(dat)
  8563. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8564. utils.ErrorLog("解析失败:%v", err)
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8569. res2.Output = resSix10265.Output
  8570. res2.ErrMsg = resSix10265.ErrMsg
  8571. res2.Cainfo = resSix10265.Cainfo
  8572. res2.WarnMsg = resSix10265.WarnMsg
  8573. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8574. res2.Infcode = infocode
  8575. } else {
  8576. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8577. var dat map[string]interface{}
  8578. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8579. fmt.Println(dat)
  8580. } else {
  8581. fmt.Println(err)
  8582. }
  8583. saveLog(result2, src_request, "2205", "撤销明细")
  8584. userJSONBytes, _ := json.Marshal(dat)
  8585. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8586. utils.ErrorLog("解析失败:%v", err)
  8587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8588. return
  8589. }
  8590. }
  8591. }
  8592. if res2.Infcode == 0 {
  8593. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8594. if err == nil {
  8595. //当押金不为零时产生退费记录
  8596. if order.Decimal != 0 {
  8597. tmp := strconv.FormatInt(order.ID, 10)
  8598. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8599. if err != nil {
  8600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8601. return
  8602. }
  8603. }
  8604. c.ServeSuccessJSON(map[string]interface{}{
  8605. "msg": "退费成功",
  8606. })
  8607. } else {
  8608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8609. return
  8610. }
  8611. } else {
  8612. c.ServeSuccessJSON(map[string]interface{}{
  8613. "code": -10,
  8614. "msg": res2.ErrMsg,
  8615. })
  8616. }
  8617. } else {
  8618. c.ServeSuccessJSON(map[string]interface{}{
  8619. "code": -10,
  8620. "msg": res.ErrMsg,
  8621. })
  8622. }
  8623. }
  8624. }
  8625. func (c *HisApiController) RefundNumber() {
  8626. record_time := c.GetString("record_time")
  8627. //patient_id, _ := c.GetInt64("patient_id")
  8628. admin_user_id, _ := c.GetInt64("admin_user_id")
  8629. his_patient_id, _ := c.GetInt64("id")
  8630. timeLayout := "2006-01-02"
  8631. loc, _ := time.LoadLocation("Local")
  8632. adminUser := c.GetAdminUserInfo()
  8633. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8634. fmt.Println(err)
  8635. if err != nil {
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8637. return
  8638. }
  8639. recordDateTime := theTime.Unix()
  8640. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8641. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8642. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8643. //order, _ := service.GetHisOrderByID(order_id)
  8644. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8645. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8646. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8647. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8648. if count > 0 {
  8649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8650. return
  8651. }
  8652. if config.IsOpen == 1 { //对接了医保,走医保流程
  8653. var res2 ResultSix
  8654. var resSix10265 ResultSix10265
  8655. if miConfig.MdtrtareaAdmvs == "421300" {
  8656. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8657. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8658. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8659. resp3, requestErr3 := http.Get(api3)
  8660. if requestErr3 != nil {
  8661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8662. return
  8663. }
  8664. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8665. if ioErr3 != nil {
  8666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8668. return
  8669. }
  8670. var respJSON3 map[string]interface{}
  8671. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8674. return
  8675. }
  8676. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8677. userJSONBytes3, _ := json.Marshal(respJSON3)
  8678. fmt.Println("log")
  8679. fmt.Println(string(userJSONBytes3))
  8680. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8681. utils.ErrorLog("解析失败:%v", err)
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8686. var api3 string
  8687. if miConfig.MdtrtareaAdmvs == "320921" {
  8688. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8689. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8690. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8691. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8692. } else {
  8693. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8694. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8695. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8697. }
  8698. resp3, requestErr3 := http.Get(api3)
  8699. if requestErr3 != nil {
  8700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8701. return
  8702. }
  8703. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8704. if ioErr3 != nil {
  8705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8707. return
  8708. }
  8709. var respJSON3 map[string]interface{}
  8710. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8713. return
  8714. }
  8715. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8716. userJSONBytes3, _ := json.Marshal(respJSON3)
  8717. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8718. utils.ErrorLog("解析失败:%v", err)
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8720. return
  8721. }
  8722. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8723. res2.Output = resSix10265.Output
  8724. res2.ErrMsg = resSix10265.ErrMsg
  8725. res2.Cainfo = resSix10265.Cainfo
  8726. res2.WarnMsg = resSix10265.WarnMsg
  8727. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8728. res2.Infcode = infocode
  8729. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8730. 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)
  8731. var dat map[string]interface{}
  8732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8733. fmt.Println(dat)
  8734. } else {
  8735. fmt.Println(err)
  8736. }
  8737. saveLog(result, request, "2202", "退号")
  8738. userJSONBytes, _ := json.Marshal(dat)
  8739. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8740. utils.ErrorLog("解析失败:%v", err)
  8741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8742. return
  8743. }
  8744. } else {
  8745. var api3 string
  8746. if miConfig.Code == "H15049901371" {
  8747. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8748. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8749. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8750. } else {
  8751. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8752. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8753. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8754. }
  8755. resp3, requestErr3 := http.Get(api3)
  8756. if requestErr3 != nil {
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8761. if ioErr3 != nil {
  8762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8764. return
  8765. }
  8766. var respJSON3 map[string]interface{}
  8767. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. return
  8771. }
  8772. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8773. userJSONBytes3, _ := json.Marshal(respJSON3)
  8774. if miConfig.Code == "H15049901371" {
  8775. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8776. utils.ErrorLog("解析失败:%v", err)
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8778. return
  8779. }
  8780. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8781. res2.Output = resSix10265.Output
  8782. res2.ErrMsg = resSix10265.ErrMsg
  8783. res2.Cainfo = resSix10265.Cainfo
  8784. res2.WarnMsg = resSix10265.WarnMsg
  8785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8786. res2.Infcode = infocode
  8787. } else {
  8788. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8789. utils.ErrorLog("解析失败:%v", err)
  8790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8791. return
  8792. }
  8793. }
  8794. }
  8795. if res2.Infcode == 0 {
  8796. if err == nil {
  8797. c.ServeSuccessJSON(map[string]interface{}{
  8798. "msg": "退号成功",
  8799. })
  8800. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8801. } else {
  8802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8803. return
  8804. }
  8805. } else {
  8806. c.ServeSuccessJSON(map[string]interface{}{
  8807. "code": -10,
  8808. "msg": res2.ErrMsg,
  8809. })
  8810. }
  8811. } else {
  8812. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8813. //if err == nil {
  8814. // c.ServeSuccessJSON(map[string]interface{}{
  8815. // "msg": "退费成功",
  8816. // })
  8817. //} else {
  8818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8819. // return
  8820. //}
  8821. }
  8822. }
  8823. func (c *HisApiController) RefundDetail() {
  8824. order_id, _ := c.GetInt64("order_id")
  8825. admin_user_id, _ := c.GetInt64("admin_user_id")
  8826. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8827. number := c.GetString("number")
  8828. record_time := c.GetString("record_time")
  8829. patient_id, _ := c.GetInt64("patient_id")
  8830. //med_type, _ := c.GetInt64("med_type")
  8831. timeLayout := "2006-01-02"
  8832. loc, _ := time.LoadLocation("Local")
  8833. adminUser := c.GetAdminUserInfo()
  8834. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8835. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8836. fmt.Println(err)
  8837. if err != nil {
  8838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8839. return
  8840. }
  8841. recordDateTime := theTime.Unix()
  8842. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8843. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8844. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8845. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8846. var order models.HisOrder
  8847. order, _ = service.GetHisOrderByID(order_id)
  8848. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8849. if config.IsOpen == 1 { //对接了医保,走医保流程
  8850. var res2 ResultSix
  8851. if miConfig.MdtrtareaAdmvs == "421300" {
  8852. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8853. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8854. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8855. resp3, requestErr3 := http.Get(api3)
  8856. if requestErr3 != nil {
  8857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8858. return
  8859. }
  8860. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8861. if ioErr3 != nil {
  8862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8864. return
  8865. }
  8866. var respJSON3 map[string]interface{}
  8867. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8870. return
  8871. }
  8872. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8873. userJSONBytes3, _ := json.Marshal(respJSON3)
  8874. fmt.Println("log")
  8875. fmt.Println(string(userJSONBytes3))
  8876. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8877. utils.ErrorLog("解析失败:%v", err)
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8879. return
  8880. }
  8881. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8882. if err == nil {
  8883. c.ServeSuccessJSON(map[string]interface{}{
  8884. "msg": "撤销明细成功",
  8885. })
  8886. return
  8887. } else {
  8888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8889. return
  8890. }
  8891. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8892. var resSix10265 ResultSix10265
  8893. var api3 string
  8894. if miConfig.MdtrtareaAdmvs == "320921" {
  8895. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8896. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8898. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8899. } else {
  8900. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8901. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8902. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8903. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8904. }
  8905. resp3, requestErr3 := http.Get(api3)
  8906. if requestErr3 != nil {
  8907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8908. return
  8909. }
  8910. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8911. if ioErr3 != nil {
  8912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8914. return
  8915. }
  8916. var respJSON3 map[string]interface{}
  8917. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8920. return
  8921. }
  8922. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8923. userJSONBytes3, _ := json.Marshal(respJSON3)
  8924. fmt.Println("log")
  8925. fmt.Println(string(userJSONBytes3))
  8926. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8927. utils.ErrorLog("解析失败:%v", err)
  8928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8929. return
  8930. }
  8931. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8932. res2.Output = resSix10265.Output
  8933. res2.ErrMsg = resSix10265.ErrMsg
  8934. res2.Cainfo = resSix10265.Cainfo
  8935. res2.WarnMsg = resSix10265.WarnMsg
  8936. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8937. res2.Infcode = infocode
  8938. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8939. if err == nil {
  8940. c.ServeSuccessJSON(map[string]interface{}{
  8941. "msg": "撤销明细成功",
  8942. })
  8943. return
  8944. } else {
  8945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8946. return
  8947. }
  8948. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8949. 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)
  8950. var dat map[string]interface{}
  8951. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8952. fmt.Println(dat)
  8953. } else {
  8954. fmt.Println(err)
  8955. }
  8956. saveLog(result2, src_request, "2205", "撤销明细")
  8957. userJSONBytes, _ := json.Marshal(dat)
  8958. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8959. utils.ErrorLog("解析失败:%v", err)
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8961. return
  8962. }
  8963. if res2.Infcode == 0 {
  8964. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8965. if err == nil {
  8966. c.ServeSuccessJSON(map[string]interface{}{
  8967. "msg": "撤销明细成功",
  8968. })
  8969. return
  8970. } else {
  8971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8972. return
  8973. }
  8974. } else {
  8975. c.ServeSuccessJSON(map[string]interface{}{
  8976. "code": -10,
  8977. "msg": res2.ErrMsg,
  8978. })
  8979. }
  8980. } else {
  8981. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8982. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8983. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8984. resp2, requestErr2 := http.Get(api2)
  8985. if requestErr2 != nil {
  8986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8987. return
  8988. }
  8989. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8990. if ioErr2 != nil {
  8991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8993. return
  8994. }
  8995. var respJSON2 map[string]interface{}
  8996. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8999. return
  9000. }
  9001. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9002. if err == nil {
  9003. c.ServeSuccessJSON(map[string]interface{}{
  9004. "msg": "撤销明细成功",
  9005. })
  9006. return
  9007. } else {
  9008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9009. return
  9010. }
  9011. }
  9012. } else {
  9013. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  9014. if err == nil {
  9015. c.ServeSuccessJSON(map[string]interface{}{
  9016. "msg": "退费成功",
  9017. })
  9018. } else {
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9020. return
  9021. }
  9022. }
  9023. }
  9024. //对账
  9025. func (c *HisApiController) GetCheckAccount() {
  9026. start_time := c.GetString("start_time")
  9027. end_time := c.GetString("end_time")
  9028. insutype := c.GetString("insutype")
  9029. clr_type := c.GetString("clr_type")
  9030. clr_org := c.GetString("clr_optins")
  9031. admin_user_id, _ := c.GetInt64("admin_user_id")
  9032. adminUser := c.GetAdminUserInfo()
  9033. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9034. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9035. if len(clr_org) == 0 {
  9036. clr_org = miConfig.MdtrtareaAdmvs
  9037. }
  9038. timeLayout := "2006-01-02"
  9039. loc, _ := time.LoadLocation("Local")
  9040. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9041. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9042. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9043. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9044. fixmedins_setl_cnt := int64(len(orders))
  9045. var medfee_sumamt float64
  9046. var acct_pay float64
  9047. var fund_pay_sumamt float64
  9048. for _, item := range orders {
  9049. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9050. acct_pay = acct_pay + item.AcctPay
  9051. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9052. }
  9053. var user_name string
  9054. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9055. if role.ID == 0 {
  9056. user_name = "xxx"
  9057. } else {
  9058. user_name = role.UserName
  9059. }
  9060. var res ResultEight
  9061. var res10188 ResultEightFor10188
  9062. if config.IsOpen == 1 {
  9063. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9064. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9065. "insutype=" + insutype +
  9066. "&clr_type=" + clr_type +
  9067. "&setl_optins=" + clr_org +
  9068. "&stmt_begndate=" + start_time +
  9069. "&stm_enddate=" + end_time +
  9070. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9071. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9072. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9073. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9074. "&fixmedins_code=" + miConfig.Code +
  9075. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9076. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9077. "&secret_key=" + miConfig.SecretKey +
  9078. "&org_name=" + miConfig.OrgName +
  9079. "&doctor=" + user_name +
  9080. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9081. fmt.Println(api)
  9082. resp, requestErr := http.Get(api)
  9083. if requestErr != nil {
  9084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9085. return
  9086. }
  9087. body, ioErr := ioutil.ReadAll(resp.Body)
  9088. fmt.Println(body)
  9089. if ioErr != nil {
  9090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9092. return
  9093. }
  9094. var respJSON map[string]interface{}
  9095. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9098. return
  9099. }
  9100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9101. userJSONBytes, _ := json.Marshal(respJSON)
  9102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9103. utils.ErrorLog("解析失败:%v", err)
  9104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9105. return
  9106. }
  9107. res.InfRefmsgid = res10188.InfRefmsgid
  9108. res.Output = res10188.Output
  9109. res.ErrMsg = res10188.ErrMsg
  9110. res.Cainfo = res10188.Cainfo
  9111. res.WarnMsg = res10188.WarnMsg
  9112. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9113. res.Infcode = infocode
  9114. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9115. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9116. "insutype=" + insutype +
  9117. "&clr_type=" + "21" +
  9118. "&setl_optins=" + clr_org +
  9119. "&stmt_begndate=" + start_time +
  9120. "&stm_enddate=" + end_time +
  9121. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9122. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9123. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9124. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  9125. "&fixmedins_code=" + miConfig.Code +
  9126. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9127. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9128. "&secret_key=" + miConfig.SecretKey +
  9129. "&org_name=" + miConfig.OrgName +
  9130. "&doctor=" + user_name
  9131. resp, requestErr := http.Get(api)
  9132. if requestErr != nil {
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9134. return
  9135. }
  9136. body, ioErr := ioutil.ReadAll(resp.Body)
  9137. if ioErr != nil {
  9138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9140. return
  9141. }
  9142. var respJSON map[string]interface{}
  9143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9146. return
  9147. }
  9148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9149. result, _ := json.Marshal(respJSON)
  9150. fmt.Println("log")
  9151. fmt.Println(string(result))
  9152. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  9153. utils.ErrorLog("解析失败:%v", err)
  9154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9155. return
  9156. }
  9157. res.InfRefmsgid = res10188.InfRefmsgid
  9158. res.Output = res10188.Output
  9159. res.ErrMsg = res10188.ErrMsg
  9160. res.Cainfo = res10188.Cainfo
  9161. res.WarnMsg = res10188.WarnMsg
  9162. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9163. res.Infcode = infocode
  9164. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9165. var baseParams models.BaseParams
  9166. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9167. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9168. baseParams.SecretKey = miConfig.SecretKey
  9169. baseParams.OrgName = miConfig.OrgName
  9170. baseParams.FixmedinsCode = miConfig.Code
  9171. baseParams.EncKey = miConfig.EncKey
  9172. baseParams.AppSecret = miConfig.AppSecret
  9173. baseParams.SignKey = miConfig.SignKey
  9174. baseParams.AppID = miConfig.Code
  9175. baseParams.Doctor = role.UserName
  9176. baseParams.RequestUrl = miConfig.Url
  9177. businessParams := models.BusinessParams{
  9178. Insutype: insutype,
  9179. ClrType: clr_type,
  9180. SetlOptins: clr_org,
  9181. StmtBegndate: start_time,
  9182. StmtEnddate: end_time,
  9183. MedfeeSumamt: medfee_sumamt,
  9184. FundPaySumamt: fund_pay_sumamt,
  9185. AcctPay: acct_pay,
  9186. FixmedinsSetlCnt: fixmedins_setl_cnt + int64(len(orders_two)*2),
  9187. }
  9188. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams)
  9189. fmt.Println(requestLog)
  9190. fmt.Println(result)
  9191. fmt.Println(err_msg)
  9192. } else {
  9193. if len(clr_type) == 0 {
  9194. clr_type = "11"
  9195. }
  9196. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9197. "insutype=" + insutype +
  9198. "&clr_type=" + clr_type +
  9199. "&setl_optins=" + clr_org +
  9200. "&stmt_begndate=" + start_time +
  9201. "&stm_enddate=" + end_time +
  9202. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9203. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9204. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9205. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9206. "&fixmedins_code=" + miConfig.Code +
  9207. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9208. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9209. "&secret_key=" + miConfig.SecretKey +
  9210. "&org_name=" + miConfig.OrgName +
  9211. "&doctor=" + user_name
  9212. fmt.Println(api)
  9213. resp, requestErr := http.Get(api)
  9214. if requestErr != nil {
  9215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9216. return
  9217. }
  9218. body, ioErr := ioutil.ReadAll(resp.Body)
  9219. fmt.Println(body)
  9220. if ioErr != nil {
  9221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9223. return
  9224. }
  9225. var respJSON map[string]interface{}
  9226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9229. return
  9230. }
  9231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9232. userJSONBytes, _ := json.Marshal(respJSON)
  9233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9234. utils.ErrorLog("解析失败:%v", err)
  9235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9236. return
  9237. }
  9238. }
  9239. if res.Infcode == 0 {
  9240. if res.Output.Stmtinfo.StmtRslt == "0" {
  9241. micc := &models.MedicalInsuranceCostCompare{
  9242. StartTime: startime.Unix(),
  9243. EndTime: endtime.Unix(),
  9244. Insutype: insutype,
  9245. CheckType: 1,
  9246. Num: fixmedins_setl_cnt,
  9247. Mtime: time.Now().Unix(),
  9248. Status: 1,
  9249. UserOrgId: adminUser.CurrentOrgId,
  9250. CostTotal: medfee_sumamt,
  9251. FuncTotal: fund_pay_sumamt,
  9252. PsnPay: acct_pay,
  9253. Creator: admin_user_id,
  9254. Ctime: time.Now().Unix(),
  9255. ClrType: clr_type,
  9256. }
  9257. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9258. if err == nil {
  9259. c.ServeSuccessJSON(map[string]interface{}{
  9260. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9261. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9262. })
  9263. } else {
  9264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9265. }
  9266. } else {
  9267. c.ServeSuccessJSON(map[string]interface{}{
  9268. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9269. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9270. })
  9271. }
  9272. } else {
  9273. c.ServeSuccessJSON(map[string]interface{}{
  9274. "code": -10,
  9275. "msg": res.ErrMsg,
  9276. })
  9277. }
  9278. }
  9279. }
  9280. func (c *HisApiController) Check310() {
  9281. adminUser := c.GetAdminUserInfo()
  9282. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9283. var user_name string
  9284. user_name = "高慧裕"
  9285. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9286. "insutype=" + "310" +
  9287. "&clr_type=" + "" +
  9288. "&setl_optins=" + "441202" +
  9289. "&stmt_begndate=" + "2022-03-01" +
  9290. "&stm_enddate=" + "2022-03-31" +
  9291. "&medfee_sumamt=" + "194930.12" +
  9292. "&fund_pay_sumamt=" + "188741.46" +
  9293. "&acct_pay=" + "0" +
  9294. "&fixmedins_setl_cnt=" + "452" +
  9295. "&fixmedins_code=" + miConfig.Code +
  9296. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9297. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9298. "&secret_key=" + miConfig.SecretKey +
  9299. "&org_name=" + miConfig.OrgName +
  9300. "&doctor=" + user_name
  9301. fmt.Println(api)
  9302. resp, requestErr := http.Get(api)
  9303. if requestErr != nil {
  9304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9305. return
  9306. }
  9307. body, ioErr := ioutil.ReadAll(resp.Body)
  9308. fmt.Println(body)
  9309. if ioErr != nil {
  9310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9312. return
  9313. }
  9314. var respJSON map[string]interface{}
  9315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9318. return
  9319. }
  9320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9321. userJSONBytes, _ := json.Marshal(respJSON)
  9322. var res ResultEight
  9323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9324. utils.ErrorLog("解析失败:%v", err)
  9325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9326. return
  9327. }
  9328. }
  9329. func (c *HisApiController) Check390() {
  9330. adminUser := c.GetAdminUserInfo()
  9331. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9332. var user_name string
  9333. user_name = "高慧裕"
  9334. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9335. "insutype=" + "390" +
  9336. "&clr_type=" + "" +
  9337. "&setl_optins=" + "441202" +
  9338. "&stmt_begndate=" + "2022-03-01" +
  9339. "&stm_enddate=" + "2022-03-31" +
  9340. "&medfee_sumamt=" + "1068448.89" +
  9341. "&fund_pay_sumamt=" + "1014677.62" +
  9342. "&acct_pay=" + "0" +
  9343. "&fixmedins_setl_cnt=" + "1950" +
  9344. "&fixmedins_code=" + miConfig.Code +
  9345. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9346. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9347. "&secret_key=" + miConfig.SecretKey +
  9348. "&org_name=" + miConfig.OrgName +
  9349. "&doctor=" + user_name
  9350. fmt.Println(api)
  9351. resp, requestErr := http.Get(api)
  9352. if requestErr != nil {
  9353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9354. return
  9355. }
  9356. body, ioErr := ioutil.ReadAll(resp.Body)
  9357. fmt.Println(body)
  9358. if ioErr != nil {
  9359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9361. return
  9362. }
  9363. var respJSON map[string]interface{}
  9364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9367. return
  9368. }
  9369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9370. userJSONBytes, _ := json.Marshal(respJSON)
  9371. var res ResultEight
  9372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9373. utils.ErrorLog("解析失败:%v", err)
  9374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9375. return
  9376. }
  9377. }
  9378. //对账明细
  9379. func (c *HisApiController) GetCheckDetailAccount() {
  9380. start_time := c.GetString("start_time")
  9381. end_time := c.GetString("end_time")
  9382. admin_user_id, _ := c.GetInt64("admin_user_id")
  9383. adminUser := c.GetAdminUserInfo()
  9384. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9385. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9386. timeLayout := "2006-01-02"
  9387. loc, _ := time.LoadLocation("Local")
  9388. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9389. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9390. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9391. rand.Seed(time.Now().UnixNano())
  9392. num := rand.Intn(30000)
  9393. Mkdir(miConfig.OrgName)
  9394. file := strconv.FormatInt(int64(num), 10)
  9395. file_name := file + ".txt"
  9396. zip_name := file + ".zip"
  9397. zip_path := miConfig.OrgName + "/" + zip_name
  9398. file_path := miConfig.OrgName + "/" + file_name
  9399. decimal.DivisionPrecision = 2
  9400. var medfee_sumamt float64
  9401. var psn_cash_pay float64
  9402. var fund_pay_sumamt float64
  9403. fixmedins_setl_cnt := int64(len(orders))
  9404. for _, item := range orders {
  9405. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9406. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9407. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9408. }
  9409. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9410. defer f.Close()
  9411. if err != nil {
  9412. fmt.Println(err.Error())
  9413. } else {
  9414. for _, item := range orders {
  9415. var refd_setl_flag string
  9416. if item.OrderStatus == 2 {
  9417. refd_setl_flag = "0"
  9418. var str string
  9419. str = item.SetlId + " " +
  9420. item.MdtrtId + " " +
  9421. item.PsnNo + " " +
  9422. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9423. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9424. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9425. _, err = f.Write([]byte(str))
  9426. }
  9427. if item.OrderStatus == 3 {
  9428. var str string
  9429. str = item.SetlId + " " +
  9430. item.MdtrtId + " " +
  9431. item.PsnNo + " " +
  9432. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9433. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9434. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9435. _, err = f.Write([]byte(str))
  9436. var str2 string
  9437. str2 = item.SetlId + " " +
  9438. item.MdtrtId + " " +
  9439. item.PsnNo + " " +
  9440. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9441. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9442. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9443. _, err = f.Write([]byte(str2))
  9444. }
  9445. }
  9446. }
  9447. Zip(file_path, zip_path)
  9448. fmt.Println(ReadFile(zip_path))
  9449. fmt.Println(string(ReadFile(zip_path)))
  9450. if config.IsOpen == 1 {
  9451. var user_name string
  9452. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9453. if role.ID == 0 {
  9454. user_name = "管理员"
  9455. } else {
  9456. user_name = role.UserName
  9457. }
  9458. baseParams := models.BaseParams{
  9459. SecretKey: miConfig.SecretKey,
  9460. FixmedinsCode: miConfig.Code,
  9461. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9462. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9463. OrgName: miConfig.OrgName,
  9464. Doctor: user_name,
  9465. }
  9466. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9467. var dat map[string]interface{}
  9468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9469. fmt.Println(dat)
  9470. } else {
  9471. fmt.Println(err)
  9472. }
  9473. userJSONBytes, _ := json.Marshal(dat)
  9474. var res ResultNine
  9475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9476. utils.ErrorLog("解析失败:%v", err)
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. if res.Infcode == 0 {
  9481. fileNo := res.Output.FileQuryNo
  9482. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9483. "file_qury_no=" + fileNo +
  9484. "&setl_optins=" + "定点医保中心" +
  9485. "&stmt_begndate=" + start_time +
  9486. "&stm_enddate=" + end_time +
  9487. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9488. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9489. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9490. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9491. "&fixmedins_code=" + miConfig.Code +
  9492. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9493. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9494. "&secret_key=" + miConfig.SecretKey +
  9495. "&org_name=" + miConfig.OrgName +
  9496. "&doctor=" + user_name
  9497. resp, requestErr := http.Get(api)
  9498. if requestErr != nil {
  9499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9500. return
  9501. }
  9502. body, ioErr := ioutil.ReadAll(resp.Body)
  9503. if ioErr != nil {
  9504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9506. return
  9507. }
  9508. var respJSON map[string]interface{}
  9509. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9512. return
  9513. }
  9514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9515. userJSONBytes, _ := json.Marshal(respJSON)
  9516. var res ResultTen
  9517. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9518. utils.ErrorLog("解析失败:%v", err)
  9519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9520. return
  9521. }
  9522. if res.Infcode == 0 {
  9523. service.Gdyb9102(baseParams, zip_name, fileNo)
  9524. micc := &models.MedicalInsuranceCostCompare{
  9525. StartTime: startime.Unix(),
  9526. EndTime: endtime.Unix(),
  9527. Insutype: "0",
  9528. CheckType: 2,
  9529. Num: fixmedins_setl_cnt,
  9530. Mtime: time.Now().Unix(),
  9531. Status: 1,
  9532. UserOrgId: adminUser.CurrentOrgId,
  9533. CostTotal: medfee_sumamt,
  9534. FuncTotal: fund_pay_sumamt,
  9535. PsnPay: psn_cash_pay,
  9536. Creator: admin_user_id,
  9537. Ctime: time.Now().Unix(),
  9538. }
  9539. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9540. c.ServeSuccessJSON(map[string]interface{}{
  9541. "msg": "明细对账成功",
  9542. })
  9543. }
  9544. } else {
  9545. }
  9546. }
  9547. }
  9548. type CustomOrderInfo struct {
  9549. Name string
  9550. Spec string
  9551. Unit string
  9552. Count float64
  9553. Price float64
  9554. Total float64
  9555. }
  9556. func (c *HisApiController) GetSettleAccounts() {
  9557. //id, _ := c.GetInt64("id")
  9558. //record_time := c.GetString("record_time")
  9559. order_id, _ := c.GetInt64("order_id")
  9560. admin_user_id, _ := c.GetInt64("admin_user_id")
  9561. //timeLayout := "2006-01-02"
  9562. //loc, _ := time.LoadLocation("Local")
  9563. //
  9564. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9565. //if err != nil {
  9566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9567. // return
  9568. //}
  9569. //recordDateTime := theTime.Unix()
  9570. adminUser := c.GetAdminUserInfo()
  9571. order, _ := service.GetHisOrderByID(order_id)
  9572. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9573. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9574. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9575. orderInfos = append(orderInfos, orderInfos_two...)
  9576. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9577. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9578. var diagnosis_ids []string
  9579. if his.ID > 0 {
  9580. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9581. } else {
  9582. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9583. }
  9584. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9585. var dia_config []*models.HisXtDiagnoseConfig
  9586. var name string
  9587. for _, item := range diagnosis_ids {
  9588. id, _ := strconv.ParseInt(item, 10, 64)
  9589. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9590. dia_config = append(dia_config, &diagnosisConfig)
  9591. if len(name) == 0 {
  9592. name = diagnosisConfig.ClassName
  9593. } else {
  9594. name = name + "," + diagnosisConfig.ClassName
  9595. }
  9596. }
  9597. var bedCostTotal float64 = 0 //床位总费
  9598. var bedCostSelfTotal float64 = 0 //床位自费
  9599. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9600. var operationCostTotal float64 = 0 //手术费
  9601. var operationCostSelfTotal float64 = 0 //手术费
  9602. var operationCostPartSelfTotal float64 = 0 //手术费
  9603. var otherCostTotal float64 = 0 //其他费用
  9604. var otherCostSelfTotal float64 = 0 //其他费用
  9605. var otherCostPartSelfTotal float64 = 0 //其他费用
  9606. var materialCostTotal float64 = 0 //材料费
  9607. var materialCostSelfTotal float64 = 0 //材料费
  9608. var materialCostPartSelfTotal float64 = 0 //材料费
  9609. var westernMedicineCostTotal float64 = 0 //西药费
  9610. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9611. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9612. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9613. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9614. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9615. var checkCostTotal float64 = 0 //检查费
  9616. var checkCostSelfTotal float64 = 0 //检查费
  9617. var checkCostPartSelfTotal float64 = 0 //检查费
  9618. var laboratoryCostTotal float64 = 0 //化验费
  9619. var laboratoryCostSelfTotal float64 = 0 //化验费
  9620. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9621. var treatCostTotal float64 = 0 //治疗费用
  9622. var treatCostSelfTotal float64 = 0 //治疗费用
  9623. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9624. decimal.DivisionPrecision = 2
  9625. for _, item := range orderInfos {
  9626. if item.MedChrgitmType == "01" { //床位费
  9627. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9628. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9629. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9630. }
  9631. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9632. if item.MedChrgitmType == "03" { //检查费
  9633. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9634. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9635. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9636. }
  9637. } else {
  9638. if item.MedChrgitmType == "03" { //检查费
  9639. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9640. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9641. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9642. }
  9643. }
  9644. if item.MedChrgitmType == "04" { //化验费
  9645. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9646. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9647. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9648. }
  9649. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9650. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9651. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9652. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9653. }
  9654. if item.MedChrgitmType == "06" { //手术费
  9655. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9656. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9657. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9658. }
  9659. if item.MedChrgitmType == "08" { //材料费
  9660. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9661. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9662. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9663. }
  9664. if item.MedChrgitmType == "09" { //西药费
  9665. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9666. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9667. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9668. }
  9669. if item.MedChrgitmType == "11" { //中成费
  9670. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9671. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9672. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9673. }
  9674. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9675. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9676. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9677. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9678. }
  9679. }
  9680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9681. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9682. var user_name string
  9683. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9684. if role.ID == 0 {
  9685. user_name = "管理员"
  9686. } else {
  9687. user_name = role.UserName
  9688. }
  9689. baseParams := models.BaseParams{
  9690. SecretKey: miConfig.SecretKey,
  9691. FixmedinsCode: miConfig.Code,
  9692. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9693. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9694. OrgName: miConfig.OrgName,
  9695. Doctor: user_name,
  9696. }
  9697. businessParams := models.BusinessParams{
  9698. PsnNo: order.PsnNo,
  9699. MdtrtId: order.MdtrtId,
  9700. SetlId: order.SetlId,
  9701. }
  9702. var res ResultEleven
  9703. var resEleven10265 ResultEleven10265
  9704. if config.IsOpen == 1 {
  9705. if miConfig.MdtrtareaAdmvs == "421300" {
  9706. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9707. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9708. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9709. resp, requestErr := http.Get(api)
  9710. if requestErr != nil {
  9711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9712. return
  9713. }
  9714. body, ioErr := ioutil.ReadAll(resp.Body)
  9715. if ioErr != nil {
  9716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9718. return
  9719. }
  9720. var respJSON map[string]interface{}
  9721. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9724. return
  9725. }
  9726. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9727. result, _ := json.Marshal(respJSON)
  9728. fmt.Println("log")
  9729. fmt.Println(string(result))
  9730. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9731. utils.ErrorLog("解析失败:%v", err)
  9732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9733. return
  9734. }
  9735. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9736. var api string
  9737. if miConfig.MdtrtareaAdmvs == "320921" {
  9738. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9739. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9740. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9741. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9742. } else {
  9743. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9744. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9745. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9747. }
  9748. resp, requestErr := http.Get(api)
  9749. if requestErr != nil {
  9750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9751. return
  9752. }
  9753. body, ioErr := ioutil.ReadAll(resp.Body)
  9754. if ioErr != nil {
  9755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9757. return
  9758. }
  9759. var respJSON map[string]interface{}
  9760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9763. return
  9764. }
  9765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9766. result, _ := json.Marshal(respJSON)
  9767. fmt.Println("log")
  9768. fmt.Println(string(result))
  9769. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9770. utils.ErrorLog("解析失败:%v", err)
  9771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9772. return
  9773. }
  9774. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9775. res.Output = resEleven10265.Output
  9776. res.ErrMsg = resEleven10265.ErrMsg
  9777. res.Cainfo = resEleven10265.Cainfo
  9778. res.WarnMsg = resEleven10265.WarnMsg
  9779. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9780. res.Infcode = infocode
  9781. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9782. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9783. saveLog(result, requestLog, "5203", "结算单")
  9784. var dat map[string]interface{}
  9785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9786. fmt.Println(dat)
  9787. } else {
  9788. fmt.Println(err)
  9789. }
  9790. userJSONBytes, _ := json.Marshal(dat)
  9791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9792. utils.ErrorLog("解析失败:%v", err)
  9793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9794. return
  9795. }
  9796. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9797. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9798. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9799. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9800. resp, requestErr := http.Get(api)
  9801. if requestErr != nil {
  9802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9803. return
  9804. }
  9805. body, ioErr := ioutil.ReadAll(resp.Body)
  9806. if ioErr != nil {
  9807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9809. return
  9810. }
  9811. var respJSON map[string]interface{}
  9812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9815. return
  9816. }
  9817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9818. result, _ := json.Marshal(respJSON)
  9819. fmt.Println("log")
  9820. fmt.Println(string(result))
  9821. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9822. utils.ErrorLog("解析失败:%v", err)
  9823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9824. return
  9825. }
  9826. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9827. res.Output = resEleven10265.Output
  9828. res.ErrMsg = resEleven10265.ErrMsg
  9829. res.Cainfo = resEleven10265.Cainfo
  9830. res.WarnMsg = resEleven10265.WarnMsg
  9831. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9832. res.Infcode = infocode
  9833. } else {
  9834. result := service.Gdyb5203(baseParams, businessParams)
  9835. //service.Gdyb5204(baseParams, businessParams)
  9836. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9837. var dat map[string]interface{}
  9838. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9839. fmt.Println(dat)
  9840. } else {
  9841. fmt.Println(err)
  9842. }
  9843. userJSONBytes, _ := json.Marshal(dat)
  9844. if miConfig.Code == "H15049901371" {
  9845. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9846. utils.ErrorLog("解析失败:%v", err)
  9847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9848. return
  9849. }
  9850. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9851. res.Output = resEleven10265.Output
  9852. res.ErrMsg = resEleven10265.ErrMsg
  9853. res.Cainfo = resEleven10265.Cainfo
  9854. res.WarnMsg = resEleven10265.WarnMsg
  9855. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9856. res.Infcode = infocode
  9857. } else {
  9858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9859. utils.ErrorLog("解析失败:%v", err)
  9860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9861. return
  9862. }
  9863. }
  9864. }
  9865. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9866. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9867. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9868. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9869. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9870. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9871. var doctor_name string
  9872. if roles.ID == 0 {
  9873. doctor_name = "管理员"
  9874. } else {
  9875. doctor_name = roles.UserName
  9876. }
  9877. yiliao_leibie := ""
  9878. switch order.MedType {
  9879. case "11":
  9880. yiliao_leibie = "普通门诊"
  9881. break
  9882. case "12":
  9883. yiliao_leibie = "门诊挂号"
  9884. break
  9885. case "13":
  9886. yiliao_leibie = "急诊"
  9887. break
  9888. case "14":
  9889. yiliao_leibie = "门诊特殊病"
  9890. break
  9891. case "15":
  9892. yiliao_leibie = "门诊统筹"
  9893. break
  9894. case "16":
  9895. yiliao_leibie = "门诊慢性病"
  9896. break
  9897. case "21":
  9898. yiliao_leibie = "普通住院"
  9899. break
  9900. }
  9901. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9902. if res.Infcode == 0 {
  9903. c.ServeSuccessJSON(map[string]interface{}{
  9904. "diagnosis": name,
  9905. "order_infos": orderInfos,
  9906. "number": order.MdtrtId,
  9907. "date": order.SettleAccountsDate,
  9908. "charge_admin": charge_admin,
  9909. "printor_admin": printor_admin,
  9910. "info": res.Output.Setlinfo,
  9911. "order": order,
  9912. "bedCostTotal": bedCostTotal,
  9913. "bedCostSelfTotal": bedCostSelfTotal,
  9914. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9915. "operationCostTotal": operationCostTotal,
  9916. "operationCostSelfTotal": operationCostSelfTotal,
  9917. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9918. "otherCostTotal": otherCostTotal,
  9919. "otherCostSelfTotal": otherCostSelfTotal,
  9920. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9921. "materialCostTotal": materialCostTotal,
  9922. "materialCostSelfTotal": materialCostSelfTotal,
  9923. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9924. "westernMedicineCostTotal": westernMedicineCostTotal,
  9925. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9926. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9927. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9928. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9929. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9930. "checkCostTotal": checkCostTotal,
  9931. "checkCostSelfTotal": checkCostSelfTotal,
  9932. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9933. "laboratoryCostTotal": laboratoryCostTotal,
  9934. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9935. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9936. "treatCostTotal": treatCostTotal,
  9937. "treatCostSelfTotal": treatCostSelfTotal,
  9938. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9939. "doctor_info": doctor_info,
  9940. "doctor_code": adminRole_two.DoctorCode,
  9941. "doctor_name": doctor_name,
  9942. "health_card_no": order.PsnNo,
  9943. "department": departments.Name,
  9944. "yiliao_leibie": yiliao_leibie,
  9945. "after_money": order.AccountPrice,
  9946. "patient": patient,
  9947. "org_name": miConfig.OrgName,
  9948. "org_code": miConfig.Code,
  9949. "order_number": order.Number,
  9950. "his_hospital": his_hospital,
  9951. "his": his,
  9952. "dia_config": dia_config,
  9953. //"check_order_info": cus_slice,
  9954. })
  9955. }
  9956. }
  9957. }
  9958. func (c *HisApiController) CheckTreatment() {
  9959. patient_id, _ := c.GetInt64("patient_id")
  9960. id_card_no := c.GetString("id_card_no")
  9961. insutype := c.GetString("insutype")
  9962. med_type := c.GetString("med_type")
  9963. admin_user_id, _ := c.GetInt64("admin_user_id")
  9964. adminUser := c.GetAdminUserInfo()
  9965. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9966. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9967. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9968. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9969. if miConfig.MdtrtareaAdmvs == "421300" {
  9970. var res ResultTwo
  9971. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9972. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9973. "&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)
  9974. resp, requestErr := http.Get(api)
  9975. if requestErr != nil {
  9976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9977. return
  9978. }
  9979. body, ioErr := ioutil.ReadAll(resp.Body)
  9980. if ioErr != nil {
  9981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9983. return
  9984. }
  9985. var respJSON map[string]interface{}
  9986. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9989. return
  9990. }
  9991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9992. result, _ := json.Marshal(respJSON)
  9993. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9994. utils.ErrorLog("解析失败:%v", err)
  9995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9996. return
  9997. }
  9998. if res.Infcode == 0 {
  9999. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  10000. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10001. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  10002. resp, requestErr := http.Get(api)
  10003. if requestErr != nil {
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10005. return
  10006. }
  10007. body, ioErr := ioutil.ReadAll(resp.Body)
  10008. if ioErr != nil {
  10009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10011. return
  10012. }
  10013. var respJSON map[string]interface{}
  10014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10017. return
  10018. }
  10019. var res Result2001
  10020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10021. result2, _ := json.Marshal(respJSON)
  10022. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10023. utils.ErrorLog("解析失败:%v", err)
  10024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10025. return
  10026. }
  10027. if res.Infcode == 0 {
  10028. c.ServeSuccessJSON(map[string]interface{}{
  10029. "msg": res.Output.Trtinfo,
  10030. })
  10031. }
  10032. } else {
  10033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10034. return
  10035. }
  10036. } else {
  10037. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10038. var dat map[string]interface{}
  10039. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10040. fmt.Println(dat)
  10041. } else {
  10042. fmt.Println(err)
  10043. }
  10044. userJSONBytes, _ := json.Marshal(dat)
  10045. var res ResultTwo
  10046. var res10265 ResultTwo10265
  10047. if miConfig.Code == "H15049901371" {
  10048. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10049. utils.ErrorLog("解析失败:%v", err)
  10050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10051. return
  10052. }
  10053. res.ErrMsg = res10265.ErrMsg
  10054. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10055. res.Infcode = infocode
  10056. res.Output = res10265.Output
  10057. res.InfRefmsgid = res10265.InfRefmsgid
  10058. } else {
  10059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10060. utils.ErrorLog("解析失败:%v", err)
  10061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10062. return
  10063. }
  10064. }
  10065. var user_name string
  10066. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10067. if role.ID == 0 {
  10068. user_name = "xxx"
  10069. } else {
  10070. user_name = role.UserName
  10071. }
  10072. baseParams := models.BaseParams{
  10073. SecretKey: miConfig.SecretKey,
  10074. FixmedinsCode: miConfig.Code,
  10075. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10076. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10077. OrgName: miConfig.OrgName,
  10078. Doctor: user_name,
  10079. }
  10080. if config.IsOpen == 1 {
  10081. if miConfig.Code == "H15049901371" {
  10082. if med_type == "14" {
  10083. if insutype == "390" {
  10084. med_type = "9933"
  10085. } else if insutype == "310" {
  10086. med_type = "990502"
  10087. }
  10088. } else if med_type == "11" {
  10089. med_type = "11"
  10090. }
  10091. }
  10092. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10093. var dat map[string]interface{}
  10094. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10095. fmt.Println(dat)
  10096. } else {
  10097. fmt.Println(err)
  10098. }
  10099. var res Result2001
  10100. var res10265 Result2001Org10265
  10101. if miConfig.Code == "H15049901371" {
  10102. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10103. utils.ErrorLog("解析失败:%v", err)
  10104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10105. return
  10106. }
  10107. res.ErrMsg = res10265.ErrMsg
  10108. res.Output = res10265.Output
  10109. res.InfRefmsgid = res10265.InfRefmsgid
  10110. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10111. res.Infcode = infocode
  10112. } else {
  10113. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10114. utils.ErrorLog("解析失败:%v", err)
  10115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10116. return
  10117. }
  10118. }
  10119. if res.Infcode == 0 {
  10120. c.ServeSuccessJSON(map[string]interface{}{
  10121. "msg": res.Output.Trtinfo,
  10122. })
  10123. }
  10124. }
  10125. }
  10126. }
  10127. //func (c *HisApiController) PutRecord() {
  10128. // id, _ := c.GetInt64("id")
  10129. // record_time := c.GetString("record_time")
  10130. // timeLayout := "2006-01-02"
  10131. // loc, _ := time.LoadLocation("Local")
  10132. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10133. // if err != nil {
  10134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10135. // return
  10136. // }
  10137. // recordDateTime := theTime.Unix()
  10138. //
  10139. // adminInfo := c.GetAdminUserInfo()
  10140. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10141. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10142. //
  10143. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10144. //
  10145. // fmt.Println(miConfig.SecretKey)
  10146. //
  10147. // if patient == nil {
  10148. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10149. // return
  10150. // }
  10151. // if len(patient.IdCardNo) == 0 {
  10152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10153. // return
  10154. // }
  10155. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10156. // if config.IsOpen == 1 {
  10157. // 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
  10158. // resp, requestErr := http.Get(api)
  10159. // if requestErr != nil {
  10160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10161. // return
  10162. // }
  10163. // defer resp.Body.Close()
  10164. // body, ioErr := ioutil.ReadAll(resp.Body)
  10165. // if ioErr != nil {
  10166. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10168. // return
  10169. // }
  10170. // var respJSON map[string]interface{}
  10171. //
  10172. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10173. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10175. // return
  10176. // }
  10177. //
  10178. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10179. // userJSONBytes, _ := json.Marshal(userJSON)
  10180. // var res ResultTwo
  10181. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10182. // utils.ErrorLog("解析失败:%v", err)
  10183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10184. // return
  10185. // }
  10186. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10187. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10188. // infoStr := string(Iinfos)
  10189. // idetinfoStr := string(Idetinfos)
  10190. //
  10191. // if res.Infcode == 0 {
  10192. // his := models.VMHisPatient{
  10193. // Status: 1,
  10194. // Ctime: time.Now().Unix(),
  10195. // Mtime: time.Now().Unix(),
  10196. // PsnNo: res.Output.Baseinfo.PsnNo,
  10197. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10198. // Certno: res.Output.Baseinfo.Certno,
  10199. // PsnName: res.Output.Baseinfo.PsnName,
  10200. // Gend: res.Output.Baseinfo.Gend,
  10201. // Naty: res.Output.Baseinfo.Naty,
  10202. // Brdy: res.Output.Baseinfo.Brdy,
  10203. // Age: res.Output.Baseinfo.Age,
  10204. // Iinfo: infoStr,
  10205. // Idetinfo: idetinfoStr,
  10206. // PatientId: patient.ID,
  10207. // RecordDate: theTime.Unix(),
  10208. // UserOrgId: adminInfo.CurrentOrgId,
  10209. // AdminUserId: adminInfo.AdminUser.Id,
  10210. // IsReturn: 1,
  10211. // }
  10212. //
  10213. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10214. // //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")
  10215. // //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")
  10216. //
  10217. // //var dat map[string]interface{}
  10218. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10219. // // fmt.Println(dat)
  10220. // //} else {
  10221. // // fmt.Println(err)
  10222. // //}
  10223. //
  10224. // var dat2 map[string]interface{}
  10225. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10226. // fmt.Println(dat2)
  10227. // } else {
  10228. // fmt.Println(err)
  10229. // }
  10230. //
  10231. // } else {
  10232. // adminUser := c.GetAdminUserInfo()
  10233. // errlog := &models.HisOrderError{
  10234. // UserOrgId: adminUser.CurrentOrgId,
  10235. // Ctime: time.Now().Unix(),
  10236. // Mtime: time.Now().Unix(),
  10237. // ErrMsg: res.ErrMsg,
  10238. // Status: 1,
  10239. // PatientId: id,
  10240. // RecordTime: recordDateTime,
  10241. // Stage: 1,
  10242. // }
  10243. // service.CreateErrMsgLog(errlog)
  10244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10245. // return
  10246. // }
  10247. // }
  10248. //
  10249. //}
  10250. //func (c *HisApiController) GetUploadDiag() {
  10251. // id, _ := c.GetInt64("id")
  10252. // record_time := c.GetString("record_time")
  10253. //
  10254. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10255. // sick_type, _ := c.GetInt64("sick_type")
  10256. // reg_type, _ := c.GetInt64("reg_type")
  10257. //
  10258. // timeLayout := "2006-01-02"
  10259. // loc, _ := time.LoadLocation("Local")
  10260. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10261. // if err != nil {
  10262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10263. // return
  10264. // }
  10265. //
  10266. // var patientPrescription models.HisPrescriptionInfo
  10267. // recordDateTime := theTime.Unix()
  10268. // adminInfo := c.GetAdminUserInfo()
  10269. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10270. //
  10271. // if patientPrescription.ID == 0 {
  10272. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10273. // }
  10274. //
  10275. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10276. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10277. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10278. // sickConfig, _ := service.FindSickById(sick_type)
  10279. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10280. //
  10281. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10282. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10283. // "&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 +
  10284. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10285. // resp2, requestErr2 := http.Get(api2)
  10286. // if requestErr2 != nil {
  10287. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10288. // return
  10289. // }
  10290. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10291. // if ioErr2 != nil {
  10292. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10294. // return
  10295. // }
  10296. // var respJSON2 map[string]interface{}
  10297. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10298. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10300. // return
  10301. // }
  10302. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10303. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10304. //
  10305. // var res2 ResultSix
  10306. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10307. // utils.ErrorLog("解析失败:%v", err)
  10308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10309. // return
  10310. // }
  10311. // if res2.Infcode != 0 {
  10312. // adminUser := c.GetAdminUserInfo()
  10313. // errlog := &models.HisOrderError{
  10314. // UserOrgId: adminUser.CurrentOrgId,
  10315. // Ctime: time.Now().Unix(),
  10316. // Mtime: time.Now().Unix(),
  10317. // ErrMsg: res2.ErrMsg,
  10318. // Status: 1,
  10319. // PatientId: id,
  10320. // RecordTime: recordDateTime,
  10321. // Stage: 3,
  10322. // }
  10323. // service.CreateErrMsgLog(errlog)
  10324. //
  10325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10326. // return
  10327. // }
  10328. //
  10329. // c.ServeSuccessJSON(map[string]interface{}{
  10330. // "msg": "上传成功",
  10331. // })
  10332. //
  10333. //}
  10334. type QueryResult struct {
  10335. ID int64
  10336. Name string
  10337. Code string
  10338. List_type_code string
  10339. }
  10340. func (c *HisApiController) GetCheckCode() {
  10341. ids_str := c.GetString("ids")
  10342. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10343. ids_arr := strings.Split(ids_str, ",")
  10344. var queryResult []QueryResult
  10345. ids := make([]int64, 0)
  10346. for _, item := range ids_arr {
  10347. id, _ := strconv.ParseInt(item, 10, 64)
  10348. ids = append(ids, id)
  10349. }
  10350. if record_type == 1 {
  10351. drugs, _ := service.GetBatchDrugList(ids)
  10352. for _, item := range drugs {
  10353. result := QueryResult{
  10354. ID: item.ID,
  10355. Name: item.DrugName,
  10356. Code: item.MedicalInsuranceNumber,
  10357. List_type_code: "101",
  10358. }
  10359. queryResult = append(queryResult, result)
  10360. }
  10361. } else if record_type == 2 {
  10362. goods, _ := service.GetBatchGoodInformationList(ids)
  10363. for _, item := range goods {
  10364. result := QueryResult{
  10365. ID: item.ID,
  10366. Name: item.GoodName,
  10367. Code: item.MedicalInsuranceNumber,
  10368. List_type_code: "301",
  10369. }
  10370. queryResult = append(queryResult, result)
  10371. }
  10372. } else if record_type == 3 {
  10373. projects, _ := service.GetBathchMyPorjecgList(ids)
  10374. for _, item := range projects {
  10375. result := QueryResult{
  10376. ID: item.ID,
  10377. Name: item.ProjectName,
  10378. Code: item.MedicalCode,
  10379. List_type_code: "201",
  10380. }
  10381. queryResult = append(queryResult, result)
  10382. }
  10383. }
  10384. admin_user_id, _ := c.GetInt64("admin_user_id")
  10385. adminUser := c.GetAdminUserInfo()
  10386. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10387. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10388. var user_name string
  10389. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10390. if role.ID == 0 {
  10391. user_name = "xxx"
  10392. } else {
  10393. user_name = role.UserName
  10394. }
  10395. baseParams := &models.BaseParams{
  10396. SecretKey: miConfig.SecretKey,
  10397. FixmedinsCode: miConfig.Code,
  10398. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10399. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10400. OrgName: miConfig.OrgName,
  10401. Doctor: user_name,
  10402. }
  10403. if config.IsOpen == 1 {
  10404. for _, item := range queryResult {
  10405. var result string
  10406. if record_type == 1 {
  10407. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10408. } else if record_type == 2 {
  10409. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10410. } else if record_type == 3 {
  10411. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10412. }
  10413. var dat map[string]interface{}
  10414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10415. fmt.Println(dat)
  10416. } else {
  10417. fmt.Println(err)
  10418. }
  10419. userJSONBytes, _ := json.Marshal(dat)
  10420. var res ResultSix
  10421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10422. utils.ErrorLog("解析失败:%v", err)
  10423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10424. return
  10425. }
  10426. if res.Infcode == 0 {
  10427. if record_type == 1 {
  10428. service.UpdateBaseDrugById(item.ID)
  10429. } else if record_type == 2 {
  10430. service.UpdateGoodInformaitonByDetail(item.ID)
  10431. } else if record_type == 3 {
  10432. service.UpdateProjectById(item.ID)
  10433. }
  10434. c.ServeSuccessJSON(map[string]interface{}{
  10435. "failed_code": 0,
  10436. "msg": "目录对照成功",
  10437. })
  10438. } else {
  10439. c.ServeSuccessJSON(map[string]interface{}{
  10440. "failed_code": -10,
  10441. "msg": res.ErrMsg,
  10442. })
  10443. }
  10444. }
  10445. }
  10446. }
  10447. func (c *HisApiController) UnCheckCode() {
  10448. ids_str := c.GetString("ids")
  10449. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10450. admin_user_id, _ := c.GetInt64("admin_user_id")
  10451. ids_arr := strings.Split(ids_str, ",")
  10452. var queryResult []QueryResult
  10453. ids := make([]int64, 0)
  10454. for _, item := range ids_arr {
  10455. id, _ := strconv.ParseInt(item, 10, 64)
  10456. ids = append(ids, id)
  10457. }
  10458. if record_type == 1 {
  10459. drugs, _ := service.GetBatchDrugList(ids)
  10460. for _, item := range drugs {
  10461. result := QueryResult{
  10462. ID: item.ID,
  10463. Name: item.DrugName,
  10464. Code: item.MedicalInsuranceNumber,
  10465. List_type_code: "101",
  10466. }
  10467. queryResult = append(queryResult, result)
  10468. }
  10469. } else if record_type == 2 {
  10470. goods, _ := service.GetBatchGoodInformationList(ids)
  10471. for _, item := range goods {
  10472. result := QueryResult{
  10473. ID: item.ID,
  10474. Name: item.GoodName,
  10475. Code: item.MedicalInsuranceNumber,
  10476. List_type_code: "301",
  10477. }
  10478. queryResult = append(queryResult, result)
  10479. }
  10480. } else if record_type == 3 {
  10481. projects, _ := service.GetBathchMyPorjecgList(ids)
  10482. for _, item := range projects {
  10483. result := QueryResult{
  10484. ID: item.ID,
  10485. Name: item.ProjectName,
  10486. Code: item.MedicalCode,
  10487. List_type_code: "201",
  10488. }
  10489. queryResult = append(queryResult, result)
  10490. }
  10491. }
  10492. adminUser := c.GetAdminUserInfo()
  10493. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10494. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10495. var user_name string
  10496. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10497. if role.ID == 0 {
  10498. user_name = "xxx"
  10499. } else {
  10500. user_name = role.UserName
  10501. }
  10502. baseParams := &models.BaseParams{
  10503. SecretKey: miConfig.SecretKey,
  10504. FixmedinsCode: miConfig.Code,
  10505. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10506. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10507. OrgName: miConfig.OrgName,
  10508. Doctor: user_name,
  10509. }
  10510. if config.IsOpen == 1 {
  10511. for _, item := range queryResult {
  10512. var result string
  10513. if record_type == 1 {
  10514. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10515. } else if record_type == 2 {
  10516. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10517. } else if record_type == 3 {
  10518. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10519. }
  10520. var dat2 map[string]interface{}
  10521. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10522. fmt.Println(dat2)
  10523. } else {
  10524. fmt.Println(err)
  10525. }
  10526. userJSONBytes, _ := json.Marshal(dat2)
  10527. var res ResultSix
  10528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10529. utils.ErrorLog("解析失败:%v", err)
  10530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10531. return
  10532. }
  10533. if res.Infcode == 0 {
  10534. if record_type == 1 {
  10535. service.UpdateDrugByIdDetail(item.ID)
  10536. } else if record_type == 2 {
  10537. service.UpdateGoodInfoById(item.ID)
  10538. } else if record_type == 3 {
  10539. service.UpdateMyProjectById(item.ID)
  10540. }
  10541. c.ServeSuccessJSON(map[string]interface{}{
  10542. "failed_code": 0,
  10543. "msg": "撤销目录对照成功",
  10544. })
  10545. } else {
  10546. c.ServeSuccessJSON(map[string]interface{}{
  10547. "failed_code": -10,
  10548. "msg": res.ErrMsg,
  10549. })
  10550. }
  10551. }
  10552. }
  10553. }
  10554. func (c *HisApiController) GetPatientInfo() {
  10555. id_card_no := c.GetString("id_card_no")
  10556. admin_user_id, _ := c.GetInt64("admin_user_id")
  10557. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10558. if patient.ID == 0 {
  10559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10560. return
  10561. }
  10562. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10564. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10565. if config.IsOpen == 1 {
  10566. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10567. var dat map[string]interface{}
  10568. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10569. fmt.Println(dat)
  10570. } else {
  10571. fmt.Println(err)
  10572. }
  10573. userJSONBytes, _ := json.Marshal(dat)
  10574. var res ResultTwo
  10575. var res10265 ResultTwo10265
  10576. if miConfig.Code == "H15049901371" {
  10577. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10578. utils.ErrorLog("解析失败:%v", err)
  10579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10580. return
  10581. }
  10582. res.ErrMsg = res10265.ErrMsg
  10583. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10584. res.Infcode = infocode
  10585. res.Output = res10265.Output
  10586. res.InfRefmsgid = res10265.InfRefmsgid
  10587. } else {
  10588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10589. utils.ErrorLog("解析失败:%v", err)
  10590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10591. return
  10592. }
  10593. }
  10594. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10595. // utils.ErrorLog("解析失败:%v", err)
  10596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10597. // return
  10598. //}
  10599. if res.Infcode != 0 {
  10600. c.ServeSuccessJSON(map[string]interface{}{
  10601. "failed_code": -10,
  10602. "msg": res.ErrMsg,
  10603. })
  10604. } else {
  10605. c.ServeSuccessJSON(map[string]interface{}{
  10606. "failed_code": 0,
  10607. "info": res,
  10608. })
  10609. }
  10610. }
  10611. }
  10612. func (c *HisApiController) PsnPutOnRecord() {
  10613. record_type, _ := c.GetInt64("type")
  10614. patient_id, _ := c.GetInt64("patient_id")
  10615. admin_user_id, _ := c.GetInt64("admin_user_id")
  10616. start_time := c.GetString("start_time")
  10617. end_time := c.GetString("end_time")
  10618. adminUser := c.GetAdminUserInfo()
  10619. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10620. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10621. var patients []*models.Patients
  10622. if record_type == 1 { //全部备案
  10623. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10624. patients = append(patients, patient...)
  10625. } else { //单个备案
  10626. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10627. patients = append(patients, patient)
  10628. }
  10629. var user_name string
  10630. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10631. if role.ID == 0 {
  10632. user_name = "xxx"
  10633. } else {
  10634. user_name = role.UserName
  10635. }
  10636. if config.IsOpen == 1 {
  10637. for _, item := range patients {
  10638. 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
  10639. resp, requestErr := http.Get(api)
  10640. if requestErr != nil {
  10641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10642. return
  10643. }
  10644. defer resp.Body.Close()
  10645. body, ioErr := ioutil.ReadAll(resp.Body)
  10646. if ioErr != nil {
  10647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10649. return
  10650. }
  10651. var respJSON map[string]interface{}
  10652. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10655. return
  10656. }
  10657. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10658. userJSONBytes, _ := json.Marshal(userJSON)
  10659. var res ResultTwo
  10660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10661. utils.ErrorLog("解析失败:%v", err)
  10662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10663. return
  10664. }
  10665. if res.Infcode == 0 {
  10666. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10667. var dat map[string]interface{}
  10668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10669. fmt.Println(dat)
  10670. } else {
  10671. fmt.Println(err)
  10672. }
  10673. userJSONBytes, _ := json.Marshal(dat)
  10674. var res2 ResultThirteen
  10675. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10676. utils.ErrorLog("解析失败:%v", err)
  10677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10678. return
  10679. }
  10680. if res2.Infcode == 0 {
  10681. psnResult := &models.GdybPsnRecord{
  10682. UserOrgId: adminUser.CurrentOrgId,
  10683. PatientId: item.ID,
  10684. PsnNo: res.Output.Baseinfo.PsnNo,
  10685. Ctime: time.Now().Unix(),
  10686. Mtime: time.Now().Unix(),
  10687. Status: 1,
  10688. IsCancel: 1,
  10689. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10690. }
  10691. service.CreatePsnRecord(psnResult)
  10692. } else {
  10693. c.ServeSuccessJSON(map[string]interface{}{
  10694. "failed_code": -10,
  10695. "msg": res2.ErrMsg,
  10696. })
  10697. return
  10698. }
  10699. }
  10700. }
  10701. }
  10702. }
  10703. func (c *HisApiController) PsnUnPutOnRecord() {
  10704. id, _ := c.GetInt64("id")
  10705. //record_type, _ := c.GetInt64("type")
  10706. admin_user_id, _ := c.GetInt64("admin_user_id")
  10707. adminUser := c.GetAdminUserInfo()
  10708. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10709. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10710. var user_name string
  10711. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10712. if role.ID == 0 {
  10713. user_name = "xxx"
  10714. } else {
  10715. user_name = role.UserName
  10716. }
  10717. psn_record, _ := service.GetPsnRecordById(id)
  10718. if psn_record.ID == 0 {
  10719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10720. return
  10721. }
  10722. if config.IsOpen == 1 {
  10723. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10724. var dat map[string]interface{}
  10725. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10726. fmt.Println(dat)
  10727. } else {
  10728. fmt.Println(err)
  10729. }
  10730. userJSONBytes, _ := json.Marshal(dat)
  10731. var res ResultFourteen
  10732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10733. utils.ErrorLog("解析失败:%v", err)
  10734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10735. return
  10736. }
  10737. if res.Infcode == 0 {
  10738. psn_record.IsCancel = 2
  10739. service.CreatePsnRecord(&psn_record)
  10740. } else {
  10741. c.ServeSuccessJSON(map[string]interface{}{
  10742. "failed_code": -10,
  10743. "msg": res.ErrMsg,
  10744. })
  10745. return
  10746. }
  10747. }
  10748. }
  10749. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10750. patient_id, _ := c.GetInt64("patient_id")
  10751. insutype_two := c.GetString("insutype")
  10752. psn_no := c.GetString("psn_no")
  10753. doctor_id, _ := c.GetInt64("doctor_id")
  10754. sick_id, _ := c.GetInt64("sick_id")
  10755. department_id, _ := c.GetInt64("department_id")
  10756. start_time := c.GetString("start_time")
  10757. end_time := c.GetString("end_time")
  10758. check_time := c.GetString("check_time")
  10759. adminUser := c.GetAdminUserInfo()
  10760. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10761. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10762. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10763. sick, _ := service.FindSickById(sick_id)
  10764. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10765. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10766. var res ResultTwo
  10767. var res10265 ResultTwo10265
  10768. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10769. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10770. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10771. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10772. "&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
  10773. resp, requestErr := http.Get(api)
  10774. if requestErr != nil {
  10775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10776. return
  10777. }
  10778. body, ioErr := ioutil.ReadAll(resp.Body)
  10779. if ioErr != nil {
  10780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. var respJSON map[string]interface{}
  10785. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10788. return
  10789. }
  10790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10791. result, _ := json.Marshal(respJSON)
  10792. fmt.Println("log")
  10793. fmt.Println(string(result))
  10794. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10795. utils.ErrorLog("解析失败:%v", err)
  10796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10797. return
  10798. }
  10799. res.ErrMsg = res10265.ErrMsg
  10800. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10801. res.Infcode = infocode
  10802. res.Output = res10265.Output
  10803. res.InfRefmsgid = res10265.InfRefmsgid
  10804. } else {
  10805. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10806. if miConfig.Code == "H15049901371" {
  10807. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10808. utils.ErrorLog("解析失败:%v", err)
  10809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10810. return
  10811. }
  10812. res.ErrMsg = res10265.ErrMsg
  10813. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10814. res.Infcode = infocode
  10815. res.Output = res10265.Output
  10816. res.InfRefmsgid = res10265.InfRefmsgid
  10817. } else {
  10818. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10819. utils.ErrorLog("解析失败:%v", err)
  10820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10821. return
  10822. }
  10823. }
  10824. }
  10825. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10826. infoStr := string(Iinfos)
  10827. var rf []*ResultFive
  10828. json.Unmarshal([]byte(infoStr), &rf)
  10829. var insuplc_admdvs string
  10830. var insutype string
  10831. var is390 int = 0
  10832. var is310 int = 0
  10833. var insutypes []*ResultFive
  10834. for _, item := range rf {
  10835. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10836. insutypes = append(insutypes, item)
  10837. }
  10838. }
  10839. if len(insutypes) == 1 {
  10840. insutype = insutypes[0].Insutype
  10841. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10842. } else {
  10843. for _, i := range insutypes {
  10844. if i.Insutype == "390" {
  10845. is390 = 1
  10846. }
  10847. if i.Insutype == "310" {
  10848. is310 = 1
  10849. }
  10850. }
  10851. }
  10852. if is390 == 1 {
  10853. insutype = "390"
  10854. }
  10855. if is310 == 1 {
  10856. insutype = "310"
  10857. }
  10858. if len(insutypes) == 2 {
  10859. insutype = insutype_two
  10860. }
  10861. if len(insutypes) == 0 {
  10862. insutype = "310"
  10863. }
  10864. insutype = insutype_two
  10865. fmt.Println(insutype)
  10866. for _, item := range rf {
  10867. fmt.Println(item.Insutype)
  10868. fmt.Println(insutype)
  10869. if item.Insutype == insutype {
  10870. fmt.Println(item.Insutype)
  10871. fmt.Println(insutype)
  10872. insuplc_admdvs = item.InsuplcAdmdvs
  10873. }
  10874. }
  10875. fmt.Println(insuplc_admdvs)
  10876. var res2 ResultThirteen
  10877. var res10265_2 ResultThirteen10265
  10878. if config.IsOpen == 1 {
  10879. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10880. } else {
  10881. 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)
  10882. var dat map[string]interface{}
  10883. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10884. fmt.Println(dat)
  10885. } else {
  10886. fmt.Println(err)
  10887. }
  10888. userJSONBytes, _ := json.Marshal(dat)
  10889. if miConfig.Code == "H15049901371" {
  10890. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10891. utils.ErrorLog("解析失败:%v", err)
  10892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10893. return
  10894. }
  10895. res2.ErrMsg = res10265_2.ErrMsg
  10896. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10897. res2.Infcode = infocode
  10898. res2.Output = res10265_2.Output
  10899. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10900. } else {
  10901. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10902. utils.ErrorLog("解析失败:%v", err)
  10903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10904. return
  10905. }
  10906. }
  10907. }
  10908. if res2.Infcode == 0 {
  10909. psnResult := &models.GdybPsnNcdsRecord{
  10910. UserOrgId: adminUser.CurrentOrgId,
  10911. PatientId: patient.ID,
  10912. PsnNo: psn_no,
  10913. DoctorId: doctor.AdminUserId,
  10914. DepartmentId: department_id,
  10915. SickType: sick_id,
  10916. Insutype: insutype,
  10917. Ctime: time.Now().Unix(),
  10918. Mtime: time.Now().Unix(),
  10919. Status: 1,
  10920. IsCancel: 1,
  10921. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10922. }
  10923. service.CreatePsnNCDSRecord(psnResult)
  10924. c.ServeSuccessJSON(map[string]interface{}{
  10925. "failed_code": 0,
  10926. "msg": "备案成功",
  10927. "result": psnResult,
  10928. })
  10929. } else {
  10930. c.ServeSuccessJSON(map[string]interface{}{
  10931. "failed_code": -10,
  10932. "msg": res2.ErrMsg,
  10933. })
  10934. return
  10935. }
  10936. }
  10937. }
  10938. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10939. id, _ := c.GetInt64("id")
  10940. admin_user_id, _ := c.GetInt64("admin_user_id")
  10941. adminUser := c.GetAdminUserInfo()
  10942. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10943. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10944. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10945. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10946. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10947. //var user_name string
  10948. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10949. //if role.ID == 0 {
  10950. // user_name = "xxx"
  10951. //} else {
  10952. // user_name = role.UserName
  10953. //}
  10954. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10955. if psn_record.ID == 0 {
  10956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10957. return
  10958. }
  10959. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10960. var res ResultTwo
  10961. var res10265 ResultTwo10265
  10962. if miConfig.Code == "H15049901371" {
  10963. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10964. utils.ErrorLog("解析失败:%v", err)
  10965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10966. return
  10967. }
  10968. res.ErrMsg = res10265.ErrMsg
  10969. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10970. res.Infcode = infocode
  10971. res.Output = res10265.Output
  10972. res.InfRefmsgid = res10265.InfRefmsgid
  10973. } else {
  10974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10975. utils.ErrorLog("解析失败:%v", err)
  10976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10977. return
  10978. }
  10979. }
  10980. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10981. infoStr := string(Iinfos)
  10982. var rf []*ResultFive
  10983. json.Unmarshal([]byte(infoStr), &rf)
  10984. var insuplc_admdvs string
  10985. var insutype string
  10986. var is390 int = 0
  10987. var is310 int = 0
  10988. var insutypes []*ResultFive
  10989. for _, item := range rf {
  10990. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10991. insutypes = append(insutypes, item)
  10992. }
  10993. }
  10994. if len(insutypes) == 1 {
  10995. insutype = insutypes[0].Insutype
  10996. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10997. } else {
  10998. for _, i := range insutypes {
  10999. if i.Insutype == "390" {
  11000. is390 = 1
  11001. }
  11002. if i.Insutype == "310" {
  11003. is310 = 1
  11004. }
  11005. }
  11006. }
  11007. if is390 == 1 {
  11008. insutype = "390"
  11009. }
  11010. if is310 == 1 {
  11011. insutype = "310"
  11012. }
  11013. if len(insutypes) == 0 {
  11014. insutype = "310"
  11015. }
  11016. insutype = psn_record.Insutype
  11017. for _, item := range rf {
  11018. if item.Insutype == insutype {
  11019. insuplc_admdvs = item.InsuplcAdmdvs
  11020. }
  11021. }
  11022. if config.IsOpen == 1 {
  11023. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  11024. var dat map[string]interface{}
  11025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11026. fmt.Println(dat)
  11027. } else {
  11028. fmt.Println(err)
  11029. }
  11030. userJSONBytes, _ := json.Marshal(dat)
  11031. var res ResultFourteen
  11032. var res10265 ResultFourteen10265
  11033. if miConfig.Code == "H15049901371" {
  11034. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11035. utils.ErrorLog("解析失败:%v", err)
  11036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11037. return
  11038. }
  11039. res.ErrMsg = res10265.ErrMsg
  11040. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11041. res.Infcode = infocode
  11042. res.Output = res10265.Output
  11043. res.InfRefmsgid = res10265.InfRefmsgid
  11044. } else {
  11045. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11046. utils.ErrorLog("解析失败:%v", err)
  11047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11048. return
  11049. }
  11050. }
  11051. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11052. // utils.ErrorLog("解析失败:%v", err)
  11053. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11054. // return
  11055. //}
  11056. if res.Infcode == 0 {
  11057. psn_record.IsCancel = 2
  11058. service.CreatePsnNCDSRecord(&psn_record)
  11059. c.ServeSuccessJSON(map[string]interface{}{
  11060. "failed_code": 0,
  11061. "msg": "撤销备案成功",
  11062. })
  11063. } else {
  11064. c.ServeSuccessJSON(map[string]interface{}{
  11065. "failed_code": -10,
  11066. "msg": res.ErrMsg,
  11067. })
  11068. return
  11069. }
  11070. }
  11071. }
  11072. func (c *HisApiController) TestTest() {
  11073. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11074. fmt.Println(patient.Iinfo)
  11075. }
  11076. type CustomData struct {
  11077. MsgId string
  11078. PsnNo string
  11079. Info string
  11080. }
  11081. func (c *HisApiController) ReversalData() {
  11082. var customData []*CustomData
  11083. custom := &CustomData{
  11084. MsgId: "H44022900158202103301714472004",
  11085. PsnNo: "44020000001101329945",
  11086. Info: "2207",
  11087. }
  11088. customData = append(customData, custom)
  11089. custom1 := &CustomData{
  11090. MsgId: "H4402290015820210330172057803",
  11091. PsnNo: "44020000001101161813",
  11092. Info: "2207",
  11093. }
  11094. customData = append(customData, custom1)
  11095. custom2 := &CustomData{
  11096. MsgId: "H44022900158202103301705198813",
  11097. PsnNo: "44190000133097375417",
  11098. Info: "2207",
  11099. }
  11100. customData = append(customData, custom2)
  11101. custom3 := &CustomData{
  11102. MsgId: "H44022900158202103301715524756",
  11103. PsnNo: "44020000001100187221",
  11104. Info: "2207",
  11105. }
  11106. customData = append(customData, custom3)
  11107. custom4 := &CustomData{
  11108. MsgId: "H44022900158202103301730376224",
  11109. PsnNo: "44020000001101959155",
  11110. Info: "2207",
  11111. }
  11112. customData = append(customData, custom4)
  11113. custom5 := &CustomData{
  11114. MsgId: "H44022900158202103301748008725",
  11115. PsnNo: "44020000001104246641",
  11116. Info: "2207",
  11117. }
  11118. customData = append(customData, custom5)
  11119. custom6 := &CustomData{
  11120. MsgId: "H44022900158202103301718096755",
  11121. PsnNo: "44020000001102211860",
  11122. Info: "2207",
  11123. }
  11124. customData = append(customData, custom6)
  11125. custom7 := &CustomData{
  11126. MsgId: "H44022900158202103301736551640",
  11127. PsnNo: "44020000001102687718",
  11128. Info: "2207",
  11129. }
  11130. customData = append(customData, custom7)
  11131. custom8 := &CustomData{
  11132. MsgId: "H44022900158202103301743097676",
  11133. PsnNo: "44020000001102127785",
  11134. Info: "2207",
  11135. }
  11136. customData = append(customData, custom8)
  11137. custom9 := &CustomData{
  11138. MsgId: "H44022900158202103301712304203",
  11139. PsnNo: "44020000001101518097",
  11140. Info: "2207",
  11141. }
  11142. customData = append(customData, custom9)
  11143. custom10 := &CustomData{
  11144. MsgId: "H44022900158202103301738448785",
  11145. PsnNo: "44020000001100500813",
  11146. Info: "2207",
  11147. }
  11148. customData = append(customData, custom10)
  11149. custom11 := &CustomData{
  11150. MsgId: "H44022900158202103301732455843",
  11151. PsnNo: "44020000001102690557",
  11152. Info: "2207",
  11153. }
  11154. customData = append(customData, custom11)
  11155. custom12 := &CustomData{
  11156. MsgId: "H44022900158202103301745421708",
  11157. PsnNo: "44020000001102211928",
  11158. Info: "2207",
  11159. }
  11160. customData = append(customData, custom12)
  11161. custom1212 := &CustomData{
  11162. MsgId: "H440229001582021033017351627",
  11163. PsnNo: "44020000001102481733",
  11164. Info: "2207",
  11165. }
  11166. customData = append(customData, custom1212)
  11167. custom13 := &CustomData{
  11168. MsgId: "H44022900158202103301740327951",
  11169. PsnNo: "44020000001103174866",
  11170. Info: "2207",
  11171. }
  11172. customData = append(customData, custom13)
  11173. custom14 := &CustomData{
  11174. MsgId: "H4402290015820210330174922668",
  11175. PsnNo: "44020000001102927272",
  11176. Info: "2207",
  11177. }
  11178. customData = append(customData, custom14)
  11179. custom15 := &CustomData{
  11180. MsgId: "H44022900158202103301752362273",
  11181. PsnNo: "44020000001102942890",
  11182. Info: "2207",
  11183. }
  11184. customData = append(customData, custom15)
  11185. custom16 := &CustomData{
  11186. MsgId: "H44022900158202103301751082917",
  11187. PsnNo: "44020000001101662162",
  11188. Info: "2207",
  11189. }
  11190. customData = append(customData, custom16)
  11191. custom17 := &CustomData{
  11192. MsgId: "H44022900158202103301754147728",
  11193. PsnNo: "44020000000229014511",
  11194. Info: "2207",
  11195. }
  11196. customData = append(customData, custom17)
  11197. adminUser := c.GetAdminUserInfo()
  11198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11199. for _, item := range customData {
  11200. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11201. fmt.Println(result)
  11202. }
  11203. }
  11204. //func (c *HisApiController) GetAllopatry() {
  11205. // year := c.GetString("year")
  11206. // month := c.GetString("month")
  11207. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11208. // adminUser := c.GetAdminUserInfo()
  11209. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11210. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11211. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11212. //
  11213. // var dat map[string]interface{}
  11214. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11215. // fmt.Println(dat)
  11216. // } else {
  11217. // fmt.Println(err)
  11218. // }
  11219. // userJSONBytes, _ := json.Marshal(dat)
  11220. // var res models.Result9001
  11221. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11222. // utils.ErrorLog("解析失败:%v", err)
  11223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11224. // return
  11225. // }
  11226. //
  11227. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11228. // var dat2 map[string]interface{}
  11229. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11230. // fmt.Println(dat)
  11231. // } else {
  11232. // fmt.Println(err)
  11233. // }
  11234. // userJSONBytes2, _ := json.Marshal(dat2)
  11235. // var res2 models.Result3260
  11236. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11237. // utils.ErrorLog("解析失败:%v", err)
  11238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11239. // return
  11240. // }
  11241. // if res2.Infcode == 0 {
  11242. // c.ServeSuccessJSON(map[string]interface{}{
  11243. // "list": res2.Output.Data,
  11244. // })
  11245. // return
  11246. // } else {
  11247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11248. // return
  11249. // }
  11250. //
  11251. //}
  11252. //func (c *HisApiController) ComfirmAllopatry() {
  11253. // year := c.GetString("year")
  11254. // month := c.GetString("month")
  11255. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11256. // adminUser := c.GetAdminUserInfo()
  11257. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11258. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11259. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11260. // var dat map[string]interface{}
  11261. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11262. // fmt.Println(dat)
  11263. // } else {
  11264. // fmt.Println(err)
  11265. // }
  11266. // userJSONBytes, _ := json.Marshal(dat)
  11267. // var res models.Result9001
  11268. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11269. // utils.ErrorLog("解析失败:%v", err)
  11270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11271. // return
  11272. // }
  11273. //
  11274. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11275. // var dat2 map[string]interface{}
  11276. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11277. // fmt.Println(dat)
  11278. // } else {
  11279. // fmt.Println(err)
  11280. // }
  11281. // userJSONBytes2, _ := json.Marshal(dat2)
  11282. // var res2 models.Result3260
  11283. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11284. // utils.ErrorLog("解析失败:%v", err)
  11285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11286. // return
  11287. // }
  11288. //
  11289. // if res2.Infcode == 0 {
  11290. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11291. // var dat map[string]interface{}
  11292. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11293. // fmt.Println(dat)
  11294. // } else {
  11295. // fmt.Println(err)
  11296. // }
  11297. // userJSONBytes, _ := json.Marshal(dat)
  11298. // var res3 models.Result3261
  11299. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11300. // utils.ErrorLog("解析失败:%v", err)
  11301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11302. // return
  11303. // }
  11304. //
  11305. // if res3.Infcode == 0 {
  11306. // record := &models.HisYidiClearRecord{
  11307. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11308. // Ctime: time.Now().Unix(),
  11309. // Mtime: time.Now().Unix(),
  11310. // Status: 1,
  11311. // MsgId: msgId,
  11312. // }
  11313. // service.SaveClearRecord(record)
  11314. // c.ServeSuccessJSON(map[string]interface{}{
  11315. // "msg": "提取成功",
  11316. // })
  11317. // }
  11318. // }
  11319. //}
  11320. func (c *HisApiController) RefundAllopatry() {
  11321. year := c.GetString("year")
  11322. month := c.GetString("month")
  11323. id, _ := c.GetInt64("id")
  11324. admin_user_id, _ := c.GetInt64("admin_user_id")
  11325. adminUser := c.GetAdminUserInfo()
  11326. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11327. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11328. record, _ := service.GetClearRecordById(id)
  11329. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11330. var dat map[string]interface{}
  11331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11332. fmt.Println(dat)
  11333. } else {
  11334. fmt.Println(err)
  11335. }
  11336. userJSONBytes, _ := json.Marshal(dat)
  11337. var empty ResultFourteen
  11338. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11339. utils.ErrorLog("解析失败:%v", err)
  11340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11341. return
  11342. }
  11343. if empty.Infcode == 0 {
  11344. c.ServeSuccessJSON(map[string]interface{}{
  11345. "msg": "撤销成功",
  11346. })
  11347. return
  11348. }
  11349. }
  11350. func (c *HisApiController) ReversalOtherData() {
  11351. var customData []*CustomData
  11352. custom := &CustomData{
  11353. MsgId: "H44022900158202103301714472004",
  11354. PsnNo: "44020000001101329945",
  11355. Info: "2208",
  11356. }
  11357. customData = append(customData, custom)
  11358. custom1 := &CustomData{
  11359. MsgId: "H4402290015820210330172057803",
  11360. PsnNo: "44020000001101161813",
  11361. Info: "2208",
  11362. }
  11363. customData = append(customData, custom1)
  11364. custom2 := &CustomData{
  11365. MsgId: "H44022900158202103301705198813",
  11366. PsnNo: "44190000133097375417",
  11367. Info: "2208",
  11368. }
  11369. customData = append(customData, custom2)
  11370. custom3 := &CustomData{
  11371. MsgId: "H44022900158202103301715524756",
  11372. PsnNo: "44020000001100187221",
  11373. Info: "2208",
  11374. }
  11375. customData = append(customData, custom3)
  11376. custom4 := &CustomData{
  11377. MsgId: "H44022900158202103301730376224",
  11378. PsnNo: "44020000001101959155",
  11379. Info: "2208",
  11380. }
  11381. customData = append(customData, custom4)
  11382. custom5 := &CustomData{
  11383. MsgId: "H44022900158202103301748008725",
  11384. PsnNo: "44020000001104246641",
  11385. Info: "2208",
  11386. }
  11387. customData = append(customData, custom5)
  11388. custom6 := &CustomData{
  11389. MsgId: "H44022900158202103301718096755",
  11390. PsnNo: "44020000001102211860",
  11391. Info: "2208",
  11392. }
  11393. customData = append(customData, custom6)
  11394. custom7 := &CustomData{
  11395. MsgId: "H44022900158202103301736551640",
  11396. PsnNo: "44020000001102687718",
  11397. Info: "2208",
  11398. }
  11399. customData = append(customData, custom7)
  11400. custom8 := &CustomData{
  11401. MsgId: "H44022900158202103301743097676",
  11402. PsnNo: "44020000001102127785",
  11403. Info: "2208",
  11404. }
  11405. customData = append(customData, custom8)
  11406. custom9 := &CustomData{
  11407. MsgId: "H44022900158202103301712304203",
  11408. PsnNo: "44020000001101518097",
  11409. Info: "2208",
  11410. }
  11411. customData = append(customData, custom9)
  11412. custom10 := &CustomData{
  11413. MsgId: "H44022900158202103301738448785",
  11414. PsnNo: "44020000001100500813",
  11415. Info: "2208",
  11416. }
  11417. customData = append(customData, custom10)
  11418. custom11 := &CustomData{
  11419. MsgId: "H44022900158202103301732455843",
  11420. PsnNo: "44020000001102690557",
  11421. Info: "2208",
  11422. }
  11423. customData = append(customData, custom11)
  11424. custom12 := &CustomData{
  11425. MsgId: "H44022900158202103301745421708",
  11426. PsnNo: "44020000001102211928",
  11427. Info: "2208",
  11428. }
  11429. customData = append(customData, custom12)
  11430. custom1212 := &CustomData{
  11431. MsgId: "H440229001582021033017351627",
  11432. PsnNo: "44020000001102481733",
  11433. Info: "2208",
  11434. }
  11435. customData = append(customData, custom1212)
  11436. custom13 := &CustomData{
  11437. MsgId: "H44022900158202103301740327951",
  11438. PsnNo: "44020000001103174866",
  11439. Info: "2208",
  11440. }
  11441. customData = append(customData, custom13)
  11442. custom14 := &CustomData{
  11443. MsgId: "H4402290015820210330174922668",
  11444. PsnNo: "44020000001102927272",
  11445. Info: "2208",
  11446. }
  11447. customData = append(customData, custom14)
  11448. custom15 := &CustomData{
  11449. MsgId: "H44022900158202103301752362273",
  11450. PsnNo: "44020000001102942890",
  11451. Info: "2208",
  11452. }
  11453. customData = append(customData, custom15)
  11454. custom16 := &CustomData{
  11455. MsgId: "H44022900158202103301751082917",
  11456. PsnNo: "44020000001101662162",
  11457. Info: "2208",
  11458. }
  11459. customData = append(customData, custom16)
  11460. custom17 := &CustomData{
  11461. MsgId: "H44022900158202103301754147728",
  11462. PsnNo: "44020000000229014511",
  11463. Info: "2208",
  11464. }
  11465. customData = append(customData, custom17)
  11466. adminUser := c.GetAdminUserInfo()
  11467. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11468. for _, item := range customData {
  11469. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11470. fmt.Println(result)
  11471. }
  11472. }
  11473. func PathExists(path string) (bool, error) {
  11474. _, err := os.Stat(path)
  11475. if err == nil {
  11476. return true, nil
  11477. }
  11478. if os.IsNotExist(err) {
  11479. return false, nil
  11480. }
  11481. return false, err
  11482. }
  11483. //创建文件夹
  11484. func Mkdir(dir string) {
  11485. // 创建文件夹
  11486. exist, err := PathExists(dir)
  11487. if err != nil {
  11488. fmt.Println(err.Error())
  11489. } else {
  11490. if exist {
  11491. fmt.Println(dir + "文件夹已存在!")
  11492. } else {
  11493. // 文件夹名称,权限
  11494. err := os.Mkdir(dir, os.ModePerm)
  11495. if err != nil {
  11496. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11497. } else {
  11498. fmt.Println(dir + "文件夹创建成功!")
  11499. }
  11500. }
  11501. }
  11502. }
  11503. //压缩文件
  11504. func Zip(srcFile string, destZip string) error {
  11505. zipfile, err := os.Create(destZip)
  11506. if err != nil {
  11507. return err
  11508. }
  11509. defer zipfile.Close()
  11510. archive := zip.NewWriter(zipfile)
  11511. defer archive.Close()
  11512. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11513. if err != nil {
  11514. return err
  11515. }
  11516. header, err := zip.FileInfoHeader(info)
  11517. if err != nil {
  11518. return err
  11519. }
  11520. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11521. // header.Name = path
  11522. if info.IsDir() {
  11523. header.Name += "/"
  11524. } else {
  11525. header.Method = zip.Deflate
  11526. }
  11527. writer, err := archive.CreateHeader(header)
  11528. if err != nil {
  11529. return err
  11530. }
  11531. if !info.IsDir() {
  11532. file, err := os.Open(path)
  11533. if err != nil {
  11534. return err
  11535. }
  11536. defer file.Close()
  11537. _, err = io.Copy(writer, file)
  11538. }
  11539. return err
  11540. })
  11541. return err
  11542. }
  11543. func ReadFile(filePath string) []byte {
  11544. f, err := os.Open(filePath)
  11545. if err != nil {
  11546. fmt.Println("read file fail", err)
  11547. return nil
  11548. }
  11549. defer f.Close()
  11550. fd, err := ioutil.ReadAll(f)
  11551. if err != nil {
  11552. fmt.Println("read to fd fail", err)
  11553. return nil
  11554. }
  11555. return fd
  11556. }
  11557. func saveLog(result string, request string, infno string, desc string) {
  11558. org_id, _ := beego.AppConfig.Int64("org_id")
  11559. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11560. dir := miConfig.OrgName + "日志"
  11561. utils.Mkdir(dir)
  11562. month := time.Unix(1557042972, 0).Format("1")
  11563. year := time.Now().Format("2006")
  11564. month = time.Now().Format("01")
  11565. day := time.Now().Format("02")
  11566. hour := time.Now().Format("15")
  11567. min := time.Now().Format("04")
  11568. sec := time.Now().Format("05")
  11569. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11570. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11571. file_name := file + ".txt"
  11572. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11573. exist, _ := utils.PathExists(file_path)
  11574. if exist { //存在
  11575. fmt.Println("存在")
  11576. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11577. if err != nil {
  11578. fmt.Println("read fail")
  11579. }
  11580. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11581. n, _ := f.Seek(0, 2)
  11582. _, err = f.WriteAt([]byte(content), n)
  11583. } else { //不存在
  11584. fmt.Println("文件不存在,创建文件")
  11585. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11586. defer f.Close()
  11587. if err != nil {
  11588. } else {
  11589. _, err = f.Write([]byte("记录日志"))
  11590. }
  11591. }
  11592. }
  11593. type Charset string
  11594. const (
  11595. UTF8 = Charset("UTF-8")
  11596. GB18030 = Charset("GB18030")
  11597. )
  11598. func ConvertToString(src string, srcCode string, tagCode string) string {
  11599. srcCoder := mahonia.NewDecoder(srcCode)
  11600. srcResult := srcCoder.ConvertString(src)
  11601. tagCoder := mahonia.NewDecoder(tagCode)
  11602. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11603. result := string(cdata)
  11604. return result
  11605. }
  11606. func (c *HisApiController) ReadEleCard() {
  11607. id_card_type, _ := c.GetInt64("id_card_type")
  11608. admin_user_id, _ := c.GetInt64("admin_user_id")
  11609. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11610. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11611. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11612. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11613. var api string
  11614. if miConfig.MdtrtareaAdmvs == "320921" {
  11615. 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 +
  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. fmt.Println(api)
  11618. } else {
  11619. 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 +
  11620. "&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
  11621. }
  11622. resp, requestErr := http.Get(api)
  11623. if requestErr != nil {
  11624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11625. return
  11626. }
  11627. body, ioErr := ioutil.ReadAll(resp.Body)
  11628. if ioErr != nil {
  11629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11631. return
  11632. }
  11633. var respJSON map[string]interface{}
  11634. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11637. return
  11638. }
  11639. var status string
  11640. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11641. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11642. var token string
  11643. var res ResultTwo //1101结果
  11644. var res10265 ResultTwo10265 //1101结果
  11645. if status == "0" { //读卡成功
  11646. var card_info string //卡信息
  11647. var busi_card_info string
  11648. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11649. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11650. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11651. fmt.Println(card_info)
  11652. fmt.Println(busi_card_info)
  11653. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11654. result, _ := json.Marshal(respJSON)
  11655. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11656. utils.ErrorLog("解析失败:%v", err)
  11657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11658. return
  11659. }
  11660. res.ErrMsg = res10265.ErrMsg
  11661. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11662. res.Infcode = infocode
  11663. res.Output = res10265.Output
  11664. res.InfRefmsgid = res10265.InfRefmsgid
  11665. if res.Infcode == 0 {
  11666. c.ServeSuccessJSON(map[string]interface{}{
  11667. "number": token,
  11668. })
  11669. }
  11670. } else {
  11671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11672. return
  11673. }
  11674. } else { //读卡失败
  11675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11676. return
  11677. }
  11678. }
  11679. func DeleteExtraSpaceTwo(s string) string {
  11680. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11681. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11682. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11683. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11684. s2 := make([]byte, len(s1)) //定义字符数组切片
  11685. copy(s2, s1) //将字符串复制到切片
  11686. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11687. for len(spc_index) > 0 { //找到适配项
  11688. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11689. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11690. }
  11691. return string(s2)
  11692. }
  11693. func Remove0000(s string) string {
  11694. str := make([]rune, 0, len(s))
  11695. for _, v := range []rune(s) {
  11696. if v == 0 {
  11697. continue
  11698. }
  11699. str = append(str, v)
  11700. }
  11701. return string(str)
  11702. }
  11703. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11704. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11705. readCard := DllDef.MustFindProc("EcQuery")
  11706. pCardInfo := make([]byte, 8192)
  11707. pBusiCardInfo := make([]byte, 8192)
  11708. data := make(map[string]interface{})
  11709. //pData := make(map[string]interface{})
  11710. inputData := make(map[string]interface{})
  11711. inputData["orgId"] = code
  11712. inputData["businessType"] = "01101"
  11713. inputData["operatorId"] = operator_id
  11714. inputData["operatorName"] = operator_name
  11715. inputData["officeId"] = "001"
  11716. inputData["officeName"] = "血透室"
  11717. //
  11718. data["data"] = inputData
  11719. data["transType"] = "ec.query"
  11720. data["orgId"] = code
  11721. bytesData, _ := json.Marshal(data)
  11722. pCardInfo = bytesData
  11723. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11724. fmt.Println(ret2)
  11725. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11726. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11727. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11728. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11729. if ret2 != 0 {
  11730. return "", ""
  11731. }
  11732. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11733. }
  11734. func DeleteExtraSpace(s string) string {
  11735. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11736. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11737. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11738. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11739. s2 := make([]byte, len(s1)) //定义字符数组切片
  11740. copy(s2, s1) //将字符串复制到切片
  11741. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11742. for len(spc_index) > 0 { //找到适配项
  11743. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11744. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11745. }
  11746. return string(s2)
  11747. }
  11748. //对账
  11749. func (c *HisApiController) Post3202() {
  11750. start_time := c.GetString("start_time")
  11751. end_time := c.GetString("end_time")
  11752. //insutype := c.GetString("insutype")
  11753. clr_type := c.GetString("clr_type")
  11754. clr_org := c.GetString("clr_optins")
  11755. admin_user_id, _ := c.GetInt64("admin_user_id")
  11756. adminUser := c.GetAdminUserInfo()
  11757. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11758. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11759. if len(clr_org) == 0 {
  11760. clr_org = miConfig.MdtrtareaAdmvs
  11761. }
  11762. timeLayout := "2006-01-02"
  11763. loc, _ := time.LoadLocation("Local")
  11764. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11765. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11766. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "390", "", clr_type)
  11767. orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  11768. //fixmedins_setl_cnt := int64(len(orders))
  11769. var medfee_sumamt float64
  11770. var acct_pay float64
  11771. var fund_pay_sumamt float64
  11772. for _, item := range orders {
  11773. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11774. acct_pay = acct_pay + item.AcctPay
  11775. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11776. }
  11777. var medfee_sumamt_two float64
  11778. var acct_pay_two float64
  11779. var fund_pay_sumamt_two float64
  11780. for _, item := range orders_two {
  11781. medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  11782. acct_pay_two = acct_pay_two + item.AcctPay
  11783. fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  11784. }
  11785. //var user_name string
  11786. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11787. //if role.ID == 0 {
  11788. // user_name = "xxx"
  11789. //} else {
  11790. // user_name = role.UserName
  11791. //}
  11792. var res ResultSix
  11793. if config.IsOpen == 1 {
  11794. var bps []*models.BusinessParamsTwo
  11795. var bp models.BusinessParamsTwo
  11796. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  11797. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  11798. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  11799. bp.MedfeeSumamt = medfee_sumamt_str
  11800. bp.AcctPay = acct_pay_str
  11801. bp.FundPaySumamt = fund_pay_sumamt_str
  11802. bp.Insutype = "390"
  11803. bp.StmtBegndate = start_time
  11804. bp.ClrType = clr_type
  11805. bp.SetlOptins = clr_org
  11806. bp.StmtEnddate = end_time
  11807. bps = append(bps, &bp)
  11808. medfee_sumamt_two_str := fmt.Sprintf("%.2f", medfee_sumamt_two)
  11809. acct_pay_two_str := fmt.Sprintf("%.2f", acct_pay_two)
  11810. fund_pay_sumamt_two_str := fmt.Sprintf("%.2f", fund_pay_sumamt_two)
  11811. var bp2 models.BusinessParamsTwo
  11812. bp2.MedfeeSumamt = medfee_sumamt_two_str
  11813. bp2.AcctPay = acct_pay_two_str
  11814. bp2.FundPaySumamt = fund_pay_sumamt_two_str
  11815. bp2.Insutype = "310"
  11816. bp2.StmtBegndate = start_time
  11817. bp2.StmtEnddate = end_time
  11818. bp2.ClrType = clr_type
  11819. bp2.SetlOptins = clr_org
  11820. bps = append(bps, &bp2)
  11821. fmt.Println(bps)
  11822. data := make(map[string]interface{})
  11823. data["bps"] = bps
  11824. data["org_name"] = miConfig.OrgName
  11825. data["doctor"] = role.UserName
  11826. data["fixmedins_code"] = miConfig.Code
  11827. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11828. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11829. if miConfig.MdtrtareaAdmvs == "421300" {
  11830. client := &http.Client{}
  11831. bytesData, _ := json.Marshal(data)
  11832. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  11833. resp, _ := client.Do(req)
  11834. defer resp.Body.Close()
  11835. body, ioErr := ioutil.ReadAll(resp.Body)
  11836. if ioErr != nil {
  11837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11839. return
  11840. }
  11841. var respJSON map[string]interface{}
  11842. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11845. return
  11846. }
  11847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11848. userJSONBytes, _ := json.Marshal(respJSON)
  11849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11850. utils.ErrorLog("解析失败:%v", err)
  11851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11852. return
  11853. }
  11854. }
  11855. if res.Infcode == 0 {
  11856. c.ServeSuccessJSON(map[string]interface{}{
  11857. "msg": "发起成功",
  11858. })
  11859. } else {
  11860. c.ServeSuccessJSON(map[string]interface{}{
  11861. "code": -10,
  11862. "msg": res.ErrMsg,
  11863. })
  11864. }
  11865. }
  11866. }