his_api_controller.go 439KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080
  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. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  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. }
  78. func (c *HisApiController) Get9001() {
  79. adminUser := c.GetAdminUserInfo()
  80. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  81. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  82. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  83. var dat map[string]interface{}
  84. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  85. fmt.Println(dat)
  86. } else {
  87. fmt.Println(err)
  88. }
  89. userJSONBytes, _ := json.Marshal(dat)
  90. var res models.Result9001
  91. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  92. utils.ErrorLog("解析失败:%v", err)
  93. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  94. return
  95. }
  96. }
  97. func (c *HisApiController) Check3101() {
  98. patient_id, _ := c.GetInt64("patient_id")
  99. his_patient_id, _ := c.GetInt64("his_patient_id")
  100. admin_user_id, _ := c.GetInt64("admin_user_id")
  101. adminUser := c.GetAdminUserInfo()
  102. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  103. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  105. record_time := c.GetString("record_time")
  106. trig_scen := c.GetString("trig_scen")
  107. timeLayout := "2006-01-02"
  108. loc, _ := time.LoadLocation("Local")
  109. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  110. if err != nil {
  111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  112. return
  113. }
  114. recordDateTime := theTime.Unix()
  115. var patientPrescription models.HisPrescriptionInfo
  116. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  117. if patientPrescription.ID == 0 {
  118. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  119. }
  120. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  121. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  122. //
  123. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  124. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  125. var pp models.PublicParams
  126. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  127. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  128. pp.FixmedinsName = miConfig.OrgName
  129. pp.FixmedinsCode = miConfig.Code
  130. pp.RequestUrl = miConfig.Url
  131. pp.Cainfo = miConfig.Cainfo
  132. pp.SecretKey = miConfig.SecretKey
  133. pp.AccessKey = miConfig.AccessKey
  134. pp.OpterName = roles.UserName
  135. var config []*models.HisXtDiagnoseConfig
  136. for _, item := range diagnosis_ids {
  137. id, _ := strconv.ParseInt(item, 10, 64)
  138. diagnosisConfig, _ := service.FindDiagnoseById(id)
  139. config = append(config, &diagnosisConfig)
  140. }
  141. var pd models.PatientDtos
  142. pd.PatnID = his.PsnNo
  143. pd.PatnName = his.Name
  144. pd.Gend = his.Gend
  145. pd.Brdy = his.Brdy
  146. pd.Poolarea = his.InsuplcAdmdvs
  147. pd.CurrMdtrtID = his.Number
  148. var fed models.FsiEncounterDtos
  149. fed.MdtrtID = his.Number
  150. fed.MedinsID = miConfig.Code
  151. fed.MedinsName = miConfig.OrgName
  152. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  153. fed.MedMdtrtType = "1"
  154. fed.MedinsType = "1"
  155. fed.MedinsLv = "11"
  156. tm := time.Unix(his.RecordDate, 0)
  157. s_tm := tm.Format("2006-01-02 15:04:05")
  158. fed.AdmDate = s_tm
  159. fed.DscgDate = s_tm
  160. fed.DscgMainDiseCodg = config[0].CountryCode
  161. fed.DscgMainDiseName = config[0].CountryContentName
  162. //诊断信息
  163. var fdds []*models.FsiDiagnoseDtos
  164. for index, item := range config {
  165. if index == 0 {
  166. var fdd models.FsiDiagnoseDtos
  167. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  168. fdd.InoutDiseType = "1"
  169. fdd.MaindiseFlag = "1"
  170. fdd.DiseDate = s_tm
  171. fdd.DiasSrtNo = "1"
  172. fdd.DiseName = item.CountryContentName
  173. fdd.DiseCodg = item.CountryCode
  174. fdds = append(fdds, &fdd)
  175. } else {
  176. var fdd models.FsiDiagnoseDtos
  177. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  178. fdd.InoutDiseType = "1"
  179. fdd.MaindiseFlag = "1"
  180. fdd.DiseDate = s_tm
  181. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  182. fdd.DiseName = item.CountryContentName
  183. fdd.DiseCodg = item.CountryCode
  184. fdds = append(fdds, &fdd)
  185. }
  186. }
  187. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  188. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  189. fed.AdmDeptName = department.Name
  190. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  191. fed.DscgDeptName = department.Name
  192. fed.MedMdtrtType = "1"
  193. fed.MedType = "11"
  194. //if his.Insutype == "390" {
  195. // fed.MedType = "1402"
  196. //} else {
  197. // fed.MedType = "9933"
  198. //}
  199. var orders []*models.FsiOrderDtos
  200. if trig_scen == "2" {
  201. //处方医嘱信息
  202. for _, item := range prescriptions {
  203. for _, subItem := range item.HisDoctorAdviceInfo {
  204. var order models.FsiOrderDtos
  205. order.RxID = strconv.FormatInt(item.ID, 10)
  206. order.Rxno = strconv.FormatInt(item.ID, 10)
  207. order.LongDrordFlag = "0"
  208. order.HilistType = "1"
  209. order.ChrgType = "1"
  210. order.DrordBhvr = "-"
  211. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  212. order.HosplistName = subItem.BaseDrugLib.DrugName
  213. order.HilistLv = "1"
  214. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  215. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  216. order.HosplistName = subItem.BaseDrugLib.DrugName
  217. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  218. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  219. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  220. order.OwnpayAmt = ""
  221. order.SelfpayAmt = ""
  222. order.Spec = ""
  223. order.SpecUnt = ""
  224. order.DrordBegnDate = s_tm
  225. order.DrordStopDate = ""
  226. order.DrordDrCodg = "1"
  227. order.DrordDeptName = department.Name
  228. order.DrordDrCodg = "1"
  229. order.DrordDrName = doctor_info.UserName
  230. order.DrordDrProfttl = ""
  231. order.CurrDrordFlag = "1"
  232. orders = append(orders, &order)
  233. }
  234. for _, subItem := range item.HisPrescriptionProject {
  235. if subItem.Type == 2 {
  236. var order models.FsiOrderDtos
  237. order.RxID = strconv.FormatInt(item.ID, 10)
  238. order.Rxno = strconv.FormatInt(item.ID, 10)
  239. order.LongDrordFlag = "0"
  240. order.HilistType = "1"
  241. order.ChrgType = "1"
  242. order.DrordBhvr = "-"
  243. order.HilistCode = subItem.HisProject.MedicalCode
  244. order.HosplistName = subItem.HisProject.ProjectName
  245. order.HilistLv = "1"
  246. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  247. order.HosplistCode = subItem.HisProject.MedicalCode
  248. order.HosplistName = subItem.HisProject.ProjectName
  249. order.Cnt = subItem.Count
  250. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  251. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  252. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  253. order.OwnpayAmt = ""
  254. order.SelfpayAmt = ""
  255. order.Spec = ""
  256. order.SpecUnt = ""
  257. order.DrordBegnDate = s_tm
  258. order.DrordStopDate = ""
  259. order.DrordDrCodg = "1"
  260. order.DrordDeptName = department.Name
  261. order.DrordDrCodg = "1"
  262. order.DrordDrName = doctor_info.UserName
  263. order.DrordDrProfttl = ""
  264. order.CurrDrordFlag = "1"
  265. orders = append(orders, &order)
  266. }
  267. if subItem.Type == 3 {
  268. var order models.FsiOrderDtos
  269. order.RxID = strconv.FormatInt(item.ID, 10)
  270. order.Rxno = strconv.FormatInt(item.ID, 10)
  271. order.LongDrordFlag = "0"
  272. order.HilistType = "1"
  273. order.ChrgType = "1"
  274. order.DrordBhvr = "-"
  275. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  276. order.HosplistName = subItem.GoodInfo.GoodName
  277. order.HilistLv = "1"
  278. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  279. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  280. order.HosplistName = subItem.GoodInfo.GoodName
  281. order.Cnt = subItem.Count
  282. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  283. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  284. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  285. order.OwnpayAmt = ""
  286. order.SelfpayAmt = ""
  287. order.Spec = ""
  288. order.SpecUnt = ""
  289. order.DrordBegnDate = s_tm
  290. order.DrordStopDate = ""
  291. order.DrordDrCodg = "1"
  292. order.DrordDeptName = department.Name
  293. order.DrordDrCodg = "1"
  294. order.DrordDrName = doctor_info.UserName
  295. order.DrordDrProfttl = ""
  296. order.CurrDrordFlag = "1"
  297. orders = append(orders, &order)
  298. }
  299. }
  300. }
  301. //处方医嘱信息
  302. }
  303. fed.MatnStas = "0"
  304. fed.MedfeeSumamt = "0"
  305. fed.OwnpayAmt = "0"
  306. fed.SelfpayAmt = "0"
  307. fed.AcctPayamt = "0"
  308. fed.MaAmt = "0"
  309. fed.HifpPayamt = "0"
  310. fed.SetlTotlnum = "1"
  311. fed.Insutype = his.Insutype
  312. fed.ReimFlag = "0"
  313. fed.OutSetlFlag = "0"
  314. var fopd []*models.FsiOperationDtosData
  315. data := make(map[string]interface{})
  316. data["fed"] = fed
  317. data["fdd"] = fdds
  318. data["fod"] = orders
  319. data["pd"] = pd
  320. data["pp"] = pp
  321. data["fopd"] = fopd
  322. data["trig_scen"] = trig_scen
  323. fmt.Println(data)
  324. fmt.Println(fed)
  325. fmt.Println(fdds)
  326. fmt.Println(orders)
  327. fmt.Println(pd)
  328. fmt.Println(pp)
  329. fmt.Println(fopd)
  330. client := &http.Client{}
  331. bytesData, _ := json.Marshal(data)
  332. var req *http.Request
  333. if miConfig.MdtrtareaAdmvs == "320921" {
  334. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  335. } else {
  336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  337. }
  338. resp, _ := client.Do(req)
  339. defer resp.Body.Close()
  340. body, ioErr := ioutil.ReadAll(resp.Body)
  341. if ioErr != nil {
  342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  344. return
  345. }
  346. var respJSON map[string]interface{}
  347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. //手术操作集合
  353. //手术操作集合
  354. }
  355. func (c *HisApiController) Check3102() {
  356. patient_id, _ := c.GetInt64("patient_id")
  357. order_id, _ := c.GetInt64("order_id")
  358. his_patient_id, _ := c.GetInt64("his_patient_id")
  359. admin_user_id, _ := c.GetInt64("admin_user_id")
  360. trig_scen := c.GetString("trig_scen")
  361. adminUser := c.GetAdminUserInfo()
  362. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  363. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  365. record_time := c.GetString("record_time")
  366. order, _ := service.GetHisOrderByID(order_id)
  367. timeLayout := "2006-01-02"
  368. loc, _ := time.LoadLocation("Local")
  369. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  370. if err != nil {
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  372. return
  373. }
  374. recordDateTime := theTime.Unix()
  375. var patientPrescription models.HisPrescriptionInfo
  376. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  377. if patientPrescription.ID == 0 {
  378. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  379. }
  380. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  381. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  382. //
  383. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  384. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  385. var pp models.PublicParams
  386. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  387. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  388. pp.FixmedinsName = miConfig.OrgName
  389. pp.FixmedinsCode = miConfig.Code
  390. pp.RequestUrl = miConfig.Url
  391. pp.Cainfo = miConfig.Cainfo
  392. pp.SecretKey = miConfig.SecretKey
  393. pp.AccessKey = miConfig.AccessKey
  394. pp.OpterName = roles.UserName
  395. var config []*models.HisXtDiagnoseConfig
  396. for _, item := range diagnosis_ids {
  397. id, _ := strconv.ParseInt(item, 10, 64)
  398. diagnosisConfig, _ := service.FindDiagnoseById(id)
  399. config = append(config, &diagnosisConfig)
  400. }
  401. var pd models.PatientDtos
  402. pd.PatnID = his.PsnNo
  403. pd.PatnName = his.Name
  404. pd.Gend = his.Gend
  405. pd.Brdy = his.Brdy
  406. pd.Poolarea = his.InsuplcAdmdvs
  407. pd.CurrMdtrtID = his.Number
  408. var fed models.FsiEncounterDtos
  409. fed.MdtrtID = his.Number
  410. fed.MedinsID = miConfig.Code
  411. fed.MedinsName = miConfig.OrgName
  412. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  413. fed.MedMdtrtType = "1"
  414. fed.MedinsType = "1"
  415. fed.MedinsLv = "11"
  416. tm := time.Unix(his.RecordDate, 0)
  417. s_tm := tm.Format("2006-01-02 15:04:05")
  418. fed.AdmDate = s_tm
  419. fed.DscgDate = s_tm
  420. fed.DscgMainDiseCodg = config[0].CountryCode
  421. fed.DscgMainDiseName = config[0].CountryContentName
  422. //诊断信息
  423. var fdds []*models.FsiDiagnoseDtos
  424. for index, item := range config {
  425. if index == 0 {
  426. var fdd models.FsiDiagnoseDtos
  427. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  428. fdd.InoutDiseType = "1"
  429. fdd.MaindiseFlag = "1"
  430. fdd.DiseDate = s_tm
  431. fdd.DiasSrtNo = "1"
  432. fdd.DiseName = item.CountryContentName
  433. fdd.DiseCodg = item.CountryCode
  434. fdds = append(fdds, &fdd)
  435. } else {
  436. var fdd models.FsiDiagnoseDtos
  437. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  438. fdd.InoutDiseType = "1"
  439. fdd.MaindiseFlag = "1"
  440. fdd.DiseDate = s_tm
  441. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  442. fdd.DiseName = item.CountryContentName
  443. fdd.DiseCodg = item.CountryCode
  444. fdds = append(fdds, &fdd)
  445. }
  446. }
  447. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  448. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  449. fed.AdmDeptName = department.Name
  450. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  451. fed.DscgDeptName = department.Name
  452. fed.MedType = order.MedType
  453. //处方医嘱信息
  454. var orders []*models.FsiOrderDtos
  455. //for _, item := range prescriptions {
  456. // for _, subItem := range item.HisDoctorAdviceInfo {
  457. // var order models.FsiOrderDtos
  458. // order.RxID = strconv.FormatInt(item.ID, 10)
  459. // order.Rxno = strconv.FormatInt(item.ID, 10)
  460. // order.LongDrordFlag = "0"
  461. // order.HilistType = "1"
  462. // order.ChrgType = "1"
  463. // order.DrordBhvr = "-"
  464. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  465. // order.HosplistName = subItem.BaseDrugLib.DrugName
  466. // order.HilistLv = "1"
  467. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  468. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  469. // order.HosplistName = subItem.BaseDrugLib.DrugName
  470. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  471. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  472. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  473. // order.OwnpayAmt = ""
  474. // order.SelfpayAmt = ""
  475. // order.Spec = ""
  476. // order.SpecUnt = ""
  477. // order.DrordBegnDate = s_tm
  478. // order.DrordStopDate = ""
  479. // order.DrordDrCodg = "1"
  480. // order.DrordDeptName = department.Name
  481. // order.DrordDrCodg = "1"
  482. // order.DrordDrName = doctor_info.UserName
  483. // order.DrordDrProfttl = ""
  484. // order.CurrDrordFlag = "1"
  485. // orders = append(orders, &order)
  486. // }
  487. // for _, subItem := range item.HisPrescriptionProject {
  488. // if subItem.Type == 2 {
  489. // var order models.FsiOrderDtos
  490. // order.RxID = strconv.FormatInt(item.ID, 10)
  491. // order.Rxno = strconv.FormatInt(item.ID, 10)
  492. // order.LongDrordFlag = "0"
  493. // order.HilistType = "1"
  494. // order.ChrgType = "1"
  495. // order.DrordBhvr = "-"
  496. // order.HilistCode = subItem.HisProject.MedicalCode
  497. // order.HosplistName = subItem.HisProject.ProjectName
  498. // order.HilistLv = "1"
  499. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  500. // order.HosplistCode = subItem.HisProject.MedicalCode
  501. // order.HosplistName = subItem.HisProject.ProjectName
  502. // order.Cnt = subItem.Count
  503. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  504. //
  505. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  507. // order.OwnpayAmt = ""
  508. // order.SelfpayAmt = ""
  509. // order.Spec = ""
  510. // order.SpecUnt = ""
  511. // order.DrordBegnDate = s_tm
  512. // order.DrordStopDate = ""
  513. // order.DrordDrCodg = "1"
  514. // order.DrordDeptName = department.Name
  515. // order.DrordDrCodg = "1"
  516. // order.DrordDrName = doctor_info.UserName
  517. // order.DrordDrProfttl = ""
  518. // order.CurrDrordFlag = "1"
  519. // orders = append(orders, &order)
  520. //
  521. // }
  522. // if subItem.Type == 3 {
  523. //
  524. // var order models.FsiOrderDtos
  525. // order.RxID = strconv.FormatInt(item.ID, 10)
  526. // order.Rxno = strconv.FormatInt(item.ID, 10)
  527. // order.LongDrordFlag = "0"
  528. // order.HilistType = "1"
  529. // order.ChrgType = "1"
  530. // order.DrordBhvr = "-"
  531. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  532. // order.HosplistName = subItem.GoodInfo.GoodName
  533. // order.HilistLv = "1"
  534. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  535. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  536. // order.HosplistName = subItem.GoodInfo.GoodName
  537. // order.Cnt = subItem.Count
  538. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  539. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  540. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  541. // order.OwnpayAmt = ""
  542. // order.SelfpayAmt = ""
  543. // order.Spec = ""
  544. // order.SpecUnt = ""
  545. // order.DrordBegnDate = s_tm
  546. // order.DrordStopDate = ""
  547. // order.DrordDrCodg = "1"
  548. // order.DrordDeptName = department.Name
  549. // order.DrordDrCodg = "1"
  550. // order.DrordDrName = doctor_info.UserName
  551. // order.DrordDrProfttl = ""
  552. // order.CurrDrordFlag = "1"
  553. // orders = append(orders, &order)
  554. //
  555. // }
  556. // }
  557. //}
  558. for _, item := range prescriptions {
  559. for _, subItem := range item.HisDoctorAdviceInfo {
  560. var order models.FsiOrderDtos
  561. order.RxID = strconv.FormatInt(item.ID, 10)
  562. order.Rxno = strconv.FormatInt(item.ID, 10)
  563. order.LongDrordFlag = "0"
  564. order.HilistType = "1"
  565. order.ChrgType = "1"
  566. order.DrordBhvr = "-"
  567. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  568. order.HosplistName = subItem.BaseDrugLib.DrugName
  569. order.HilistLv = "1"
  570. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  571. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  572. order.HosplistName = subItem.BaseDrugLib.DrugName
  573. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  574. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  575. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  576. order.OwnpayAmt = ""
  577. order.SelfpayAmt = ""
  578. order.Spec = ""
  579. order.SpecUnt = ""
  580. order.DrordBegnDate = s_tm
  581. order.DrordStopDate = ""
  582. order.DrordDrCodg = "1"
  583. order.DrordDeptName = department.Name
  584. order.DrordDrCodg = "1"
  585. order.DrordDrName = doctor_info.UserName
  586. order.DrordDrProfttl = ""
  587. order.CurrDrordFlag = "1"
  588. orders = append(orders, &order)
  589. }
  590. for _, subItem := range item.HisPrescriptionProject {
  591. if subItem.Type == 2 {
  592. var order models.FsiOrderDtos
  593. order.RxID = strconv.FormatInt(item.ID, 10)
  594. order.Rxno = strconv.FormatInt(item.ID, 10)
  595. order.LongDrordFlag = "0"
  596. order.HilistType = "1"
  597. order.ChrgType = "1"
  598. order.DrordBhvr = "-"
  599. order.HilistCode = subItem.HisProject.MedicalCode
  600. order.HosplistName = subItem.HisProject.ProjectName
  601. order.HilistLv = "1"
  602. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  603. order.HosplistCode = subItem.HisProject.MedicalCode
  604. order.HosplistName = subItem.HisProject.ProjectName
  605. order.Cnt = subItem.Count
  606. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  607. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  608. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  609. order.OwnpayAmt = ""
  610. order.SelfpayAmt = ""
  611. order.Spec = ""
  612. order.SpecUnt = ""
  613. order.DrordBegnDate = s_tm
  614. order.DrordStopDate = ""
  615. order.DrordDrCodg = "1"
  616. order.DrordDeptName = department.Name
  617. order.DrordDrCodg = "1"
  618. order.DrordDrName = doctor_info.UserName
  619. order.DrordDrProfttl = ""
  620. order.CurrDrordFlag = "1"
  621. orders = append(orders, &order)
  622. }
  623. if subItem.Type == 3 {
  624. var order models.FsiOrderDtos
  625. order.RxID = strconv.FormatInt(item.ID, 10)
  626. order.Rxno = strconv.FormatInt(item.ID, 10)
  627. order.LongDrordFlag = "0"
  628. order.HilistType = "1"
  629. order.ChrgType = "1"
  630. order.DrordBhvr = "-"
  631. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  632. order.HosplistName = subItem.GoodInfo.GoodName
  633. order.HilistLv = "1"
  634. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  635. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  636. order.HosplistName = subItem.GoodInfo.GoodName
  637. order.Cnt = subItem.Count
  638. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  639. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  640. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  641. order.OwnpayAmt = ""
  642. order.SelfpayAmt = ""
  643. order.Spec = ""
  644. order.SpecUnt = ""
  645. order.DrordBegnDate = s_tm
  646. order.DrordStopDate = ""
  647. order.DrordDrCodg = "1"
  648. order.DrordDeptName = department.Name
  649. order.DrordDrCodg = "1"
  650. order.DrordDrName = doctor_info.UserName
  651. order.DrordDrProfttl = ""
  652. order.CurrDrordFlag = "1"
  653. orders = append(orders, &order)
  654. }
  655. }
  656. }
  657. //处方医嘱信息
  658. fed.MatnStas = "0"
  659. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  660. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  661. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  662. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  663. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  664. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  665. fed.SetlTotlnum = "1"
  666. fed.Insutype = his.Insutype
  667. fed.ReimFlag = "0"
  668. fed.OutSetlFlag = "0"
  669. var fopd []*models.FsiOperationDtosData
  670. data := make(map[string]interface{})
  671. data["fed"] = fed
  672. data["fdd"] = fdds
  673. data["fod"] = orders
  674. data["pd"] = pd
  675. data["pp"] = pp
  676. data["fopd"] = fopd
  677. data["trig_scen"] = trig_scen
  678. client := &http.Client{}
  679. bytesData, _ := json.Marshal(data)
  680. var req *http.Request
  681. if miConfig.MdtrtareaAdmvs == "320921" {
  682. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  683. } else {
  684. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  685. }
  686. resp, _ := client.Do(req)
  687. defer resp.Body.Close()
  688. body, ioErr := ioutil.ReadAll(resp.Body)
  689. if ioErr != nil {
  690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  692. return
  693. }
  694. var respJSON map[string]interface{}
  695. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. //手术操作集合
  701. //手术操作集合
  702. }
  703. func (c *HisApiController) Check() {
  704. psn_no := c.GetString("psn_no")
  705. in := c.GetString("in")
  706. mt := c.GetString("mt")
  707. baseParams := models.BaseParams{
  708. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  709. FixmedinsCode: "H15049901371",
  710. InsuplcAdmdvs: "150499",
  711. MdtrtareaAdmvs: "150499",
  712. OrgName: "赤峰费森血液透析中心",
  713. Doctor: "1111",
  714. }
  715. service.Gdyb2001(baseParams, psn_no, in, mt)
  716. }
  717. func (c *HisApiController) GetPsnNcdsInfo() {
  718. admin_user_id, _ := c.GetInt64("admin_user_id")
  719. patient_id, _ := c.GetInt64("patient_id")
  720. id, _ := c.GetInt64("id")
  721. adminUser := c.GetAdminUserInfo()
  722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  723. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  724. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  725. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  726. psn_record, _ := service.GetPsnNCDSRecordById(id)
  727. //
  728. //if psn_record.ID == 0 {
  729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  730. // return
  731. //}
  732. var res Result5301
  733. var res10265 Result5301For10265
  734. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  735. psn_info, _ := service.GetPsnByPatientId(patient_id)
  736. var api string
  737. if miConfig.MdtrtareaAdmvs == "320921" {
  738. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  739. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  740. } else {
  741. 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 +
  742. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  743. }
  744. resp, requestErr := http.Get(api)
  745. if requestErr != nil {
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. body, ioErr := ioutil.ReadAll(resp.Body)
  750. if ioErr != nil {
  751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. var respJSON map[string]interface{}
  756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  762. result, _ := json.Marshal(respJSON)
  763. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  764. utils.ErrorLog("解析失败:%v", err)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. res.ErrMsg = res10265.ErrMsg
  769. res.Output = res10265.Output
  770. res.InfRefmsgid = res10265.InfRefmsgid
  771. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  772. res.Infcode = infocode
  773. } else {
  774. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  775. var dat map[string]interface{}
  776. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  777. fmt.Println(dat)
  778. } else {
  779. fmt.Println(err)
  780. }
  781. userJSONBytes, _ := json.Marshal(dat)
  782. if miConfig.Code == "H15049901371" {
  783. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  784. utils.ErrorLog("解析失败:%v", err)
  785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  786. return
  787. }
  788. res.InfRefmsgid = res10265.InfRefmsgid
  789. res.Output = res10265.Output
  790. res.ErrMsg = res10265.ErrMsg
  791. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  792. res.Infcode = infocode
  793. } else {
  794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  795. utils.ErrorLog("解析失败:%v", err)
  796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  797. return
  798. }
  799. }
  800. }
  801. if res.Infcode == 0 {
  802. c.ServeSuccessJSON(map[string]interface{}{
  803. "result": res.Output.Result,
  804. })
  805. }
  806. }
  807. func (c *HisApiController) CheckInsutype() {
  808. his_patient_id, _ := c.GetInt64("his_patient_id")
  809. admin_user_id, _ := c.GetInt64("admin_user_id")
  810. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  811. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  812. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  813. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  814. var dat map[string]interface{}
  815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  816. fmt.Println(dat)
  817. } else {
  818. fmt.Println(err)
  819. }
  820. userJSONBytes, _ := json.Marshal(dat)
  821. var res Result90100
  822. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  823. utils.ErrorLog("解析失败:%v", err)
  824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  825. return
  826. }
  827. if res.Infcode != 0 {
  828. c.ServeSuccessJSON(map[string]interface{}{
  829. "failed_code": -10,
  830. "msg": res.ErrMsg,
  831. })
  832. return
  833. } else {
  834. fmt.Println(res)
  835. }
  836. }
  837. func (c *HisApiController) CheckCardPWD() {
  838. card_pwd := c.GetString("card_pwd")
  839. his_patient_id, _ := c.GetInt64("his_patient_id")
  840. admin_user_id, _ := c.GetInt64("admin_user_id")
  841. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  842. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  843. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  844. psn, _ := service.GetPsnByPatientId(his.PatientId)
  845. bas := strings.Split(psn.CardInfo, "|")
  846. basNumber := bas[2]
  847. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  848. var dat map[string]interface{}
  849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  850. fmt.Println(dat)
  851. } else {
  852. fmt.Println(err)
  853. }
  854. userJSONBytes, _ := json.Marshal(dat)
  855. var res Result90991
  856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  857. utils.ErrorLog("解析失败:%v", err)
  858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  859. return
  860. }
  861. if res.Infcode != 0 {
  862. c.ServeSuccessJSON(map[string]interface{}{
  863. "failed_code": -10,
  864. "msg": res.ErrMsg,
  865. })
  866. return
  867. } else {
  868. if res.Output.Result.SscnoCheckStat == "0" {
  869. var msg string
  870. switch res.Output.Result.CardStat {
  871. case "00":
  872. msg = "未激活"
  873. break
  874. case "10":
  875. msg = "激活"
  876. break
  877. case "20":
  878. msg = "窗口挂失"
  879. break
  880. case "21":
  881. msg = "电话挂失"
  882. break
  883. case "22":
  884. msg = "单位网上申报挂失"
  885. break
  886. case "23":
  887. msg = "保健办挂失"
  888. break
  889. case "24":
  890. msg = "个人网上挂失"
  891. break
  892. case "25":
  893. msg = "网上服务大厅挂失"
  894. break
  895. case "30":
  896. msg = "注销"
  897. break
  898. case "40":
  899. msg = "回收"
  900. break
  901. case "99":
  902. msg = "制卡中(无效卡)"
  903. break
  904. }
  905. c.ServeSuccessJSON(map[string]interface{}{
  906. "failed_code": -10,
  907. "msg": msg,
  908. })
  909. return
  910. } else {
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "msg": "校验成功",
  913. })
  914. return
  915. }
  916. }
  917. }
  918. func (c *HisApiController) CheckCardPWDTwo() {
  919. //card_pwd := c.GetString("card_pwd")
  920. //his_patient_id, _ := c.GetInt64("his_patient_id")
  921. admin_user_id, _ := c.GetInt64("admin_user_id")
  922. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  923. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  924. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  925. var dat map[string]interface{}
  926. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  927. fmt.Println(dat)
  928. } else {
  929. fmt.Println(err)
  930. }
  931. userJSONBytes, _ := json.Marshal(dat)
  932. var res Result90991
  933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  934. utils.ErrorLog("解析失败:%v", err)
  935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  936. return
  937. }
  938. if res.Infcode != 0 {
  939. c.ServeSuccessJSON(map[string]interface{}{
  940. "failed_code": -10,
  941. "msg": res.ErrMsg,
  942. })
  943. return
  944. } else {
  945. if res.Output.Result.SscnoCheckStat == "0" {
  946. var msg string
  947. switch res.Output.Result.CardStat {
  948. case "00":
  949. msg = "未激活"
  950. break
  951. case "10":
  952. msg = "激活"
  953. break
  954. case "20":
  955. msg = "窗口挂失"
  956. break
  957. case "21":
  958. msg = "电话挂失"
  959. break
  960. case "22":
  961. msg = "单位网上申报挂失"
  962. break
  963. case "23":
  964. msg = "保健办挂失"
  965. break
  966. case "24":
  967. msg = "个人网上挂失"
  968. break
  969. case "25":
  970. msg = "网上服务大厅挂失"
  971. break
  972. case "30":
  973. msg = "注销"
  974. break
  975. case "40":
  976. msg = "回收"
  977. break
  978. case "99":
  979. msg = "制卡中(无效卡)"
  980. break
  981. }
  982. c.ServeSuccessJSON(map[string]interface{}{
  983. "failed_code": -10,
  984. "msg": msg,
  985. })
  986. return
  987. } else {
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "msg": "校验成功",
  990. })
  991. return
  992. }
  993. }
  994. }
  995. func (c *HisApiController) ReadCard() {
  996. id_card_type, _ := c.GetInt64("id_card_type")
  997. admin_user_id, _ := c.GetInt64("admin_user_id")
  998. certificates, _ := c.GetInt64("certificates")
  999. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1000. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1001. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1002. switch id_card_type {
  1003. case 1:
  1004. if miConfig.MdtrtareaAdmvs == "421300" {
  1005. var res ResultTwo
  1006. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1007. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1008. "&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)
  1009. resp, requestErr := http.Get(api)
  1010. if requestErr != nil {
  1011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1012. return
  1013. }
  1014. body, ioErr := ioutil.ReadAll(resp.Body)
  1015. if ioErr != nil {
  1016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. var respJSON map[string]interface{}
  1021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1027. result, _ := json.Marshal(respJSON)
  1028. fmt.Println("log")
  1029. fmt.Println(string(result))
  1030. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1031. utils.ErrorLog("解析失败:%v", err)
  1032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1033. return
  1034. }
  1035. if res.Infcode == 0 {
  1036. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1037. if err == gorm.ErrRecordNotFound {
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1039. return
  1040. } else if err != nil {
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1042. return
  1043. } else {
  1044. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1045. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1046. infoStr := string(Iinfos)
  1047. idetinfoStr := string(Idetinfos)
  1048. psn := &models.HisPsn{
  1049. PsnNo: res.Output.Baseinfo.PsnNo,
  1050. Age: res.Output.Baseinfo.Age,
  1051. PatientId: patient.ID,
  1052. Certno: res.Output.Baseinfo.Certno,
  1053. Brdy: res.Output.Baseinfo.Brdy,
  1054. Gend: res.Output.Baseinfo.Gend,
  1055. Naty: res.Output.Baseinfo.Naty,
  1056. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1057. PsnName: res.Output.Baseinfo.PsnName,
  1058. Idetinfo: idetinfoStr,
  1059. Insuinfo: infoStr,
  1060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1061. }
  1062. service.CreateHisPsn(psn)
  1063. c.ServeSuccessJSON(map[string]interface{}{
  1064. "patient": patient,
  1065. "number": res.Output.Baseinfo.Certno,
  1066. })
  1067. }
  1068. } else {
  1069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1070. return
  1071. }
  1072. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1073. var api string
  1074. if miConfig.MdtrtareaAdmvs == "320921" {
  1075. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1076. "&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
  1077. fmt.Println(api)
  1078. } else {
  1079. 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 +
  1080. "&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)
  1081. }
  1082. resp, requestErr := http.Get(api)
  1083. if requestErr != nil {
  1084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1085. return
  1086. }
  1087. body, ioErr := ioutil.ReadAll(resp.Body)
  1088. if ioErr != nil {
  1089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. var respJSON map[string]interface{}
  1094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var status string
  1100. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1101. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1102. //console.log()
  1103. fmt.Println("type===")
  1104. fmt.Println(card_type)
  1105. var token string
  1106. var res ResultTwo //1101结果
  1107. var res10265 ResultTwo10265 //1101结果
  1108. var card_info string //卡信息
  1109. var busi_card_info string
  1110. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1111. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1112. if status == "0" { //读卡成功
  1113. if card_type == "1" {
  1114. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1115. result, _ := json.Marshal(respJSON)
  1116. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1117. utils.ErrorLog("解析失败:%v", err)
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1119. return
  1120. }
  1121. res.ErrMsg = res10265.ErrMsg
  1122. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1123. res.Infcode = infocode
  1124. res.Output = res10265.Output
  1125. res.InfRefmsgid = res10265.InfRefmsgid
  1126. } else {
  1127. //var card_info string //卡信息
  1128. //var busi_card_info string
  1129. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1130. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1131. //fmt.Println(card_info)
  1132. //fmt.Println(busi_card_info)
  1133. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1134. result, _ := json.Marshal(respJSON)
  1135. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1136. utils.ErrorLog("解析失败:%v", err)
  1137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. return
  1139. }
  1140. res.ErrMsg = res10265.ErrMsg
  1141. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1142. res.Infcode = infocode
  1143. res.Output = res10265.Output
  1144. res.InfRefmsgid = res10265.InfRefmsgid
  1145. }
  1146. if res.Infcode == 0 {
  1147. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1148. if err == gorm.ErrRecordNotFound {
  1149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1150. return
  1151. } else if err != nil {
  1152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1153. return
  1154. } else {
  1155. if card_type == "1" {
  1156. bas := strings.Split(card_info, "|")
  1157. basNumber := bas[2]
  1158. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1159. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1160. infoStr := string(Iinfos)
  1161. idetinfoStr := string(Idetinfos)
  1162. psn := &models.HisPsn{
  1163. PsnNo: res.Output.Baseinfo.PsnNo,
  1164. Age: res.Output.Baseinfo.Age,
  1165. PatientId: patient.ID,
  1166. Certno: res.Output.Baseinfo.Certno,
  1167. Brdy: res.Output.Baseinfo.Brdy,
  1168. Gend: res.Output.Baseinfo.Gend,
  1169. Naty: res.Output.Baseinfo.Naty,
  1170. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1171. PsnName: res.Output.Baseinfo.PsnName,
  1172. Idetinfo: idetinfoStr,
  1173. Insuinfo: infoStr,
  1174. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1175. CardInfo: card_info,
  1176. VerifyNumber: busi_card_info,
  1177. }
  1178. service.CreateHisPsn(psn)
  1179. var rf []*ResultFive
  1180. json.Unmarshal([]byte(infoStr), &rf)
  1181. var insutypes []*ResultFive
  1182. var insutype string
  1183. var is390 int = 0
  1184. var is310 int = 0
  1185. for _, item := range rf {
  1186. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1187. insutypes = append(insutypes, item)
  1188. }
  1189. }
  1190. if len(insutypes) == 1 {
  1191. insutype = insutypes[0].Insutype
  1192. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1193. } else {
  1194. for _, i := range insutypes {
  1195. if i.Insutype == "390" {
  1196. is390 = 1
  1197. }
  1198. if i.Insutype == "310" {
  1199. is310 = 1
  1200. }
  1201. }
  1202. }
  1203. if is390 == 1 {
  1204. insutype = "390"
  1205. }
  1206. if is310 == 1 {
  1207. insutype = "310"
  1208. }
  1209. if len(insutypes) == 0 {
  1210. insutype = "310"
  1211. }
  1212. c.ServeSuccessJSON(map[string]interface{}{
  1213. "patient": patient,
  1214. "number": basNumber,
  1215. "insutype": insutype,
  1216. })
  1217. } else {
  1218. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1219. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1220. infoStr := string(Iinfos)
  1221. idetinfoStr := string(Idetinfos)
  1222. psn := &models.HisPsn{
  1223. PsnNo: res.Output.Baseinfo.PsnNo,
  1224. Age: res.Output.Baseinfo.Age,
  1225. PatientId: patient.ID,
  1226. Certno: res.Output.Baseinfo.Certno,
  1227. Brdy: res.Output.Baseinfo.Brdy,
  1228. Gend: res.Output.Baseinfo.Gend,
  1229. Naty: res.Output.Baseinfo.Naty,
  1230. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1231. PsnName: res.Output.Baseinfo.PsnName,
  1232. Idetinfo: idetinfoStr,
  1233. Insuinfo: infoStr,
  1234. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1235. CardInfo: card_info,
  1236. VerifyNumber: token,
  1237. }
  1238. service.CreateHisPsn(psn)
  1239. c.ServeSuccessJSON(map[string]interface{}{
  1240. "patient": patient,
  1241. "number": token,
  1242. })
  1243. }
  1244. }
  1245. } else {
  1246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1247. return
  1248. }
  1249. } else { //读卡失败
  1250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1251. return
  1252. }
  1253. } else {
  1254. if initFlag == 0 {
  1255. c.TestGetBasBaseInit()
  1256. }
  1257. basStr := c.GetBasBaseInfo()
  1258. if len(basStr) == 0 {
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1260. return
  1261. }
  1262. fmt.Println(basStr)
  1263. bas := strings.Split(basStr, "|")
  1264. basNumber := bas[1]
  1265. fmt.Println(basNumber)
  1266. card_sn := bas[3]
  1267. fmt.Println(card_sn)
  1268. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1269. var dat map[string]interface{}
  1270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1271. fmt.Println(dat)
  1272. } else {
  1273. fmt.Println(err)
  1274. }
  1275. userJSONBytes, _ := json.Marshal(dat)
  1276. var res ResultTwo
  1277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1278. utils.ErrorLog("解析失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. return
  1281. }
  1282. if res.Infcode == 0 {
  1283. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1284. if err == gorm.ErrRecordNotFound {
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1286. return
  1287. } else if err != nil {
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1289. return
  1290. } else {
  1291. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1292. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1293. infoStr := string(Iinfos)
  1294. idetinfoStr := string(Idetinfos)
  1295. psn := &models.HisPsn{
  1296. PsnNo: res.Output.Baseinfo.PsnNo,
  1297. Age: res.Output.Baseinfo.Age,
  1298. PatientId: patient.ID,
  1299. Certno: res.Output.Baseinfo.Certno,
  1300. Brdy: res.Output.Baseinfo.Brdy,
  1301. Gend: res.Output.Baseinfo.Gend,
  1302. Naty: res.Output.Baseinfo.Naty,
  1303. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1304. PsnName: res.Output.Baseinfo.PsnName,
  1305. Idetinfo: idetinfoStr,
  1306. Insuinfo: infoStr,
  1307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1308. CardInfo: basStr,
  1309. VerifyNumber: "",
  1310. }
  1311. service.CreateHisPsn(psn)
  1312. c.ServeSuccessJSON(map[string]interface{}{
  1313. "patient": patient,
  1314. "number": basNumber,
  1315. })
  1316. }
  1317. } else {
  1318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1319. return
  1320. }
  1321. break
  1322. }
  1323. case 2:
  1324. SFZStr := c.GetSFZBaseInfo()
  1325. id_card_str := strings.Split(SFZStr, "^")
  1326. id_card_number := id_card_str[0]
  1327. card_sn := ""
  1328. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1329. var dat map[string]interface{}
  1330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1331. fmt.Println(dat)
  1332. } else {
  1333. fmt.Println(err)
  1334. }
  1335. userJSONBytes, _ := json.Marshal(dat)
  1336. var res ResultTwo
  1337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1338. utils.ErrorLog("解析失败:%v", err)
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. return
  1341. }
  1342. if res.Infcode == 0 {
  1343. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1344. if err == gorm.ErrRecordNotFound {
  1345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1346. return
  1347. } else if err != nil {
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1349. return
  1350. } else {
  1351. c.ServeSuccessJSON(map[string]interface{}{
  1352. "patient": patient,
  1353. "number": id_card_number,
  1354. })
  1355. }
  1356. } else {
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1358. return
  1359. }
  1360. break
  1361. case 3:
  1362. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1363. var api string
  1364. if miConfig.MdtrtareaAdmvs == "320921" {
  1365. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1366. "&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
  1367. fmt.Println(api)
  1368. } else {
  1369. 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 +
  1370. "&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)
  1371. }
  1372. resp, requestErr := http.Get(api)
  1373. if requestErr != nil {
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. return
  1376. }
  1377. body, ioErr := ioutil.ReadAll(resp.Body)
  1378. if ioErr != nil {
  1379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1381. return
  1382. }
  1383. var respJSON map[string]interface{}
  1384. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1387. return
  1388. }
  1389. var status string
  1390. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1391. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1392. var token string
  1393. var res ResultTwo //1101结果
  1394. var res10265 ResultTwo10265 //1101结果
  1395. var card_info string //卡信息
  1396. var busi_card_info string
  1397. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1398. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1399. if status == "0" { //读卡成功
  1400. if card_type == "1" {
  1401. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1402. result, _ := json.Marshal(respJSON)
  1403. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1404. utils.ErrorLog("解析失败:%v", err)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. res.ErrMsg = res10265.ErrMsg
  1409. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1410. res.Infcode = infocode
  1411. res.Output = res10265.Output
  1412. res.InfRefmsgid = res10265.InfRefmsgid
  1413. } else {
  1414. //var card_info string //卡信息
  1415. //var busi_card_info string
  1416. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1417. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1418. //fmt.Println(card_info)
  1419. //fmt.Println(busi_card_info)
  1420. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1421. result, _ := json.Marshal(respJSON)
  1422. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1423. utils.ErrorLog("解析失败:%v", err)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. return
  1426. }
  1427. res.ErrMsg = res10265.ErrMsg
  1428. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1429. res.Infcode = infocode
  1430. res.Output = res10265.Output
  1431. res.InfRefmsgid = res10265.InfRefmsgid
  1432. }
  1433. if res.Infcode == 0 {
  1434. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1435. if err == gorm.ErrRecordNotFound {
  1436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1437. return
  1438. } else if err != nil {
  1439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1440. return
  1441. } else {
  1442. if card_type == "1" {
  1443. bas := strings.Split(card_info, "|")
  1444. basNumber := bas[2]
  1445. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1446. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1447. infoStr := string(Iinfos)
  1448. idetinfoStr := string(Idetinfos)
  1449. psn := &models.HisPsn{
  1450. PsnNo: res.Output.Baseinfo.PsnNo,
  1451. Age: res.Output.Baseinfo.Age,
  1452. PatientId: patient.ID,
  1453. Certno: res.Output.Baseinfo.Certno,
  1454. Brdy: res.Output.Baseinfo.Brdy,
  1455. Gend: res.Output.Baseinfo.Gend,
  1456. Naty: res.Output.Baseinfo.Naty,
  1457. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1458. PsnName: res.Output.Baseinfo.PsnName,
  1459. Idetinfo: idetinfoStr,
  1460. Insuinfo: infoStr,
  1461. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1462. CardInfo: card_info,
  1463. VerifyNumber: busi_card_info,
  1464. }
  1465. service.CreateHisPsn(psn)
  1466. c.ServeSuccessJSON(map[string]interface{}{
  1467. "patient": patient,
  1468. "number": basNumber,
  1469. })
  1470. } else {
  1471. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1472. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1473. infoStr := string(Iinfos)
  1474. idetinfoStr := string(Idetinfos)
  1475. psn := &models.HisPsn{
  1476. PsnNo: res.Output.Baseinfo.PsnNo,
  1477. Age: res.Output.Baseinfo.Age,
  1478. PatientId: patient.ID,
  1479. Certno: res.Output.Baseinfo.Certno,
  1480. Brdy: res.Output.Baseinfo.Brdy,
  1481. Gend: res.Output.Baseinfo.Gend,
  1482. Naty: res.Output.Baseinfo.Naty,
  1483. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1484. PsnName: res.Output.Baseinfo.PsnName,
  1485. Idetinfo: idetinfoStr,
  1486. Insuinfo: infoStr,
  1487. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1488. CardInfo: card_info,
  1489. VerifyNumber: token,
  1490. }
  1491. service.CreateHisPsn(psn)
  1492. var rf []*ResultFive
  1493. json.Unmarshal([]byte(infoStr), &rf)
  1494. var insutypes []*ResultFive
  1495. var insutype string
  1496. var is390 int = 0
  1497. var is310 int = 0
  1498. for _, item := range rf {
  1499. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1500. insutypes = append(insutypes, item)
  1501. }
  1502. }
  1503. if len(insutypes) == 1 {
  1504. insutype = insutypes[0].Insutype
  1505. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1506. } else {
  1507. for _, i := range insutypes {
  1508. if i.Insutype == "390" {
  1509. is390 = 1
  1510. }
  1511. if i.Insutype == "310" {
  1512. is310 = 1
  1513. }
  1514. }
  1515. }
  1516. if is390 == 1 {
  1517. insutype = "390"
  1518. }
  1519. if is310 == 1 {
  1520. insutype = "310"
  1521. }
  1522. if len(insutypes) == 0 {
  1523. insutype = "310"
  1524. }
  1525. c.ServeSuccessJSON(map[string]interface{}{
  1526. "patient": patient,
  1527. "number": token,
  1528. "insutype": insutype,
  1529. })
  1530. }
  1531. }
  1532. } else {
  1533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1534. return
  1535. }
  1536. } else { //读卡失败
  1537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1538. return
  1539. }
  1540. }
  1541. break
  1542. case 4:
  1543. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1544. var api string
  1545. if miConfig.MdtrtareaAdmvs == "320921" {
  1546. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1547. "&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
  1548. fmt.Println(api)
  1549. } else {
  1550. 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 +
  1551. "&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)
  1552. }
  1553. resp, requestErr := http.Get(api)
  1554. if requestErr != nil {
  1555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1556. return
  1557. }
  1558. body, ioErr := ioutil.ReadAll(resp.Body)
  1559. if ioErr != nil {
  1560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1562. return
  1563. }
  1564. var respJSON map[string]interface{}
  1565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1568. return
  1569. }
  1570. var status string
  1571. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1572. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1573. var token string
  1574. var res ResultTwo //1101结果
  1575. var res10265 ResultTwo10265 //1101结果
  1576. if status == "0" { //读卡成功
  1577. var card_info string //卡信息
  1578. var busi_card_info string
  1579. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1580. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1581. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1582. fmt.Println(card_info)
  1583. fmt.Println(busi_card_info)
  1584. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1585. result, _ := json.Marshal(respJSON)
  1586. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1587. utils.ErrorLog("解析失败:%v", err)
  1588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1589. return
  1590. }
  1591. res.ErrMsg = res10265.ErrMsg
  1592. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. res.Output = res10265.Output
  1595. res.InfRefmsgid = res10265.InfRefmsgid
  1596. if res.Infcode == 0 {
  1597. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1598. if err == gorm.ErrRecordNotFound {
  1599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1600. return
  1601. } else if err != nil {
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1603. return
  1604. } else {
  1605. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1606. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1607. infoStr := string(Iinfos)
  1608. idetinfoStr := string(Idetinfos)
  1609. psn := &models.HisPsn{
  1610. PsnNo: res.Output.Baseinfo.PsnNo,
  1611. Age: res.Output.Baseinfo.Age,
  1612. PatientId: patient.ID,
  1613. Certno: res.Output.Baseinfo.Certno,
  1614. Brdy: res.Output.Baseinfo.Brdy,
  1615. Gend: res.Output.Baseinfo.Gend,
  1616. Naty: res.Output.Baseinfo.Naty,
  1617. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1618. PsnName: res.Output.Baseinfo.PsnName,
  1619. Idetinfo: idetinfoStr,
  1620. Insuinfo: infoStr,
  1621. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1622. CardInfo: card_info,
  1623. VerifyNumber: token,
  1624. }
  1625. service.CreateHisPsn(psn)
  1626. c.ServeSuccessJSON(map[string]interface{}{
  1627. "patient": patient,
  1628. "number": token,
  1629. })
  1630. }
  1631. } else {
  1632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1633. return
  1634. }
  1635. } else { //读卡失败
  1636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1637. return
  1638. }
  1639. }
  1640. break
  1641. }
  1642. }
  1643. var initFlag int64 = 0
  1644. func (c *HisApiController) TestGetBasBaseInit() {
  1645. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1646. Iinit := DllDef.MustFindProc("Init")
  1647. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1648. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1649. if ret != 0 {
  1650. fmt.Println("SSCard的报错原因:", err)
  1651. fmt.Println("SSCard的运算结果为:", ret)
  1652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1653. return
  1654. }
  1655. result := int(ret)
  1656. fmt.Println("SSCard的运算结果为1:", result)
  1657. initFlag = 1
  1658. return
  1659. }
  1660. func (c *HisApiController) GetSFZBaseInfo() string {
  1661. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1662. readCard := DllDef.MustFindProc("ReadSFZ")
  1663. if readCard == nil {
  1664. fmt.Println("readcard is nil")
  1665. readCard = DllDef.MustFindProc("ReadSFZ")
  1666. }
  1667. str := make([]byte, 256)
  1668. str1 := make([]byte, 256)
  1669. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1670. fmt.Println(r)
  1671. return string(str)
  1672. }
  1673. func (c *HisApiController) GetBasBaseInfo() string {
  1674. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1675. readCard := DllDef.MustFindProc("ReadCardBas")
  1676. if readCard == nil {
  1677. fmt.Println("readcard is nil")
  1678. readCard = DllDef.MustFindProc("ReadCardBas")
  1679. }
  1680. str := make([]byte, 1024)
  1681. str1 := make([]byte, 1024)
  1682. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1683. fmt.Println(string(str1))
  1684. fmt.Println(string(str))
  1685. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1686. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1687. if ret2 != 0 {
  1688. return ""
  1689. }
  1690. return string(str)
  1691. }
  1692. type CustomFundPay struct {
  1693. FundPayType string `json:"fund_pay_type"`
  1694. FundPayamt float64 `json:"fund_payamt"`
  1695. }
  1696. func (c *HisApiController) GetSettleList() {
  1697. order_id, _ := c.GetInt64("order_id")
  1698. admin_user_id, _ := c.GetInt64("admin_user_id")
  1699. order, _ := service.GetHisOrderByIDTwo(order_id)
  1700. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1701. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1702. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1703. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1704. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1705. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1706. if order.ID == 0 {
  1707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1708. return
  1709. }
  1710. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1711. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1712. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1713. fmt.Println(count)
  1714. var zero string
  1715. number := count + 1
  1716. if number >= 1000 {
  1717. zero = "0000" + strconv.FormatInt(number, 10)
  1718. } else if number >= 10000 {
  1719. zero = "000" + strconv.FormatInt(number, 10)
  1720. } else if number >= 100000 {
  1721. zero = "00" + strconv.FormatInt(number, 10)
  1722. } else if number >= 1000000 {
  1723. zero = "0" + strconv.FormatInt(number, 10)
  1724. } else {
  1725. zero = strconv.FormatInt(number, 10)
  1726. }
  1727. fmt.Println(zero)
  1728. struct4101 := service.Struct4101{
  1729. PsnNo: order.PsnNo,
  1730. MdtrtId: order.MdtrtId,
  1731. SetlId: order.SetlId,
  1732. PsnName: order.PsnName,
  1733. Gend: order.Gend,
  1734. Brdy: his.Brdy,
  1735. Age: his.Age,
  1736. Naty: order.Naty,
  1737. PatnCertType: "01",
  1738. Certno: order.Certno,
  1739. Prfs: "90",
  1740. ConerName: roles[0].UserName,
  1741. PatnRlts: "99",
  1742. ConerAddr: miConfig.OrgName,
  1743. ConerTel: admin.Mobile,
  1744. HiType: order.Insutype,
  1745. Insuplc: miConfig.InsuplcAdmdvs,
  1746. MaindiagFlag: "1",
  1747. BillCode: last_order.FaPiaoCode,
  1748. BillNo: zero,
  1749. BizSn: order.Number,
  1750. PsnSelfPay: order.PsnPartAmt,
  1751. PsnOwnPay: order.PsnPartAmt,
  1752. AcctPay: order.AcctPay,
  1753. PsnCashpay: order.PsnCashPay,
  1754. HiPaymtd: "1",
  1755. Hsorg: miConfig.InsuplcAdmdvs,
  1756. HsorgOpter: miConfig.InsuplcAdmdvs,
  1757. MedinsFillPsn: curRoles.UserName,
  1758. MedinsFillDept: depart.Name,
  1759. IptMedType: "2",
  1760. }
  1761. struct4101.SetlBegnDate = order.SetlTime
  1762. struct4101.SetlEndDate = order.SetlTime
  1763. time_arr := strings.Split(order.SetlTime, " ")
  1764. struct4101.AdmTime = time_arr[0]
  1765. struct4101.AdmEndTime = time_arr[0]
  1766. var rf []CustomFundPay
  1767. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1768. var tempFunPays []service.CustomStruct
  1769. for _, item := range rf {
  1770. var tempFunPay service.CustomStruct
  1771. tempFunPay.FundPayamt = item.FundPayamt
  1772. tempFunPay.FundPayType = item.FundPayType
  1773. tempFunPays = append(tempFunPays, tempFunPay)
  1774. }
  1775. struct4101.CustomStruct = tempFunPays
  1776. var tempDiaginfos []service.DiaginfoStructTwo
  1777. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1778. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1779. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1780. var config []*models.HisXtDiagnoseConfig
  1781. for _, item := range diagnosis_ids {
  1782. id, _ := strconv.ParseInt(item, 10, 64)
  1783. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1784. config = append(config, &diagnosisConfig)
  1785. }
  1786. for index, item := range config {
  1787. if index == 0 {
  1788. var tempDiaginfo service.DiaginfoStructTwo
  1789. tempDiaginfo.DiagCode = item.CountryCode
  1790. tempDiaginfo.DiagName = item.CountryContentName
  1791. tempDiaginfo.DiagType = "1"
  1792. tempDiaginfo.MaindiagFlag = "1"
  1793. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1794. } else {
  1795. var tempDiaginfo service.DiaginfoStructTwo
  1796. tempDiaginfo.DiagCode = item.CountryCode
  1797. tempDiaginfo.DiagName = item.CountryContentName
  1798. tempDiaginfo.DiagType = "2"
  1799. tempDiaginfo.MaindiagFlag = "0"
  1800. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1801. }
  1802. }
  1803. struct4101.Diseinfo = tempDiaginfos
  1804. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1805. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1806. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1807. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1808. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1809. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1810. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1811. var iteminfo service.IteminfoStruct
  1812. var bedCostTotal float64 = 0 //床位总费
  1813. var bedCostSelfTotal float64 = 0 //床位自费
  1814. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1815. var operationCostTotal float64 = 0 //手术费
  1816. var operationCostSelfTotal float64 = 0 //手术费
  1817. var operationCostPartSelfTotal float64 = 0 //手术费
  1818. var otherCostTotal float64 = 0 //其他费用
  1819. var otherCostSelfTotal float64 = 0 //其他费用
  1820. var otherCostPartSelfTotal float64 = 0 //其他费用
  1821. var materialCostTotal float64 = 0 //材料费
  1822. var materialCostSelfTotal float64 = 0 //材料费
  1823. var materialCostPartSelfTotal float64 = 0 //材料费
  1824. var westernMedicineCostTotal float64 = 0 //西药费
  1825. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1826. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1827. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1828. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1829. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1830. var checkCostTotal float64 = 0 //检查费
  1831. var checkCostSelfTotal float64 = 0 //检查费
  1832. var checkCostPartSelfTotal float64 = 0 //检查费
  1833. var laboratoryCostTotal float64 = 0 //化验费
  1834. var laboratoryCostSelfTotal float64 = 0 //化验费
  1835. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1836. var treatCostTotal float64 = 0 //治疗费用
  1837. var treatCostSelfTotal float64 = 0 //治疗费用
  1838. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1839. decimal.DivisionPrecision = 2
  1840. var bed_fulamt_ownpay_amt float64 = 0
  1841. var operation_fulamt_ownpay_amt float64 = 0
  1842. var other_fulamt_ownpay_amt float64 = 0
  1843. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1844. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1845. var check_fulamt_ownpay_amt float64 = 0
  1846. var material_fulamt_ownpay_amt float64 = 0
  1847. var laboratory_fulamt_ownpay_amt float64 = 0
  1848. var treat_fulamt_ownpay_amt float64 = 0
  1849. var bed_claa_sunmfee float64 = 0
  1850. var bed_clab_amt float64 = 0
  1851. var bed_other_amt float64 = 0
  1852. var operation_claa_sunmfee float64 = 0
  1853. var operation_clab_amt float64 = 0
  1854. var operation_other_amt float64 = 0
  1855. var other_claa_sunmfee float64 = 0
  1856. var other_clab_amt float64 = 0
  1857. var other_other_amt float64 = 0
  1858. var westernMedicine_claa_sunmfee float64 = 0
  1859. var westernMedicine_clab_amt float64 = 0
  1860. var westernMedicine_other_amt float64 = 0
  1861. var chineseTraditional_claa_sunmfee float64 = 0
  1862. var chineseTraditional_clab_amt float64 = 0
  1863. var chineseTraditional_other_amt float64 = 0
  1864. var check_claa_sunmfee float64 = 0
  1865. var check_clab_amt float64 = 0
  1866. var check_other_amt float64 = 0
  1867. var material_claa_sunmfee float64 = 0
  1868. var material_clab_amt float64 = 0
  1869. var material_other_amt float64 = 0
  1870. var laboratory_claa_sunmfee float64 = 0
  1871. var laboratory_clab_amt float64 = 0
  1872. var laboratory_other_amt float64 = 0
  1873. var treat_claa_sunmfee float64 = 0
  1874. var treat_clab_amt float64 = 0
  1875. var treat_other_amt float64 = 0
  1876. for _, item := range order.HisOrderInfo {
  1877. if item.MedChrgitmType == "01" { //床位费
  1878. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1879. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1880. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1881. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1882. if item.ChrgitmLv == "1" {
  1883. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1884. }
  1885. if item.ChrgitmLv == "2" {
  1886. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1887. }
  1888. if item.ChrgitmLv == "3" {
  1889. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1890. }
  1891. }
  1892. if item.MedChrgitmType == "03" { //检查费
  1893. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1894. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1895. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1896. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1897. if item.ChrgitmLv == "1" {
  1898. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1899. }
  1900. if item.ChrgitmLv == "2" {
  1901. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1902. }
  1903. if item.ChrgitmLv == "3" {
  1904. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1905. }
  1906. }
  1907. if item.MedChrgitmType == "04" { //化验费
  1908. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1909. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1910. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1911. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1912. if item.ChrgitmLv == "1" {
  1913. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1914. }
  1915. if item.ChrgitmLv == "2" {
  1916. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1917. }
  1918. if item.ChrgitmLv == "3" {
  1919. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1920. }
  1921. }
  1922. if item.MedChrgitmType == "05" { //治疗费
  1923. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1924. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1925. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1926. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1927. if item.ChrgitmLv == "1" {
  1928. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1929. }
  1930. if item.ChrgitmLv == "2" {
  1931. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1932. }
  1933. if item.ChrgitmLv == "3" {
  1934. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1935. }
  1936. }
  1937. if item.MedChrgitmType == "06" { //手术费
  1938. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1939. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1940. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1941. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1942. if item.ChrgitmLv == "1" {
  1943. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1944. }
  1945. if item.ChrgitmLv == "2" {
  1946. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1947. }
  1948. if item.ChrgitmLv == "3" {
  1949. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1950. }
  1951. }
  1952. if item.MedChrgitmType == "08" { //材料费
  1953. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1954. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1955. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1956. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1957. if item.ChrgitmLv == "1" {
  1958. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1959. }
  1960. if item.ChrgitmLv == "2" {
  1961. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1962. }
  1963. if item.ChrgitmLv == "3" {
  1964. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1965. }
  1966. }
  1967. if item.MedChrgitmType == "09" { //西药费
  1968. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1969. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1970. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1971. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1972. if item.ChrgitmLv == "1" {
  1973. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1974. }
  1975. if item.ChrgitmLv == "2" {
  1976. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1977. }
  1978. if item.ChrgitmLv == "3" {
  1979. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1980. }
  1981. }
  1982. if item.MedChrgitmType == "11" { //中成费
  1983. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1984. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1985. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1987. if item.ChrgitmLv == "1" {
  1988. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "2" {
  1991. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. }
  1993. if item.ChrgitmLv == "3" {
  1994. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1995. }
  1996. }
  1997. if item.MedChrgitmType == "14" { //其他费
  1998. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1999. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2000. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2002. if item.ChrgitmLv == "1" {
  2003. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "2" {
  2006. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. }
  2008. if item.ChrgitmLv == "3" {
  2009. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2010. }
  2011. }
  2012. }
  2013. var iteminfoStructs []service.IteminfoStruct
  2014. if bedCostTotal != 0 {
  2015. iteminfo.MedChrgitm = "01"
  2016. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2017. iteminfo.Amt = bedCostTotal
  2018. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2019. iteminfo.ClabAmt = bed_clab_amt
  2020. iteminfo.OthAmt = bed_other_amt
  2021. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2022. }
  2023. if checkCostTotal != 0 {
  2024. iteminfo.MedChrgitm = "03"
  2025. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2026. iteminfo.Amt = checkCostTotal
  2027. iteminfo.ClaaSumfee = check_claa_sunmfee
  2028. iteminfo.ClabAmt = check_clab_amt
  2029. iteminfo.OthAmt = check_other_amt
  2030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2031. }
  2032. if laboratoryCostTotal != 0 {
  2033. iteminfo.MedChrgitm = "04"
  2034. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2035. iteminfo.Amt = laboratoryCostTotal
  2036. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2037. iteminfo.ClabAmt = laboratory_clab_amt
  2038. iteminfo.OthAmt = laboratory_other_amt
  2039. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2040. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2041. }
  2042. if treatCostTotal != 0 {
  2043. iteminfo.MedChrgitm = "05"
  2044. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2045. iteminfo.Amt = treatCostTotal
  2046. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2047. iteminfo.ClabAmt = treat_clab_amt
  2048. iteminfo.OthAmt = treat_other_amt
  2049. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2050. //(struct4101.IteminfoStruct, iteminfo)
  2051. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2052. }
  2053. if operationCostTotal != 0 {
  2054. iteminfo.MedChrgitm = "06"
  2055. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2056. iteminfo.Amt = operationCostTotal
  2057. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2058. iteminfo.ClabAmt = operation_clab_amt
  2059. iteminfo.OthAmt = operation_other_amt
  2060. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2061. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2062. }
  2063. if materialCostTotal != 0 {
  2064. iteminfo.MedChrgitm = "08"
  2065. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2066. iteminfo.Amt = materialCostTotal
  2067. iteminfo.ClaaSumfee = material_claa_sunmfee
  2068. iteminfo.ClabAmt = material_clab_amt
  2069. iteminfo.OthAmt = material_other_amt
  2070. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2071. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2072. }
  2073. if westernMedicineCostTotal != 0 {
  2074. iteminfo.MedChrgitm = "09"
  2075. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2076. iteminfo.Amt = westernMedicineCostTotal
  2077. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2078. iteminfo.ClabAmt = westernMedicine_clab_amt
  2079. iteminfo.OthAmt = westernMedicine_other_amt
  2080. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2081. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2082. }
  2083. if chineseTraditionalMedicineCostTotal != 0 {
  2084. iteminfo.MedChrgitm = "11"
  2085. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2086. iteminfo.Amt = westernMedicineCostTotal
  2087. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2088. iteminfo.ClabAmt = westernMedicine_clab_amt
  2089. iteminfo.OthAmt = westernMedicine_other_amt
  2090. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2091. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2092. }
  2093. if otherCostTotal != 0 {
  2094. iteminfo.MedChrgitm = "14"
  2095. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2096. iteminfo.Amt = otherCostTotal
  2097. iteminfo.ClaaSumfee = other_claa_sunmfee
  2098. iteminfo.ClabAmt = other_clab_amt
  2099. iteminfo.OthAmt = other_other_amt
  2100. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2101. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2102. }
  2103. struct4101.IteminfoStruct = iteminfoStructs
  2104. struct4101.Ntly = "中国"
  2105. struct4101.AdmCaty = "A03.06"
  2106. var res ResultSeventeen
  2107. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2108. var resOther ResultSeventeenOther
  2109. var pp models.PublicParams
  2110. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2111. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2112. pp.FixmedinsName = miConfig.OrgName
  2113. pp.FixmedinsCode = miConfig.Code
  2114. pp.RequestUrl = miConfig.Url
  2115. pp.Cainfo = miConfig.Cainfo
  2116. pp.SecretKey = miConfig.SecretKey
  2117. pp.AccessKey = miConfig.AccessKey
  2118. pp.OpterName = curRoles.UserName
  2119. client := &http.Client{}
  2120. var req *http.Request
  2121. data := make(map[string]interface{})
  2122. data["struct4101"] = struct4101
  2123. data["pp"] = pp
  2124. bytesData, _ := json.Marshal(data)
  2125. if miConfig.MdtrtareaAdmvs == "320921" {
  2126. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2127. } else {
  2128. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2129. }
  2130. resp, _ := client.Do(req)
  2131. defer resp.Body.Close()
  2132. body, ioErr := ioutil.ReadAll(resp.Body)
  2133. if ioErr != nil {
  2134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2136. return
  2137. }
  2138. var respJSON map[string]interface{}
  2139. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2142. return
  2143. }
  2144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2145. userJSONBytes, _ := json.Marshal(respJSON)
  2146. fmt.Println("log")
  2147. fmt.Println(string(userJSONBytes))
  2148. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2149. utils.ErrorLog("解析失败:%v", err)
  2150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. return
  2152. }
  2153. res.InfRefmsgid = resOther.InfRefmsgid
  2154. res.Output = resOther.Output
  2155. res.ErrMsg = resOther.ErrMsg
  2156. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2157. res.Infcode = infocode
  2158. } else {
  2159. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2160. var dat map[string]interface{}
  2161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2162. fmt.Println(dat)
  2163. } else {
  2164. fmt.Println(err)
  2165. }
  2166. userJSONBytes, _ := json.Marshal(dat)
  2167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2168. utils.ErrorLog("解析失败:%v", err)
  2169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2170. return
  2171. }
  2172. }
  2173. if res.Infcode != 0 {
  2174. c.ServeSuccessJSON(map[string]interface{}{
  2175. "failed_code": -10,
  2176. "msg": res.ErrMsg,
  2177. })
  2178. return
  2179. } else {
  2180. order.FaPiaoNumber = zero
  2181. order.FaPiaoCode = last_order.FaPiaoCode
  2182. service.UpdateOrder(order)
  2183. hisFundSettleListResult := &models.HisFundSettleListResult{
  2184. Number: res.Output.SetlListId,
  2185. Status: 1,
  2186. Ctime: time.Now().Unix(),
  2187. Mtime: time.Now().Unix(),
  2188. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2189. IsUpload: 1,
  2190. OrderId: order_id,
  2191. }
  2192. service.CreateUploadRecord(hisFundSettleListResult)
  2193. c.ServeSuccessJSON(map[string]interface{}{
  2194. "msg": "上传成功",
  2195. "result": hisFundSettleListResult,
  2196. })
  2197. return
  2198. }
  2199. }
  2200. func (c *HisApiController) GetSettleListHospital() {
  2201. order_id, _ := c.GetInt64("order_id")
  2202. admin_user_id, _ := c.GetInt64("admin_user_id")
  2203. order, _ := service.GetHisOrderByIDTwo(order_id)
  2204. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2205. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2206. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2207. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2208. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2209. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2210. if order.ID == 0 {
  2211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2212. return
  2213. }
  2214. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2215. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2216. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2217. fmt.Println(count)
  2218. var zero string
  2219. number := count + 1
  2220. if number >= 1000 {
  2221. zero = "0000" + strconv.FormatInt(number, 10)
  2222. } else if number >= 10000 {
  2223. zero = "000" + strconv.FormatInt(number, 10)
  2224. } else if number >= 100000 {
  2225. zero = "00" + strconv.FormatInt(number, 10)
  2226. } else if number >= 1000000 {
  2227. zero = "0" + strconv.FormatInt(number, 10)
  2228. } else {
  2229. zero = strconv.FormatInt(number, 10)
  2230. }
  2231. fmt.Println(zero)
  2232. struct4101 := service.Struct4101{
  2233. PsnNo: order.PsnNo,
  2234. MdtrtId: order.MdtrtId,
  2235. SetlId: order.SetlId,
  2236. PsnName: order.PsnName,
  2237. Gend: order.Gend,
  2238. Brdy: his.Brdy,
  2239. Age: int64(order.Age),
  2240. Naty: order.Naty,
  2241. PatnCertType: "01",
  2242. Certno: order.Certno,
  2243. Prfs: "90",
  2244. ConerName: roles[0].UserName,
  2245. PatnRlts: "99",
  2246. ConerAddr: miConfig.OrgName,
  2247. ConerTel: admin.Mobile,
  2248. HiType: order.Insutype,
  2249. Insuplc: miConfig.InsuplcAdmdvs,
  2250. MaindiagFlag: "1",
  2251. BillCode: last_order.FaPiaoCode,
  2252. BillNo: zero,
  2253. BizSn: order.Number,
  2254. PsnSelfPay: order.PsnPartAmt,
  2255. PsnOwnPay: order.PsnPartAmt,
  2256. AcctPay: order.AcctPay,
  2257. PsnCashpay: order.PsnCashPay,
  2258. HiPaymtd: "1",
  2259. Hsorg: miConfig.InsuplcAdmdvs,
  2260. HsorgOpter: miConfig.InsuplcAdmdvs,
  2261. MedinsFillPsn: curRoles.UserName,
  2262. MedinsFillDept: depart.Name,
  2263. IptMedType: "2",
  2264. AdmTime: his.InHosptialTime,
  2265. AdmEndTime: his.OutHosptialTime,
  2266. }
  2267. struct4101.SetlBegnDate = order.SetlTime
  2268. struct4101.SetlEndDate = order.SetlTime
  2269. var rf []CustomFundPay
  2270. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2271. var tempFunPays []service.CustomStruct
  2272. for _, item := range rf {
  2273. var tempFunPay service.CustomStruct
  2274. tempFunPay.FundPayamt = item.FundPayamt
  2275. tempFunPay.FundPayType = item.FundPayType
  2276. tempFunPays = append(tempFunPays, tempFunPay)
  2277. }
  2278. struct4101.CustomStruct = tempFunPays
  2279. var tempDiaginfos []service.DiaginfoStructTwo
  2280. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2281. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2282. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2283. var config []*models.HisXtDiagnoseConfig
  2284. for _, item := range diagnosis_ids {
  2285. id, _ := strconv.ParseInt(item, 10, 64)
  2286. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2287. config = append(config, &diagnosisConfig)
  2288. }
  2289. for index, item := range config {
  2290. if index == 0 {
  2291. var tempDiaginfo service.DiaginfoStructTwo
  2292. tempDiaginfo.DiagCode = item.CountryCode
  2293. tempDiaginfo.DiagName = item.CountryContentName
  2294. tempDiaginfo.DiagType = "1"
  2295. tempDiaginfo.MaindiagFlag = "1"
  2296. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2297. } else {
  2298. var tempDiaginfo service.DiaginfoStructTwo
  2299. tempDiaginfo.DiagCode = item.CountryCode
  2300. tempDiaginfo.DiagName = item.CountryContentName
  2301. tempDiaginfo.DiagType = "2"
  2302. tempDiaginfo.MaindiagFlag = "0"
  2303. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2304. }
  2305. }
  2306. struct4101.Diseinfo = tempDiaginfos
  2307. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2308. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2309. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2310. tempOpspdiseinfo2.OprnOprtCode = ""
  2311. tempOpspdiseinfo2.OprnOprtName = ""
  2312. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2313. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2314. var iteminfo service.IteminfoStruct
  2315. var bedCostTotal float64 = 0 //床位总费
  2316. var bedCostSelfTotal float64 = 0 //床位自费
  2317. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2318. var operationCostTotal float64 = 0 //手术费
  2319. var operationCostSelfTotal float64 = 0 //手术费
  2320. var operationCostPartSelfTotal float64 = 0 //手术费
  2321. var otherCostTotal float64 = 0 //其他费用
  2322. var otherCostSelfTotal float64 = 0 //其他费用
  2323. var otherCostPartSelfTotal float64 = 0 //其他费用
  2324. var materialCostTotal float64 = 0 //材料费
  2325. var materialCostSelfTotal float64 = 0 //材料费
  2326. var materialCostPartSelfTotal float64 = 0 //材料费
  2327. var westernMedicineCostTotal float64 = 0 //西药费
  2328. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2329. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2330. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2331. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2332. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2333. var checkCostTotal float64 = 0 //检查费
  2334. var checkCostSelfTotal float64 = 0 //检查费
  2335. var checkCostPartSelfTotal float64 = 0 //检查费
  2336. var laboratoryCostTotal float64 = 0 //化验费
  2337. var laboratoryCostSelfTotal float64 = 0 //化验费
  2338. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2339. var treatCostTotal float64 = 0 //治疗费用
  2340. var treatCostSelfTotal float64 = 0 //治疗费用
  2341. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2342. decimal.DivisionPrecision = 2
  2343. var bed_fulamt_ownpay_amt float64 = 0
  2344. var operation_fulamt_ownpay_amt float64 = 0
  2345. var other_fulamt_ownpay_amt float64 = 0
  2346. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2347. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2348. var check_fulamt_ownpay_amt float64 = 0
  2349. var material_fulamt_ownpay_amt float64 = 0
  2350. var laboratory_fulamt_ownpay_amt float64 = 0
  2351. var treat_fulamt_ownpay_amt float64 = 0
  2352. var bed_claa_sunmfee float64 = 0
  2353. var bed_clab_amt float64 = 0
  2354. var bed_other_amt float64 = 0
  2355. var operation_claa_sunmfee float64 = 0
  2356. var operation_clab_amt float64 = 0
  2357. var operation_other_amt float64 = 0
  2358. var other_claa_sunmfee float64 = 0
  2359. var other_clab_amt float64 = 0
  2360. var other_other_amt float64 = 0
  2361. var westernMedicine_claa_sunmfee float64 = 0
  2362. var westernMedicine_clab_amt float64 = 0
  2363. var westernMedicine_other_amt float64 = 0
  2364. var chineseTraditional_claa_sunmfee float64 = 0
  2365. var chineseTraditional_clab_amt float64 = 0
  2366. var chineseTraditional_other_amt float64 = 0
  2367. var check_claa_sunmfee float64 = 0
  2368. var check_clab_amt float64 = 0
  2369. var check_other_amt float64 = 0
  2370. var material_claa_sunmfee float64 = 0
  2371. var material_clab_amt float64 = 0
  2372. var material_other_amt float64 = 0
  2373. var laboratory_claa_sunmfee float64 = 0
  2374. var laboratory_clab_amt float64 = 0
  2375. var laboratory_other_amt float64 = 0
  2376. var treat_claa_sunmfee float64 = 0
  2377. var treat_clab_amt float64 = 0
  2378. var treat_other_amt float64 = 0
  2379. for _, item := range order.HisOrderInfo {
  2380. if item.MedChrgitmType == "01" { //床位费
  2381. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2382. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2383. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2384. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2385. if item.ChrgitmLv == "1" {
  2386. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2387. }
  2388. if item.ChrgitmLv == "2" {
  2389. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2390. }
  2391. if item.ChrgitmLv == "3" {
  2392. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2393. }
  2394. }
  2395. if item.MedChrgitmType == "03" { //检查费
  2396. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2397. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2398. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2399. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2400. if item.ChrgitmLv == "1" {
  2401. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2402. }
  2403. if item.ChrgitmLv == "2" {
  2404. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2405. }
  2406. if item.ChrgitmLv == "3" {
  2407. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2408. }
  2409. }
  2410. if item.MedChrgitmType == "04" { //化验费
  2411. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2412. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2413. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2414. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2415. if item.ChrgitmLv == "1" {
  2416. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2417. }
  2418. if item.ChrgitmLv == "2" {
  2419. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2420. }
  2421. if item.ChrgitmLv == "3" {
  2422. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2423. }
  2424. }
  2425. if item.MedChrgitmType == "05" { //治疗费
  2426. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2427. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2428. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2429. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2430. if item.ChrgitmLv == "1" {
  2431. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2432. }
  2433. if item.ChrgitmLv == "2" {
  2434. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2435. }
  2436. if item.ChrgitmLv == "3" {
  2437. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2438. }
  2439. }
  2440. if item.MedChrgitmType == "06" { //手术费
  2441. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2442. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2443. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2444. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2445. if item.ChrgitmLv == "1" {
  2446. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2447. }
  2448. if item.ChrgitmLv == "2" {
  2449. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2450. }
  2451. if item.ChrgitmLv == "3" {
  2452. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2453. }
  2454. }
  2455. if item.MedChrgitmType == "08" { //材料费
  2456. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2457. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2458. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2459. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2460. if item.ChrgitmLv == "1" {
  2461. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2462. }
  2463. if item.ChrgitmLv == "2" {
  2464. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2465. }
  2466. if item.ChrgitmLv == "3" {
  2467. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2468. }
  2469. }
  2470. if item.MedChrgitmType == "09" { //西药费
  2471. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2472. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2473. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2474. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2475. if item.ChrgitmLv == "1" {
  2476. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2477. }
  2478. if item.ChrgitmLv == "2" {
  2479. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2480. }
  2481. if item.ChrgitmLv == "3" {
  2482. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2483. }
  2484. }
  2485. if item.MedChrgitmType == "11" { //中成费
  2486. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2487. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2488. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2489. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2490. if item.ChrgitmLv == "1" {
  2491. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2492. }
  2493. if item.ChrgitmLv == "2" {
  2494. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2495. }
  2496. if item.ChrgitmLv == "3" {
  2497. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2498. }
  2499. }
  2500. if item.MedChrgitmType == "14" { //其他费
  2501. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2502. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2503. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2504. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2505. if item.ChrgitmLv == "1" {
  2506. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2507. }
  2508. if item.ChrgitmLv == "2" {
  2509. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2510. }
  2511. if item.ChrgitmLv == "3" {
  2512. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2513. }
  2514. }
  2515. }
  2516. var iteminfoStructs []service.IteminfoStruct
  2517. if bedCostTotal != 0 {
  2518. iteminfo.MedChrgitm = "01"
  2519. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2520. iteminfo.Amt = bedCostTotal
  2521. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2522. iteminfo.ClabAmt = bed_clab_amt
  2523. iteminfo.OthAmt = bed_other_amt
  2524. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2525. }
  2526. if checkCostTotal != 0 {
  2527. iteminfo.MedChrgitm = "03"
  2528. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2529. iteminfo.Amt = checkCostTotal
  2530. iteminfo.ClaaSumfee = check_claa_sunmfee
  2531. iteminfo.ClabAmt = check_clab_amt
  2532. iteminfo.OthAmt = check_other_amt
  2533. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2534. }
  2535. if laboratoryCostTotal != 0 {
  2536. iteminfo.MedChrgitm = "04"
  2537. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2538. iteminfo.Amt = laboratoryCostTotal
  2539. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2540. iteminfo.ClabAmt = laboratory_clab_amt
  2541. iteminfo.OthAmt = laboratory_other_amt
  2542. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2543. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2544. }
  2545. if treatCostTotal != 0 {
  2546. iteminfo.MedChrgitm = "05"
  2547. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2548. iteminfo.Amt = treatCostTotal
  2549. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2550. iteminfo.ClabAmt = treat_clab_amt
  2551. iteminfo.OthAmt = treat_other_amt
  2552. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2553. //(struct4101.IteminfoStruct, iteminfo)
  2554. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2555. }
  2556. if operationCostTotal != 0 {
  2557. iteminfo.MedChrgitm = "06"
  2558. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2559. iteminfo.Amt = operationCostTotal
  2560. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2561. iteminfo.ClabAmt = operation_clab_amt
  2562. iteminfo.OthAmt = operation_other_amt
  2563. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2564. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2565. }
  2566. if materialCostTotal != 0 {
  2567. iteminfo.MedChrgitm = "08"
  2568. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2569. iteminfo.Amt = materialCostTotal
  2570. iteminfo.ClaaSumfee = material_claa_sunmfee
  2571. iteminfo.ClabAmt = material_clab_amt
  2572. iteminfo.OthAmt = material_other_amt
  2573. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2574. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2575. }
  2576. if westernMedicineCostTotal != 0 {
  2577. iteminfo.MedChrgitm = "09"
  2578. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2579. iteminfo.Amt = westernMedicineCostTotal
  2580. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2581. iteminfo.ClabAmt = westernMedicine_clab_amt
  2582. iteminfo.OthAmt = westernMedicine_other_amt
  2583. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2584. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2585. }
  2586. if chineseTraditionalMedicineCostTotal != 0 {
  2587. iteminfo.MedChrgitm = "11"
  2588. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2589. iteminfo.Amt = westernMedicineCostTotal
  2590. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2591. iteminfo.ClabAmt = westernMedicine_clab_amt
  2592. iteminfo.OthAmt = westernMedicine_other_amt
  2593. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2594. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2595. }
  2596. if otherCostTotal != 0 {
  2597. iteminfo.MedChrgitm = "14"
  2598. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2599. iteminfo.Amt = otherCostTotal
  2600. iteminfo.ClaaSumfee = other_claa_sunmfee
  2601. iteminfo.ClabAmt = other_clab_amt
  2602. iteminfo.OthAmt = other_other_amt
  2603. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2605. }
  2606. struct4101.IteminfoStruct = iteminfoStructs
  2607. struct4101.Ntly = "中国"
  2608. struct4101.AdmCaty = "A03.06"
  2609. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2610. fmt.Println(result)
  2611. var dat map[string]interface{}
  2612. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2613. fmt.Println(dat)
  2614. } else {
  2615. fmt.Println(err)
  2616. }
  2617. userJSONBytes, _ := json.Marshal(dat)
  2618. var res ResultSeventeen
  2619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2620. utils.ErrorLog("解析失败:%v", err)
  2621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2622. return
  2623. }
  2624. if res.Infcode != 0 {
  2625. c.ServeSuccessJSON(map[string]interface{}{
  2626. "failed_code": -10,
  2627. "msg": res.ErrMsg,
  2628. })
  2629. return
  2630. } else {
  2631. order.FaPiaoNumber = zero
  2632. order.FaPiaoCode = last_order.FaPiaoCode
  2633. service.UpdateOrder(order)
  2634. hisFundSettleListResult := &models.HisFundSettleListResult{
  2635. Number: res.Output.SetlListId,
  2636. Status: 1,
  2637. Ctime: time.Now().Unix(),
  2638. Mtime: time.Now().Unix(),
  2639. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2640. IsUpload: 1,
  2641. OrderId: order_id,
  2642. }
  2643. service.CreateUploadRecord(hisFundSettleListResult)
  2644. c.ServeSuccessJSON(map[string]interface{}{
  2645. "msg": "上传成功",
  2646. "result": hisFundSettleListResult,
  2647. })
  2648. return
  2649. }
  2650. }
  2651. func (c *HisApiController) GetBatchSettleList() {
  2652. orders, _ := service.GetAllHisOrder(10106)
  2653. for _, item := range orders {
  2654. order_id := item.ID
  2655. order, _ := service.GetHisOrderByIDTwo(order_id)
  2656. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2657. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2658. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2659. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2660. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2661. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2662. if order.ID == 0 {
  2663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2664. return
  2665. }
  2666. if his.BalanceAccountsType == 2 {
  2667. continue
  2668. }
  2669. struct4101 := service.Struct4101{
  2670. PsnNo: order.PsnNo,
  2671. MdtrtId: order.MdtrtId,
  2672. SetlId: order.SetlId,
  2673. PsnName: order.PsnName,
  2674. Gend: order.Gend,
  2675. Brdy: his.Brdy,
  2676. Age: his.Age,
  2677. Naty: order.Naty,
  2678. PatnCertType: "01",
  2679. Certno: order.Certno,
  2680. Prfs: "90",
  2681. ConerName: roles[0].UserName,
  2682. PatnRlts: "99",
  2683. ConerAddr: miConfig.OrgName,
  2684. ConerTel: admin.Mobile,
  2685. HiType: order.Insutype,
  2686. Insuplc: his.InsuplcAdmdvs,
  2687. MaindiagFlag: "1",
  2688. BillCode: order.FaPiaoCode,
  2689. BillNo: order.FaPiaoNumber,
  2690. BizSn: order.Number,
  2691. PsnSelfPay: order.PsnPartAmt,
  2692. PsnOwnPay: order.PsnPartAmt,
  2693. AcctPay: order.AcctPay,
  2694. PsnCashpay: order.PsnCashPay,
  2695. HiPaymtd: "1",
  2696. Hsorg: his.InsuplcAdmdvs,
  2697. HsorgOpter: his.InsuplcAdmdvs,
  2698. MedinsFillPsn: curRoles.UserName,
  2699. MedinsFillDept: depart.Name,
  2700. IptMedType: "2",
  2701. }
  2702. struct4101.SetlBegnDate = order.SetlTime
  2703. struct4101.SetlEndDate = order.SetlTime
  2704. //if order.SettleType == 1 {
  2705. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2706. // dateStr := t.Format("2006-01-02")
  2707. // struct4101.SetlBegnDate = dateStr
  2708. // struct4101.SetlEndDate = dateStr
  2709. //} else {
  2710. // t := time.Unix(int64(order.SettleStartTime), 0)
  2711. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2712. // dateStartStr := t.Format("2006-01-02")
  2713. // dateEndStr := t2.Format("2006-01-02")
  2714. // struct4101.SetlBegnDate = dateStartStr
  2715. // struct4101.SetlEndDate = dateEndStr
  2716. //}
  2717. var rf []CustomFundPay
  2718. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2719. var tempFunPays []service.CustomStruct
  2720. var tempFunPay610100 service.CustomStruct
  2721. for _, item := range rf {
  2722. if item.FundPayType == "610100" {
  2723. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2724. tempFunPay610100.FundPayType = item.FundPayType
  2725. } else {
  2726. var tempFunPay service.CustomStruct
  2727. tempFunPay.FundPayamt = item.FundPayamt
  2728. tempFunPay.FundPayType = item.FundPayType
  2729. tempFunPays = append(tempFunPays, tempFunPay)
  2730. }
  2731. }
  2732. tempFunPays = append(tempFunPays, tempFunPay610100)
  2733. struct4101.CustomStruct = tempFunPays
  2734. var tempDiaginfos []service.DiaginfoStructTwo
  2735. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2736. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2737. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2738. var config []*models.HisXtDiagnoseConfig
  2739. for _, item := range diagnosis_ids {
  2740. id, _ := strconv.ParseInt(item, 10, 64)
  2741. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2742. config = append(config, &diagnosisConfig)
  2743. }
  2744. for index, item := range config {
  2745. if index == 0 {
  2746. var tempDiaginfo service.DiaginfoStructTwo
  2747. tempDiaginfo.DiagCode = item.CountryCode
  2748. tempDiaginfo.DiagName = item.CountryContentName
  2749. tempDiaginfo.DiagType = "1"
  2750. tempDiaginfo.MaindiagFlag = "1"
  2751. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2752. } else {
  2753. var tempDiaginfo service.DiaginfoStructTwo
  2754. tempDiaginfo.DiagCode = item.CountryCode
  2755. tempDiaginfo.DiagName = item.CountryContentName
  2756. tempDiaginfo.DiagType = "2"
  2757. tempDiaginfo.MaindiagFlag = "0"
  2758. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2759. }
  2760. }
  2761. struct4101.Diseinfo = tempDiaginfos
  2762. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2763. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2764. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2765. tempOpspdiseinfo2.OprnOprtCode = ""
  2766. tempOpspdiseinfo2.OprnOprtName = ""
  2767. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2768. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2769. var iteminfo service.IteminfoStruct
  2770. var bedCostTotal float64 = 0 //床位总费
  2771. var bedCostSelfTotal float64 = 0 //床位自费
  2772. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2773. var examineCostTotal float64 = 0 //诊查总费
  2774. var examineCostSelfTotal float64 = 0 //诊查自费
  2775. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2776. var nursingCostTotal float64 = 0 //护理总费
  2777. var nursingCostSelfTotal float64 = 0 //护理自费
  2778. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2779. var chineseMedicineCostTotal float64 = 0 //中成药
  2780. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2781. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2782. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2783. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2784. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2785. var registerCostTotal float64 = 0 //一般诊疗费
  2786. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2787. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2788. var operationCostTotal float64 = 0 //手术费
  2789. var operationCostSelfTotal float64 = 0 //手术费
  2790. var operationCostPartSelfTotal float64 = 0 //手术费
  2791. var otherCostTotal float64 = 0 //其他费用
  2792. var otherCostSelfTotal float64 = 0 //其他费用
  2793. var otherCostPartSelfTotal float64 = 0 //其他费用
  2794. var materialCostTotal float64 = 0 //材料费
  2795. var materialCostSelfTotal float64 = 0 //材料费
  2796. var materialCostPartSelfTotal float64 = 0 //材料费
  2797. var westernMedicineCostTotal float64 = 0 //西药费
  2798. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2799. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2800. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2801. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2802. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2803. var checkCostTotal float64 = 0 //检查费
  2804. var checkCostSelfTotal float64 = 0 //检查费
  2805. var checkCostPartSelfTotal float64 = 0 //检查费
  2806. var laboratoryCostTotal float64 = 0 //化验费
  2807. var laboratoryCostSelfTotal float64 = 0 //化验费
  2808. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2809. var treatCostTotal float64 = 0 //治疗费用
  2810. var treatCostSelfTotal float64 = 0 //治疗费用
  2811. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2812. decimal.DivisionPrecision = 2
  2813. var bed_fulamt_ownpay_amt float64 = 0
  2814. var examine_fulamt_ownpay_amt float64 = 0
  2815. var nursing_fulamt_ownpay_amt float64 = 0
  2816. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2817. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2818. var register_fulamt_ownpay_amt float64 = 0
  2819. var operation_fulamt_ownpay_amt float64 = 0
  2820. var other_fulamt_ownpay_amt float64 = 0
  2821. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2822. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2823. var check_fulamt_ownpay_amt float64 = 0
  2824. var material_fulamt_ownpay_amt float64 = 0
  2825. var laboratory_fulamt_ownpay_amt float64 = 0
  2826. var treat_fulamt_ownpay_amt float64 = 0
  2827. var bed_claa_sunmfee float64 = 0
  2828. var bed_clab_amt float64 = 0
  2829. var bed_other_amt float64 = 0
  2830. var examine_claa_sunmfee float64 = 0
  2831. var examine_clab_amt float64 = 0
  2832. var examine_other_amt float64 = 0
  2833. var nursing_claa_sunmfee float64 = 0
  2834. var nursing_clab_amt float64 = 0
  2835. var nursing_other_amt float64 = 0
  2836. var chinese_medicine_claa_sunmfee float64 = 0
  2837. var chinese_medicine_clab_amt float64 = 0
  2838. var chinese_medicine_other_amt float64 = 0
  2839. var commonly_treatment_claa_sunmfee float64 = 0
  2840. var commonly_treatment_clab_amt float64 = 0
  2841. var commonly_treatment_other_amt float64 = 0
  2842. var operation_claa_sunmfee float64 = 0
  2843. var operation_clab_amt float64 = 0
  2844. var operation_other_amt float64 = 0
  2845. var other_claa_sunmfee float64 = 0
  2846. var other_clab_amt float64 = 0
  2847. var other_other_amt float64 = 0
  2848. var westernMedicine_claa_sunmfee float64 = 0
  2849. var westernMedicine_clab_amt float64 = 0
  2850. var westernMedicine_other_amt float64 = 0
  2851. var chineseTraditional_claa_sunmfee float64 = 0
  2852. var chineseTraditional_clab_amt float64 = 0
  2853. var chineseTraditional_other_amt float64 = 0
  2854. var check_claa_sunmfee float64 = 0
  2855. var check_clab_amt float64 = 0
  2856. var check_other_amt float64 = 0
  2857. var material_claa_sunmfee float64 = 0
  2858. var material_clab_amt float64 = 0
  2859. var material_other_amt float64 = 0
  2860. var laboratory_claa_sunmfee float64 = 0
  2861. var laboratory_clab_amt float64 = 0
  2862. var laboratory_other_amt float64 = 0
  2863. var treat_claa_sunmfee float64 = 0
  2864. var treat_clab_amt float64 = 0
  2865. var treat_other_amt float64 = 0
  2866. var register_claa_sunmfee float64 = 0
  2867. var register_clab_amt float64 = 0
  2868. var register_other_amt float64 = 0
  2869. for _, item := range order.HisOrderInfo {
  2870. if item.MedChrgitmType == "01" { //床位费
  2871. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2872. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2873. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2874. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2875. if item.ChrgitmLv == "1" {
  2876. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2877. }
  2878. if item.ChrgitmLv == "2" {
  2879. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2880. }
  2881. if item.ChrgitmLv == "3" {
  2882. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2883. }
  2884. }
  2885. if item.MedChrgitmType == "02" { //诊查
  2886. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2887. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2888. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2889. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2890. if item.ChrgitmLv == "1" {
  2891. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2892. }
  2893. if item.ChrgitmLv == "2" {
  2894. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2895. }
  2896. if item.ChrgitmLv == "3" {
  2897. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2898. }
  2899. }
  2900. if item.MedChrgitmType == "03" { //检查费
  2901. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2902. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2903. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2904. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2905. if item.ChrgitmLv == "1" {
  2906. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2907. }
  2908. if item.ChrgitmLv == "2" {
  2909. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2910. }
  2911. if item.ChrgitmLv == "3" {
  2912. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2913. }
  2914. }
  2915. if item.MedChrgitmType == "04" { //化验费
  2916. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2917. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2918. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2919. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2920. if item.ChrgitmLv == "1" {
  2921. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2922. }
  2923. if item.ChrgitmLv == "2" {
  2924. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2925. }
  2926. if item.ChrgitmLv == "3" {
  2927. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2928. }
  2929. }
  2930. if item.MedChrgitmType == "05" { //治疗费
  2931. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2932. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2933. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2934. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2935. if item.ChrgitmLv == "1" {
  2936. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2937. }
  2938. if item.ChrgitmLv == "2" {
  2939. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2940. }
  2941. if item.ChrgitmLv == "3" {
  2942. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2943. }
  2944. }
  2945. if item.MedChrgitmType == "06" { //手术费
  2946. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2947. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2948. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2949. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2950. if item.ChrgitmLv == "1" {
  2951. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2952. }
  2953. if item.ChrgitmLv == "2" {
  2954. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2955. }
  2956. if item.ChrgitmLv == "3" {
  2957. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2958. }
  2959. }
  2960. if item.MedChrgitmType == "07" { //手术费
  2961. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2962. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2963. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2964. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2965. if item.ChrgitmLv == "1" {
  2966. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2967. }
  2968. if item.ChrgitmLv == "2" {
  2969. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2970. }
  2971. if item.ChrgitmLv == "3" {
  2972. nursing_other_amt, _ = decimal.NewFromFloat(nursing_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 == "10" { //中药饮片
  3006. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3007. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3008. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3009. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3010. if item.ChrgitmLv == "1" {
  3011. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3012. }
  3013. if item.ChrgitmLv == "2" {
  3014. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3015. }
  3016. if item.ChrgitmLv == "3" {
  3017. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3018. }
  3019. }
  3020. if item.MedChrgitmType == "11" { //中成费
  3021. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3022. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3023. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3024. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3025. if item.ChrgitmLv == "1" {
  3026. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3027. }
  3028. if item.ChrgitmLv == "2" {
  3029. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3030. }
  3031. if item.ChrgitmLv == "3" {
  3032. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3033. }
  3034. }
  3035. if item.MedChrgitmType == "12" { //中成费
  3036. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3037. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3038. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3039. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3040. if item.ChrgitmLv == "1" {
  3041. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3042. }
  3043. if item.ChrgitmLv == "2" {
  3044. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3045. }
  3046. if item.ChrgitmLv == "3" {
  3047. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3048. }
  3049. }
  3050. if item.MedChrgitmType == "13" { //中成费
  3051. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3052. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3053. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3054. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3055. if item.ChrgitmLv == "1" {
  3056. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3057. }
  3058. if item.ChrgitmLv == "2" {
  3059. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3060. }
  3061. if item.ChrgitmLv == "3" {
  3062. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3063. }
  3064. }
  3065. if item.MedChrgitmType == "14" { //其他费
  3066. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3067. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3068. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3069. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3070. if item.ChrgitmLv == "1" {
  3071. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3072. }
  3073. if item.ChrgitmLv == "2" {
  3074. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3075. }
  3076. if item.ChrgitmLv == "3" {
  3077. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3078. }
  3079. }
  3080. }
  3081. var iteminfoStructs []service.IteminfoStruct
  3082. if bedCostTotal != 0 {
  3083. iteminfo.MedChrgitm = "01"
  3084. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3085. iteminfo.Amt = bedCostTotal
  3086. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3087. iteminfo.ClabAmt = bed_clab_amt
  3088. iteminfo.OthAmt = bed_other_amt
  3089. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3090. }
  3091. if examineCostTotal != 0 {
  3092. iteminfo.MedChrgitm = "02"
  3093. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3094. iteminfo.Amt = examineCostTotal
  3095. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3096. iteminfo.ClabAmt = examine_clab_amt
  3097. iteminfo.OthAmt = examine_other_amt
  3098. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3099. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3100. }
  3101. if checkCostTotal != 0 {
  3102. iteminfo.MedChrgitm = "03"
  3103. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3104. iteminfo.Amt = checkCostTotal
  3105. iteminfo.ClaaSumfee = check_claa_sunmfee
  3106. iteminfo.ClabAmt = check_clab_amt
  3107. iteminfo.OthAmt = check_other_amt
  3108. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3109. }
  3110. if laboratoryCostTotal != 0 {
  3111. iteminfo.MedChrgitm = "04"
  3112. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3113. iteminfo.Amt = laboratoryCostTotal
  3114. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3115. iteminfo.ClabAmt = laboratory_clab_amt
  3116. iteminfo.OthAmt = laboratory_other_amt
  3117. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3118. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3119. }
  3120. if treatCostTotal != 0 {
  3121. iteminfo.MedChrgitm = "05"
  3122. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3123. iteminfo.Amt = treatCostTotal
  3124. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3125. iteminfo.ClabAmt = treat_clab_amt
  3126. iteminfo.OthAmt = treat_other_amt
  3127. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3128. //(struct4101.IteminfoStruct, iteminfo)
  3129. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3130. }
  3131. if operationCostTotal != 0 {
  3132. iteminfo.MedChrgitm = "06"
  3133. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3134. iteminfo.Amt = operationCostTotal
  3135. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3136. iteminfo.ClabAmt = operation_clab_amt
  3137. iteminfo.OthAmt = operation_other_amt
  3138. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3139. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3140. }
  3141. if nursingCostTotal != 0 {
  3142. iteminfo.MedChrgitm = "07"
  3143. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3144. iteminfo.Amt = nursingCostTotal
  3145. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3146. iteminfo.ClabAmt = nursing_clab_amt
  3147. iteminfo.OthAmt = nursing_other_amt
  3148. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3149. }
  3150. if materialCostTotal != 0 {
  3151. iteminfo.MedChrgitm = "08"
  3152. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3153. iteminfo.Amt = materialCostTotal
  3154. iteminfo.ClaaSumfee = material_claa_sunmfee
  3155. iteminfo.ClabAmt = material_clab_amt
  3156. iteminfo.OthAmt = material_other_amt
  3157. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3158. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3159. }
  3160. if westernMedicineCostTotal != 0 {
  3161. iteminfo.MedChrgitm = "09"
  3162. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3163. iteminfo.Amt = westernMedicineCostTotal
  3164. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3165. iteminfo.ClabAmt = westernMedicine_clab_amt
  3166. iteminfo.OthAmt = westernMedicine_other_amt
  3167. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3168. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3169. }
  3170. if chineseMedicineCostTotal != 0 {
  3171. iteminfo.MedChrgitm = "10"
  3172. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3173. iteminfo.Amt = chineseMedicineCostTotal
  3174. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3175. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3176. iteminfo.OthAmt = chinese_medicine_other_amt
  3177. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3178. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3179. }
  3180. if chineseTraditionalMedicineCostTotal != 0 {
  3181. iteminfo.MedChrgitm = "11"
  3182. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3183. iteminfo.Amt = westernMedicineCostTotal
  3184. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3185. iteminfo.ClabAmt = westernMedicine_clab_amt
  3186. iteminfo.OthAmt = westernMedicine_other_amt
  3187. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3188. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3189. }
  3190. if commonlyTreatmentCostTotal != 0 {
  3191. iteminfo.MedChrgitm = "12"
  3192. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3193. iteminfo.Amt = commonlyTreatmentCostTotal
  3194. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3195. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3196. iteminfo.OthAmt = commonly_treatment_other_amt
  3197. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3198. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3199. }
  3200. if registerCostTotal != 0 {
  3201. iteminfo.MedChrgitm = "13"
  3202. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3203. iteminfo.Amt = registerCostTotal
  3204. iteminfo.ClaaSumfee = register_claa_sunmfee
  3205. iteminfo.ClabAmt = register_clab_amt
  3206. iteminfo.OthAmt = register_other_amt
  3207. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3208. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3209. }
  3210. if otherCostTotal != 0 {
  3211. iteminfo.MedChrgitm = "14"
  3212. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3213. iteminfo.Amt = otherCostTotal
  3214. iteminfo.ClaaSumfee = other_claa_sunmfee
  3215. iteminfo.ClabAmt = other_clab_amt
  3216. iteminfo.OthAmt = other_other_amt
  3217. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3218. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3219. }
  3220. struct4101.IteminfoStruct = iteminfoStructs
  3221. struct4101.Ntly = "中国"
  3222. struct4101.AdmCaty = "A03.06"
  3223. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3224. fmt.Println(result)
  3225. var dat map[string]interface{}
  3226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3227. fmt.Println(dat)
  3228. } else {
  3229. fmt.Println(err)
  3230. }
  3231. userJSONBytes, _ := json.Marshal(dat)
  3232. var res ResultSeventeen
  3233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3234. utils.ErrorLog("解析失败:%v", err)
  3235. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. adminUser := c.GetAdminUserInfo()
  3237. errlog := &models.HisOrderError{
  3238. UserOrgId: adminUser.CurrentOrgId,
  3239. Ctime: time.Now().Unix(),
  3240. Mtime: time.Now().Unix(),
  3241. ErrMsg: res.ErrMsg + "解析失败",
  3242. Status: 1,
  3243. PatientId: order_id,
  3244. Stage: 10106,
  3245. }
  3246. service.CreateErrMsgLog(errlog)
  3247. continue
  3248. }
  3249. if res.Infcode != 0 {
  3250. adminUser := c.GetAdminUserInfo()
  3251. errlog := &models.HisOrderError{
  3252. UserOrgId: adminUser.CurrentOrgId,
  3253. Ctime: time.Now().Unix(),
  3254. Mtime: time.Now().Unix(),
  3255. ErrMsg: res.ErrMsg,
  3256. Status: 1,
  3257. PatientId: order_id,
  3258. Stage: 10106,
  3259. }
  3260. service.CreateErrMsgLog(errlog)
  3261. continue
  3262. } else {
  3263. hisFundSettleListResult := &models.HisFundSettleListResult{
  3264. Number: res.Output.SetlListId,
  3265. Status: 1,
  3266. Ctime: time.Now().Unix(),
  3267. Mtime: time.Now().Unix(),
  3268. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3269. IsUpload: 1,
  3270. OrderId: order_id,
  3271. }
  3272. service.CreateUploadRecord(hisFundSettleListResult)
  3273. continue
  3274. }
  3275. }
  3276. }
  3277. func (c *HisApiController) GetOrgInfo() {
  3278. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3279. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3280. }
  3281. func (c *HisApiController) GetHisPatientInfo() {
  3282. medical_insurance_card := c.GetString("medical_insurance_card")
  3283. id_card_type, _ := c.GetInt64("id_card_type")
  3284. id_card := c.GetString("id_card")
  3285. adminInfo := c.GetAdminUserInfo()
  3286. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3287. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3288. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3289. IdCardNo := ""
  3290. if id_card_type == 1 {
  3291. IdCardNo = medical_insurance_card
  3292. } else if id_card_type == 2 {
  3293. IdCardNo = id_card
  3294. }
  3295. if config.IsOpen == 1 {
  3296. 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
  3297. resp, requestErr := http.Get(api)
  3298. if requestErr != nil {
  3299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3300. return
  3301. }
  3302. defer resp.Body.Close()
  3303. body, ioErr := ioutil.ReadAll(resp.Body)
  3304. if ioErr != nil {
  3305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3307. return
  3308. }
  3309. var respJSON map[string]interface{}
  3310. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3313. return
  3314. }
  3315. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3316. userJSONBytes, _ := json.Marshal(userJSON)
  3317. var res ResultTwo
  3318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3319. utils.ErrorLog("解析失败:%v", err)
  3320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3321. return
  3322. }
  3323. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3324. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3325. infoStr := string(Iinfos)
  3326. idetinfoStr := string(Idetinfos)
  3327. if res.Infcode == 0 {
  3328. his := models.VMHisPatient{
  3329. Status: 1,
  3330. Ctime: time.Now().Unix(),
  3331. Mtime: time.Now().Unix(),
  3332. PsnNo: res.Output.Baseinfo.PsnNo,
  3333. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3334. Certno: res.Output.Baseinfo.Certno,
  3335. PsnName: res.Output.Baseinfo.PsnName,
  3336. Gend: res.Output.Baseinfo.Gend,
  3337. Naty: res.Output.Baseinfo.Naty,
  3338. Brdy: res.Output.Baseinfo.Brdy,
  3339. Age: res.Output.Baseinfo.Age,
  3340. Iinfo: infoStr,
  3341. Idetinfo: idetinfoStr,
  3342. UserOrgId: adminInfo.CurrentOrgId,
  3343. IsReturn: 1,
  3344. IdCardType: id_card_type,
  3345. }
  3346. c.ServeSuccessJSON(map[string]interface{}{
  3347. "info": his,
  3348. })
  3349. } else {
  3350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3351. return
  3352. }
  3353. }
  3354. }
  3355. //func GetBasBaseInfo() (jsonStr string, err error) {
  3356. //
  3357. // handle := syscall.NewLazyDLL("SSCard.dll")
  3358. // add := handle.NewProc("ReadCardBas")
  3359. // str := make([]byte, 1024)
  3360. // str1 := make([]byte, 1024)
  3361. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3362. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3363. //
  3364. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3365. //
  3366. // fmt.Println("> Add(4,5)的结果为:", ret)
  3367. // handle.Release()
  3368. //
  3369. // return "", nil
  3370. //
  3371. //}
  3372. //func GetQRBaseInfo() (jsonStr string, err error) {
  3373. // handle := syscall.LoadDLL("SSCard.dll")
  3374. // ReadCardBas := handle.FindProc("GetQRBase")
  3375. //
  3376. // str := make([]byte, 256)
  3377. // str1 := make([]byte, 256)
  3378. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3379. //
  3380. // fmt.Println(string(str))
  3381. // fmt.Println(r)
  3382. // return string(str), nil
  3383. //}
  3384. //func CardInit() int {
  3385. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3386. // add := DllTestDef.MustFindProc("Init")
  3387. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3388. // if err != nil {
  3389. // fmt.Println("SSCard的运算结果为:", ret)
  3390. // }
  3391. // result := int(ret)
  3392. // return result
  3393. //}
  3394. //func CardInit() int {
  3395. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3396. // if err != nil {
  3397. // fmt.Println("SSCard的运算结果为:", ret)
  3398. // }
  3399. // fmt.Println(err)
  3400. // result := int(ret)
  3401. // return result
  3402. //}
  3403. func IntPtr(n int) uintptr {
  3404. return uintptr(n)
  3405. }
  3406. func StrPtr(s string) uintptr {
  3407. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3408. }
  3409. type Result2001 struct {
  3410. Cainfo interface{} `json:"cainfo"`
  3411. ErrMsg string `json:"err_msg"`
  3412. InfRefmsgid string `json:"inf_refmsgid"`
  3413. Infcode int64 `json:"infcode"`
  3414. Output struct {
  3415. Trtinfo struct {
  3416. PsnNo string `json:"psn_no"`
  3417. TrtChkType string `json:"trt_chk_type"`
  3418. FundPayType string `json:"fund_pay_type"`
  3419. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3420. Begndate string `json:"begndate"`
  3421. Enddate string `json:"enddate"`
  3422. TrtChkRslt string `json:"trt_chk_rslt"`
  3423. } `json:"trtinfo"`
  3424. } `json:"output"`
  3425. RefmsgTime string `json:"refmsg_time"`
  3426. RespondTime string `json:"respond_time"`
  3427. Signtype interface{} `json:"signtype"`
  3428. WarnMsg interface{} `json:"warn_msg"`
  3429. }
  3430. type Result2001Org10265 struct {
  3431. Cainfo interface{} `json:"cainfo"`
  3432. ErrMsg string `json:"err_msg"`
  3433. InfRefmsgid string `json:"inf_refmsgid"`
  3434. Infcode string `json:"infcode"`
  3435. Output struct {
  3436. Trtinfo struct {
  3437. PsnNo string `json:"psn_no"`
  3438. TrtChkType string `json:"trt_chk_type"`
  3439. FundPayType string `json:"fund_pay_type"`
  3440. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3441. Begndate string `json:"begndate"`
  3442. Enddate string `json:"enddate"`
  3443. TrtChkRslt string `json:"trt_chk_rslt"`
  3444. } `json:"trtinfo"`
  3445. } `json:"output"`
  3446. RefmsgTime string `json:"refmsg_time"`
  3447. RespondTime string `json:"respond_time"`
  3448. Signtype interface{} `json:"signtype"`
  3449. WarnMsg interface{} `json:"warn_msg"`
  3450. }
  3451. type ResultTwo struct {
  3452. ErrMsg string `json:"err_msg"`
  3453. InfRefmsgid string `json:"inf_refmsgid"`
  3454. Infcode int64 `json:"infcode"`
  3455. Output struct {
  3456. Baseinfo struct {
  3457. Age float64 `json:"age"`
  3458. Brdy string `json:"brdy"`
  3459. Certno string `json:"certno"`
  3460. Gend string `json:"gend"`
  3461. Naty string `json:"naty"`
  3462. PsnCertType string `json:"psn_cert_type"`
  3463. PsnName string `json:"psn_name"`
  3464. PsnNo string `json:"psn_no"`
  3465. } `json:"baseinfo"`
  3466. Idetinfo []interface{} `json:"idetinfo"`
  3467. Iinfo []struct {
  3468. Balc float64 `json:"balc"`
  3469. CvlservFlag string `json:"cvlserv_flag"`
  3470. EmpName string `json:"emp_name"`
  3471. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3472. Insutype string `json:"insutype"`
  3473. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3474. PausInsuDate string `json:"paus_insu_date"`
  3475. PsnInsuDate string `json:"psn_insu_date"`
  3476. PsnInsuStas string `json:"psn_insu_stas"`
  3477. PsnType string `json:"psn_type"`
  3478. } `json:"insuinfo"`
  3479. } `json:"output"`
  3480. RefmsgTime string `json:"refmsg_time"`
  3481. RespondTime string `json:"respond_time"`
  3482. Signtype interface{} `json:"signtype"`
  3483. WarnInfo interface{} `json:"warn_info"`
  3484. }
  3485. type ResultTwo10265 struct {
  3486. ErrMsg string `json:"err_msg"`
  3487. InfRefmsgid string `json:"inf_refmsgid"`
  3488. Infcode string `json:"infcode"`
  3489. Output struct {
  3490. Baseinfo struct {
  3491. Age float64 `json:"age"`
  3492. Brdy string `json:"brdy"`
  3493. Certno string `json:"certno"`
  3494. Gend string `json:"gend"`
  3495. Naty string `json:"naty"`
  3496. PsnCertType string `json:"psn_cert_type"`
  3497. PsnName string `json:"psn_name"`
  3498. PsnNo string `json:"psn_no"`
  3499. } `json:"baseinfo"`
  3500. Idetinfo []interface{} `json:"idetinfo"`
  3501. Iinfo []struct {
  3502. Balc float64 `json:"balc"`
  3503. CvlservFlag string `json:"cvlserv_flag"`
  3504. EmpName string `json:"emp_name"`
  3505. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3506. Insutype string `json:"insutype"`
  3507. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3508. PausInsuDate string `json:"paus_insu_date"`
  3509. PsnInsuDate string `json:"psn_insu_date"`
  3510. PsnInsuStas string `json:"psn_insu_stas"`
  3511. PsnType string `json:"psn_type"`
  3512. } `json:"insuinfo"`
  3513. } `json:"output"`
  3514. RefmsgTime string `json:"refmsg_time"`
  3515. RespondTime string `json:"respond_time"`
  3516. Signtype interface{} `json:"signtype"`
  3517. WarnInfo interface{} `json:"warn_info"`
  3518. }
  3519. type ResultThree struct {
  3520. Cainfo interface{} `json:"cainfo"`
  3521. ErrMsg string `json:"err_msg"`
  3522. InfRefmsgid string `json:"inf_refmsgid"`
  3523. Infcode int64 `json:"infcode"`
  3524. Output struct {
  3525. Data struct {
  3526. IptOtpNo string `json:"ipt_otp_no"`
  3527. MdtrtID string `json:"mdtrt_id"`
  3528. PsnNo string `json:"psn_no"`
  3529. } `json:"data"`
  3530. } `json:"output"`
  3531. RefmsgTime string `json:"refmsg_time"`
  3532. RespondTime string `json:"respond_time"`
  3533. Signtype interface{} `json:"signtype"`
  3534. WarnMsg interface{} `json:"warn_msg"`
  3535. }
  3536. type ResultThree10265 struct {
  3537. Cainfo interface{} `json:"cainfo"`
  3538. ErrMsg string `json:"err_msg"`
  3539. InfRefmsgid string `json:"inf_refmsgid"`
  3540. Infcode string `json:"infcode"`
  3541. Output struct {
  3542. Data struct {
  3543. IptOtpNo string `json:"ipt_otp_no"`
  3544. MdtrtID string `json:"mdtrt_id"`
  3545. PsnNo string `json:"psn_no"`
  3546. } `json:"data"`
  3547. } `json:"output"`
  3548. RefmsgTime string `json:"refmsg_time"`
  3549. RespondTime string `json:"respond_time"`
  3550. Signtype interface{} `json:"signtype"`
  3551. WarnMsg interface{} `json:"warn_msg"`
  3552. }
  3553. type ResultFour struct {
  3554. Cainfo string `json:"cainfo"`
  3555. ErrMsg string `json:"err_msg"`
  3556. InfRefmsgid string `json:"inf_refmsgid"`
  3557. Infcode int64 `json:"infcode"`
  3558. Output struct {
  3559. Result []struct {
  3560. BasMednFlag string `json:"bas_medn_flag"`
  3561. ChldMedcFlag string `json:"chld_medc_flag"`
  3562. ChrgitmLv string `json:"chrgitm_lv"`
  3563. Cnt float64 `json:"cnt"`
  3564. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3565. DrtReimFlag string `json:"drt_reim_flag"`
  3566. FeedetlSn string `json:"feedetl_sn"`
  3567. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3568. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3569. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3570. ListSpItemFlag string `json:"list_sp_item_flag"`
  3571. LmtUsedFlag string `json:"lmt_used_flag"`
  3572. MedChrgitmType string `json:"med_chrgitm_type"`
  3573. Memo string `json:"memo"`
  3574. OverlmtAmt float64 `json:"overlmt_amt"`
  3575. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3576. Pric float64 `json:"pric"`
  3577. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3578. SelfpayProp float64 `json:"selfpay_prop"`
  3579. } `json:"result"`
  3580. } `json:"output"`
  3581. RefmsgTime string `json:"refmsg_time"`
  3582. RespondTime string `json:"respond_time"`
  3583. Signtype string `json:"signtype"`
  3584. WarnMsg string `json:"warn_msg"`
  3585. }
  3586. type ResultFour10265 struct {
  3587. Cainfo string `json:"cainfo"`
  3588. ErrMsg string `json:"err_msg"`
  3589. InfRefmsgid string `json:"inf_refmsgid"`
  3590. Infcode string `json:"infcode"`
  3591. Output struct {
  3592. Result []struct {
  3593. BasMednFlag string `json:"bas_medn_flag"`
  3594. ChldMedcFlag string `json:"chld_medc_flag"`
  3595. ChrgitmLv string `json:"chrgitm_lv"`
  3596. Cnt float64 `json:"cnt"`
  3597. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3598. DrtReimFlag string `json:"drt_reim_flag"`
  3599. FeedetlSn string `json:"feedetl_sn"`
  3600. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3601. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3602. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3603. ListSpItemFlag string `json:"list_sp_item_flag"`
  3604. LmtUsedFlag string `json:"lmt_used_flag"`
  3605. MedChrgitmType string `json:"med_chrgitm_type"`
  3606. Memo string `json:"memo"`
  3607. OverlmtAmt float64 `json:"overlmt_amt"`
  3608. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3609. Pric float64 `json:"pric"`
  3610. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3611. SelfpayProp float64 `json:"selfpay_prop"`
  3612. } `json:"result"`
  3613. } `json:"output"`
  3614. RefmsgTime string `json:"refmsg_time"`
  3615. RespondTime string `json:"respond_time"`
  3616. Signtype string `json:"signtype"`
  3617. WarnMsg string `json:"warn_msg"`
  3618. }
  3619. type ResultFive struct {
  3620. Balc float64 `json:"balc"`
  3621. CvlservFlag string `json:"cvlserv_flag"`
  3622. EmpName string `json:"emp_name"`
  3623. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3624. Insutype string `json:"insutype"`
  3625. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3626. PausInsuDate string `json:"paus_insu_date"`
  3627. PsnInsuDate string `json:"psn_insu_date"`
  3628. PsnInsuStas string `json:"psn_insu_stas"`
  3629. PsnType string `json:"psn_type"`
  3630. }
  3631. type ResultSix struct {
  3632. Cainfo interface{} `json:"cainfo"`
  3633. ErrMsg string `json:"err_msg"`
  3634. InfRefmsgid string `json:"inf_refmsgid"`
  3635. Infcode int64 `json:"infcode"`
  3636. Output struct {
  3637. } `json:"output"`
  3638. RefmsgTime string `json:"refmsg_time"`
  3639. RespondTime string `json:"respond_time"`
  3640. Signtype interface{} `json:"signtype"`
  3641. WarnMsg interface{} `json:"warn_msg"`
  3642. }
  3643. type ResultSix10265 struct {
  3644. Cainfo interface{} `json:"cainfo"`
  3645. ErrMsg string `json:"err_msg"`
  3646. InfRefmsgid string `json:"inf_refmsgid"`
  3647. Infcode string `json:"infcode"`
  3648. Output struct {
  3649. } `json:"output"`
  3650. RefmsgTime string `json:"refmsg_time"`
  3651. RespondTime string `json:"respond_time"`
  3652. Signtype interface{} `json:"signtype"`
  3653. WarnMsg interface{} `json:"warn_msg"`
  3654. }
  3655. type ResultSeven struct {
  3656. Cainfo string `json:"cainfo"`
  3657. ErrMsg string `json:"err_msg"`
  3658. InfRefmsgid string `json:"inf_refmsgid"`
  3659. Infcode int64 `json:"infcode"`
  3660. Output struct {
  3661. Setldetail []interface{} `json:"setldetail"`
  3662. Setlinfo struct {
  3663. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3664. AcctPay float64 `json:"acct_pay"`
  3665. ActPayDedc float64 `json:"act_pay_dedc"`
  3666. Age float64 `json:"age"`
  3667. Balc float64 `json:"balc"`
  3668. Brdy string `json:"brdy"`
  3669. Certno string `json:"certno"`
  3670. ClrOptins string `json:"clr_optins"`
  3671. ClrType string `json:"clr_type"`
  3672. ClrWay string `json:"clr_way"`
  3673. CvlservFlag string `json:"cvlserv_flag"`
  3674. CvlservPay float64 `json:"cvlserv_pay"`
  3675. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3676. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3677. Gend string `json:"gend"`
  3678. HifesPay float64 `json:"hifes_pay"`
  3679. HifmiPay float64 `json:"hifmi_pay"`
  3680. HifpPay float64 `json:"hifp_pay"`
  3681. HospPartAmt float64 `json:"hosp_part_amt"`
  3682. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3683. Insutype string `json:"insutype"`
  3684. MafPay float64 `json:"maf_pay"`
  3685. MdtrtCertType string `json:"mdtrt_cert_type"`
  3686. HifobPay float64 `json:"hifob_pay"`
  3687. MdtrtID string `json:"mdtrt_id"`
  3688. MedType string `json:"med_type"`
  3689. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3690. MedinsSetlID string `json:"medins_setl_id"`
  3691. Naty string `json:"naty"`
  3692. OthPay float64 `json:"oth_pay"`
  3693. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3694. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3695. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3696. PsnCashPay float64 `json:"psn_cash_pay"`
  3697. PsnCertType string `json:"psn_cert_type"`
  3698. PsnName string `json:"psn_name"`
  3699. PsnNo string `json:"psn_no"`
  3700. PsnPartAmt float64 `json:"psn_part_amt"`
  3701. PsnType string `json:"psn_type"`
  3702. SetlID string `json:"setl_id"`
  3703. SetlTime string `json:"setl_time"`
  3704. } `json:"setlinfo"`
  3705. } `json:"output"`
  3706. RefmsgTime string `json:"refmsg_time"`
  3707. RespondTime string `json:"respond_time"`
  3708. Signtype interface{} `json:"signtype"`
  3709. WarnMsg interface{} `json:"warn_msg"`
  3710. }
  3711. type ResultSeven10265 struct {
  3712. Cainfo string `json:"cainfo"`
  3713. ErrMsg string `json:"err_msg"`
  3714. InfRefmsgid string `json:"inf_refmsgid"`
  3715. Infcode string `json:"infcode"`
  3716. Output struct {
  3717. Setldetail []interface{} `json:"setldetail"`
  3718. Setlinfo struct {
  3719. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3720. AcctPay float64 `json:"acct_pay"`
  3721. ActPayDedc float64 `json:"act_pay_dedc"`
  3722. Age float64 `json:"age"`
  3723. Balc float64 `json:"balc"`
  3724. Brdy string `json:"brdy"`
  3725. Certno string `json:"certno"`
  3726. ClrOptins string `json:"clr_optins"`
  3727. ClrType string `json:"clr_type"`
  3728. ClrWay string `json:"clr_way"`
  3729. CvlservFlag string `json:"cvlserv_flag"`
  3730. CvlservPay float64 `json:"cvlserv_pay"`
  3731. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3732. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3733. Gend string `json:"gend"`
  3734. HifesPay float64 `json:"hifes_pay"`
  3735. HifmiPay float64 `json:"hifmi_pay"`
  3736. HifpPay float64 `json:"hifp_pay"`
  3737. HospPartAmt float64 `json:"hosp_part_amt"`
  3738. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3739. Insutype string `json:"insutype"`
  3740. MafPay float64 `json:"maf_pay"`
  3741. MdtrtCertType string `json:"mdtrt_cert_type"`
  3742. HifobPay float64 `json:"hifob_pay"`
  3743. MdtrtID string `json:"mdtrt_id"`
  3744. MedType string `json:"med_type"`
  3745. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3746. MedinsSetlID string `json:"medins_setl_id"`
  3747. Naty string `json:"naty"`
  3748. OthPay float64 `json:"oth_pay"`
  3749. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3750. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3751. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3752. PsnCashPay float64 `json:"psn_cash_pay"`
  3753. PsnCertType string `json:"psn_cert_type"`
  3754. PsnName string `json:"psn_name"`
  3755. PsnNo string `json:"psn_no"`
  3756. PsnPartAmt float64 `json:"psn_part_amt"`
  3757. PsnType string `json:"psn_type"`
  3758. SetlID string `json:"setl_id"`
  3759. SetlTime string `json:"setl_time"`
  3760. } `json:"setlinfo"`
  3761. } `json:"output"`
  3762. RefmsgTime string `json:"refmsg_time"`
  3763. RespondTime string `json:"respond_time"`
  3764. Signtype interface{} `json:"signtype"`
  3765. WarnMsg interface{} `json:"warn_msg"`
  3766. }
  3767. type ResultEight struct {
  3768. Cainfo string `json:"cainfo"`
  3769. ErrMsg string `json:"err_msg"`
  3770. InfRefmsgid string `json:"inf_refmsgid"`
  3771. Infcode int64 `json:"infcode"`
  3772. Output struct {
  3773. Stmtinfo struct {
  3774. SetlOptins string `json:"setl_optins"`
  3775. StmtRslt string `json:"stmt_rslt"`
  3776. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3777. } `json:"stmtinfo"`
  3778. } `json:"output"`
  3779. RefmsgTime string `json:"refmsg_time"`
  3780. RespondTime string `json:"respond_time"`
  3781. Signtype interface{} `json:"signtype"`
  3782. WarnMsg interface{} `json:"warn_msg"`
  3783. }
  3784. type ResultEightFor10188 struct {
  3785. Cainfo string `json:"cainfo"`
  3786. ErrMsg string `json:"err_msg"`
  3787. InfRefmsgid string `json:"inf_refmsgid"`
  3788. Infcode string `json:"infcode"`
  3789. Output struct {
  3790. Stmtinfo struct {
  3791. SetlOptins string `json:"setl_optins"`
  3792. StmtRslt string `json:"stmt_rslt"`
  3793. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3794. } `json:"stmtinfo"`
  3795. } `json:"output"`
  3796. RefmsgTime string `json:"refmsg_time"`
  3797. RespondTime string `json:"respond_time"`
  3798. Signtype interface{} `json:"signtype"`
  3799. WarnMsg interface{} `json:"warn_msg"`
  3800. }
  3801. type ResultNine struct {
  3802. Cainfo string `json:"cainfo"`
  3803. ErrMsg string `json:"err_msg"`
  3804. InfRefmsgid string `json:"inf_refmsgid"`
  3805. Infcode int64 `json:"infcode"`
  3806. Output struct {
  3807. FileQuryNo string `json:"file_qury_no"`
  3808. } `json:"output"`
  3809. RefmsgTime string `json:"refmsg_time"`
  3810. RespondTime string `json:"respond_time"`
  3811. Signtype interface{} `json:"signtype"`
  3812. WarnMsg interface{} `json:"warn_msg"`
  3813. }
  3814. type ResultTen struct {
  3815. Cainfo string `json:"cainfo"`
  3816. ErrMsg string `json:"err_msg"`
  3817. InfRefmsgid string `json:"inf_refmsgid"`
  3818. Infcode int64 `json:"infcode"`
  3819. Output struct {
  3820. DldEndtime string `json:"dld_endtime"`
  3821. FileQuryNo string `json:"file_qury_no"`
  3822. Filename string `json:"filename"`
  3823. } `json:"output"`
  3824. RefmsgTime string `json:"refmsg_time"`
  3825. RespondTime string `json:"respond_time"`
  3826. Signtype interface{} `json:"signtype"`
  3827. WarnMsg interface{} `json:"warn_msg"`
  3828. }
  3829. //type Autogenerated struct {
  3830. // Output struct {
  3831. // Setlinfo struct {
  3832. // SetlTime string `json:"setl_time"`
  3833. // CvlservPay float64 `json:"cvlserv_pay"`
  3834. // Year string `json:"year"`
  3835. // MedType string `json:"med_type"`
  3836. // PsnPay float64 `json:"psn_pay"`
  3837. // OpterID string `json:"opter_id"`
  3838. // Begndate string `json:"begndate"`
  3839. // FlxempeFlag string `json:"flxempe_flag"`
  3840. // HifmiPay float64 `json:"hifmi_pay"`
  3841. // PsnNo string `json:"psn_no"`
  3842. // ActPayDedc float64 `json:"act_pay_dedc"`
  3843. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3844. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3845. // ClrWay string `json:"clr_way"`
  3846. // OthPay float64 `json:"oth_pay"`
  3847. // Gend string `json:"gend"`
  3848. // MdtrtID string `json:"mdtrt_id"`
  3849. // AcctPay float64 `json:"acct_pay"`
  3850. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3851. // Insutype string `json:"insutype"`
  3852. // Invono interface{} `json:"invono"`
  3853. // Enddate string `json:"enddate"`
  3854. // CashPayamt float64 `json:"cash_payamt"`
  3855. // PsnType string `json:"psn_type"`
  3856. // FixmedinsName string `json:"fixmedins_name"`
  3857. // HifpPay float64 `json:"hifp_pay"`
  3858. // NewFlag interface{} `json:"new_flag"`
  3859. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3860. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3861. // PayLoc string `json:"pay_loc"`
  3862. // ClrType string `json:"clr_type"`
  3863. // RefdSetlFlag string `json:"refd_setl_flag"`
  3864. // CvlservFlag string `json:"cvlserv_flag"`
  3865. // EmpName string `json:"emp_name"`
  3866. // Brdy string `json:"brdy"`
  3867. // Naty string `json:"naty"`
  3868. // Certno string `json:"certno"`
  3869. // DiseCode string `json:"dise_code"`
  3870. // FixmedinsCode string `json:"fixmedins_code"`
  3871. // DedcHospLv string `json:"dedc_hosp_lv"`
  3872. // OpterName string `json:"opter_name"`
  3873. // Balc float64 `json:"balc"`
  3874. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3875. // PsnCertType string `json:"psn_cert_type"`
  3876. // HifobPay float64 `json:"hifob_pay"`
  3877. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3878. // HifesPay float64 `json:"hifes_pay"`
  3879. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3880. // OptTime string `json:"opt_time"`
  3881. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3882. // SetlID string `json:"setl_id"`
  3883. // MafPay float64 `json:"maf_pay"`
  3884. // PsnName string `json:"psn_name"`
  3885. // InsuOptins interface{} `json:"insu_optins"`
  3886. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3887. // ClrOptins string `json:"clr_optins"`
  3888. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3889. // DiseName string `json:"dise_name"`
  3890. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3891. // Age float64 `json:"age"`
  3892. // DtrtCertType string `json:"dtrt_cert_type"`
  3893. // HospLv string `json:"hosp_lv"`
  3894. // } `json:"setlinfo"`
  3895. // Setldetail []struct {
  3896. // FundPayType string `json:"fund_pay_type"`
  3897. // FundPayamt float64 `json:"fund_payamt"`
  3898. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3899. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3900. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3901. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3902. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3903. // } `json:"setldetail"`
  3904. // } `json:"output"`
  3905. // Infcode int `json:"infcode"`
  3906. // WarnMsg interface{} `json:"warn_msg"`
  3907. // Cainfo interface{} `json:"cainfo"`
  3908. // ErrMsg interface{} `json:"err_msg"`
  3909. // RefmsgTime string `json:"refmsg_time"`
  3910. // Signtype interface{} `json:"signtype"`
  3911. // RespondTime string `json:"respond_time"`
  3912. // InfRefmsgid string `json:"inf_refmsgid"`
  3913. //}
  3914. type ResultEleven struct {
  3915. Cainfo string `json:"cainfo"`
  3916. ErrMsg string `json:"err_msg"`
  3917. InfRefmsgid string `json:"inf_refmsgid"`
  3918. Infcode int64 `json:"infcode"`
  3919. Output struct {
  3920. Setlinfo struct {
  3921. SetlTime string `json:"setl_time"`
  3922. CvlservPay float64 `json:"cvlserv_pay"`
  3923. Year string `json:"year"`
  3924. MedType string `json:"med_type"`
  3925. PsnPay float64 `json:"psn_pay"`
  3926. OpterID string `json:"opter_id"`
  3927. Begndate string `json:"begndate"`
  3928. FlxempeFlag string `json:"flxempe_flag"`
  3929. HifmiPay float64 `json:"hifmi_pay"`
  3930. PsnNo string `json:"psn_no"`
  3931. ActPayDedc float64 `json:"act_pay_dedc"`
  3932. MedinsSetlID interface{} `json:"medins_setl_id"`
  3933. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3934. ClrWay string `json:"clr_way"`
  3935. OthPay float64 `json:"oth_pay"`
  3936. Gend string `json:"gend"`
  3937. MdtrtID string `json:"mdtrt_id"`
  3938. AcctPay float64 `json:"acct_pay"`
  3939. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3940. Insutype string `json:"insutype"`
  3941. Invono interface{} `json:"invono"`
  3942. Enddate string `json:"enddate"`
  3943. CashPayamt float64 `json:"cash_payamt"`
  3944. PsnType string `json:"psn_type"`
  3945. FixmedinsName string `json:"fixmedins_name"`
  3946. HifpPay float64 `json:"hifp_pay"`
  3947. NewFlag interface{} `json:"new_flag"`
  3948. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3949. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3950. PayLoc string `json:"pay_loc"`
  3951. ClrType string `json:"clr_type"`
  3952. RefdSetlFlag string `json:"refd_setl_flag"`
  3953. CvlservFlag string `json:"cvlserv_flag"`
  3954. EmpName string `json:"emp_name"`
  3955. Brdy string `json:"brdy"`
  3956. Naty string `json:"naty"`
  3957. Certno string `json:"certno"`
  3958. DiseCode string `json:"dise_code"`
  3959. FixmedinsCode string `json:"fixmedins_code"`
  3960. DedcHospLv string `json:"dedc_hosp_lv"`
  3961. OpterName string `json:"opter_name"`
  3962. Balc float64 `json:"balc"`
  3963. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3964. PsnCertType string `json:"psn_cert_type"`
  3965. HifobPay float64 `json:"hifob_pay"`
  3966. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3967. HifesPay float64 `json:"hifes_pay"`
  3968. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3969. OptTime string `json:"opt_time"`
  3970. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3971. SetlID string `json:"setl_id"`
  3972. MafPay float64 `json:"maf_pay"`
  3973. PsnName string `json:"psn_name"`
  3974. InsuOptins interface{} `json:"insu_optins"`
  3975. PrefFundPay interface{} `json:"pref_fund_pay"`
  3976. ClrOptins string `json:"clr_optins"`
  3977. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3978. DiseName string `json:"dise_name"`
  3979. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3980. Age float64 `json:"age"`
  3981. DtrtCertType string `json:"dtrt_cert_type"`
  3982. HospLv string `json:"hosp_lv"`
  3983. } `json:"setlinfo"`
  3984. } `json:"output"`
  3985. RefmsgTime string `json:"refmsg_time"`
  3986. RespondTime string `json:"respond_time"`
  3987. Signtype interface{} `json:"signtype"`
  3988. WarnMsg interface{} `json:"warn_msg"`
  3989. }
  3990. type ResultEleven10265 struct {
  3991. Cainfo string `json:"cainfo"`
  3992. ErrMsg string `json:"err_msg"`
  3993. InfRefmsgid string `json:"inf_refmsgid"`
  3994. Infcode string `json:"infcode"`
  3995. Output struct {
  3996. Setlinfo struct {
  3997. SetlTime string `json:"setl_time"`
  3998. CvlservPay float64 `json:"cvlserv_pay"`
  3999. Year string `json:"year"`
  4000. MedType string `json:"med_type"`
  4001. PsnPay float64 `json:"psn_pay"`
  4002. OpterID string `json:"opter_id"`
  4003. Begndate string `json:"begndate"`
  4004. FlxempeFlag string `json:"flxempe_flag"`
  4005. HifmiPay float64 `json:"hifmi_pay"`
  4006. PsnNo string `json:"psn_no"`
  4007. ActPayDedc float64 `json:"act_pay_dedc"`
  4008. MedinsSetlID interface{} `json:"medins_setl_id"`
  4009. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4010. ClrWay string `json:"clr_way"`
  4011. OthPay float64 `json:"oth_pay"`
  4012. Gend string `json:"gend"`
  4013. MdtrtID string `json:"mdtrt_id"`
  4014. AcctPay float64 `json:"acct_pay"`
  4015. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4016. Insutype string `json:"insutype"`
  4017. Invono interface{} `json:"invono"`
  4018. Enddate string `json:"enddate"`
  4019. CashPayamt float64 `json:"cash_payamt"`
  4020. PsnType string `json:"psn_type"`
  4021. FixmedinsName string `json:"fixmedins_name"`
  4022. HifpPay float64 `json:"hifp_pay"`
  4023. NewFlag interface{} `json:"new_flag"`
  4024. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4025. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4026. PayLoc string `json:"pay_loc"`
  4027. ClrType string `json:"clr_type"`
  4028. RefdSetlFlag string `json:"refd_setl_flag"`
  4029. CvlservFlag string `json:"cvlserv_flag"`
  4030. EmpName string `json:"emp_name"`
  4031. Brdy string `json:"brdy"`
  4032. Naty string `json:"naty"`
  4033. Certno string `json:"certno"`
  4034. DiseCode string `json:"dise_code"`
  4035. FixmedinsCode string `json:"fixmedins_code"`
  4036. DedcHospLv string `json:"dedc_hosp_lv"`
  4037. OpterName string `json:"opter_name"`
  4038. Balc float64 `json:"balc"`
  4039. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4040. PsnCertType string `json:"psn_cert_type"`
  4041. HifobPay float64 `json:"hifob_pay"`
  4042. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4043. HifesPay float64 `json:"hifes_pay"`
  4044. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4045. OptTime string `json:"opt_time"`
  4046. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4047. SetlID string `json:"setl_id"`
  4048. MafPay float64 `json:"maf_pay"`
  4049. PsnName string `json:"psn_name"`
  4050. InsuOptins interface{} `json:"insu_optins"`
  4051. PrefFundPay interface{} `json:"pref_fund_pay"`
  4052. ClrOptins string `json:"clr_optins"`
  4053. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4054. DiseName string `json:"dise_name"`
  4055. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4056. Age float64 `json:"age"`
  4057. DtrtCertType string `json:"dtrt_cert_type"`
  4058. HospLv string `json:"hosp_lv"`
  4059. } `json:"setlinfo"`
  4060. } `json:"output"`
  4061. RefmsgTime string `json:"refmsg_time"`
  4062. RespondTime string `json:"respond_time"`
  4063. Signtype interface{} `json:"signtype"`
  4064. WarnMsg interface{} `json:"warn_msg"`
  4065. }
  4066. type ResultTwelve struct {
  4067. Cainfo string `json:"cainfo"`
  4068. ErrMsg string `json:"err_msg"`
  4069. InfRefmsgid string `json:"inf_refmsgid"`
  4070. Infcode int64 `json:"infcode"`
  4071. Output struct {
  4072. MdtrtId string `json:"mdtrt_id"`
  4073. ChrgBchno string `json:"chrg_bchno"`
  4074. PsnNo string `json:"psn_no"`
  4075. } `json:"output"`
  4076. RefmsgTime string `json:"refmsg_time"`
  4077. RespondTime string `json:"respond_time"`
  4078. Signtype interface{} `json:"signtype"`
  4079. WarnMsg interface{} `json:"warn_msg"`
  4080. }
  4081. type ResultThirteen struct {
  4082. ErrMsg string `json:"err_msg"`
  4083. InfRefmsgid string `json:"inf_refmsgid"`
  4084. Infcode int64 `json:"infcode"`
  4085. Output struct {
  4086. Result struct {
  4087. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4088. } `json:"result"`
  4089. } `json:"output"`
  4090. RefmsgTime string `json:"refmsg_time"`
  4091. RespondTime string `json:"respond_time"`
  4092. Signtype interface{} `json:"signtype"`
  4093. WarnInfo interface{} `json:"warn_info"`
  4094. }
  4095. type ResultThirteen10265 struct {
  4096. ErrMsg string `json:"err_msg"`
  4097. InfRefmsgid string `json:"inf_refmsgid"`
  4098. Infcode string `json:"infcode"`
  4099. Output struct {
  4100. Result struct {
  4101. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4102. } `json:"result"`
  4103. } `json:"output"`
  4104. RefmsgTime string `json:"refmsg_time"`
  4105. RespondTime string `json:"respond_time"`
  4106. Signtype interface{} `json:"signtype"`
  4107. WarnInfo interface{} `json:"warn_info"`
  4108. }
  4109. type ResultFourteen struct {
  4110. ErrMsg string `json:"err_msg"`
  4111. InfRefmsgid string `json:"inf_refmsgid"`
  4112. Infcode int64 `json:"infcode"`
  4113. Output struct {
  4114. } `json:"output"`
  4115. RefmsgTime string `json:"refmsg_time"`
  4116. RespondTime string `json:"respond_time"`
  4117. Signtype interface{} `json:"signtype"`
  4118. WarnInfo interface{} `json:"warn_info"`
  4119. }
  4120. type ResultFourteen10265 struct {
  4121. ErrMsg string `json:"err_msg"`
  4122. InfRefmsgid string `json:"inf_refmsgid"`
  4123. Infcode string `json:"infcode"`
  4124. Output struct {
  4125. } `json:"output"`
  4126. RefmsgTime string `json:"refmsg_time"`
  4127. RespondTime string `json:"respond_time"`
  4128. Signtype interface{} `json:"signtype"`
  4129. WarnInfo interface{} `json:"warn_info"`
  4130. }
  4131. type ResultSixteen struct {
  4132. Cainfo string `json:"cainfo"`
  4133. ErrMsg string `json:"err_msg"`
  4134. InfRefmsgid string `json:"inf_refmsgid"`
  4135. Infcode int64 `json:"infcode"`
  4136. Output struct {
  4137. Setldetail []interface{} `json:"setldetail"`
  4138. Setlinfo struct {
  4139. MdtrtID string `json:"mdtrt_id"`
  4140. SetlID string `json:"setl_id"`
  4141. ClrOptins string `json:"clr_optins"`
  4142. SetlTime string `json:"setl_time"`
  4143. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4144. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4145. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4146. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4147. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4148. ActPayDedc float64 `json:"act_pay_dedc"`
  4149. HifpPay float64 `json:"hifp_pay"`
  4150. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4151. Lfpay float64 `json:"selfpay"`
  4152. CvlservPay float64 `json:"cvlserv_pay"`
  4153. HifesPay float64 `json:"hifes_pay"`
  4154. HifmiPay float64 `json:"hifmi_pay"`
  4155. HifobPay float64 `json:"hifob_pay"`
  4156. MafPay float64 `json:"maf_pay"`
  4157. OthPay float64 `json:"oth_pay"`
  4158. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4159. PsnPartAmt float64 `json:"psn_part_amt"`
  4160. AcctPay float64 `json:"acct_pay"`
  4161. Balc float64 `json:"balc"`
  4162. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4163. HospPartAmt float64 `json:"hosp_part_amt"`
  4164. MedinsSetlID string `json:"medins_setl_id"`
  4165. PdnCashPay string `json:"pdn_cash_pay"`
  4166. } `json:"setlinfo"`
  4167. } `json:"output"`
  4168. RefmsgTime string `json:"refmsg_time"`
  4169. RespondTime string `json:"respond_time"`
  4170. Signtype interface{} `json:"signtype"`
  4171. WarnMsg interface{} `json:"warn_msg"`
  4172. }
  4173. type ResultSixteen10265 struct {
  4174. Cainfo string `json:"cainfo"`
  4175. ErrMsg string `json:"err_msg"`
  4176. InfRefmsgid string `json:"inf_refmsgid"`
  4177. Infcode string `json:"infcode"`
  4178. Output struct {
  4179. Setldetail []interface{} `json:"setldetail"`
  4180. Setlinfo struct {
  4181. MdtrtID string `json:"mdtrt_id"`
  4182. SetlID string `json:"setl_id"`
  4183. ClrOptins string `json:"clr_optins"`
  4184. SetlTime string `json:"setl_time"`
  4185. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4186. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4187. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4188. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4189. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4190. ActPayDedc float64 `json:"act_pay_dedc"`
  4191. HifpPay float64 `json:"hifp_pay"`
  4192. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4193. Lfpay float64 `json:"selfpay"`
  4194. CvlservPay float64 `json:"cvlserv_pay"`
  4195. HifesPay float64 `json:"hifes_pay"`
  4196. HifmiPay float64 `json:"hifmi_pay"`
  4197. HifobPay float64 `json:"hifob_pay"`
  4198. MafPay float64 `json:"maf_pay"`
  4199. OthPay float64 `json:"oth_pay"`
  4200. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4201. PsnPartAmt float64 `json:"psn_part_amt"`
  4202. AcctPay float64 `json:"acct_pay"`
  4203. Balc float64 `json:"balc"`
  4204. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4205. HospPartAmt float64 `json:"hosp_part_amt"`
  4206. MedinsSetlID string `json:"medins_setl_id"`
  4207. PdnCashPay string `json:"pdn_cash_pay"`
  4208. } `json:"setlinfo"`
  4209. } `json:"output"`
  4210. RefmsgTime string `json:"refmsg_time"`
  4211. RespondTime string `json:"respond_time"`
  4212. Signtype interface{} `json:"signtype"`
  4213. WarnMsg interface{} `json:"warn_msg"`
  4214. }
  4215. type ResultSeventeen struct {
  4216. ErrMsg string `json:"err_msg"`
  4217. InfRefmsgid string `json:"inf_refmsgid"`
  4218. Infcode int64 `json:"infcode"`
  4219. Output struct {
  4220. SetlListId string `json:"setl_list_id"`
  4221. } `json:"output"`
  4222. RefmsgTime string `json:"refmsg_time"`
  4223. RespondTime string `json:"respond_time"`
  4224. Signtype string `json:"signtype"`
  4225. WarnInfo string `json:"warn_info"`
  4226. }
  4227. type ResultSeventeenOther struct {
  4228. ErrMsg string `json:"err_msg"`
  4229. InfRefmsgid string `json:"inf_refmsgid"`
  4230. Infcode string `json:"infcode"`
  4231. Output struct {
  4232. SetlListId string `json:"setl_list_id"`
  4233. } `json:"output"`
  4234. RefmsgTime string `json:"refmsg_time"`
  4235. RespondTime string `json:"respond_time"`
  4236. Signtype string `json:"signtype"`
  4237. WarnInfo string `json:"warn_info"`
  4238. }
  4239. type Result90991 struct {
  4240. ErrMsg string `json:"err_msg"`
  4241. InfRefmsgid string `json:"inf_refmsgid"`
  4242. Infcode int64 `json:"infcode"`
  4243. Output struct {
  4244. Result struct {
  4245. PsnNo string `json:"psn_no"`
  4246. CardStat string `json:"card_stat"`
  4247. Certno string `json:"certno"`
  4248. PsnName string `json:"psn_name"`
  4249. CheckStat string `json:"check_stat"`
  4250. SscnoCheckStat string `json:"sscno_check_stat"`
  4251. } `json:"result"`
  4252. } `json:"output"`
  4253. RefmsgTime string `json:"refmsg_time"`
  4254. RespondTime string `json:"respond_time"`
  4255. Signtype interface{} `json:"signtype"`
  4256. WarnInfo interface{} `json:"warn_info"`
  4257. }
  4258. type Result90100 struct {
  4259. ErrMsg string `json:"err_msg"`
  4260. InfRefmsgid string `json:"inf_refmsgid"`
  4261. Infcode int64 `json:"infcode"`
  4262. Output struct {
  4263. PoolareaNo string `json:"poolarea_no"`
  4264. PoolareaNoName string `json:"poolarea_no_name"`
  4265. Insutype string `json:"insutype"`
  4266. InsutypeName string `json:"insutype_name"`
  4267. ClctType string `json:"clct_type"`
  4268. ClctTypeName string `json:"clct_type_name"`
  4269. ClctFlag string `json:"clct_flag"`
  4270. ClctFlagName string `json:"clct_flag_name"`
  4271. AccrymBegn string `json:"accrym_begn"`
  4272. AccrymEnd string `json:"accrym_end"`
  4273. ClctTime string `json:"clct_time"`
  4274. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4275. } `json:"output"`
  4276. RefmsgTime string `json:"refmsg_time"`
  4277. RespondTime string `json:"respond_time"`
  4278. Signtype interface{} `json:"signtype"`
  4279. WarnInfo interface{} `json:"warn_info"`
  4280. }
  4281. type Custom struct {
  4282. DetItemFeeSumamt string
  4283. Cut string
  4284. FeedetlSn string
  4285. Price string
  4286. MedListCodg string
  4287. Type int64
  4288. AdviceId int64
  4289. ProjectId int64
  4290. ItemId int64
  4291. }
  4292. type Result5301 struct {
  4293. ErrMsg string `json:"err_msg"`
  4294. InfRefmsgid string `json:"inf_refmsgid"`
  4295. Infcode int64 `json:"infcode"`
  4296. Output struct {
  4297. Result []struct {
  4298. OpspDiseCode string `json:"opsp_dise_code"`
  4299. OpspDiseName string `json:"opsp_dise_name"`
  4300. Begndate string `json:"begndate"`
  4301. Enddate string `json:"enddate"`
  4302. } `json:"feedetail"`
  4303. } `json:"output"`
  4304. RefmsgTime string `json:"refmsg_time"`
  4305. RespondTime string `json:"respond_time"`
  4306. Signtype interface{} `json:"signtype"`
  4307. WarnInfo interface{} `json:"warn_info"`
  4308. }
  4309. type Result5301For10265 struct {
  4310. ErrMsg string `json:"err_msg"`
  4311. InfRefmsgid string `json:"inf_refmsgid"`
  4312. Infcode string `json:"infcode"`
  4313. Output struct {
  4314. Result []struct {
  4315. OpspDiseCode string `json:"opsp_dise_code"`
  4316. OpspDiseName string `json:"opsp_dise_name"`
  4317. Begndate string `json:"begndate"`
  4318. Enddate string `json:"enddate"`
  4319. } `json:"feedetail"`
  4320. } `json:"output"`
  4321. RefmsgTime string `json:"refmsg_time"`
  4322. RespondTime string `json:"respond_time"`
  4323. Signtype interface{} `json:"signtype"`
  4324. WarnInfo interface{} `json:"warn_info"`
  4325. }
  4326. //获取个人信息----挂号-----上传就诊信息
  4327. func (c *HisApiController) GetRegisterInfo() {
  4328. id, _ := c.GetInt64("id")
  4329. record_time := c.GetString("record_time")
  4330. settlementValue, _ := c.GetInt64("settlement_value")
  4331. medical_insurance_card := c.GetString("medical_insurance_card")
  4332. name := c.GetString("name")
  4333. id_card_type, _ := c.GetInt64("id_card_type")
  4334. certificates, _ := c.GetInt64("certificates")
  4335. medical_care, _ := c.GetInt64("medical_care")
  4336. birthday := c.GetString("birthday")
  4337. id_card := c.GetString("id_card")
  4338. register_type, _ := c.GetInt64("register")
  4339. doctor, _ := c.GetInt64("doctor")
  4340. department, _ := c.GetInt64("department")
  4341. gender, _ := c.GetInt64("sex")
  4342. registration_fee, _ := c.GetFloat("registration_fee")
  4343. medical_expenses, _ := c.GetFloat("medical_expenses")
  4344. social_type, _ := c.GetInt64("social_type")
  4345. med_type := c.GetString("social_type")
  4346. admin_user_id, _ := c.GetInt64("admin_user_id")
  4347. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4348. timeLayout := "2006-01-02"
  4349. loc, _ := time.LoadLocation("Local")
  4350. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4351. birthUnix := birthdays.Unix()
  4352. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4353. if err != nil {
  4354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4355. return
  4356. }
  4357. recordDateTime := theTime.Unix()
  4358. adminInfo := c.GetAdminUserInfo()
  4359. var patient service.Patients
  4360. if id == 0 {
  4361. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4362. } else {
  4363. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4364. }
  4365. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4366. if patientPrescription.ID == 0 {
  4367. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4368. }
  4369. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4370. if patient.ID == 0 {
  4371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4372. return
  4373. }
  4374. if len(patient.IdCardNo) == 0 {
  4375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4376. return
  4377. }
  4378. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4379. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4380. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4381. //就诊结算未完成,不能进行二次挂号
  4382. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4383. if len(his) >= 1 {
  4384. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4385. if len(his) >= 1 && order.ID == 0 {
  4386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4387. return
  4388. }
  4389. }
  4390. //var register_log string
  4391. if config.IsOpen == 1 {
  4392. var res ResultTwo
  4393. var res10265 ResultTwo10265
  4394. var PsnNo string
  4395. var PsnCertType string
  4396. var Certno string
  4397. var PsnName string
  4398. var Gend string
  4399. var Naty string
  4400. var Brdy string
  4401. var Age float64
  4402. var infoStr string
  4403. var idetinfoStr string
  4404. var infocode int64
  4405. var verify_number string
  4406. fmt.Println(verify_number)
  4407. if miConfig.MdtrtareaAdmvs == "421300" {
  4408. psn_info, _ := service.GetPsnByPatientId(id)
  4409. PsnNo = psn_info.PsnNo
  4410. PsnCertType = psn_info.PsnCertType
  4411. Certno = psn_info.Certno
  4412. PsnName = psn_info.PsnName
  4413. Gend = psn_info.Gend
  4414. Naty = psn_info.Naty
  4415. Brdy = psn_info.Brdy
  4416. Age = psn_info.Age
  4417. infoStr = psn_info.Insuinfo
  4418. idetinfoStr = psn_info.Idetinfo
  4419. infocode = 0
  4420. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4421. psn_info, _ := service.GetPsnByPatientId(id)
  4422. PsnNo = psn_info.PsnNo
  4423. PsnCertType = psn_info.PsnCertType
  4424. Certno = psn_info.Certno
  4425. PsnName = psn_info.PsnName
  4426. Gend = psn_info.Gend
  4427. Naty = psn_info.Naty
  4428. Brdy = psn_info.Brdy
  4429. Age = psn_info.Age
  4430. infoStr = psn_info.Insuinfo
  4431. idetinfoStr = psn_info.Idetinfo
  4432. infocode = 0
  4433. verify_number = psn_info.VerifyNumber
  4434. } else {
  4435. var result string
  4436. var requestLog string
  4437. if miConfig.UserOrgId == 10138 {
  4438. 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)
  4439. } else {
  4440. 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)
  4441. }
  4442. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4443. if miConfig.Code == "H15049901371" {
  4444. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4445. utils.ErrorLog("解析失败:%v", err)
  4446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4447. return
  4448. }
  4449. res.ErrMsg = res10265.ErrMsg
  4450. res.Output = res10265.Output
  4451. res.InfRefmsgid = res10265.InfRefmsgid
  4452. } else {
  4453. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4454. utils.ErrorLog("解析失败:%v", err)
  4455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4456. return
  4457. }
  4458. }
  4459. PsnNo = res.Output.Baseinfo.PsnNo
  4460. PsnCertType = res.Output.Baseinfo.PsnCertType
  4461. Certno = res.Output.Baseinfo.Certno
  4462. PsnName = res.Output.Baseinfo.PsnName
  4463. Gend = res.Output.Baseinfo.Gend
  4464. Naty = res.Output.Baseinfo.Naty
  4465. Brdy = res.Output.Baseinfo.Brdy
  4466. Age = res.Output.Baseinfo.Age
  4467. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4468. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4469. infoStr = string(Iinfos)
  4470. idetinfoStr = string(Idetinfos)
  4471. if miConfig.Code == "H15049901371" {
  4472. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4473. } else {
  4474. infocode = res.Infcode
  4475. }
  4476. }
  4477. if infocode == 0 {
  4478. his := models.VMHisPatient{
  4479. Name: name,
  4480. Gender: gender,
  4481. Birthday: birthUnix,
  4482. MedicalTreatmentType: medical_care,
  4483. IdType: certificates,
  4484. IdCardNo: id_card,
  4485. BalanceAccountsType: settlementValue,
  4486. SocialType: social_type,
  4487. MedicalInsuranceNumber: medical_insurance_card,
  4488. RegisterType: register_type,
  4489. RegisterCost: registration_fee,
  4490. TreatmentCost: medical_expenses,
  4491. Status: 1,
  4492. Ctime: time.Now().Unix(),
  4493. Mtime: time.Now().Unix(),
  4494. PsnNo: PsnNo,
  4495. PsnCertType: PsnCertType,
  4496. Certno: Certno,
  4497. PsnName: PsnName,
  4498. Gend: Gend,
  4499. Naty: Naty,
  4500. Brdy: Brdy,
  4501. Age: Age,
  4502. Iinfo: infoStr,
  4503. Idetinfo: idetinfoStr,
  4504. PatientId: patient.ID,
  4505. RecordDate: theTime.Unix(),
  4506. UserOrgId: adminInfo.CurrentOrgId,
  4507. AdminUserId: admin_user_id,
  4508. IsReturn: 1,
  4509. IdCardType: id_card_type,
  4510. Doctor: doctor,
  4511. Departments: department,
  4512. }
  4513. timestamp := time.Now().Unix()
  4514. tempTime := time.Unix(timestamp, 0)
  4515. timeFormat := tempTime.Format("20060102150405")
  4516. chrgBchno := rand.Intn(100000) + 10000
  4517. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4518. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4519. department, _ := service.GetDepartMentDetail(department)
  4520. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4521. IdCardNo := ""
  4522. if id_card_type == 1 {
  4523. // IdCardNo = medical_insurance_card
  4524. IdCardNo = patient.IdCardNo
  4525. } else {
  4526. IdCardNo = patient.IdCardNo
  4527. }
  4528. var rf []*ResultFive
  4529. json.Unmarshal([]byte(his.Iinfo), &rf)
  4530. var insutypes []*ResultFive
  4531. var insutype string
  4532. var insuplc_admdvs_temp string
  4533. var is390 int = 0
  4534. var is310 int = 0
  4535. for _, item := range rf {
  4536. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4537. insutypes = append(insutypes, item)
  4538. }
  4539. }
  4540. if len(insutypes) == 1 {
  4541. insutype = insutypes[0].Insutype
  4542. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4543. } else {
  4544. for _, i := range insutypes {
  4545. if i.Insutype == "390" {
  4546. is390 = 1
  4547. }
  4548. if i.Insutype == "310" {
  4549. is310 = 1
  4550. }
  4551. }
  4552. }
  4553. if is390 == 1 {
  4554. insutype = "390"
  4555. }
  4556. if is310 == 1 {
  4557. insutype = "310"
  4558. }
  4559. if len(insutypes) == 0 {
  4560. insutype = "310"
  4561. }
  4562. if len(insutypes) == 2 {
  4563. insutype = med_type
  4564. }
  4565. if len(med_type) > 0 {
  4566. insutype = med_type
  4567. }
  4568. //for _, item := range rf {
  4569. // if item.Insutype == insutype {
  4570. // insuplc_admdvs = item.InsuplcAdmdvs
  4571. // }
  4572. //}
  4573. var infocode int64
  4574. var resThree ResultThree
  4575. var resThree10265 ResultThree10265
  4576. if len(insuplc_admdvs) == 0 {
  4577. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4578. } else {
  4579. insuplc_admdvs_temp = insuplc_admdvs
  4580. }
  4581. if miConfig.MdtrtareaAdmvs == "421300" {
  4582. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4583. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4584. "&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_id + "&doctor_name=" + doctor_info.UserName
  4585. resp, requestErr := http.Get(api)
  4586. if requestErr != nil {
  4587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. return
  4589. }
  4590. body, ioErr := ioutil.ReadAll(resp.Body)
  4591. if ioErr != nil {
  4592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4594. return
  4595. }
  4596. var respJSON map[string]interface{}
  4597. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4600. return
  4601. }
  4602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4603. result, _ := json.Marshal(respJSON)
  4604. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4605. utils.ErrorLog("解析失败:%v", err)
  4606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4607. return
  4608. }
  4609. infocode = resThree.Infcode
  4610. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4611. psn_info, _ := service.GetPsnByPatientId(id)
  4612. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4613. var cert_no string
  4614. if id_card_type == 3 {
  4615. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4616. cert_no = IdCardNo
  4617. } else {
  4618. bas := strings.Split(psn_info.CardInfo, "|")
  4619. cert_no = bas[2]
  4620. }
  4621. var api string
  4622. if miConfig.MdtrtareaAdmvs == "320921" {
  4623. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4624. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4625. "&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_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4626. } else {
  4627. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4628. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4629. "&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_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4630. }
  4631. resp, requestErr := http.Get(api)
  4632. if requestErr != nil {
  4633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4634. return
  4635. }
  4636. body, ioErr := ioutil.ReadAll(resp.Body)
  4637. if ioErr != nil {
  4638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4640. return
  4641. }
  4642. var respJSON map[string]interface{}
  4643. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4646. return
  4647. }
  4648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4649. result, _ := json.Marshal(respJSON)
  4650. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4651. utils.ErrorLog("解析失败:%v", err)
  4652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4653. return
  4654. }
  4655. resThree.ErrMsg = resThree10265.ErrMsg
  4656. resThree.Output = resThree10265.Output
  4657. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4658. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4659. } else {
  4660. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4661. saveLog(result, requestLog, "2201A", "挂号")
  4662. if miConfig.Code == "H15049901371" {
  4663. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4664. utils.ErrorLog("解析失败:%v", err)
  4665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4666. return
  4667. }
  4668. resThree.ErrMsg = resThree10265.ErrMsg
  4669. resThree.Output = resThree10265.Output
  4670. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4671. } else {
  4672. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4673. utils.ErrorLog("解析失败:%v", err)
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4675. return
  4676. }
  4677. }
  4678. if miConfig.Code == "H15049901371" {
  4679. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4680. } else {
  4681. infocode = resThree.Infcode
  4682. }
  4683. }
  4684. if infocode != 0 {
  4685. adminUser := c.GetAdminUserInfo()
  4686. errlog := &models.HisOrderError{
  4687. UserOrgId: adminUser.CurrentOrgId,
  4688. Ctime: time.Now().Unix(),
  4689. Mtime: time.Now().Unix(),
  4690. ErrMsg: resThree.ErrMsg,
  4691. Status: 1,
  4692. PatientId: id,
  4693. RecordTime: recordDateTime,
  4694. Stage: 2,
  4695. }
  4696. service.CreateErrMsgLog(errlog)
  4697. c.ServeSuccessJSON(map[string]interface{}{
  4698. "failed_code": -10,
  4699. "msg": resThree.ErrMsg,
  4700. })
  4701. return
  4702. }
  4703. his.Number = resThree.Output.Data.MdtrtID
  4704. his.PsnNo = resThree.Output.Data.PsnNo
  4705. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4706. his.IdCardNo = patient.IdCardNo
  4707. his.PhoneNumber = patient.Phone
  4708. his.UserOrgId = adminInfo.CurrentOrgId
  4709. his.Insutype = insutype
  4710. his.Ctime = time.Now().Unix()
  4711. his.Mtime = time.Now().Unix()
  4712. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4713. his.Status = 1
  4714. service.UpdateHisPatientStatus(&his)
  4715. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4716. c.ServeSuccessJSON(map[string]interface{}{
  4717. "his_info": his,
  4718. })
  4719. } else {
  4720. adminUser := c.GetAdminUserInfo()
  4721. errlog := &models.HisOrderError{
  4722. UserOrgId: adminUser.CurrentOrgId,
  4723. Ctime: time.Now().Unix(),
  4724. Mtime: time.Now().Unix(),
  4725. ErrMsg: res.ErrMsg,
  4726. Status: 1,
  4727. PatientId: id,
  4728. RecordTime: recordDateTime,
  4729. Stage: 1,
  4730. }
  4731. service.CreateErrMsgLog(errlog)
  4732. c.ServeSuccessJSON(map[string]interface{}{
  4733. "failed_code": -10,
  4734. "msg": res.ErrMsg,
  4735. })
  4736. return
  4737. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4738. }
  4739. }
  4740. }
  4741. //上传明细----预结算----确认订单
  4742. func (c *HisApiController) GetUploadInfo() {
  4743. id, _ := c.GetInt64("id")
  4744. record_time := c.GetString("record_time")
  4745. his_patient_id, _ := c.GetInt64("his_patient_id")
  4746. order_id, _ := c.GetInt64("order_id")
  4747. pay_way, _ := c.GetInt64("pay_way")
  4748. pay_price, _ := c.GetFloat("pay_price")
  4749. pay_card_no := c.GetString("pay_card_no")
  4750. discount_price, _ := c.GetFloat("discount_price")
  4751. preferential_price, _ := c.GetFloat("preferential_price")
  4752. reality_price, _ := c.GetFloat("reality_price")
  4753. found_price, _ := c.GetFloat("found_price")
  4754. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4755. private_price, _ := c.GetFloat("private_price")
  4756. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4757. admin_user_id, _ := c.GetInt64("admin_user_id")
  4758. fapiao_code := c.GetString("fapiao_code")
  4759. fapiao_number := c.GetString("fapiao_number")
  4760. diagnosis_id := c.GetString("diagnosis")
  4761. sick_type, _ := c.GetInt64("sick_type")
  4762. reg_type, _ := c.GetInt64("p_type")
  4763. begin_time := c.GetString("begin_time")
  4764. id_str := c.GetString("ids")
  4765. ids_arr := strings.Split(id_str, ",")
  4766. timeLayout := "2006-01-02"
  4767. loc, _ := time.LoadLocation("Local")
  4768. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4769. if err != nil {
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4771. return
  4772. }
  4773. recordDateTime := theTime.Unix()
  4774. adminUser := c.GetAdminUserInfo()
  4775. var tempOrder models.HisOrder
  4776. tempOrder, _ = service.GetHisOrderByID(order_id)
  4777. var prescriptions []*models.HisPrescription
  4778. var start_time int64
  4779. var end_time int64
  4780. //押金模块
  4781. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4782. tmp_decimal := c.GetString("tmp_decimal")
  4783. var decimal float64 //本次使用的押金
  4784. var errmsg error
  4785. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4786. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4787. return
  4788. }
  4789. if len(tmp_decimal) > 0 {
  4790. if tmp_decimal[0] == 45 {
  4791. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4792. return
  4793. }
  4794. }
  4795. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4796. fmt.Println(errs)
  4797. decimal = tt
  4798. //if adminUser.CurrentOrgId == 10106{
  4799. // if len(fapiao_code) == 0{
  4800. // fapiao_code = "144072080589"
  4801. // }
  4802. // if len(fapiao_number) == 0{
  4803. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4804. // if order.ID == 0{
  4805. // fapiao_number = "00001520"
  4806. // }else{
  4807. // //fapiao_code = "00001520"
  4808. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4809. // var zero string
  4810. // if fpNumber >= 1000{
  4811. // zero = "0000" + strconv.Itoa(fpNumber)
  4812. // }else if fpNumber >= 10000{
  4813. // zero = "000" + strconv.Itoa(fpNumber)
  4814. // } else if fpNumber >= 100000{
  4815. // zero = "00" + strconv.Itoa(fpNumber)
  4816. // } else if fpNumber >= 1000000{
  4817. // zero = "0" + strconv.Itoa(fpNumber)
  4818. // }else {
  4819. // zero = strconv.Itoa(fpNumber)
  4820. // }
  4821. // fapiao_number = zero
  4822. // }
  4823. // }
  4824. //}
  4825. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4826. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4827. var patientPrescription models.HisPrescriptionInfo
  4828. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4829. if patientPrescription.ID == 0 {
  4830. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4831. }
  4832. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4833. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4834. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4835. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4836. var config []*models.HisXtDiagnoseConfig
  4837. for _, item := range diagnosis_ids {
  4838. id, _ := strconv.ParseInt(item, 10, 64)
  4839. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4840. config = append(config, &diagnosisConfig)
  4841. }
  4842. sickConfig, _ := service.FindSickById(sick_type)
  4843. //if tempOrder.ID == 0 {
  4844. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4845. //}
  4846. if tempOrder.ID == 0 {
  4847. var result string
  4848. var requestLog string
  4849. var res2 ResultSix
  4850. var ressix10265 ResultSix10265
  4851. if miConfig.MdtrtareaAdmvs == "421300" {
  4852. data := make(map[string]interface{})
  4853. client := &http.Client{}
  4854. data["psn_no"] = his.PsnNo
  4855. data["mdtrt_id"] = his.Number
  4856. data["doctor"] = roles.UserName
  4857. data["department"] = department.Name
  4858. data["org_name"] = miConfig.OrgName
  4859. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4860. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4861. data["fixmedins_code"] = miConfig.Code
  4862. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4863. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4864. data["secret_key"] = miConfig.SecretKey
  4865. data["sick_code"] = sickConfig.CountryCode
  4866. data["sick_name"] = sickConfig.ClassName
  4867. data["dept"] = strconv.FormatInt(department.ID, 10)
  4868. data["config"] = config
  4869. data["begin_time"] = begin_time
  4870. bytesData, _ := json.Marshal(data)
  4871. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4872. resp, _ := client.Do(req)
  4873. defer resp.Body.Close()
  4874. body, ioErr := ioutil.ReadAll(resp.Body)
  4875. if ioErr != nil {
  4876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4878. return
  4879. }
  4880. var respJSON map[string]interface{}
  4881. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4884. return
  4885. }
  4886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4887. userJSONBytes, _ := json.Marshal(respJSON)
  4888. fmt.Println("log")
  4889. fmt.Println(string(userJSONBytes))
  4890. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4891. utils.ErrorLog("解析失败:%v", err)
  4892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4893. return
  4894. }
  4895. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4896. //江苏地区国家医保医疗类别
  4897. //职工透析:医疗类别选特殊情况门诊9933
  4898. //居民血透门慢: 医疗类别选门诊慢病1402
  4899. //var med_type string
  4900. //if his.Insutype == "310" {
  4901. // if reg_type == 14 {
  4902. // med_type = "9933"
  4903. // } else if reg_type == 11 {
  4904. // med_type = "11"
  4905. //
  4906. // }
  4907. //} else if his.Insutype == "390" {
  4908. // if reg_type == 14 {
  4909. // med_type = "1402"
  4910. // } else if reg_type == 11 {
  4911. // med_type = "11"
  4912. // }
  4913. //}
  4914. data := make(map[string]interface{})
  4915. client := &http.Client{}
  4916. data["psn_no"] = his.PsnNo
  4917. data["mdtrt_id"] = his.Number
  4918. data["doctor"] = roles.UserName
  4919. data["department"] = department.Name
  4920. data["org_name"] = miConfig.OrgName
  4921. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4922. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4923. data["fixmedins_code"] = miConfig.Code
  4924. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4925. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4926. data["secret_key"] = miConfig.SecretKey
  4927. data["sick_code"] = sickConfig.CountryCode
  4928. data["sick_name"] = sickConfig.ClassName
  4929. data["url"] = miConfig.Url
  4930. data["ak"] = miConfig.AccessKey
  4931. data["begin_time"] = begin_time
  4932. data["cainfo"] = miConfig.Cainfo
  4933. data["dept"] = strconv.FormatInt(department.ID, 10)
  4934. data["config"] = config
  4935. bytesData, _ := json.Marshal(data)
  4936. var req *http.Request
  4937. if miConfig.MdtrtareaAdmvs == "320921" {
  4938. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4939. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4940. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4941. } else {
  4942. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4943. }
  4944. resp, _ := client.Do(req)
  4945. defer resp.Body.Close()
  4946. body, ioErr := ioutil.ReadAll(resp.Body)
  4947. if ioErr != nil {
  4948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4950. return
  4951. }
  4952. var respJSON map[string]interface{}
  4953. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4956. return
  4957. }
  4958. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4959. userJSONBytes, _ := json.Marshal(respJSON)
  4960. fmt.Println("log")
  4961. fmt.Println(string(userJSONBytes))
  4962. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4963. utils.ErrorLog("解析失败:%v", err)
  4964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4965. return
  4966. }
  4967. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4968. res2.Output = ressix10265.Output
  4969. res2.ErrMsg = ressix10265.ErrMsg
  4970. res2.Cainfo = ressix10265.Cainfo
  4971. res2.WarnMsg = ressix10265.WarnMsg
  4972. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4973. res2.Infcode = infocode
  4974. } else {
  4975. if miConfig.MdtrtareaAdmvs == "440781" { //
  4976. 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)
  4977. } else {
  4978. if miConfig.Code == "H15049901371" {
  4979. //赤峰地区国家医保医疗类别
  4980. //职工透析:医疗类别选特殊情况门诊990502
  4981. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4982. var med_type string
  4983. if his.Insutype == "390" {
  4984. if reg_type == 14 {
  4985. med_type = "9933"
  4986. } else if reg_type == 11 {
  4987. med_type = "11"
  4988. }
  4989. } else if his.Insutype == "310" {
  4990. if reg_type == 14 {
  4991. med_type = "990502"
  4992. } else if reg_type == 11 {
  4993. med_type = "11"
  4994. }
  4995. }
  4996. 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)
  4997. } else {
  4998. 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)
  4999. }
  5000. }
  5001. saveLog(result, requestLog, "2203", "上传就诊信息")
  5002. var respJSON2 map[string]interface{}
  5003. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5006. return
  5007. }
  5008. userJSONBytes2, _ := json.Marshal(respJSON2)
  5009. if miConfig.Code == "H15049901371" {
  5010. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5011. utils.ErrorLog("解析失败:%v", err)
  5012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5013. return
  5014. }
  5015. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5016. res2.Output = ressix10265.Output
  5017. res2.ErrMsg = ressix10265.ErrMsg
  5018. res2.Cainfo = ressix10265.Cainfo
  5019. res2.WarnMsg = ressix10265.WarnMsg
  5020. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5021. res2.Infcode = infocode
  5022. } else {
  5023. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5024. utils.ErrorLog("解析失败:%v", err)
  5025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5026. return
  5027. }
  5028. }
  5029. }
  5030. if res2.Infcode != 0 {
  5031. adminUser := c.GetAdminUserInfo()
  5032. errlog := &models.HisOrderError{
  5033. UserOrgId: adminUser.CurrentOrgId,
  5034. Ctime: time.Now().Unix(),
  5035. Mtime: time.Now().Unix(),
  5036. ErrMsg: res2.ErrMsg,
  5037. Status: 1,
  5038. PatientId: id,
  5039. RecordTime: recordDateTime,
  5040. Stage: 3,
  5041. }
  5042. service.CreateErrMsgLog(errlog)
  5043. c.ServeSuccessJSON(map[string]interface{}{
  5044. "failed_code": -10,
  5045. "msg": res2.ErrMsg,
  5046. })
  5047. return
  5048. } else {
  5049. his.Diagnosis = diagnosis_id
  5050. his.SickType = sickConfig.ID
  5051. //var p_type int64
  5052. //if reg_type == 1111 || reg_type == 1112 {
  5053. // p_type = 11
  5054. //
  5055. //}
  5056. his.PType = fmt.Sprintf("%d", reg_type)
  5057. service.UpdateHisPatientThree(&his)
  5058. data := make(map[string]interface{})
  5059. if settle_accounts_type == 1 { //日结
  5060. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5061. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5062. } else {
  5063. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5064. }
  5065. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5066. data["pre"] = prescriptions
  5067. } else { //月结
  5068. start_time_str := c.GetString("start_time")
  5069. end_time_str := c.GetString("end_time")
  5070. timeLayout := "2006-01-02"
  5071. loc, _ := time.LoadLocation("Local")
  5072. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5073. if err != nil {
  5074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5075. return
  5076. }
  5077. recordStartTime := theStartTime.Unix()
  5078. start_time = recordStartTime
  5079. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5080. if err != nil {
  5081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5082. return
  5083. }
  5084. recordEndTime := theEndTime.Unix()
  5085. end_time = recordEndTime
  5086. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5087. data["pre"] = prescriptions
  5088. }
  5089. timestamp := time.Now().Unix()
  5090. tempTime := time.Unix(timestamp, 0)
  5091. timeFormat := tempTime.Format("20060102150405")
  5092. chrgBchno := rand.Intn(100000) + 10000
  5093. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5094. strconv.FormatInt(his.PatientId, 10)
  5095. client := &http.Client{}
  5096. data["psn_no"] = his.PsnNo
  5097. data["mdtrt_id"] = his.Number
  5098. data["chrg_bchno"] = chrg_bchno
  5099. data["org_name"] = miConfig.OrgName
  5100. data["doctor"] = roles.UserName
  5101. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5102. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5103. data["fixmedins_code"] = miConfig.Code
  5104. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5105. // data["dept_code"] = "15"
  5106. //} else {
  5107. data["dept_code"] = department.Number
  5108. //}
  5109. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5110. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5111. data["secret_key"] = miConfig.SecretKey
  5112. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5113. data["url"] = miConfig.Url
  5114. data["ak"] = miConfig.AccessKey
  5115. data["new_doctor_name"] = patientPrescription.Doctor
  5116. data["diag_code"] = sickConfig.CountryCode
  5117. data["cainfo"] = miConfig.Cainfo
  5118. var ids []int64
  5119. for _, item := range prescriptions {
  5120. ids = append(ids, item.ID)
  5121. }
  5122. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5123. if config.IsOpen == 1 { //对接了医保,走医保流程
  5124. var res ResultFour
  5125. var resFour10265 ResultFour10265
  5126. if miConfig.MdtrtareaAdmvs == "421300" {
  5127. bytesData, _ := json.Marshal(data)
  5128. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5129. resp, _ := client.Do(req)
  5130. defer resp.Body.Close()
  5131. body, ioErr := ioutil.ReadAll(resp.Body)
  5132. if ioErr != nil {
  5133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5135. return
  5136. }
  5137. var respJSON map[string]interface{}
  5138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5141. return
  5142. }
  5143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5144. userJSONBytes, _ := json.Marshal(respJSON)
  5145. fmt.Println("log")
  5146. fmt.Println(string(userJSONBytes))
  5147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5148. utils.ErrorLog("解析失败:%v", err)
  5149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5150. return
  5151. }
  5152. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5153. bytesData, _ := json.Marshal(data)
  5154. var req *http.Request
  5155. if miConfig.MdtrtareaAdmvs == "320921" {
  5156. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5157. } else {
  5158. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5159. }
  5160. resp, _ := client.Do(req)
  5161. defer resp.Body.Close()
  5162. body, ioErr := ioutil.ReadAll(resp.Body)
  5163. if ioErr != nil {
  5164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5166. return
  5167. }
  5168. var respJSON map[string]interface{}
  5169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5172. return
  5173. }
  5174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5175. userJSONBytes, _ := json.Marshal(respJSON)
  5176. fmt.Println("log")
  5177. fmt.Println(string(userJSONBytes))
  5178. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5179. utils.ErrorLog("解析失败:%v", err)
  5180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5181. return
  5182. }
  5183. res.InfRefmsgid = resFour10265.InfRefmsgid
  5184. res.Output = resFour10265.Output
  5185. res.ErrMsg = resFour10265.ErrMsg
  5186. res.Cainfo = resFour10265.Cainfo
  5187. res.WarnMsg = resFour10265.WarnMsg
  5188. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5189. res.Infcode = infocode
  5190. } else {
  5191. if miConfig.Code == "H15049901371" {
  5192. 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)
  5193. var dat map[string]interface{}
  5194. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5195. fmt.Println(dat)
  5196. } else {
  5197. fmt.Println(err)
  5198. }
  5199. saveLog(result, request_log, "2204", "上传费用明细")
  5200. userJSONBytes, _ := json.Marshal(dat)
  5201. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5202. utils.ErrorLog("解析失败:%v", err)
  5203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5204. return
  5205. }
  5206. res.InfRefmsgid = resFour10265.InfRefmsgid
  5207. res.Output = resFour10265.Output
  5208. res.ErrMsg = resFour10265.ErrMsg
  5209. res.Cainfo = resFour10265.Cainfo
  5210. res.WarnMsg = resFour10265.WarnMsg
  5211. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5212. res.Infcode = infocode
  5213. } else {
  5214. 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)
  5215. var dat map[string]interface{}
  5216. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5217. fmt.Println(dat)
  5218. } else {
  5219. fmt.Println(err)
  5220. }
  5221. saveLog(result, request_log, "2204", "上传费用明细")
  5222. userJSONBytes, _ := json.Marshal(dat)
  5223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5224. utils.ErrorLog("解析失败:%v", err)
  5225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5226. return
  5227. }
  5228. }
  5229. }
  5230. if res.Infcode == 0 {
  5231. order := &models.HisOrder{
  5232. UserOrgId: adminUser.CurrentOrgId,
  5233. HisPatientId: his.ID,
  5234. PatientId: his.PatientId,
  5235. SettleAccountsDate: recordDateTime,
  5236. MdtrtId: his.Number,
  5237. PsnNo: his.PsnNo,
  5238. MedType: strconv.FormatInt(reg_type, 10),
  5239. Ctime: time.Now().Unix(),
  5240. Mtime: time.Now().Unix(),
  5241. Status: 1,
  5242. Number: chrg_bchno,
  5243. Infcode: res.Infcode,
  5244. WarnMsg: res.WarnMsg,
  5245. Cainfo: res.Cainfo,
  5246. ErrMsg: res.ErrMsg,
  5247. RespondTime: res.RefmsgTime,
  5248. InfRefmsgid: res.InfRefmsgid,
  5249. OrderStatus: 1,
  5250. PayWay: pay_way,
  5251. PayPrice: pay_price,
  5252. PayCardNo: pay_card_no,
  5253. DiscountPrice: discount_price,
  5254. PreferentialPrice: preferential_price,
  5255. RealityPrice: reality_price,
  5256. FoundPrice: found_price,
  5257. MedicalInsurancePrice: medical_insurance_price,
  5258. PrivatePrice: private_price,
  5259. IsMedicineInsurance: 1,
  5260. SettleType: settle_accounts_type,
  5261. SettleStartTime: start_time,
  5262. SettleEndTime: end_time,
  5263. Creator: roles.AdminUserId,
  5264. Modify: roles.AdminUserId,
  5265. FaPiaoNumber: fapiao_number,
  5266. FaPiaoCode: fapiao_code,
  5267. PType: 2,
  5268. Diagnosis: diagnosis_id,
  5269. }
  5270. err = service.CreateOrder(order)
  5271. if err != nil {
  5272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5273. return
  5274. }
  5275. for _, item := range res.Output.Result {
  5276. temp := strings.Split(item.FeedetlSn, "-")
  5277. var advice_id int64 = 0
  5278. var project_id int64 = 0
  5279. var types int64 = 0
  5280. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5281. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5282. if temp[1] == "1" {
  5283. advice_id = id
  5284. project_id = 0
  5285. } else if temp[1] == "2" {
  5286. advice_id = 0
  5287. project_id = id
  5288. }
  5289. info := &models.HisOrderInfo{
  5290. OrderNumber: order.Number,
  5291. FeedetlSn: item.FeedetlSn,
  5292. UploadDate: time.Now().Unix(),
  5293. AdviceId: advice_id,
  5294. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5295. Cnt: item.Cnt,
  5296. Pric: float64(item.Pric),
  5297. PatientId: his.PatientId,
  5298. PricUplmtAmt: item.PricUplmtAmt,
  5299. SelfpayProp: item.SelfpayProp,
  5300. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5301. OverlmtAmt: item.OverlmtAmt,
  5302. PreselfpayAmt: item.PreselfpayAmt,
  5303. BasMednFlag: item.BasMednFlag,
  5304. MedChrgitmType: item.MedChrgitmType,
  5305. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5306. Status: 1,
  5307. Memo: item.Memo,
  5308. Mtime: time.Now().Unix(),
  5309. InscpScpAmt: item.InscpScpAmt,
  5310. DrtReimFlag: item.DrtReimFlag,
  5311. Ctime: time.Now().Unix(),
  5312. ListSpItemFlag: item.ListSpItemFlag,
  5313. ChldMedcFlag: item.ChldMedcFlag,
  5314. LmtUsedFlag: item.LmtUsedFlag,
  5315. ChrgitmLv: item.ChrgitmLv,
  5316. UserOrgId: adminUser.CurrentOrgId,
  5317. HisPatientId: his.ID,
  5318. OrderId: order.ID,
  5319. ProjectId: project_id,
  5320. Type: types,
  5321. }
  5322. service.CreateOrderInfo(info)
  5323. }
  5324. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5325. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5326. var total float64
  5327. for _, item := range prescriptions {
  5328. if item.Type == 1 { //药品
  5329. for _, subItem := range item.HisDoctorAdviceInfo {
  5330. total = total + (subItem.Price * subItem.PrescribingNumber)
  5331. }
  5332. }
  5333. if item.Type == 2 { //项目
  5334. for _, subItem := range item.HisPrescriptionProject {
  5335. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5336. total = total + (subItem.Price * cnt)
  5337. }
  5338. }
  5339. }
  5340. for _, item := range prescriptions {
  5341. for _, subItem := range item.HisAdditionalCharge {
  5342. total = total + (subItem.Price * float64(subItem.Count))
  5343. }
  5344. }
  5345. var allTotal string
  5346. if adminUser.CurrentOrgId == 9919 {
  5347. allTotal = fmt.Sprintf("%.4f", total)
  5348. } else {
  5349. allTotal = fmt.Sprintf("%.4f", total)
  5350. }
  5351. if res.Infcode == 0 {
  5352. var rf []*ResultFive
  5353. json.Unmarshal([]byte(his.Iinfo), &rf)
  5354. chrg_bchno := chrg_bchno
  5355. cert_no := his.Certno
  5356. var insutypes []string
  5357. var insutype string
  5358. var is390 int = 0
  5359. var is310 int = 0
  5360. for _, item := range rf {
  5361. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5362. insutypes = append(insutypes, item.Insutype)
  5363. }
  5364. }
  5365. if len(insutypes) == 1 {
  5366. insutype = insutypes[0]
  5367. } else {
  5368. for _, i := range insutypes {
  5369. if i == "390" {
  5370. is390 = 1
  5371. }
  5372. if i == "310" {
  5373. is310 = 1
  5374. }
  5375. }
  5376. }
  5377. if is390 == 1 {
  5378. insutype = "390"
  5379. }
  5380. if is310 == 1 {
  5381. insutype = "310"
  5382. }
  5383. if len(insutypes) == 0 {
  5384. insutype = "310"
  5385. }
  5386. if len(insutypes) == 2 {
  5387. insutype = strconv.FormatInt(his.SocialType, 10)
  5388. }
  5389. insutype = strconv.FormatInt(his.SocialType, 10)
  5390. //insutype = "390"
  5391. if his.IdCardType == 1 {
  5392. // cert_no = his.MedicalInsuranceNumber
  5393. cert_no = his.Certno
  5394. } else {
  5395. cert_no = his.Certno
  5396. }
  5397. var res ResultSeven
  5398. var resSeven10265 ResultSeven10265
  5399. var src_resquest string
  5400. var result2 string
  5401. var acct_used_flag string
  5402. fmt.Println("pay_way")
  5403. fmt.Println(pay_way)
  5404. fmt.Println("pay_way")
  5405. if pay_way == 4 {
  5406. acct_used_flag = "1"
  5407. } else {
  5408. acct_used_flag = "0"
  5409. }
  5410. if miConfig.MdtrtareaAdmvs == "421300" {
  5411. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5412. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5413. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5414. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5415. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5416. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5417. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5418. resp, requestErr := http.Get(api)
  5419. if requestErr != nil {
  5420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5421. return
  5422. }
  5423. body, ioErr := ioutil.ReadAll(resp.Body)
  5424. if ioErr != nil {
  5425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5427. return
  5428. }
  5429. var respJSON map[string]interface{}
  5430. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5433. return
  5434. }
  5435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5436. result, _ := json.Marshal(respJSON)
  5437. if miConfig.Code == "H15049901371" {
  5438. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5439. utils.ErrorLog("解析失败:%v", err)
  5440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5441. return
  5442. }
  5443. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5444. res.Output = resSeven10265.Output
  5445. res.ErrMsg = resSeven10265.ErrMsg
  5446. res.Cainfo = resSeven10265.Cainfo
  5447. res.WarnMsg = resSeven10265.WarnMsg
  5448. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5449. res.Infcode = infocode
  5450. } else {
  5451. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5452. utils.ErrorLog("解析失败:%v", err)
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5454. return
  5455. }
  5456. }
  5457. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5458. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5459. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5460. //psn_info, _ := service.GetPsnByPatientId(id)
  5461. bas := strings.Split(psn_info.CardInfo, "|")
  5462. if his.IdCardType == 1 {
  5463. cert_no = bas[2]
  5464. } else if his.IdCardType == 3 {
  5465. cert_no = his.Certno
  5466. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5467. } else {
  5468. cert_no = bas[1]
  5469. }
  5470. //江苏地区国家医保医疗类别
  5471. //职工透析:医疗类别选特殊情况门诊9933
  5472. //居民血透门慢: 医疗类别选门诊慢病1402
  5473. //var med_type string
  5474. //if his.Insutype == "310" {
  5475. // if reg_type == 14 {
  5476. // med_type = "9933"
  5477. // } else if reg_type == 11 {
  5478. // med_type = "11"
  5479. //
  5480. // }
  5481. //} else if his.Insutype == "390" {
  5482. // if reg_type == 14 {
  5483. // med_type = "1402"
  5484. // } else if reg_type == 11 {
  5485. // med_type = "11"
  5486. // }
  5487. //}
  5488. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5489. var api string
  5490. if miConfig.MdtrtareaAdmvs == "320921" {
  5491. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5492. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5493. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5495. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5496. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5497. "&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
  5498. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5499. } else {
  5500. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5501. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5507. "&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
  5508. }
  5509. resp, requestErr := http.Get(api)
  5510. if requestErr != nil {
  5511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5512. return
  5513. }
  5514. body, ioErr := ioutil.ReadAll(resp.Body)
  5515. if ioErr != nil {
  5516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5518. return
  5519. }
  5520. var respJSON map[string]interface{}
  5521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5527. result, _ := json.Marshal(respJSON)
  5528. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5529. utils.ErrorLog("解析失败:%v", err)
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5534. res.Output = resSeven10265.Output
  5535. res.ErrMsg = resSeven10265.ErrMsg
  5536. res.Cainfo = resSeven10265.Cainfo
  5537. res.WarnMsg = resSeven10265.WarnMsg
  5538. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5539. res.Infcode = infocode
  5540. } else {
  5541. if miConfig.Code == "H15049901371" {
  5542. //赤峰地区国家医保医疗类别
  5543. //职工透析:医疗类别选特殊情况门诊990502
  5544. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5545. var med_type string
  5546. if his.Insutype == "390" {
  5547. if reg_type == 14 {
  5548. med_type = "9933"
  5549. } else if reg_type == 11 {
  5550. med_type = "11"
  5551. }
  5552. } else if his.Insutype == "310" {
  5553. if reg_type == 14 {
  5554. med_type = "990502"
  5555. } else if reg_type == 11 {
  5556. med_type = "11"
  5557. }
  5558. }
  5559. 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)
  5560. } else {
  5561. 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)
  5562. }
  5563. //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)
  5564. var dat map[string]interface{}
  5565. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5566. fmt.Println(dat)
  5567. } else {
  5568. fmt.Println(err)
  5569. }
  5570. saveLog(result2, src_resquest, "2207", "结算")
  5571. userJSONBytes, _ := json.Marshal(dat)
  5572. if miConfig.Code == "H15049901371" {
  5573. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5574. utils.ErrorLog("解析失败:%v", err)
  5575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5576. return
  5577. }
  5578. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5579. res.Output = resSeven10265.Output
  5580. res.ErrMsg = resSeven10265.ErrMsg
  5581. res.Cainfo = resSeven10265.Cainfo
  5582. res.WarnMsg = resSeven10265.WarnMsg
  5583. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5584. res.Infcode = infocode
  5585. } else {
  5586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5587. utils.ErrorLog("解析失败:%v", err)
  5588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5589. return
  5590. }
  5591. }
  5592. }
  5593. if res.Infcode != 0 {
  5594. errlog := &models.HisOrderError{
  5595. UserOrgId: adminUser.CurrentOrgId,
  5596. Ctime: time.Now().Unix(),
  5597. Mtime: time.Now().Unix(),
  5598. Number: chrg_bchno,
  5599. ErrMsg: res.ErrMsg,
  5600. Status: 1,
  5601. PatientId: id,
  5602. RecordTime: recordDateTime,
  5603. Stage: 6,
  5604. }
  5605. service.CreateErrMsgLog(errlog)
  5606. c.ServeSuccessJSON(map[string]interface{}{
  5607. "failed_code": -10,
  5608. "msg": res.ErrMsg,
  5609. })
  5610. return
  5611. } else {
  5612. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5613. order.OrderStatus = 2
  5614. order.Status = 1
  5615. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5616. order.SetlId = res.Output.Setlinfo.SetlID
  5617. order.PsnNo = res.Output.Setlinfo.PsnNo
  5618. order.PsnName = res.Output.Setlinfo.PsnName
  5619. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5620. order.Certno = res.Output.Setlinfo.Certno
  5621. order.Gend = res.Output.Setlinfo.Gend
  5622. order.Naty = res.Output.Setlinfo.Naty
  5623. order.Age = res.Output.Setlinfo.Age
  5624. order.Insutype = res.Output.Setlinfo.Insutype
  5625. order.PsnType = res.Output.Setlinfo.PsnType
  5626. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5627. order.SetlTime = res.Output.Setlinfo.SetlTime
  5628. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5629. if res.Output.Setlinfo.MedType == "140101" {
  5630. order.MedType = "14"
  5631. } else {
  5632. order.MedType = res.Output.Setlinfo.MedType
  5633. }
  5634. if reg_type == 1112 {
  5635. order.MedType = "1112"
  5636. }
  5637. if reg_type == 1111 {
  5638. order.MedType = "1111"
  5639. }
  5640. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5641. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5642. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5643. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5644. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5645. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5646. order.HifpPay = res.Output.Setlinfo.HifpPay
  5647. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5648. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5649. order.HifesPay = res.Output.Setlinfo.HifesPay
  5650. order.HifobPay = res.Output.Setlinfo.HifobPay
  5651. order.MafPay = res.Output.Setlinfo.MafPay
  5652. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5653. order.OthPay = res.Output.Setlinfo.OthPay
  5654. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5655. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5656. order.AcctPay = res.Output.Setlinfo.AcctPay
  5657. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5658. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5659. order.Balc = res.Output.Setlinfo.Balc
  5660. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5661. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5662. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5663. order.ClrType = res.Output.Setlinfo.ClrType
  5664. order.ClrWay = res.Output.Setlinfo.ClrWay
  5665. order.Creator = order.Creator
  5666. order.Modify = roles.AdminUserId
  5667. order.RequestLog = src_resquest
  5668. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5669. detailStr := string(setlDetail)
  5670. order.SetlDetail = detailStr
  5671. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5672. err = service.UpDateOrder(order)
  5673. if err == nil {
  5674. //判断是否使用了押金
  5675. if dec_way == "true" {
  5676. tmpstring := strconv.FormatInt(order.ID, 10)
  5677. order.Decimal = decimal
  5678. service.UpDateOrder(order)
  5679. //扣押金
  5680. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5681. if errmsg != nil {
  5682. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5683. return
  5684. }
  5685. }
  5686. c.ServeSuccessJSON(map[string]interface{}{
  5687. "msg": "结算成功",
  5688. })
  5689. } else {
  5690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5691. return
  5692. }
  5693. }
  5694. } else {
  5695. adminUser := c.GetAdminUserInfo()
  5696. errlog := &models.HisOrderError{
  5697. UserOrgId: adminUser.CurrentOrgId,
  5698. Ctime: time.Now().Unix(),
  5699. Mtime: time.Now().Unix(),
  5700. ErrMsg: res.ErrMsg,
  5701. Status: 1,
  5702. PatientId: id,
  5703. RecordTime: recordDateTime,
  5704. Stage: 4,
  5705. }
  5706. service.CreateErrMsgLog(errlog)
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5708. return
  5709. }
  5710. } else {
  5711. adminUser := c.GetAdminUserInfo()
  5712. errlog := &models.HisOrderError{
  5713. UserOrgId: adminUser.CurrentOrgId,
  5714. Ctime: time.Now().Unix(),
  5715. Mtime: time.Now().Unix(),
  5716. ErrMsg: res.ErrMsg,
  5717. Status: 1,
  5718. PatientId: id,
  5719. RecordTime: recordDateTime,
  5720. Stage: 4,
  5721. }
  5722. service.CreateErrMsgLog(errlog)
  5723. c.ServeSuccessJSON(map[string]interface{}{
  5724. "failed_code": -10,
  5725. "msg": res.ErrMsg,
  5726. })
  5727. return
  5728. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5729. //return
  5730. }
  5731. }
  5732. }
  5733. } else if tempOrder.ID > 0 {
  5734. if tempOrder.IsPre == 1 {
  5735. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5736. var rf []*ResultFive
  5737. json.Unmarshal([]byte(his.Iinfo), &rf)
  5738. chrg_bchno := tempOrder.Number
  5739. cert_no := his.Certno
  5740. var insutypes []string
  5741. var insutype string
  5742. var is390 int = 0
  5743. var is310 int = 0
  5744. for _, item := range rf {
  5745. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5746. insutypes = append(insutypes, item.Insutype)
  5747. }
  5748. }
  5749. if len(insutypes) == 1 {
  5750. insutype = insutypes[0]
  5751. } else {
  5752. for _, i := range insutypes {
  5753. if i == "390" {
  5754. is390 = 1
  5755. }
  5756. if i == "310" {
  5757. is310 = 1
  5758. }
  5759. }
  5760. }
  5761. if is390 == 1 {
  5762. insutype = "390"
  5763. }
  5764. if is310 == 1 {
  5765. insutype = "310"
  5766. }
  5767. if len(insutypes) == 0 {
  5768. insutype = "310"
  5769. }
  5770. if len(insutypes) == 2 {
  5771. insutype = strconv.FormatInt(his.SocialType, 64)
  5772. }
  5773. //insutype = "390"
  5774. if his.IdCardType == 1 {
  5775. // cert_no = his.MedicalInsuranceNumber
  5776. cert_no = his.Certno
  5777. } else {
  5778. cert_no = his.Certno
  5779. }
  5780. var res ResultSeven
  5781. var resSeven10265 ResultSeven10265
  5782. var src_resquest string
  5783. var result2 string
  5784. var acct_used_flag string
  5785. fmt.Println("pay_way")
  5786. fmt.Println(pay_way)
  5787. fmt.Println("pay_way")
  5788. if pay_way == 4 {
  5789. acct_used_flag = "1"
  5790. } else {
  5791. acct_used_flag = "0"
  5792. }
  5793. if miConfig.MdtrtareaAdmvs == "421300" {
  5794. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5795. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5796. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5798. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5799. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5800. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5801. resp, requestErr := http.Get(api)
  5802. if requestErr != nil {
  5803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5804. return
  5805. }
  5806. body, ioErr := ioutil.ReadAll(resp.Body)
  5807. if ioErr != nil {
  5808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5810. return
  5811. }
  5812. var respJSON map[string]interface{}
  5813. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5816. return
  5817. }
  5818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5819. result, _ := json.Marshal(respJSON)
  5820. fmt.Println("log")
  5821. fmt.Println(string(result))
  5822. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5823. utils.ErrorLog("解析失败:%v", err)
  5824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5825. return
  5826. }
  5827. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5828. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5829. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5830. //psn_info, _ := service.GetPsnByPatientId(id)
  5831. bas := strings.Split(psn_info.CardInfo, "|")
  5832. if his.IdCardType == 1 {
  5833. cert_no = bas[2]
  5834. } else {
  5835. cert_no = bas[1]
  5836. }
  5837. //江苏地区国家医保医疗类别
  5838. //职工透析:医疗类别选特殊情况门诊9933
  5839. //居民血透门慢: 医疗类别选门诊慢病1402
  5840. //var med_type string
  5841. //if his.Insutype == "310" {
  5842. // if reg_type == 14 {
  5843. // med_type = "9933"
  5844. // } else if reg_type == 11 {
  5845. // med_type = "11"
  5846. //
  5847. // }
  5848. //} else if his.Insutype == "390" {
  5849. // if reg_type == 14 {
  5850. // med_type = "1402"
  5851. // } else if reg_type == 11 {
  5852. // med_type = "11"
  5853. // }
  5854. //}
  5855. var api string
  5856. if miConfig.MdtrtareaAdmvs == "320921" {
  5857. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5858. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5859. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5860. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5861. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5862. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5863. "&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
  5864. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5865. } else {
  5866. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5867. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5868. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5869. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5870. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5871. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5872. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5873. "&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
  5874. }
  5875. resp, requestErr := http.Get(api)
  5876. if requestErr != nil {
  5877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5878. return
  5879. }
  5880. body, ioErr := ioutil.ReadAll(resp.Body)
  5881. if ioErr != nil {
  5882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5884. return
  5885. }
  5886. var respJSON map[string]interface{}
  5887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. return
  5891. }
  5892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5893. result, _ := json.Marshal(respJSON)
  5894. fmt.Println("log")
  5895. fmt.Println(string(result))
  5896. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5897. utils.ErrorLog("解析失败:%v", err)
  5898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5899. return
  5900. }
  5901. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5902. res.Output = resSeven10265.Output
  5903. res.ErrMsg = resSeven10265.ErrMsg
  5904. res.Cainfo = resSeven10265.Cainfo
  5905. res.WarnMsg = resSeven10265.WarnMsg
  5906. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5907. res.Infcode = infocode
  5908. } else {
  5909. var src_resquest string
  5910. if miConfig.Code == "H15049901371" {
  5911. //赤峰地区国家医保医疗类别
  5912. //职工透析:医疗类别选特殊情况门诊990502
  5913. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5914. var med_type string
  5915. if his.Insutype == "390" {
  5916. if reg_type == 14 {
  5917. med_type = "9933"
  5918. } else if reg_type == 11 {
  5919. med_type = "11"
  5920. }
  5921. } else if his.Insutype == "310" {
  5922. if reg_type == 14 {
  5923. med_type = "990502"
  5924. } else if reg_type == 11 {
  5925. med_type = "11"
  5926. }
  5927. }
  5928. 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)
  5929. } else {
  5930. 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)
  5931. }
  5932. var dat map[string]interface{}
  5933. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5934. fmt.Println(dat)
  5935. } else {
  5936. fmt.Println(err)
  5937. }
  5938. saveLog(result2, src_resquest, "2207", "结算")
  5939. userJSONBytes, _ := json.Marshal(dat)
  5940. if miConfig.Code == "H15049901371" {
  5941. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5942. utils.ErrorLog("解析失败:%v", err)
  5943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5944. return
  5945. }
  5946. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5947. res.Output = resSeven10265.Output
  5948. res.ErrMsg = resSeven10265.ErrMsg
  5949. res.Cainfo = resSeven10265.Cainfo
  5950. res.WarnMsg = resSeven10265.WarnMsg
  5951. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5952. res.Infcode = infocode
  5953. } else {
  5954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5955. utils.ErrorLog("解析失败:%v", err)
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5957. return
  5958. }
  5959. }
  5960. }
  5961. if res.Infcode != 0 {
  5962. errlog := &models.HisOrderError{
  5963. UserOrgId: adminUser.CurrentOrgId,
  5964. Ctime: time.Now().Unix(),
  5965. Mtime: time.Now().Unix(),
  5966. Number: chrg_bchno,
  5967. ErrMsg: res.ErrMsg,
  5968. Status: 1,
  5969. PatientId: id,
  5970. RecordTime: recordDateTime,
  5971. Stage: 6,
  5972. }
  5973. service.CreateErrMsgLog(errlog)
  5974. c.ServeSuccessJSON(map[string]interface{}{
  5975. "failed_code": -10,
  5976. "msg": res.ErrMsg,
  5977. })
  5978. return
  5979. } else {
  5980. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5981. order.OrderStatus = 2
  5982. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5983. order.SetlId = res.Output.Setlinfo.SetlID
  5984. order.PsnNo = res.Output.Setlinfo.PsnNo
  5985. order.PsnName = res.Output.Setlinfo.PsnName
  5986. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5987. order.Certno = res.Output.Setlinfo.Certno
  5988. order.Gend = res.Output.Setlinfo.Gend
  5989. order.Naty = res.Output.Setlinfo.Naty
  5990. order.Age = res.Output.Setlinfo.Age
  5991. order.Insutype = res.Output.Setlinfo.Insutype
  5992. order.PsnType = res.Output.Setlinfo.PsnType
  5993. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5994. order.SetlTime = res.Output.Setlinfo.SetlTime
  5995. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5996. //order.MedType = res.Output.Setlinfo.MedType
  5997. if reg_type == 1112 {
  5998. order.MedType = "1112"
  5999. }
  6000. if reg_type == 1111 {
  6001. order.MedType = "1111"
  6002. }
  6003. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6004. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6005. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6006. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6007. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6008. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6009. order.HifpPay = res.Output.Setlinfo.HifpPay
  6010. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6011. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6012. order.HifesPay = res.Output.Setlinfo.HifesPay
  6013. order.HifobPay = res.Output.Setlinfo.HifobPay
  6014. order.MafPay = res.Output.Setlinfo.MafPay
  6015. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6016. order.OthPay = res.Output.Setlinfo.OthPay
  6017. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6018. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6019. order.AcctPay = res.Output.Setlinfo.AcctPay
  6020. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6021. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6022. order.Balc = res.Output.Setlinfo.Balc
  6023. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6024. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6025. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6026. order.ClrWay = res.Output.Setlinfo.ClrWay
  6027. order.Creator = order.Creator
  6028. order.Modify = roles.AdminUserId
  6029. order.RequestLog = src_resquest
  6030. order.Diagnosis = diagnosis_id
  6031. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6032. detailStr := string(setlDetail)
  6033. order.SetlDetail = detailStr
  6034. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6035. err = service.UpDateOrder(order)
  6036. if err == nil {
  6037. //判断是否使用了押金
  6038. if dec_way == "true" {
  6039. tmpstring := strconv.FormatInt(order.ID, 10)
  6040. //扣押金
  6041. order.Decimal = decimal
  6042. service.UpDateOrder(order)
  6043. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6044. if errmsg != nil {
  6045. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6046. return
  6047. }
  6048. }
  6049. c.ServeSuccessJSON(map[string]interface{}{
  6050. "msg": "结算成功",
  6051. })
  6052. } else {
  6053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6054. return
  6055. }
  6056. }
  6057. }
  6058. }
  6059. }
  6060. //func (c *HisApiController) GetPreUploadInfo() {
  6061. // id, _ := c.GetInt64("id")
  6062. // record_time := c.GetString("record_time")
  6063. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6064. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6065. //
  6066. // timeLayout := "2006-01-02"
  6067. // loc, _ := time.LoadLocation("Local")
  6068. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6069. // if err != nil {
  6070. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6071. // return
  6072. // }
  6073. // recordDateTime := theTime.Unix()
  6074. // adminUser := c.GetAdminUserInfo()
  6075. //
  6076. // var prescriptions []*models.HisPrescription
  6077. //
  6078. // var start_time int64
  6079. // var end_time int64
  6080. //
  6081. // data := make(map[string]interface{})
  6082. // if settle_accounts_type == 1 { //日结
  6083. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6084. // data["pre"] = prescriptions
  6085. //
  6086. // } else { //月结
  6087. // start_time_str := c.GetString("start_time")
  6088. // end_time_str := c.GetString("end_time")
  6089. // timeLayout := "2006-01-02"
  6090. // loc, _ := time.LoadLocation("Local")
  6091. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6092. // if err != nil {
  6093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6094. // return
  6095. // }
  6096. // recordStartTime := theStartTime.Unix()
  6097. // start_time = recordStartTime
  6098. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6099. // if err != nil {
  6100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6101. // return
  6102. // }
  6103. // recordEndTime := theEndTime.Unix()
  6104. // end_time = recordEndTime
  6105. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6106. // data["pre"] = prescriptions
  6107. //
  6108. // }
  6109. //
  6110. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6111. //
  6112. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6113. // timestamp := time.Now().Unix()
  6114. // tempTime := time.Unix(timestamp, 0)
  6115. // timeFormat := tempTime.Format("20060102150405")
  6116. // chrgBchno := rand.Intn(100000) + 10000
  6117. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6118. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6119. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6120. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6121. // strconv.FormatInt(his.PatientId, 10)
  6122. // client := &http.Client{}
  6123. // data["psn_no"] = his.PsnNo
  6124. // data["mdtrt_id"] = his.Number
  6125. // data["chrg_bchno"] = chrg_bchno
  6126. // data["org_name"] = miConfig.OrgName
  6127. // data["doctor"] = roles.UserName
  6128. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6129. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6130. // data["fixmedins_code"] = miConfig.Code
  6131. // data["dept_code"] = department.Number
  6132. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6133. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6134. // data["secret_key"] = miConfig.SecretKey
  6135. // var ids []int64
  6136. //
  6137. // for _, item := range prescriptions {
  6138. // ids = append(ids, item.ID)
  6139. // }
  6140. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6141. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6142. // bytesData, _ := json.Marshal(data)
  6143. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6144. // resp, _ := client.Do(req)
  6145. // defer resp.Body.Close()
  6146. // body, ioErr := ioutil.ReadAll(resp.Body)
  6147. // if ioErr != nil {
  6148. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6150. // return
  6151. // }
  6152. // var respJSON map[string]interface{}
  6153. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6154. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6155. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6156. // return
  6157. // }
  6158. //
  6159. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6160. // userJSONBytes, _ := json.Marshal(respJSON)
  6161. // var res ResultFour
  6162. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6163. // utils.ErrorLog("解析失败:%v", err)
  6164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6165. // return
  6166. // }
  6167. //
  6168. // if res.Infcode == 0 {
  6169. // order := &models.HisOrder{
  6170. // UserOrgId: adminUser.CurrentOrgId,
  6171. // HisPatientId: his.ID,
  6172. // PatientId: his.PatientId,
  6173. // SettleAccountsDate: recordDateTime,
  6174. // Ctime: time.Now().Unix(),
  6175. // Mtime: time.Now().Unix(),
  6176. // Status: 1,
  6177. // Number: chrg_bchno,
  6178. // Infcode: res.Infcode,
  6179. // WarnMsg: res.WarnMsg,
  6180. // Cainfo: res.Cainfo,
  6181. // ErrMsg: res.ErrMsg,
  6182. // RespondTime: res.RefmsgTime,
  6183. // InfRefmsgid: res.InfRefmsgid,
  6184. // OrderStatus: 1,
  6185. // IsMedicineInsurance: 1,
  6186. // SettleType: settle_accounts_type,
  6187. // SettleStartTime: start_time,
  6188. // SettleEndTime: end_time,
  6189. // Creator: roles.ID,
  6190. // Modify: roles.ID,
  6191. // PType: 2,
  6192. // }
  6193. // err = service.CreateOrder(order)
  6194. // if err != nil {
  6195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6196. // return
  6197. // }
  6198. //
  6199. // for _, item := range res.Output.Result {
  6200. // temp := strings.Split(item.FeedetlSn, "-")
  6201. // var advice_id int64 = 0
  6202. // var project_id int64 = 0
  6203. // var types int64 = 0
  6204. //
  6205. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6206. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6207. //
  6208. // if temp[1] == "1" {
  6209. // advice_id = id
  6210. // project_id = 0
  6211. // } else if temp[1] == "2" {
  6212. // advice_id = 0
  6213. // project_id = id
  6214. // }
  6215. //
  6216. // info := &models.HisOrderInfo{
  6217. // OrderNumber: order.Number,
  6218. // FeedetlSn: item.FeedetlSn,
  6219. // UploadDate: time.Now().Unix(),
  6220. // AdviceId: advice_id,
  6221. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6222. // Cnt: item.Cnt,
  6223. // Pric: float64(item.Pric),
  6224. // PatientId: his.PatientId,
  6225. // PricUplmtAmt: item.PricUplmtAmt,
  6226. // SelfpayProp: item.SelfpayProp,
  6227. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6228. // OverlmtAmt: item.OverlmtAmt,
  6229. // PreselfpayAmt: item.PreselfpayAmt,
  6230. // BasMednFlag: item.BasMednFlag,
  6231. // MedChrgitmType: item.MedChrgitmType,
  6232. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6233. // Status: 1,
  6234. // Memo: item.Memo,
  6235. // Mtime: time.Now().Unix(),
  6236. // InscpScpAmt: item.InscpScpAmt,
  6237. // DrtReimFlag: item.DrtReimFlag,
  6238. // Ctime: time.Now().Unix(),
  6239. // ListSpItemFlag: item.ListSpItemFlag,
  6240. // ChldMedcFlag: item.ChldMedcFlag,
  6241. // LmtUsedFlag: item.LmtUsedFlag,
  6242. // ChrgitmLv: item.ChrgitmLv,
  6243. // UserOrgId: adminUser.CurrentOrgId,
  6244. // HisPatientId: his.ID,
  6245. // OrderId: order.ID,
  6246. // ProjectId: project_id,
  6247. // Type: types,
  6248. // }
  6249. // service.CreateOrderInfo(info)
  6250. //
  6251. // }
  6252. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6253. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6254. //
  6255. // var total float64
  6256. // for _, item := range prescriptions {
  6257. // if item.Type == 1 { //药品
  6258. // for _, subItem := range item.HisDoctorAdviceInfo {
  6259. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6260. // }
  6261. // }
  6262. // if item.Type == 2 { //项目
  6263. // for _, subItem := range item.HisPrescriptionProject {
  6264. // total = total + (subItem.Price * float64(subItem.Count))
  6265. // }
  6266. // }
  6267. // }
  6268. //
  6269. // for _, item := range prescriptions {
  6270. // for _, subItem := range item.HisAdditionalCharge {
  6271. // total = total + (subItem.Price * float64(subItem.Count))
  6272. // }
  6273. // }
  6274. //
  6275. // allTotal := fmt.Sprintf("%.2f", total)
  6276. // if res.Infcode == 0 {
  6277. // var rf []*ResultFive
  6278. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6279. // psn_no := his.PsnNo
  6280. // mdtrt_id := his.Number
  6281. // chrg_bchno := chrg_bchno
  6282. // cert_no := his.Certno
  6283. // insutype := rf[0].Insutype
  6284. //
  6285. // if his.IdCardType == 1 {
  6286. // cert_no = his.MedicalInsuranceNumber
  6287. //
  6288. // } else {
  6289. //
  6290. // cert_no = his.Certno
  6291. //
  6292. // }
  6293. //
  6294. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6295. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6296. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6297. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6298. // resp, requestErr := http.Get(api)
  6299. // if requestErr != nil {
  6300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6301. // return
  6302. // }
  6303. // defer resp.Body.Close()
  6304. // body, ioErr := ioutil.ReadAll(resp.Body)
  6305. // if ioErr != nil {
  6306. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6308. // return
  6309. // }
  6310. // var respJSON map[string]interface{}
  6311. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6312. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6314. // return
  6315. // }
  6316. // fmt.Println(respJSON)
  6317. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6318. // userJSONBytes, _ := json.Marshal(respJSON)
  6319. // var res ResultSeven
  6320. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6321. // utils.ErrorLog("解析失败:%v", err)
  6322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6323. // return
  6324. // }
  6325. // if res.Infcode != 0 {
  6326. // errlog := &models.HisOrderError{
  6327. // UserOrgId: adminUser.CurrentOrgId,
  6328. // Ctime: time.Now().Unix(),
  6329. // Mtime: time.Now().Unix(),
  6330. // Number: chrg_bchno,
  6331. // ErrMsg: res.ErrMsg,
  6332. // Status: 1,
  6333. // PatientId: id,
  6334. // RecordTime: recordDateTime,
  6335. // Stage: 7,
  6336. // }
  6337. // service.CreateErrMsgLog(errlog)
  6338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6339. // return
  6340. // } else {
  6341. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6342. // order.OrderStatus = 1
  6343. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6344. // order.SetlId = res.Output.Setlinfo.SetlID
  6345. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6346. // order.PsnName = res.Output.Setlinfo.PsnName
  6347. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6348. // order.Certno = res.Output.Setlinfo.Certno
  6349. // order.Gend = res.Output.Setlinfo.Gend
  6350. // order.Naty = res.Output.Setlinfo.Naty
  6351. // order.Age = res.Output.Setlinfo.Age
  6352. // order.Insutype = res.Output.Setlinfo.Insutype
  6353. // order.PsnType = res.Output.Setlinfo.PsnType
  6354. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6355. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6356. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6357. // order.MedType = res.Output.Setlinfo.MedType
  6358. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6359. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6360. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6361. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6362. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6363. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6364. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6365. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6366. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6367. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6368. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6369. // order.MafPay = res.Output.Setlinfo.MafPay
  6370. // order.OthPay = res.Output.Setlinfo.OthPay
  6371. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6372. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6373. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6374. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6375. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6376. // order.Balc = res.Output.Setlinfo.Balc
  6377. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6378. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6379. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6380. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6381. // order.Creator = order.Creator
  6382. // order.Modify = roles.ID
  6383. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6384. // detailStr := string(setlDetail)
  6385. // order.SetlDetail = detailStr
  6386. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6387. // err = service.UpDateOrder(order)
  6388. // if err == nil {
  6389. // c.ServeSuccessJSON(map[string]interface{}{
  6390. // "msg": "预结算成功",
  6391. // })
  6392. // } else {
  6393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6394. // return
  6395. // }
  6396. // }
  6397. // } else {
  6398. // adminUser := c.GetAdminUserInfo()
  6399. // errlog := &models.HisOrderError{
  6400. // UserOrgId: adminUser.CurrentOrgId,
  6401. // Ctime: time.Now().Unix(),
  6402. // Mtime: time.Now().Unix(),
  6403. // ErrMsg: res.ErrMsg,
  6404. // Status: 1,
  6405. // PatientId: id,
  6406. // RecordTime: recordDateTime,
  6407. // Stage: 4,
  6408. // }
  6409. // service.CreateErrMsgLog(errlog)
  6410. //
  6411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6412. // return
  6413. // }
  6414. // } else {
  6415. // adminUser := c.GetAdminUserInfo()
  6416. // errlog := &models.HisOrderError{
  6417. // UserOrgId: adminUser.CurrentOrgId,
  6418. // Ctime: time.Now().Unix(),
  6419. // Mtime: time.Now().Unix(),
  6420. // ErrMsg: res.ErrMsg,
  6421. // Status: 1,
  6422. // PatientId: id,
  6423. // RecordTime: recordDateTime,
  6424. // Stage: 4,
  6425. // }
  6426. // service.CreateErrMsgLog(errlog)
  6427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6428. // return
  6429. // }
  6430. //
  6431. // } else {
  6432. // var total float64
  6433. // for _, item := range prescriptions {
  6434. // if item.Type == 1 { //药品
  6435. // for _, subItem := range item.HisDoctorAdviceInfo {
  6436. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6437. // }
  6438. // }
  6439. // if item.Type == 2 { //项目
  6440. // for _, subItem := range item.HisPrescriptionProject {
  6441. // total = total + (subItem.Price * float64(subItem.Count))
  6442. // }
  6443. // }
  6444. //
  6445. // for _, subItem := range item.HisAdditionalCharge {
  6446. // total = total + (subItem.Price * float64(subItem.Count))
  6447. // }
  6448. // }
  6449. //
  6450. // allTotal := fmt.Sprintf("%.2f", total)
  6451. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6452. // order := &models.HisOrder{
  6453. // UserOrgId: adminUser.CurrentOrgId,
  6454. // HisPatientId: his.ID,
  6455. // PatientId: id,
  6456. // SettleAccountsDate: recordDateTime,
  6457. // Ctime: time.Now().Unix(),
  6458. // Mtime: time.Now().Unix(),
  6459. // Status: 1,
  6460. // OrderStatus: 2,
  6461. // Number: chrg_bchno,
  6462. // MedfeeSumamt: totals,
  6463. // }
  6464. // err = service.CreateOrder(order)
  6465. // if err != nil {
  6466. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6467. // return
  6468. // }
  6469. //
  6470. // var customs []*Custom
  6471. // for _, item := range prescriptions {
  6472. //
  6473. // if item.Type == 1 { //药品
  6474. // for _, subItem := range item.HisDoctorAdviceInfo {
  6475. // cus := &Custom{
  6476. // AdviceId: subItem.ID,
  6477. // ProjectId: 0,
  6478. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6479. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6480. // FeedetlSn: subItem.FeedetlSn,
  6481. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6482. // MedListCodg: subItem.MedListCodg,
  6483. // Type: 1,
  6484. // }
  6485. // customs = append(customs, cus)
  6486. // }
  6487. // }
  6488. //
  6489. // if item.Type == 2 { //项目
  6490. // for _, subItem := range item.HisPrescriptionProject {
  6491. //
  6492. // cus := &Custom{
  6493. // AdviceId: 0,
  6494. // ProjectId: subItem.ID,
  6495. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6496. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6497. // FeedetlSn: subItem.FeedetlSn,
  6498. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6499. // MedListCodg: subItem.MedListCodg,
  6500. // Type: 2,
  6501. // }
  6502. //
  6503. // customs = append(customs, cus)
  6504. // }
  6505. // }
  6506. //
  6507. // for _, item := range item.HisAdditionalCharge {
  6508. // cus := &Custom{
  6509. // ItemId: item.ID,
  6510. // AdviceId: 0,
  6511. // ProjectId: 0,
  6512. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6513. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6514. // FeedetlSn: item.FeedetlSn,
  6515. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6516. // MedListCodg: item.XtHisAddtionConfig.Code,
  6517. // Type: 3,
  6518. // }
  6519. //
  6520. // customs = append(customs, cus)
  6521. // }
  6522. //
  6523. // }
  6524. //
  6525. // for _, item := range customs {
  6526. // var advice_id int64 = 0
  6527. // var project_id int64 = 0
  6528. // var item_id int64 = 0
  6529. //
  6530. // var types int64 = 0
  6531. //
  6532. // if item.Type == 1 {
  6533. // advice_id = item.AdviceId
  6534. // project_id = 0
  6535. // item_id = 0
  6536. // } else if item.Type == 2 {
  6537. // advice_id = 0
  6538. // item_id = 0
  6539. //
  6540. // project_id = item.ProjectId
  6541. // } else if item.Type == 3 {
  6542. // advice_id = 0
  6543. // item_id = item.ItemId
  6544. // project_id = 0
  6545. // }
  6546. //
  6547. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6548. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6549. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6550. //
  6551. // info := &models.HisOrderInfo{
  6552. // OrderNumber: order.Number,
  6553. // UploadDate: time.Now().Unix(),
  6554. // AdviceId: advice_id,
  6555. // DetItemFeeSumamt: detItemFeeSumamt,
  6556. // Cnt: cut,
  6557. // Pric: pric,
  6558. // PatientId: id,
  6559. // Status: 1,
  6560. // Mtime: time.Now().Unix(),
  6561. // Ctime: time.Now().Unix(),
  6562. // UserOrgId: adminUser.CurrentOrgId,
  6563. // HisPatientId: his.ID,
  6564. // OrderId: order.ID,
  6565. // ProjectId: project_id,
  6566. // Type: types,
  6567. // ItemId: item_id,
  6568. // }
  6569. // service.CreateOrderInfo(info)
  6570. // }
  6571. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6572. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6573. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6574. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6575. // if err == nil {
  6576. // c.ServeSuccessJSON(map[string]interface{}{
  6577. // "msg": "结算成功",
  6578. // })
  6579. // } else {
  6580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6581. // return
  6582. // }
  6583. // }
  6584. //}
  6585. //上传明细-预结算-
  6586. func (c *HisApiController) GetPreUploadInfo() {
  6587. id, _ := c.GetInt64("id")
  6588. record_time := c.GetString("record_time")
  6589. his_patient_id, _ := c.GetInt64("his_patient_id")
  6590. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6591. admin_user_id, _ := c.GetInt64("admin_user_id")
  6592. diagnosis_id := c.GetString("diagnosis")
  6593. sick_type, _ := c.GetInt64("sick_type")
  6594. reg_type, _ := c.GetInt64("p_type")
  6595. begin_time := c.GetString("begin_time")
  6596. id_str := c.GetString("ids")
  6597. ids_arr := strings.Split(id_str, ",")
  6598. timeLayout := "2006-01-02"
  6599. loc, _ := time.LoadLocation("Local")
  6600. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6601. if err != nil {
  6602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6603. return
  6604. }
  6605. recordDateTime := theTime.Unix()
  6606. adminUser := c.GetAdminUserInfo()
  6607. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6608. var config []*models.HisXtDiagnoseConfig
  6609. for _, item := range diagnosis_ids {
  6610. id, _ := strconv.ParseInt(item, 10, 64)
  6611. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6612. config = append(config, &diagnosisConfig)
  6613. }
  6614. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6615. sickConfig, _ := service.FindSickById(sick_type)
  6616. var prescriptions []*models.HisPrescription
  6617. var start_time int64
  6618. var end_time int64
  6619. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6620. fmt.Println(his_patient_id)
  6621. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6622. timestamp := time.Now().Unix()
  6623. tempTime := time.Unix(timestamp, 0)
  6624. timeFormat := tempTime.Format("20060102150405")
  6625. chrgBchno := rand.Intn(100000) + 10000
  6626. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6627. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6628. var patientPrescription models.HisPrescriptionInfo
  6629. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6630. if patientPrescription.ID == 0 {
  6631. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6632. }
  6633. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6634. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6635. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6636. strconv.FormatInt(his.PatientId, 10)
  6637. var res2 ResultSix
  6638. var resSix10265 ResultSix10265
  6639. var time_stamp string
  6640. if miConfig.MdtrtareaAdmvs == "421300" {
  6641. data := make(map[string]interface{})
  6642. client := &http.Client{}
  6643. data["psn_no"] = his.PsnNo
  6644. data["mdtrt_id"] = his.Number
  6645. data["doctor"] = roles.UserName
  6646. data["department"] = department.Name
  6647. data["org_name"] = miConfig.OrgName
  6648. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6649. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6650. data["fixmedins_code"] = miConfig.Code
  6651. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6652. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6653. data["secret_key"] = miConfig.SecretKey
  6654. data["sick_code"] = sickConfig.CountryCode
  6655. data["sick_name"] = sickConfig.ClassName
  6656. data["begin_time"] = begin_time
  6657. data["dept"] = strconv.FormatInt(department.ID, 10)
  6658. data["config"] = config
  6659. fmt.Println(data)
  6660. bytesData, _ := json.Marshal(data)
  6661. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6662. resp, _ := client.Do(req)
  6663. defer resp.Body.Close()
  6664. body, ioErr := ioutil.ReadAll(resp.Body)
  6665. if ioErr != nil {
  6666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6668. return
  6669. }
  6670. var respJSON map[string]interface{}
  6671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6674. return
  6675. }
  6676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6677. userJSONBytes, _ := json.Marshal(respJSON)
  6678. fmt.Println("log")
  6679. fmt.Println(string(userJSONBytes))
  6680. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6681. utils.ErrorLog("解析失败:%v", err)
  6682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6683. return
  6684. }
  6685. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6686. //江苏地区国家医保医疗类别
  6687. //职工透析:医疗类别选特殊情况门诊9933
  6688. //居民血透门慢: 医疗类别选门诊慢病1402
  6689. //var med_type string
  6690. //if his.Insutype == "310" {
  6691. // if reg_type == 14 {
  6692. // med_type = "9933"
  6693. // } else if reg_type == 11 {
  6694. // med_type = "11"
  6695. //
  6696. // }
  6697. //} else if his.Insutype == "390" {
  6698. // if reg_type == 14 {
  6699. // med_type = "1402"
  6700. // } else if reg_type == 11 {
  6701. // med_type = "11"
  6702. // }
  6703. //}
  6704. data := make(map[string]interface{})
  6705. client := &http.Client{}
  6706. data["psn_no"] = his.PsnNo
  6707. data["mdtrt_id"] = his.Number
  6708. data["doctor"] = roles.UserName
  6709. data["department"] = department.Name
  6710. data["org_name"] = miConfig.OrgName
  6711. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6712. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6713. data["fixmedins_code"] = miConfig.Code
  6714. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6715. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6716. data["secret_key"] = miConfig.SecretKey
  6717. data["sick_code"] = sickConfig.CountryCode
  6718. data["sick_name"] = sickConfig.ClassName
  6719. data["begin_time"] = begin_time
  6720. data["dept"] = strconv.FormatInt(department.ID, 10)
  6721. data["config"] = config
  6722. data["url"] = miConfig.Url
  6723. data["ak"] = miConfig.AccessKey
  6724. data["cainfo"] = miConfig.Cainfo
  6725. bytesData, _ := json.Marshal(data)
  6726. var req *http.Request
  6727. if miConfig.MdtrtareaAdmvs == "320921" {
  6728. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6729. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6730. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6731. } else {
  6732. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6733. }
  6734. resp, _ := client.Do(req)
  6735. defer resp.Body.Close()
  6736. body, ioErr := ioutil.ReadAll(resp.Body)
  6737. if ioErr != nil {
  6738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6740. return
  6741. }
  6742. var respJSON map[string]interface{}
  6743. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6746. return
  6747. }
  6748. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6749. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6750. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6752. userJSONBytes, _ := json.Marshal(respJSON)
  6753. fmt.Println("log")
  6754. fmt.Println(string(userJSONBytes))
  6755. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6756. utils.ErrorLog("解析失败:%v", err)
  6757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6758. return
  6759. }
  6760. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6761. res2.Output = resSix10265.Output
  6762. res2.ErrMsg = resSix10265.ErrMsg
  6763. res2.Cainfo = resSix10265.Cainfo
  6764. res2.WarnMsg = resSix10265.WarnMsg
  6765. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6766. res2.Infcode = infocode
  6767. } else {
  6768. var result string
  6769. var requestLog string
  6770. if miConfig.MdtrtareaAdmvs == "440781" { //
  6771. 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)
  6772. } else {
  6773. if miConfig.Code == "H15049901371" {
  6774. //赤峰地区国家医保医疗类别
  6775. //职工透析:医疗类别选特殊情况门诊990502
  6776. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6777. var med_type string
  6778. if his.Insutype == "390" {
  6779. if reg_type == 14 {
  6780. med_type = "9933"
  6781. } else if reg_type == 11 {
  6782. med_type = "11"
  6783. }
  6784. } else if his.Insutype == "310" {
  6785. if reg_type == 14 {
  6786. med_type = "990502"
  6787. } else if reg_type == 11 {
  6788. med_type = "11"
  6789. }
  6790. }
  6791. 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)
  6792. } else {
  6793. 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)
  6794. }
  6795. saveLog(result, requestLog, "2203", "上传就诊信息")
  6796. var respJSON2 map[string]interface{}
  6797. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6800. return
  6801. }
  6802. userJSONBytes2, _ := json.Marshal(respJSON2)
  6803. if miConfig.Code == "H15049901371" {
  6804. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6805. utils.ErrorLog("解析失败:%v", err)
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. return
  6808. }
  6809. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6810. res2.Output = resSix10265.Output
  6811. res2.ErrMsg = resSix10265.ErrMsg
  6812. res2.Cainfo = resSix10265.Cainfo
  6813. res2.WarnMsg = resSix10265.WarnMsg
  6814. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6815. res2.Infcode = infocode
  6816. } else {
  6817. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6818. utils.ErrorLog("解析失败:%v", err)
  6819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6820. return
  6821. }
  6822. }
  6823. }
  6824. }
  6825. if res2.Infcode != 0 {
  6826. adminUser := c.GetAdminUserInfo()
  6827. errlog := &models.HisOrderError{
  6828. UserOrgId: adminUser.CurrentOrgId,
  6829. Ctime: time.Now().Unix(),
  6830. Mtime: time.Now().Unix(),
  6831. ErrMsg: res2.ErrMsg,
  6832. Status: 1,
  6833. PatientId: id,
  6834. RecordTime: recordDateTime,
  6835. Stage: 3,
  6836. }
  6837. service.CreateErrMsgLog(errlog)
  6838. c.ServeSuccessJSON(map[string]interface{}{
  6839. "failed_code": -10,
  6840. "msg": res2.ErrMsg,
  6841. })
  6842. return
  6843. } else {
  6844. his.Diagnosis = diagnosis_id
  6845. his.SickType = sickConfig.ID
  6846. his.PType = fmt.Sprintf("%d", reg_type)
  6847. service.UpdateHisPatientThree(&his)
  6848. data := make(map[string]interface{})
  6849. if settle_accounts_type == 1 { //日结
  6850. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6851. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6852. } else {
  6853. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6854. }
  6855. data["pre"] = prescriptions
  6856. } else { //月结
  6857. start_time_str := c.GetString("start_time")
  6858. end_time_str := c.GetString("end_time")
  6859. timeLayout := "2006-01-02"
  6860. loc, _ := time.LoadLocation("Local")
  6861. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6862. if err != nil {
  6863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6864. return
  6865. }
  6866. recordStartTime := theStartTime.Unix()
  6867. start_time = recordStartTime
  6868. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6869. if err != nil {
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6871. return
  6872. }
  6873. recordEndTime := theEndTime.Unix()
  6874. end_time = recordEndTime
  6875. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6876. data["pre"] = prescriptions
  6877. }
  6878. client := &http.Client{}
  6879. data["psn_no"] = his.PsnNo
  6880. data["mdtrt_id"] = his.Number
  6881. data["chrg_bchno"] = chrg_bchno
  6882. data["org_name"] = miConfig.OrgName
  6883. data["doctor"] = roles.UserName
  6884. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6885. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6886. data["fixmedins_code"] = miConfig.Code
  6887. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6888. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6889. data["dept_code"] = "15"
  6890. } else {
  6891. data["dept_code"] = department.Number
  6892. }
  6893. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6894. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6895. data["secret_key"] = miConfig.SecretKey
  6896. data["url"] = miConfig.Url
  6897. data["ak"] = miConfig.AccessKey
  6898. data["new_doctor_name"] = patientPrescription.Doctor
  6899. data["diag_code"] = sickConfig.CountryCode
  6900. data["time_stamp"] = time_stamp
  6901. data["cainfo"] = miConfig.Cainfo
  6902. var ids []int64
  6903. for _, item := range prescriptions {
  6904. ids = append(ids, item.ID)
  6905. }
  6906. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6907. if config.IsOpen == 1 { //对接了医保,走医保流程
  6908. var res ResultFour
  6909. var resFour10265 ResultFour10265
  6910. if miConfig.MdtrtareaAdmvs == "421300" {
  6911. bytesData, _ := json.Marshal(data)
  6912. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6913. resp, _ := client.Do(req)
  6914. defer resp.Body.Close()
  6915. body, ioErr := ioutil.ReadAll(resp.Body)
  6916. if ioErr != nil {
  6917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6919. return
  6920. }
  6921. var respJSON map[string]interface{}
  6922. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return
  6926. }
  6927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6928. userJSONBytes, _ := json.Marshal(respJSON)
  6929. fmt.Println("log")
  6930. fmt.Println(string(userJSONBytes))
  6931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6932. utils.ErrorLog("解析失败:%v", err)
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. return
  6935. }
  6936. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6937. bytesData, _ := json.Marshal(data)
  6938. var req *http.Request
  6939. if miConfig.MdtrtareaAdmvs == "320921" {
  6940. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6941. } else {
  6942. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6943. }
  6944. resp, _ := client.Do(req)
  6945. defer resp.Body.Close()
  6946. body, ioErr := ioutil.ReadAll(resp.Body)
  6947. if ioErr != nil {
  6948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6950. return
  6951. }
  6952. var respJSON map[string]interface{}
  6953. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. return
  6957. }
  6958. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6959. userJSONBytes, _ := json.Marshal(respJSON)
  6960. fmt.Println("log")
  6961. fmt.Println(string(userJSONBytes))
  6962. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6963. utils.ErrorLog("解析失败:%v", err)
  6964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6965. return
  6966. }
  6967. res.InfRefmsgid = resFour10265.InfRefmsgid
  6968. res.Output = resFour10265.Output
  6969. res.ErrMsg = resFour10265.ErrMsg
  6970. res.Cainfo = resFour10265.Cainfo
  6971. res.WarnMsg = resFour10265.WarnMsg
  6972. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6973. res.Infcode = infocode
  6974. } else {
  6975. if miConfig.Code == "H15049901371" {
  6976. 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)
  6977. var dat map[string]interface{}
  6978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6979. fmt.Println(dat)
  6980. } else {
  6981. fmt.Println(err)
  6982. }
  6983. saveLog(result, request_log, "2204", "上传费用明细")
  6984. userJSONBytes, _ := json.Marshal(dat)
  6985. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6986. utils.ErrorLog("解析失败:%v", err)
  6987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6988. return
  6989. }
  6990. res.InfRefmsgid = resFour10265.InfRefmsgid
  6991. res.Output = resFour10265.Output
  6992. res.ErrMsg = resFour10265.ErrMsg
  6993. res.Cainfo = resFour10265.Cainfo
  6994. res.WarnMsg = resFour10265.WarnMsg
  6995. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6996. res.Infcode = infocode
  6997. } else {
  6998. 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)
  6999. var dat map[string]interface{}
  7000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7001. fmt.Println(dat)
  7002. } else {
  7003. fmt.Println(err)
  7004. }
  7005. saveLog(result, request_log, "2204", "上传费用明细")
  7006. userJSONBytes, _ := json.Marshal(dat)
  7007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7008. utils.ErrorLog("解析失败:%v", err)
  7009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7010. return
  7011. }
  7012. }
  7013. }
  7014. if res.Infcode == 0 {
  7015. order := &models.HisOrder{
  7016. UserOrgId: adminUser.CurrentOrgId,
  7017. HisPatientId: his.ID,
  7018. PatientId: his.PatientId,
  7019. SettleAccountsDate: recordDateTime,
  7020. Ctime: time.Now().Unix(),
  7021. Mtime: time.Now().Unix(),
  7022. MdtrtId: his.Number,
  7023. PsnNo: his.PsnNo,
  7024. MedType: strconv.FormatInt(reg_type, 10),
  7025. Status: 1,
  7026. Number: chrg_bchno,
  7027. Infcode: res.Infcode,
  7028. WarnMsg: res.WarnMsg,
  7029. Cainfo: res.Cainfo,
  7030. ErrMsg: res.ErrMsg,
  7031. RespondTime: res.RefmsgTime,
  7032. InfRefmsgid: res.InfRefmsgid,
  7033. OrderStatus: 1,
  7034. IsMedicineInsurance: 1,
  7035. SettleType: settle_accounts_type,
  7036. SettleStartTime: start_time,
  7037. SettleEndTime: end_time,
  7038. Creator: roles.AdminUserId,
  7039. Modify: roles.AdminUserId,
  7040. PType: 2,
  7041. Diagnosis: diagnosis_id,
  7042. }
  7043. err = service.CreateOrder(order)
  7044. if err != nil {
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7046. return
  7047. }
  7048. for _, item := range res.Output.Result {
  7049. temp := strings.Split(item.FeedetlSn, "-")
  7050. var advice_id int64 = 0
  7051. var project_id int64 = 0
  7052. var types int64 = 0
  7053. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7054. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7055. if temp[1] == "1" {
  7056. advice_id = id
  7057. project_id = 0
  7058. } else if temp[1] == "2" {
  7059. advice_id = 0
  7060. project_id = id
  7061. }
  7062. info := &models.HisOrderInfo{
  7063. OrderNumber: order.Number,
  7064. FeedetlSn: item.FeedetlSn,
  7065. UploadDate: time.Now().Unix(),
  7066. AdviceId: advice_id,
  7067. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7068. Cnt: item.Cnt,
  7069. Pric: float64(item.Pric),
  7070. PatientId: his.PatientId,
  7071. PricUplmtAmt: item.PricUplmtAmt,
  7072. SelfpayProp: item.SelfpayProp,
  7073. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7074. OverlmtAmt: item.OverlmtAmt,
  7075. PreselfpayAmt: item.PreselfpayAmt,
  7076. BasMednFlag: item.BasMednFlag,
  7077. MedChrgitmType: item.MedChrgitmType,
  7078. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7079. Status: 1,
  7080. Memo: item.Memo,
  7081. Mtime: time.Now().Unix(),
  7082. InscpScpAmt: item.InscpScpAmt,
  7083. DrtReimFlag: item.DrtReimFlag,
  7084. Ctime: time.Now().Unix(),
  7085. ListSpItemFlag: item.ListSpItemFlag,
  7086. ChldMedcFlag: item.ChldMedcFlag,
  7087. LmtUsedFlag: item.LmtUsedFlag,
  7088. ChrgitmLv: item.ChrgitmLv,
  7089. UserOrgId: adminUser.CurrentOrgId,
  7090. HisPatientId: his.ID,
  7091. OrderId: order.ID,
  7092. ProjectId: project_id,
  7093. Type: types,
  7094. }
  7095. service.CreateOrderInfo(info)
  7096. }
  7097. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7098. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7099. var total float64
  7100. for _, item := range prescriptions {
  7101. if item.Type == 1 { //药品
  7102. for _, subItem := range item.HisDoctorAdviceInfo {
  7103. total = total + (subItem.Price * subItem.PrescribingNumber)
  7104. }
  7105. }
  7106. if item.Type == 2 { //项目
  7107. for _, subItem := range item.HisPrescriptionProject {
  7108. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7109. total = total + (subItem.Price * cnt)
  7110. }
  7111. }
  7112. }
  7113. for _, item := range prescriptions {
  7114. for _, subItem := range item.HisAdditionalCharge {
  7115. total = total + (subItem.Price * float64(subItem.Count))
  7116. }
  7117. }
  7118. allTotal := fmt.Sprintf("%.4f", total)
  7119. if res.Infcode == 0 {
  7120. var rf []*ResultFive
  7121. json.Unmarshal([]byte(his.Iinfo), &rf)
  7122. chrg_bchno := chrg_bchno
  7123. cert_no := his.Certno
  7124. var insutypes []string
  7125. var insutype string
  7126. var is390 int = 0
  7127. var is310 int = 0
  7128. for _, item := range rf {
  7129. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7130. insutypes = append(insutypes, item.Insutype)
  7131. }
  7132. }
  7133. if len(insutypes) == 1 {
  7134. insutype = insutypes[0]
  7135. } else {
  7136. for _, i := range insutypes {
  7137. if i == "390" {
  7138. is390 = 1
  7139. }
  7140. if i == "310" {
  7141. is310 = 1
  7142. }
  7143. }
  7144. }
  7145. if is390 == 1 {
  7146. insutype = "390"
  7147. }
  7148. if is310 == 1 {
  7149. insutype = "310"
  7150. }
  7151. if len(insutypes) == 0 {
  7152. insutype = "310"
  7153. }
  7154. if len(insutypes) == 2 {
  7155. insutype = strconv.FormatInt(his.SocialType, 64)
  7156. }
  7157. //insutype = "390"
  7158. if his.IdCardType == 1 {
  7159. cert_no = his.MedicalInsuranceNumber
  7160. } else {
  7161. cert_no = his.Certno
  7162. }
  7163. var res ResultSeven
  7164. var resSeven10265 ResultSeven10265
  7165. if miConfig.MdtrtareaAdmvs == "421300" {
  7166. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7167. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7168. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7169. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7170. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7171. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7172. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7173. resp, requestErr := http.Get(api)
  7174. if requestErr != nil {
  7175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7176. return
  7177. }
  7178. body, ioErr := ioutil.ReadAll(resp.Body)
  7179. if ioErr != nil {
  7180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7182. return
  7183. }
  7184. var respJSON map[string]interface{}
  7185. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7188. return
  7189. }
  7190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7191. result, _ := json.Marshal(respJSON)
  7192. fmt.Println("log")
  7193. fmt.Println(string(result))
  7194. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7195. utils.ErrorLog("解析失败:%v", err)
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7200. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7201. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7202. bas := strings.Split(psn_info.CardInfo, "|")
  7203. if his.IdCardType == 1 {
  7204. cert_no = bas[2]
  7205. } else {
  7206. cert_no = bas[1]
  7207. }
  7208. //江苏地区国家医保医疗类别
  7209. //职工透析:医疗类别选特殊情况门诊9933
  7210. //居民血透门慢: 医疗类别选门诊慢病1402
  7211. //var med_type string
  7212. //if his.Insutype == "310" {
  7213. // if reg_type == 14 {
  7214. // med_type = "9933"
  7215. // } else if reg_type == 11 {
  7216. // med_type = "11"
  7217. //
  7218. // }
  7219. //} else if his.Insutype == "390" {
  7220. // if reg_type == 14 {
  7221. // med_type = "1402"
  7222. // } else if reg_type == 11 {
  7223. // med_type = "11"
  7224. // }
  7225. //}
  7226. var api string
  7227. if miConfig.MdtrtareaAdmvs == "320921" {
  7228. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7229. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7230. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7231. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7232. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7233. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7234. "&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
  7235. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7236. } else {
  7237. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7238. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7239. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7240. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7241. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7242. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7243. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7244. "&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
  7245. }
  7246. resp, requestErr := http.Get(api)
  7247. if requestErr != nil {
  7248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7249. return
  7250. }
  7251. body, ioErr := ioutil.ReadAll(resp.Body)
  7252. if ioErr != nil {
  7253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. var respJSON map[string]interface{}
  7258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7264. result, _ := json.Marshal(respJSON)
  7265. fmt.Println("log")
  7266. fmt.Println(string(result))
  7267. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7268. utils.ErrorLog("解析失败:%v", err)
  7269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7270. return
  7271. }
  7272. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7273. res.Output = resSeven10265.Output
  7274. res.ErrMsg = resSeven10265.ErrMsg
  7275. res.Cainfo = resSeven10265.Cainfo
  7276. res.WarnMsg = resSeven10265.WarnMsg
  7277. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7278. res.Infcode = infocode
  7279. } else {
  7280. var result string
  7281. var request_log string
  7282. if miConfig.Code == "H15049901371" {
  7283. //赤峰地区国家医保医疗类别
  7284. //职工透析:医疗类别选特殊情况门诊990502
  7285. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7286. var med_type string
  7287. if his.Insutype == "390" {
  7288. if reg_type == 14 {
  7289. med_type = "9933"
  7290. } else if reg_type == 11 {
  7291. med_type = "11"
  7292. }
  7293. } else if his.Insutype == "310" {
  7294. if reg_type == 14 {
  7295. med_type = "990502"
  7296. } else if reg_type == 11 {
  7297. med_type = "11"
  7298. }
  7299. }
  7300. 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)
  7301. } else {
  7302. 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)
  7303. }
  7304. var dat map[string]interface{}
  7305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7306. fmt.Println(dat)
  7307. } else {
  7308. fmt.Println(err)
  7309. }
  7310. saveLog(result, request_log, "2206", "预结算")
  7311. //userJSONBytes, _ := json.Marshal(dat)
  7312. //
  7313. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7314. // utils.ErrorLog("解析失败:%v", err)
  7315. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7316. // return
  7317. //}
  7318. userJSONBytes, _ := json.Marshal(dat)
  7319. if miConfig.Code == "H15049901371" {
  7320. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7321. utils.ErrorLog("解析失败:%v", err)
  7322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7323. return
  7324. }
  7325. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7326. res.Output = resSeven10265.Output
  7327. res.ErrMsg = resSeven10265.ErrMsg
  7328. res.Cainfo = resSeven10265.Cainfo
  7329. res.WarnMsg = resSeven10265.WarnMsg
  7330. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7331. res.Infcode = infocode
  7332. } else {
  7333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7334. utils.ErrorLog("解析失败:%v", err)
  7335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7336. return
  7337. }
  7338. }
  7339. }
  7340. if res.Infcode != 0 {
  7341. errlog := &models.HisOrderError{
  7342. UserOrgId: adminUser.CurrentOrgId,
  7343. Ctime: time.Now().Unix(),
  7344. Mtime: time.Now().Unix(),
  7345. Number: chrg_bchno,
  7346. ErrMsg: res.ErrMsg,
  7347. Status: 1,
  7348. PatientId: id,
  7349. RecordTime: recordDateTime,
  7350. Stage: 20,
  7351. }
  7352. service.CreateErrMsgLog(errlog)
  7353. c.ServeSuccessJSON(map[string]interface{}{
  7354. "failed_code": -10,
  7355. "msg": res.ErrMsg,
  7356. })
  7357. return
  7358. } else {
  7359. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7360. order.OrderStatus = 1
  7361. order.IsPre = 1
  7362. order.Status = 1
  7363. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7364. order.SetlId = res.Output.Setlinfo.SetlID
  7365. order.PsnNo = res.Output.Setlinfo.PsnNo
  7366. order.PsnName = res.Output.Setlinfo.PsnName
  7367. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7368. order.Certno = res.Output.Setlinfo.Certno
  7369. order.Gend = res.Output.Setlinfo.Gend
  7370. order.Naty = res.Output.Setlinfo.Naty
  7371. order.Age = res.Output.Setlinfo.Age
  7372. order.Insutype = res.Output.Setlinfo.Insutype
  7373. order.PsnType = res.Output.Setlinfo.PsnType
  7374. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7375. order.SetlTime = res.Output.Setlinfo.SetlTime
  7376. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7377. if res.Output.Setlinfo.MedType == "140101" {
  7378. order.MedType = "14"
  7379. } else {
  7380. order.MedType = res.Output.Setlinfo.MedType
  7381. }
  7382. if reg_type == 1112 {
  7383. order.MedType = "1112"
  7384. }
  7385. if reg_type == 1111 {
  7386. order.MedType = "1111"
  7387. }
  7388. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7389. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7390. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7391. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7392. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7393. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7394. order.HifpPay = res.Output.Setlinfo.HifpPay
  7395. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7396. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7397. order.HifesPay = res.Output.Setlinfo.HifesPay
  7398. order.HifobPay = res.Output.Setlinfo.HifobPay
  7399. order.MafPay = res.Output.Setlinfo.MafPay
  7400. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7401. order.OthPay = res.Output.Setlinfo.OthPay
  7402. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7403. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7404. order.AcctPay = res.Output.Setlinfo.AcctPay
  7405. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7406. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7407. order.Balc = res.Output.Setlinfo.Balc
  7408. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7409. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7410. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7411. order.ClrWay = res.Output.Setlinfo.ClrWay
  7412. order.Creator = order.Creator
  7413. order.Modify = roles.AdminUserId
  7414. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7415. detailStr := string(setlDetail)
  7416. order.SetlDetail = detailStr
  7417. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7418. err = service.UpDateOrder(order)
  7419. if err == nil {
  7420. c.ServeSuccessJSON(map[string]interface{}{
  7421. "msg": "预结算成功",
  7422. })
  7423. } else {
  7424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7425. return
  7426. }
  7427. }
  7428. } else {
  7429. adminUser := c.GetAdminUserInfo()
  7430. errlog := &models.HisOrderError{
  7431. UserOrgId: adminUser.CurrentOrgId,
  7432. Ctime: time.Now().Unix(),
  7433. Mtime: time.Now().Unix(),
  7434. ErrMsg: res.ErrMsg,
  7435. Status: 1,
  7436. PatientId: id,
  7437. RecordTime: recordDateTime,
  7438. Stage: 4,
  7439. }
  7440. service.CreateErrMsgLog(errlog)
  7441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7442. return
  7443. }
  7444. } else {
  7445. adminUser := c.GetAdminUserInfo()
  7446. errlog := &models.HisOrderError{
  7447. UserOrgId: adminUser.CurrentOrgId,
  7448. Ctime: time.Now().Unix(),
  7449. Mtime: time.Now().Unix(),
  7450. ErrMsg: res.ErrMsg,
  7451. Status: 1,
  7452. PatientId: id,
  7453. RecordTime: recordDateTime,
  7454. Stage: 4,
  7455. }
  7456. service.CreateErrMsgLog(errlog)
  7457. c.ServeSuccessJSON(map[string]interface{}{
  7458. "failed_code": -10,
  7459. "msg": res.ErrMsg,
  7460. })
  7461. return
  7462. }
  7463. }
  7464. }
  7465. }
  7466. //func (c *HisApiController) GetSettleInfo() {
  7467. // id, _ := c.GetInt64("id")
  7468. // order_id, _ := c.GetInt64("order_id")
  7469. //
  7470. // record_time := c.GetString("record_time")
  7471. // pay_way, _ := c.GetInt64("pay_way")
  7472. // pay_price, _ := c.GetFloat("pay_price")
  7473. // pay_card_no := c.GetString("pay_card_no")
  7474. // discount_price, _ := c.GetFloat("discount_price")
  7475. // preferential_price, _ := c.GetFloat("preferential_price")
  7476. // reality_price, _ := c.GetFloat("reality_price")
  7477. // found_price, _ := c.GetFloat("found_price")
  7478. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7479. // private_price, _ := c.GetFloat("private_price")
  7480. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7481. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7482. //
  7483. // timeLayout := "2006-01-02"
  7484. // loc, _ := time.LoadLocation("Local")
  7485. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7486. // if err != nil {
  7487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7488. // return
  7489. // }
  7490. // recordDateTime := theTime.Unix()
  7491. // adminUser := c.GetAdminUserInfo()
  7492. //
  7493. // var prescriptions []*models.HisPrescription
  7494. //
  7495. // data := make(map[string]interface{})
  7496. // if settle_accounts_type == 1 { //日结
  7497. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7498. // data["pre"] = prescriptions
  7499. //
  7500. // } else { //月结
  7501. // start_time_str := c.GetString("start_time")
  7502. // end_time_str := c.GetString("end_time")
  7503. // timeLayout := "2006-01-02"
  7504. // loc, _ := time.LoadLocation("Local")
  7505. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7506. // if err != nil {
  7507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7508. // return
  7509. // }
  7510. // recordStartTime := theStartTime.Unix()
  7511. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7512. // if err != nil {
  7513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7514. // return
  7515. // }
  7516. // recordEndTime := theEndTime.Unix()
  7517. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7518. // data["pre"] = prescriptions
  7519. //
  7520. // }
  7521. //
  7522. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7523. //
  7524. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7525. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7526. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7527. // strconv.FormatInt(his.PatientId, 10)
  7528. //
  7529. // order_src, _ := service.GetHisOrderByID(order_id)
  7530. //
  7531. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7532. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7533. //
  7534. // var total float64
  7535. // for _, item := range prescriptions {
  7536. // if item.Type == 1 { //药品
  7537. // for _, subItem := range item.HisDoctorAdviceInfo {
  7538. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7539. // }
  7540. // }
  7541. // if item.Type == 2 { //项目
  7542. // for _, subItem := range item.HisPrescriptionProject {
  7543. // total = total + (subItem.Price * float64(subItem.Count))
  7544. // }
  7545. // }
  7546. // }
  7547. //
  7548. // for _, item := range prescriptions {
  7549. // for _, subItem := range item.HisAdditionalCharge {
  7550. // total = total + (subItem.Price * float64(subItem.Count))
  7551. // }
  7552. // }
  7553. //
  7554. // allTotal := fmt.Sprintf("%.2f", total)
  7555. // var rf []*ResultFive
  7556. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7557. // psn_no := order_src.PsnNo
  7558. // mdtrt_id := order_src.MdtrtId
  7559. // chrg_bchno := order_src.Number
  7560. // cert_no := order_src.Certno
  7561. // insutype := rf[0].Insutype
  7562. //
  7563. // if his.IdCardType == 1 {
  7564. // cert_no = his.MedicalInsuranceNumber
  7565. // } else {
  7566. // cert_no = his.Certno
  7567. // }
  7568. //
  7569. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  7570. // var dat map[string]interface{}
  7571. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7572. // fmt.Println(dat)
  7573. // } else {
  7574. // fmt.Println(err)
  7575. // }
  7576. //
  7577. // userJSONBytes, _ := json.Marshal(dat)
  7578. //
  7579. //
  7580. //
  7581. // var res ResultSeven
  7582. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7583. // utils.ErrorLog("解析失败:%v", err)
  7584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. // return
  7586. // }
  7587. // if res.Infcode == -1 {
  7588. // errlog := &models.HisOrderError{
  7589. // UserOrgId: adminUser.CurrentOrgId,
  7590. // Ctime: time.Now().Unix(),
  7591. // Mtime: time.Now().Unix(),
  7592. // Number: chrg_bchno,
  7593. // ErrMsg: res.ErrMsg,
  7594. // Status: 1,
  7595. // PatientId: id,
  7596. // RecordTime: recordDateTime,
  7597. // Stage: 6,
  7598. // }
  7599. // service.CreateErrMsgLog(errlog)
  7600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7601. // return
  7602. // } else {
  7603. // order_src.OrderStatus = 2
  7604. // order_src.PayWay = pay_way
  7605. // order_src.PayPrice = pay_price
  7606. // order_src.PayCardNo = pay_card_no
  7607. // order_src.DiscountPrice = discount_price
  7608. // order_src.PreferentialPrice = preferential_price
  7609. // order_src.RealityPrice = reality_price
  7610. // order_src.FoundPrice = found_price
  7611. // order_src.MedicalInsurancePrice = medical_insurance_price
  7612. // order_src.PrivatePrice = private_price
  7613. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7614. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7615. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7616. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7617. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7618. // order_src.Certno = res.Output.Setlinfo.Certno
  7619. // order_src.Gend = res.Output.Setlinfo.Gend
  7620. // order_src.Naty = res.Output.Setlinfo.Naty
  7621. // order_src.Age = res.Output.Setlinfo.Age
  7622. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7623. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7624. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7625. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7626. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7627. // order_src.MedType = res.Output.Setlinfo.MedType
  7628. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7629. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7630. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7631. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7632. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7633. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7634. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7635. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7636. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7637. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7638. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7639. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7640. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7641. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7642. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7643. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7644. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7645. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7646. // order_src.Balc = res.Output.Setlinfo.Balc
  7647. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7648. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7649. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7650. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7651. // order_src.Creator = order_src.Creator
  7652. // order_src.Modify = roles.ID
  7653. // order_src.RequestLog = src_resquest
  7654. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7655. // detailStr := string(setlDetail)
  7656. // order_src.SetlDetail = detailStr
  7657. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7658. // err = service.UpDateOrder(order_src)
  7659. //
  7660. // if err == nil {
  7661. // c.ServeSuccessJSON(map[string]interface{}{
  7662. // "msg": "结算成功",
  7663. // })
  7664. // } else {
  7665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7666. // return
  7667. // }
  7668. // }
  7669. // }
  7670. //}
  7671. //退款
  7672. func (c *HisApiController) Refund() {
  7673. order_id, _ := c.GetInt64("order_id")
  7674. admin_user_id, _ := c.GetInt64("admin_user_id")
  7675. adminUser := c.GetAdminUserInfo()
  7676. var order models.HisOrder
  7677. order, _ = service.GetHisOrderByID(order_id)
  7678. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7679. if order.ID == 0 {
  7680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7681. return
  7682. }
  7683. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7684. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7685. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7686. if config.IsOpen == 1 { //对接了医保,走医保流程
  7687. var res ResultSixteen
  7688. var resSixteen10265 ResultSixteen10265
  7689. var src_resquest string
  7690. var result string
  7691. if miConfig.MdtrtareaAdmvs == "421300" {
  7692. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7693. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7694. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7695. resp3, requestErr3 := http.Get(api3)
  7696. if requestErr3 != nil {
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. return
  7699. }
  7700. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7701. if ioErr3 != nil {
  7702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7704. return
  7705. }
  7706. var respJSON3 map[string]interface{}
  7707. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7710. return
  7711. }
  7712. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7713. userJSONBytes3, _ := json.Marshal(respJSON3)
  7714. fmt.Println("log")
  7715. fmt.Println(string(userJSONBytes3))
  7716. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7717. utils.ErrorLog("解析失败:%v", err)
  7718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7719. return
  7720. }
  7721. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7722. var api3 string
  7723. if miConfig.MdtrtareaAdmvs == "320921" {
  7724. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7725. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7726. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7727. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7728. } else {
  7729. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7730. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7731. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7732. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7733. }
  7734. resp3, requestErr3 := http.Get(api3)
  7735. if requestErr3 != nil {
  7736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7737. return
  7738. }
  7739. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7740. if ioErr3 != nil {
  7741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7743. return
  7744. }
  7745. var respJSON3 map[string]interface{}
  7746. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7749. return
  7750. }
  7751. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7752. userJSONBytes3, _ := json.Marshal(respJSON3)
  7753. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7754. utils.ErrorLog("解析失败:%v", err)
  7755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7756. return
  7757. }
  7758. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7759. res.Output = resSixteen10265.Output
  7760. res.ErrMsg = resSixteen10265.ErrMsg
  7761. res.Cainfo = resSixteen10265.Cainfo
  7762. res.WarnMsg = resSixteen10265.WarnMsg
  7763. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7764. res.Infcode = infocode
  7765. } else {
  7766. if miConfig.Code == "H15049901371" {
  7767. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7768. var dat map[string]interface{}
  7769. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7770. fmt.Println(dat)
  7771. } else {
  7772. fmt.Println(err)
  7773. }
  7774. saveLog(result, src_resquest, "2208", "退费")
  7775. userJSONBytes, _ := json.Marshal(dat)
  7776. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7777. utils.ErrorLog("解析失败:%v", err)
  7778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7779. return
  7780. }
  7781. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7782. res.Output = resSixteen10265.Output
  7783. res.ErrMsg = resSixteen10265.ErrMsg
  7784. res.Cainfo = resSixteen10265.Cainfo
  7785. res.WarnMsg = resSixteen10265.WarnMsg
  7786. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7787. res.Infcode = infocode
  7788. } else {
  7789. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  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, src_resquest, "2208", "退费")
  7797. userJSONBytes, _ := json.Marshal(dat)
  7798. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7799. utils.ErrorLog("解析失败:%v", err)
  7800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7801. return
  7802. }
  7803. }
  7804. }
  7805. if res.Infcode == 0 {
  7806. var res2 ResultSix
  7807. var resSix10265 ResultSix10265
  7808. if miConfig.MdtrtareaAdmvs == "421300" {
  7809. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7810. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7811. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7812. resp3, requestErr3 := http.Get(api3)
  7813. if requestErr3 != nil {
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. return
  7816. }
  7817. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7818. if ioErr3 != nil {
  7819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7821. return
  7822. }
  7823. var respJSON3 map[string]interface{}
  7824. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7827. return
  7828. }
  7829. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7830. userJSONBytes3, _ := json.Marshal(respJSON3)
  7831. fmt.Println("log")
  7832. fmt.Println(string(userJSONBytes3))
  7833. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7834. utils.ErrorLog("解析失败:%v", err)
  7835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7836. return
  7837. }
  7838. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7839. var api3 string
  7840. if miConfig.MdtrtareaAdmvs == "320921" {
  7841. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7842. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7844. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7845. } else {
  7846. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7847. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7848. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7849. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7850. }
  7851. resp3, requestErr3 := http.Get(api3)
  7852. if requestErr3 != nil {
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7854. return
  7855. }
  7856. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7857. if ioErr3 != nil {
  7858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7860. return
  7861. }
  7862. var respJSON3 map[string]interface{}
  7863. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7866. return
  7867. }
  7868. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7869. userJSONBytes3, _ := json.Marshal(respJSON3)
  7870. fmt.Println("log")
  7871. fmt.Println(string(userJSONBytes3))
  7872. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7873. utils.ErrorLog("解析失败:%v", err)
  7874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7875. return
  7876. }
  7877. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7878. res2.Output = resSix10265.Output
  7879. res2.ErrMsg = resSix10265.ErrMsg
  7880. res2.Cainfo = resSix10265.Cainfo
  7881. res2.WarnMsg = resSix10265.WarnMsg
  7882. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7883. res2.Infcode = infocode
  7884. } else {
  7885. if miConfig.Code == "H15049901371" {
  7886. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7887. var dat map[string]interface{}
  7888. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7889. fmt.Println(dat)
  7890. } else {
  7891. fmt.Println(err)
  7892. }
  7893. saveLog(result2, src_request, "2205", "撤销明细")
  7894. userJSONBytes, _ := json.Marshal(dat)
  7895. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7896. utils.ErrorLog("解析失败:%v", err)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7901. res2.Output = resSix10265.Output
  7902. res2.ErrMsg = resSix10265.ErrMsg
  7903. res2.Cainfo = resSix10265.Cainfo
  7904. res2.WarnMsg = resSix10265.WarnMsg
  7905. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7906. res2.Infcode = infocode
  7907. } else {
  7908. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7909. var dat map[string]interface{}
  7910. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7911. fmt.Println(dat)
  7912. } else {
  7913. fmt.Println(err)
  7914. }
  7915. saveLog(result2, src_request, "2205", "撤销明细")
  7916. userJSONBytes, _ := json.Marshal(dat)
  7917. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7918. utils.ErrorLog("解析失败:%v", err)
  7919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7920. return
  7921. }
  7922. }
  7923. }
  7924. if res2.Infcode == 0 {
  7925. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7926. if err == nil {
  7927. //当押金不为零时产生退费记录
  7928. if order.Decimal != 0 {
  7929. tmp := strconv.FormatInt(order.ID, 10)
  7930. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7931. if err != nil {
  7932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7933. return
  7934. }
  7935. }
  7936. c.ServeSuccessJSON(map[string]interface{}{
  7937. "msg": "退费成功",
  7938. })
  7939. } else {
  7940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7941. return
  7942. }
  7943. } else {
  7944. c.ServeSuccessJSON(map[string]interface{}{
  7945. "code": -10,
  7946. "msg": res2.ErrMsg,
  7947. })
  7948. }
  7949. } else {
  7950. c.ServeSuccessJSON(map[string]interface{}{
  7951. "code": -10,
  7952. "msg": res.ErrMsg,
  7953. })
  7954. }
  7955. }
  7956. }
  7957. func (c *HisApiController) RefundNumber() {
  7958. record_time := c.GetString("record_time")
  7959. //patient_id, _ := c.GetInt64("patient_id")
  7960. admin_user_id, _ := c.GetInt64("admin_user_id")
  7961. his_patient_id, _ := c.GetInt64("id")
  7962. timeLayout := "2006-01-02"
  7963. loc, _ := time.LoadLocation("Local")
  7964. adminUser := c.GetAdminUserInfo()
  7965. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7966. fmt.Println(err)
  7967. if err != nil {
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7969. return
  7970. }
  7971. recordDateTime := theTime.Unix()
  7972. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7973. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7974. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7975. //order, _ := service.GetHisOrderByID(order_id)
  7976. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7977. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7978. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7979. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7980. if count > 0 {
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7982. return
  7983. }
  7984. if config.IsOpen == 1 { //对接了医保,走医保流程
  7985. var res2 ResultSix
  7986. var resSix10265 ResultSix10265
  7987. if miConfig.MdtrtareaAdmvs == "421300" {
  7988. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7989. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7991. resp3, requestErr3 := http.Get(api3)
  7992. if requestErr3 != nil {
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7994. return
  7995. }
  7996. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7997. if ioErr3 != nil {
  7998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. return
  8001. }
  8002. var respJSON3 map[string]interface{}
  8003. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. return
  8007. }
  8008. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8009. userJSONBytes3, _ := json.Marshal(respJSON3)
  8010. fmt.Println("log")
  8011. fmt.Println(string(userJSONBytes3))
  8012. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8013. utils.ErrorLog("解析失败:%v", err)
  8014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8015. return
  8016. }
  8017. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8018. var api3 string
  8019. if miConfig.MdtrtareaAdmvs == "320921" {
  8020. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8021. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8022. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8023. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8024. } else {
  8025. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8026. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8027. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8028. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8029. }
  8030. resp3, requestErr3 := http.Get(api3)
  8031. if requestErr3 != nil {
  8032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8033. return
  8034. }
  8035. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8036. if ioErr3 != nil {
  8037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8039. return
  8040. }
  8041. var respJSON3 map[string]interface{}
  8042. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8045. return
  8046. }
  8047. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8048. userJSONBytes3, _ := json.Marshal(respJSON3)
  8049. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8050. utils.ErrorLog("解析失败:%v", err)
  8051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8052. return
  8053. }
  8054. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8055. res2.Output = resSix10265.Output
  8056. res2.ErrMsg = resSix10265.ErrMsg
  8057. res2.Cainfo = resSix10265.Cainfo
  8058. res2.WarnMsg = resSix10265.WarnMsg
  8059. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8060. res2.Infcode = infocode
  8061. } else {
  8062. var api3 string
  8063. if miConfig.Code == "H15049901371" {
  8064. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8065. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8066. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8067. } else {
  8068. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8069. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8070. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8071. }
  8072. resp3, requestErr3 := http.Get(api3)
  8073. if requestErr3 != nil {
  8074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. return
  8076. }
  8077. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8078. if ioErr3 != nil {
  8079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. return
  8082. }
  8083. var respJSON3 map[string]interface{}
  8084. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8090. userJSONBytes3, _ := json.Marshal(respJSON3)
  8091. if miConfig.Code == "H15049901371" {
  8092. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8093. utils.ErrorLog("解析失败:%v", err)
  8094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8095. return
  8096. }
  8097. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8098. res2.Output = resSix10265.Output
  8099. res2.ErrMsg = resSix10265.ErrMsg
  8100. res2.Cainfo = resSix10265.Cainfo
  8101. res2.WarnMsg = resSix10265.WarnMsg
  8102. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8103. res2.Infcode = infocode
  8104. } else {
  8105. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8106. utils.ErrorLog("解析失败:%v", err)
  8107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8108. return
  8109. }
  8110. }
  8111. }
  8112. if res2.Infcode == 0 {
  8113. if err == nil {
  8114. c.ServeSuccessJSON(map[string]interface{}{
  8115. "msg": "退号成功",
  8116. })
  8117. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8118. } else {
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8120. return
  8121. }
  8122. } else {
  8123. c.ServeSuccessJSON(map[string]interface{}{
  8124. "code": -10,
  8125. "msg": res2.ErrMsg,
  8126. })
  8127. }
  8128. } else {
  8129. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8130. //if err == nil {
  8131. // c.ServeSuccessJSON(map[string]interface{}{
  8132. // "msg": "退费成功",
  8133. // })
  8134. //} else {
  8135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8136. // return
  8137. //}
  8138. }
  8139. }
  8140. func (c *HisApiController) RefundDetail() {
  8141. order_id, _ := c.GetInt64("order_id")
  8142. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8143. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8144. number := c.GetString("number")
  8145. record_time := c.GetString("record_time")
  8146. patient_id, _ := c.GetInt64("patient_id")
  8147. //med_type, _ := c.GetInt64("med_type")
  8148. timeLayout := "2006-01-02"
  8149. loc, _ := time.LoadLocation("Local")
  8150. adminUser := c.GetAdminUserInfo()
  8151. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8152. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8153. fmt.Println(err)
  8154. if err != nil {
  8155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8156. return
  8157. }
  8158. recordDateTime := theTime.Unix()
  8159. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8160. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8161. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8162. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8163. var order models.HisOrder
  8164. order, _ = service.GetHisOrderByID(order_id)
  8165. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8166. if config.IsOpen == 1 { //对接了医保,走医保流程
  8167. var res2 ResultSix
  8168. if miConfig.MdtrtareaAdmvs == "421300" {
  8169. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8170. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8171. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8172. resp3, requestErr3 := http.Get(api3)
  8173. if requestErr3 != nil {
  8174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8175. return
  8176. }
  8177. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8178. if ioErr3 != nil {
  8179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8181. return
  8182. }
  8183. var respJSON3 map[string]interface{}
  8184. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8187. return
  8188. }
  8189. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8190. userJSONBytes3, _ := json.Marshal(respJSON3)
  8191. fmt.Println("log")
  8192. fmt.Println(string(userJSONBytes3))
  8193. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8194. utils.ErrorLog("解析失败:%v", err)
  8195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8196. return
  8197. }
  8198. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8199. if err == nil {
  8200. c.ServeSuccessJSON(map[string]interface{}{
  8201. "msg": "撤销明细成功",
  8202. })
  8203. return
  8204. } else {
  8205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8206. return
  8207. }
  8208. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8209. var resSix10265 ResultSix10265
  8210. var api3 string
  8211. if miConfig.MdtrtareaAdmvs == "320921" {
  8212. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8213. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8214. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8215. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8216. } else {
  8217. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8218. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8219. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8220. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8221. }
  8222. resp3, requestErr3 := http.Get(api3)
  8223. if requestErr3 != nil {
  8224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8225. return
  8226. }
  8227. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8228. if ioErr3 != nil {
  8229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8231. return
  8232. }
  8233. var respJSON3 map[string]interface{}
  8234. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8237. return
  8238. }
  8239. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8240. userJSONBytes3, _ := json.Marshal(respJSON3)
  8241. fmt.Println("log")
  8242. fmt.Println(string(userJSONBytes3))
  8243. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8244. utils.ErrorLog("解析失败:%v", err)
  8245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8246. return
  8247. }
  8248. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8249. res2.Output = resSix10265.Output
  8250. res2.ErrMsg = resSix10265.ErrMsg
  8251. res2.Cainfo = resSix10265.Cainfo
  8252. res2.WarnMsg = resSix10265.WarnMsg
  8253. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8254. res2.Infcode = infocode
  8255. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8256. if err == nil {
  8257. c.ServeSuccessJSON(map[string]interface{}{
  8258. "msg": "撤销明细成功",
  8259. })
  8260. return
  8261. } else {
  8262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8263. return
  8264. }
  8265. } else {
  8266. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8267. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8268. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8269. resp2, requestErr2 := http.Get(api2)
  8270. if requestErr2 != nil {
  8271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8272. return
  8273. }
  8274. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8275. if ioErr2 != nil {
  8276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8278. return
  8279. }
  8280. var respJSON2 map[string]interface{}
  8281. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8284. return
  8285. }
  8286. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8287. if err == nil {
  8288. c.ServeSuccessJSON(map[string]interface{}{
  8289. "msg": "撤销明细成功",
  8290. })
  8291. return
  8292. } else {
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. }
  8297. } else {
  8298. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8299. if err == nil {
  8300. c.ServeSuccessJSON(map[string]interface{}{
  8301. "msg": "退费成功",
  8302. })
  8303. } else {
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. }
  8308. }
  8309. //对账
  8310. func (c *HisApiController) GetCheckAccount() {
  8311. start_time := c.GetString("start_time")
  8312. end_time := c.GetString("end_time")
  8313. insutype := c.GetString("insutype")
  8314. clr_type := c.GetString("clr_type")
  8315. clr_org := c.GetString("clr_optins")
  8316. admin_user_id, _ := c.GetInt64("admin_user_id")
  8317. adminUser := c.GetAdminUserInfo()
  8318. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8319. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8320. if len(clr_org) == 0 {
  8321. clr_org = miConfig.MdtrtareaAdmvs
  8322. }
  8323. timeLayout := "2006-01-02"
  8324. loc, _ := time.LoadLocation("Local")
  8325. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8326. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8327. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8328. fixmedins_setl_cnt := int64(len(orders))
  8329. var medfee_sumamt float64
  8330. var acct_pay float64
  8331. var fund_pay_sumamt float64
  8332. for _, item := range orders {
  8333. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8334. acct_pay = acct_pay + item.AcctPay
  8335. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8336. }
  8337. var user_name string
  8338. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8339. if role.ID == 0 {
  8340. user_name = "xxx"
  8341. } else {
  8342. user_name = role.UserName
  8343. }
  8344. var res ResultEight
  8345. var res10188 ResultEightFor10188
  8346. if config.IsOpen == 1 {
  8347. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8348. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8349. "insutype=" + insutype +
  8350. "&clr_type=" + "11" +
  8351. "&setl_optins=" + clr_org +
  8352. "&stmt_begndate=" + start_time +
  8353. "&stm_enddate=" + end_time +
  8354. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8355. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8356. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8357. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8358. "&fixmedins_code=" + miConfig.Code +
  8359. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8360. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8361. "&secret_key=" + miConfig.SecretKey +
  8362. "&org_name=" + miConfig.OrgName +
  8363. "&doctor=" + user_name +
  8364. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8365. fmt.Println(api)
  8366. resp, requestErr := http.Get(api)
  8367. if requestErr != nil {
  8368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8369. return
  8370. }
  8371. body, ioErr := ioutil.ReadAll(resp.Body)
  8372. fmt.Println(body)
  8373. if ioErr != nil {
  8374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8376. return
  8377. }
  8378. var respJSON map[string]interface{}
  8379. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8382. return
  8383. }
  8384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8385. userJSONBytes, _ := json.Marshal(respJSON)
  8386. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8387. utils.ErrorLog("解析失败:%v", err)
  8388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8389. return
  8390. }
  8391. res.InfRefmsgid = res10188.InfRefmsgid
  8392. res.Output = res10188.Output
  8393. res.ErrMsg = res10188.ErrMsg
  8394. res.Cainfo = res10188.Cainfo
  8395. res.WarnMsg = res10188.WarnMsg
  8396. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8397. res.Infcode = infocode
  8398. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8399. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8400. "insutype=" + insutype +
  8401. "&clr_type=" + "21" +
  8402. "&setl_optins=" + clr_org +
  8403. "&stmt_begndate=" + start_time +
  8404. "&stm_enddate=" + end_time +
  8405. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8406. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8407. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8408. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8409. "&fixmedins_code=" + miConfig.Code +
  8410. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8411. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8412. "&secret_key=" + miConfig.SecretKey +
  8413. "&org_name=" + miConfig.OrgName +
  8414. "&doctor=" + user_name
  8415. resp, requestErr := http.Get(api)
  8416. if requestErr != nil {
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. return
  8419. }
  8420. body, ioErr := ioutil.ReadAll(resp.Body)
  8421. if ioErr != nil {
  8422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8424. return
  8425. }
  8426. var respJSON map[string]interface{}
  8427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8430. return
  8431. }
  8432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8433. result, _ := json.Marshal(respJSON)
  8434. fmt.Println("log")
  8435. fmt.Println(string(result))
  8436. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8437. utils.ErrorLog("解析失败:%v", err)
  8438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8439. return
  8440. }
  8441. res.InfRefmsgid = res10188.InfRefmsgid
  8442. res.Output = res10188.Output
  8443. res.ErrMsg = res10188.ErrMsg
  8444. res.Cainfo = res10188.Cainfo
  8445. res.WarnMsg = res10188.WarnMsg
  8446. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8447. res.Infcode = infocode
  8448. } else {
  8449. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8450. "insutype=" + insutype +
  8451. "&clr_type=" + clr_type +
  8452. "&setl_optins=" + clr_org +
  8453. "&stmt_begndate=" + start_time +
  8454. "&stm_enddate=" + end_time +
  8455. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8456. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8457. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8458. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8459. "&fixmedins_code=" + miConfig.Code +
  8460. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8461. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8462. "&secret_key=" + miConfig.SecretKey +
  8463. "&org_name=" + miConfig.OrgName +
  8464. "&doctor=" + user_name
  8465. fmt.Println(api)
  8466. resp, requestErr := http.Get(api)
  8467. if requestErr != nil {
  8468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8469. return
  8470. }
  8471. body, ioErr := ioutil.ReadAll(resp.Body)
  8472. fmt.Println(body)
  8473. if ioErr != nil {
  8474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. var respJSON map[string]interface{}
  8479. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8482. return
  8483. }
  8484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8485. userJSONBytes, _ := json.Marshal(respJSON)
  8486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8487. utils.ErrorLog("解析失败:%v", err)
  8488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8489. return
  8490. }
  8491. }
  8492. if res.Infcode == 0 {
  8493. if res.Output.Stmtinfo.StmtRslt == "0" {
  8494. micc := &models.MedicalInsuranceCostCompare{
  8495. StartTime: startime.Unix(),
  8496. EndTime: endtime.Unix(),
  8497. Insutype: insutype,
  8498. CheckType: 1,
  8499. Num: fixmedins_setl_cnt,
  8500. Mtime: time.Now().Unix(),
  8501. Status: 1,
  8502. UserOrgId: adminUser.CurrentOrgId,
  8503. CostTotal: medfee_sumamt,
  8504. FuncTotal: fund_pay_sumamt,
  8505. PsnPay: acct_pay,
  8506. Creator: admin_user_id,
  8507. Ctime: time.Now().Unix(),
  8508. ClrType: clr_type,
  8509. }
  8510. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8511. if err == nil {
  8512. c.ServeSuccessJSON(map[string]interface{}{
  8513. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8514. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8515. })
  8516. } else {
  8517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8518. }
  8519. } else {
  8520. c.ServeSuccessJSON(map[string]interface{}{
  8521. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8522. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8523. })
  8524. }
  8525. } else {
  8526. c.ServeSuccessJSON(map[string]interface{}{
  8527. "code": -10,
  8528. "msg": res.ErrMsg,
  8529. })
  8530. }
  8531. }
  8532. }
  8533. func (c *HisApiController) Check310() {
  8534. adminUser := c.GetAdminUserInfo()
  8535. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8536. var user_name string
  8537. user_name = "高慧裕"
  8538. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8539. "insutype=" + "310" +
  8540. "&clr_type=" + "" +
  8541. "&setl_optins=" + "441202" +
  8542. "&stmt_begndate=" + "2022-03-01" +
  8543. "&stm_enddate=" + "2022-03-31" +
  8544. "&medfee_sumamt=" + "194930.12" +
  8545. "&fund_pay_sumamt=" + "188741.46" +
  8546. "&acct_pay=" + "0" +
  8547. "&fixmedins_setl_cnt=" + "452" +
  8548. "&fixmedins_code=" + miConfig.Code +
  8549. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8550. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8551. "&secret_key=" + miConfig.SecretKey +
  8552. "&org_name=" + miConfig.OrgName +
  8553. "&doctor=" + user_name
  8554. fmt.Println(api)
  8555. resp, requestErr := http.Get(api)
  8556. if requestErr != nil {
  8557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8558. return
  8559. }
  8560. body, ioErr := ioutil.ReadAll(resp.Body)
  8561. fmt.Println(body)
  8562. if ioErr != nil {
  8563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8565. return
  8566. }
  8567. var respJSON map[string]interface{}
  8568. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8571. return
  8572. }
  8573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8574. userJSONBytes, _ := json.Marshal(respJSON)
  8575. var res ResultEight
  8576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8577. utils.ErrorLog("解析失败:%v", err)
  8578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8579. return
  8580. }
  8581. }
  8582. func (c *HisApiController) Check390() {
  8583. adminUser := c.GetAdminUserInfo()
  8584. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8585. var user_name string
  8586. user_name = "高慧裕"
  8587. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8588. "insutype=" + "390" +
  8589. "&clr_type=" + "" +
  8590. "&setl_optins=" + "441202" +
  8591. "&stmt_begndate=" + "2022-03-01" +
  8592. "&stm_enddate=" + "2022-03-31" +
  8593. "&medfee_sumamt=" + "1068448.89" +
  8594. "&fund_pay_sumamt=" + "1014677.62" +
  8595. "&acct_pay=" + "0" +
  8596. "&fixmedins_setl_cnt=" + "1950" +
  8597. "&fixmedins_code=" + miConfig.Code +
  8598. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8599. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8600. "&secret_key=" + miConfig.SecretKey +
  8601. "&org_name=" + miConfig.OrgName +
  8602. "&doctor=" + user_name
  8603. fmt.Println(api)
  8604. resp, requestErr := http.Get(api)
  8605. if requestErr != nil {
  8606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8607. return
  8608. }
  8609. body, ioErr := ioutil.ReadAll(resp.Body)
  8610. fmt.Println(body)
  8611. if ioErr != nil {
  8612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8614. return
  8615. }
  8616. var respJSON map[string]interface{}
  8617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8620. return
  8621. }
  8622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8623. userJSONBytes, _ := json.Marshal(respJSON)
  8624. var res ResultEight
  8625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8626. utils.ErrorLog("解析失败:%v", err)
  8627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8628. return
  8629. }
  8630. }
  8631. //对账明细
  8632. func (c *HisApiController) GetCheckDetailAccount() {
  8633. start_time := c.GetString("start_time")
  8634. end_time := c.GetString("end_time")
  8635. admin_user_id, _ := c.GetInt64("admin_user_id")
  8636. adminUser := c.GetAdminUserInfo()
  8637. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8638. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8639. timeLayout := "2006-01-02"
  8640. loc, _ := time.LoadLocation("Local")
  8641. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8642. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8643. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8644. rand.Seed(time.Now().UnixNano())
  8645. num := rand.Intn(30000)
  8646. Mkdir(miConfig.OrgName)
  8647. file := strconv.FormatInt(int64(num), 10)
  8648. file_name := file + ".txt"
  8649. zip_name := file + ".zip"
  8650. zip_path := miConfig.OrgName + "/" + zip_name
  8651. file_path := miConfig.OrgName + "/" + file_name
  8652. decimal.DivisionPrecision = 2
  8653. var medfee_sumamt float64
  8654. var psn_cash_pay float64
  8655. var fund_pay_sumamt float64
  8656. fixmedins_setl_cnt := int64(len(orders))
  8657. for _, item := range orders {
  8658. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8659. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8660. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8661. }
  8662. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8663. defer f.Close()
  8664. if err != nil {
  8665. fmt.Println(err.Error())
  8666. } else {
  8667. for _, item := range orders {
  8668. var refd_setl_flag string
  8669. if item.OrderStatus == 2 {
  8670. refd_setl_flag = "0"
  8671. var str string
  8672. str = item.SetlId + " " +
  8673. item.MdtrtId + " " +
  8674. item.PsnNo + " " +
  8675. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8676. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8677. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8678. _, err = f.Write([]byte(str))
  8679. }
  8680. if item.OrderStatus == 3 {
  8681. var str string
  8682. str = item.SetlId + " " +
  8683. item.MdtrtId + " " +
  8684. item.PsnNo + " " +
  8685. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8686. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8687. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8688. _, err = f.Write([]byte(str))
  8689. var str2 string
  8690. str2 = item.SetlId + " " +
  8691. item.MdtrtId + " " +
  8692. item.PsnNo + " " +
  8693. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8694. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8695. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8696. _, err = f.Write([]byte(str2))
  8697. }
  8698. }
  8699. }
  8700. Zip(file_path, zip_path)
  8701. fmt.Println(ReadFile(zip_path))
  8702. fmt.Println(string(ReadFile(zip_path)))
  8703. if config.IsOpen == 1 {
  8704. var user_name string
  8705. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8706. if role.ID == 0 {
  8707. user_name = "管理员"
  8708. } else {
  8709. user_name = role.UserName
  8710. }
  8711. baseParams := models.BaseParams{
  8712. SecretKey: miConfig.SecretKey,
  8713. FixmedinsCode: miConfig.Code,
  8714. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8715. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8716. OrgName: miConfig.OrgName,
  8717. Doctor: user_name,
  8718. }
  8719. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8720. var dat map[string]interface{}
  8721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8722. fmt.Println(dat)
  8723. } else {
  8724. fmt.Println(err)
  8725. }
  8726. userJSONBytes, _ := json.Marshal(dat)
  8727. var res ResultNine
  8728. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8729. utils.ErrorLog("解析失败:%v", err)
  8730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8731. return
  8732. }
  8733. if res.Infcode == 0 {
  8734. fileNo := res.Output.FileQuryNo
  8735. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8736. "file_qury_no=" + fileNo +
  8737. "&setl_optins=" + "定点医保中心" +
  8738. "&stmt_begndate=" + start_time +
  8739. "&stm_enddate=" + end_time +
  8740. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8741. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8742. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8743. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8744. "&fixmedins_code=" + miConfig.Code +
  8745. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8746. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8747. "&secret_key=" + miConfig.SecretKey +
  8748. "&org_name=" + miConfig.OrgName +
  8749. "&doctor=" + user_name
  8750. resp, requestErr := http.Get(api)
  8751. if requestErr != nil {
  8752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8753. return
  8754. }
  8755. body, ioErr := ioutil.ReadAll(resp.Body)
  8756. if ioErr != nil {
  8757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8759. return
  8760. }
  8761. var respJSON map[string]interface{}
  8762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8765. return
  8766. }
  8767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8768. userJSONBytes, _ := json.Marshal(respJSON)
  8769. var res ResultTen
  8770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8771. utils.ErrorLog("解析失败:%v", err)
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. return
  8774. }
  8775. if res.Infcode == 0 {
  8776. service.Gdyb9102(baseParams, zip_name, fileNo)
  8777. micc := &models.MedicalInsuranceCostCompare{
  8778. StartTime: startime.Unix(),
  8779. EndTime: endtime.Unix(),
  8780. Insutype: "0",
  8781. CheckType: 2,
  8782. Num: fixmedins_setl_cnt,
  8783. Mtime: time.Now().Unix(),
  8784. Status: 1,
  8785. UserOrgId: adminUser.CurrentOrgId,
  8786. CostTotal: medfee_sumamt,
  8787. FuncTotal: fund_pay_sumamt,
  8788. PsnPay: psn_cash_pay,
  8789. Creator: admin_user_id,
  8790. Ctime: time.Now().Unix(),
  8791. }
  8792. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8793. c.ServeSuccessJSON(map[string]interface{}{
  8794. "msg": "明细对账成功",
  8795. })
  8796. }
  8797. } else {
  8798. }
  8799. }
  8800. }
  8801. type CustomOrderInfo struct {
  8802. Name string
  8803. Spec string
  8804. Unit string
  8805. Count float64
  8806. Price float64
  8807. Total float64
  8808. }
  8809. func (c *HisApiController) GetSettleAccounts() {
  8810. //id, _ := c.GetInt64("id")
  8811. //record_time := c.GetString("record_time")
  8812. order_id, _ := c.GetInt64("order_id")
  8813. admin_user_id, _ := c.GetInt64("admin_user_id")
  8814. //timeLayout := "2006-01-02"
  8815. //loc, _ := time.LoadLocation("Local")
  8816. //
  8817. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8818. //if err != nil {
  8819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8820. // return
  8821. //}
  8822. //recordDateTime := theTime.Unix()
  8823. adminUser := c.GetAdminUserInfo()
  8824. order, _ := service.GetHisOrderByID(order_id)
  8825. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8826. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8827. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8828. orderInfos = append(orderInfos, orderInfos_two...)
  8829. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8830. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8831. var diagnosis_ids []string
  8832. if his.ID > 0 {
  8833. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8834. } else {
  8835. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8836. }
  8837. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8838. var dia_config []*models.HisXtDiagnoseConfig
  8839. var name string
  8840. for _, item := range diagnosis_ids {
  8841. id, _ := strconv.ParseInt(item, 10, 64)
  8842. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8843. dia_config = append(dia_config, &diagnosisConfig)
  8844. if len(name) == 0 {
  8845. name = diagnosisConfig.ClassName
  8846. } else {
  8847. name = name + "," + diagnosisConfig.ClassName
  8848. }
  8849. }
  8850. var bedCostTotal float64 = 0 //床位总费
  8851. var bedCostSelfTotal float64 = 0 //床位自费
  8852. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8853. var operationCostTotal float64 = 0 //手术费
  8854. var operationCostSelfTotal float64 = 0 //手术费
  8855. var operationCostPartSelfTotal float64 = 0 //手术费
  8856. var otherCostTotal float64 = 0 //其他费用
  8857. var otherCostSelfTotal float64 = 0 //其他费用
  8858. var otherCostPartSelfTotal float64 = 0 //其他费用
  8859. var materialCostTotal float64 = 0 //材料费
  8860. var materialCostSelfTotal float64 = 0 //材料费
  8861. var materialCostPartSelfTotal float64 = 0 //材料费
  8862. var westernMedicineCostTotal float64 = 0 //西药费
  8863. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8864. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8865. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8866. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8867. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8868. var checkCostTotal float64 = 0 //检查费
  8869. var checkCostSelfTotal float64 = 0 //检查费
  8870. var checkCostPartSelfTotal float64 = 0 //检查费
  8871. var laboratoryCostTotal float64 = 0 //化验费
  8872. var laboratoryCostSelfTotal float64 = 0 //化验费
  8873. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8874. var treatCostTotal float64 = 0 //治疗费用
  8875. var treatCostSelfTotal float64 = 0 //治疗费用
  8876. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8877. decimal.DivisionPrecision = 2
  8878. for _, item := range orderInfos {
  8879. if item.MedChrgitmType == "01" { //床位费
  8880. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8881. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8882. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8883. }
  8884. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8885. if item.MedChrgitmType == "03" { //检查费
  8886. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8887. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8888. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8889. }
  8890. } else {
  8891. if item.MedChrgitmType == "03" { //检查费
  8892. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8893. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8894. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8895. }
  8896. }
  8897. if item.MedChrgitmType == "04" { //化验费
  8898. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8899. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8900. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8901. }
  8902. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8903. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8904. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8905. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8906. }
  8907. if item.MedChrgitmType == "06" { //手术费
  8908. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8909. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8910. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8911. }
  8912. if item.MedChrgitmType == "08" { //材料费
  8913. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8914. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8915. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8916. }
  8917. if item.MedChrgitmType == "09" { //西药费
  8918. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8919. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8920. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8921. }
  8922. if item.MedChrgitmType == "11" { //中成费
  8923. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8924. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8925. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8926. }
  8927. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8928. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8929. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8930. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8931. }
  8932. }
  8933. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8934. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8935. var user_name string
  8936. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8937. if role.ID == 0 {
  8938. user_name = "管理员"
  8939. } else {
  8940. user_name = role.UserName
  8941. }
  8942. baseParams := models.BaseParams{
  8943. SecretKey: miConfig.SecretKey,
  8944. FixmedinsCode: miConfig.Code,
  8945. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8946. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8947. OrgName: miConfig.OrgName,
  8948. Doctor: user_name,
  8949. }
  8950. businessParams := models.BusinessParams{
  8951. PsnNo: order.PsnNo,
  8952. MdtrtId: order.MdtrtId,
  8953. SetlId: order.SetlId,
  8954. }
  8955. var res ResultEleven
  8956. var resEleven10265 ResultEleven10265
  8957. if config.IsOpen == 1 {
  8958. if miConfig.MdtrtareaAdmvs == "421300" {
  8959. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8960. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8961. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8962. resp, requestErr := http.Get(api)
  8963. if requestErr != nil {
  8964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8965. return
  8966. }
  8967. body, ioErr := ioutil.ReadAll(resp.Body)
  8968. if ioErr != nil {
  8969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8971. return
  8972. }
  8973. var respJSON map[string]interface{}
  8974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8977. return
  8978. }
  8979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8980. result, _ := json.Marshal(respJSON)
  8981. fmt.Println("log")
  8982. fmt.Println(string(result))
  8983. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8984. utils.ErrorLog("解析失败:%v", err)
  8985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8986. return
  8987. }
  8988. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8989. var api string
  8990. if miConfig.MdtrtareaAdmvs == "320921" {
  8991. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8992. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8993. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8994. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8995. } else {
  8996. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8997. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8998. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8999. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9000. }
  9001. resp, requestErr := http.Get(api)
  9002. if requestErr != nil {
  9003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9004. return
  9005. }
  9006. body, ioErr := ioutil.ReadAll(resp.Body)
  9007. if ioErr != nil {
  9008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9010. return
  9011. }
  9012. var respJSON map[string]interface{}
  9013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9016. return
  9017. }
  9018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9019. result, _ := json.Marshal(respJSON)
  9020. fmt.Println("log")
  9021. fmt.Println(string(result))
  9022. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9023. utils.ErrorLog("解析失败:%v", err)
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9028. res.Output = resEleven10265.Output
  9029. res.ErrMsg = resEleven10265.ErrMsg
  9030. res.Cainfo = resEleven10265.Cainfo
  9031. res.WarnMsg = resEleven10265.WarnMsg
  9032. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9033. res.Infcode = infocode
  9034. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9035. fmt.Println("~~~~~~~")
  9036. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9037. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9038. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9039. resp, requestErr := http.Get(api)
  9040. if requestErr != nil {
  9041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9042. return
  9043. }
  9044. body, ioErr := ioutil.ReadAll(resp.Body)
  9045. if ioErr != nil {
  9046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9048. return
  9049. }
  9050. var respJSON map[string]interface{}
  9051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9054. return
  9055. }
  9056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9057. result, _ := json.Marshal(respJSON)
  9058. fmt.Println("log")
  9059. fmt.Println(string(result))
  9060. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9061. utils.ErrorLog("解析失败:%v", err)
  9062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9063. return
  9064. }
  9065. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9066. res.Output = resEleven10265.Output
  9067. res.ErrMsg = resEleven10265.ErrMsg
  9068. res.Cainfo = resEleven10265.Cainfo
  9069. res.WarnMsg = resEleven10265.WarnMsg
  9070. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9071. res.Infcode = infocode
  9072. } else {
  9073. result := service.Gdyb5203(baseParams, businessParams)
  9074. //service.Gdyb5204(baseParams, businessParams)
  9075. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9076. var dat map[string]interface{}
  9077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9078. fmt.Println(dat)
  9079. } else {
  9080. fmt.Println(err)
  9081. }
  9082. userJSONBytes, _ := json.Marshal(dat)
  9083. if miConfig.Code == "H15049901371" {
  9084. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9085. utils.ErrorLog("解析失败:%v", err)
  9086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9087. return
  9088. }
  9089. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9090. res.Output = resEleven10265.Output
  9091. res.ErrMsg = resEleven10265.ErrMsg
  9092. res.Cainfo = resEleven10265.Cainfo
  9093. res.WarnMsg = resEleven10265.WarnMsg
  9094. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9095. res.Infcode = infocode
  9096. } else {
  9097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9098. utils.ErrorLog("解析失败:%v", err)
  9099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9100. return
  9101. }
  9102. }
  9103. }
  9104. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9105. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9106. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9107. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9108. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9109. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9110. var doctor_name string
  9111. if roles.ID == 0 {
  9112. doctor_name = "管理员"
  9113. } else {
  9114. doctor_name = roles.UserName
  9115. }
  9116. yiliao_leibie := ""
  9117. switch order.MedType {
  9118. case "11":
  9119. yiliao_leibie = "普通门诊"
  9120. break
  9121. case "12":
  9122. yiliao_leibie = "门诊挂号"
  9123. break
  9124. case "13":
  9125. yiliao_leibie = "急诊"
  9126. break
  9127. case "14":
  9128. yiliao_leibie = "门诊特殊病"
  9129. break
  9130. case "15":
  9131. yiliao_leibie = "门诊统筹"
  9132. break
  9133. case "16":
  9134. yiliao_leibie = "门诊慢性病"
  9135. break
  9136. case "21":
  9137. yiliao_leibie = "普通住院"
  9138. break
  9139. }
  9140. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9141. if res.Infcode == 0 {
  9142. c.ServeSuccessJSON(map[string]interface{}{
  9143. "diagnosis": name,
  9144. "order_infos": orderInfos,
  9145. "number": order.MdtrtId,
  9146. "date": order.SettleAccountsDate,
  9147. "charge_admin": charge_admin,
  9148. "printor_admin": printor_admin,
  9149. "info": res.Output.Setlinfo,
  9150. "order": order,
  9151. "bedCostTotal": bedCostTotal,
  9152. "bedCostSelfTotal": bedCostSelfTotal,
  9153. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9154. "operationCostTotal": operationCostTotal,
  9155. "operationCostSelfTotal": operationCostSelfTotal,
  9156. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9157. "otherCostTotal": otherCostTotal,
  9158. "otherCostSelfTotal": otherCostSelfTotal,
  9159. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9160. "materialCostTotal": materialCostTotal,
  9161. "materialCostSelfTotal": materialCostSelfTotal,
  9162. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9163. "westernMedicineCostTotal": westernMedicineCostTotal,
  9164. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9165. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9166. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9167. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9168. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9169. "checkCostTotal": checkCostTotal,
  9170. "checkCostSelfTotal": checkCostSelfTotal,
  9171. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9172. "laboratoryCostTotal": laboratoryCostTotal,
  9173. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9174. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9175. "treatCostTotal": treatCostTotal,
  9176. "treatCostSelfTotal": treatCostSelfTotal,
  9177. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9178. "doctor_info": doctor_info,
  9179. "doctor_code": adminRole_two.DoctorCode,
  9180. "doctor_name": doctor_name,
  9181. "health_card_no": order.PsnNo,
  9182. "department": departments.Name,
  9183. "yiliao_leibie": yiliao_leibie,
  9184. "after_money": order.AccountPrice,
  9185. "patient": patient,
  9186. "org_name": miConfig.OrgName,
  9187. "org_code": miConfig.Code,
  9188. "order_number": order.Number,
  9189. "his_hospital": his_hospital,
  9190. "his": his,
  9191. "dia_config": dia_config,
  9192. //"check_order_info": cus_slice,
  9193. })
  9194. }
  9195. }
  9196. }
  9197. func (c *HisApiController) CheckTreatment() {
  9198. patient_id, _ := c.GetInt64("patient_id")
  9199. id_card_no := c.GetString("id_card_no")
  9200. insutype := c.GetString("insutype")
  9201. med_type := c.GetString("med_type")
  9202. admin_user_id, _ := c.GetInt64("admin_user_id")
  9203. adminUser := c.GetAdminUserInfo()
  9204. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9205. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9206. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9207. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9208. if miConfig.MdtrtareaAdmvs == "421300" {
  9209. var res ResultTwo
  9210. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9211. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9212. "&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)
  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. if ioErr != nil {
  9220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9222. return
  9223. }
  9224. var respJSON map[string]interface{}
  9225. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9228. return
  9229. }
  9230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9231. result, _ := json.Marshal(respJSON)
  9232. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9233. utils.ErrorLog("解析失败:%v", err)
  9234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9235. return
  9236. }
  9237. if res.Infcode == 0 {
  9238. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9239. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9240. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9241. resp, requestErr := http.Get(api)
  9242. if requestErr != nil {
  9243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9244. return
  9245. }
  9246. body, ioErr := ioutil.ReadAll(resp.Body)
  9247. if ioErr != nil {
  9248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9250. return
  9251. }
  9252. var respJSON map[string]interface{}
  9253. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9256. return
  9257. }
  9258. var res Result2001
  9259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9260. result2, _ := json.Marshal(respJSON)
  9261. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9262. utils.ErrorLog("解析失败:%v", err)
  9263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9264. return
  9265. }
  9266. if res.Infcode == 0 {
  9267. c.ServeSuccessJSON(map[string]interface{}{
  9268. "msg": res.Output.Trtinfo,
  9269. })
  9270. }
  9271. } else {
  9272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9273. return
  9274. }
  9275. } else {
  9276. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9277. var dat map[string]interface{}
  9278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9279. fmt.Println(dat)
  9280. } else {
  9281. fmt.Println(err)
  9282. }
  9283. userJSONBytes, _ := json.Marshal(dat)
  9284. var res ResultTwo
  9285. var res10265 ResultTwo10265
  9286. if miConfig.Code == "H15049901371" {
  9287. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9288. utils.ErrorLog("解析失败:%v", err)
  9289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9290. return
  9291. }
  9292. res.ErrMsg = res10265.ErrMsg
  9293. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9294. res.Infcode = infocode
  9295. res.Output = res10265.Output
  9296. res.InfRefmsgid = res10265.InfRefmsgid
  9297. } else {
  9298. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9299. utils.ErrorLog("解析失败:%v", err)
  9300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9301. return
  9302. }
  9303. }
  9304. var user_name string
  9305. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9306. if role.ID == 0 {
  9307. user_name = "xxx"
  9308. } else {
  9309. user_name = role.UserName
  9310. }
  9311. baseParams := models.BaseParams{
  9312. SecretKey: miConfig.SecretKey,
  9313. FixmedinsCode: miConfig.Code,
  9314. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9315. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9316. OrgName: miConfig.OrgName,
  9317. Doctor: user_name,
  9318. }
  9319. if config.IsOpen == 1 {
  9320. if miConfig.Code == "H15049901371" {
  9321. if med_type == "14" {
  9322. if insutype == "390" {
  9323. med_type = "9933"
  9324. } else if insutype == "310" {
  9325. med_type = "990502"
  9326. }
  9327. } else if med_type == "11" {
  9328. med_type = "11"
  9329. }
  9330. }
  9331. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9332. var dat map[string]interface{}
  9333. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9334. fmt.Println(dat)
  9335. } else {
  9336. fmt.Println(err)
  9337. }
  9338. var res Result2001
  9339. var res10265 Result2001Org10265
  9340. if miConfig.Code == "H15049901371" {
  9341. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9342. utils.ErrorLog("解析失败:%v", err)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. res.ErrMsg = res10265.ErrMsg
  9347. res.Output = res10265.Output
  9348. res.InfRefmsgid = res10265.InfRefmsgid
  9349. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9350. res.Infcode = infocode
  9351. } else {
  9352. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9353. utils.ErrorLog("解析失败:%v", err)
  9354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9355. return
  9356. }
  9357. }
  9358. if res.Infcode == 0 {
  9359. c.ServeSuccessJSON(map[string]interface{}{
  9360. "msg": res.Output.Trtinfo,
  9361. })
  9362. }
  9363. }
  9364. }
  9365. }
  9366. //func (c *HisApiController) PutRecord() {
  9367. // id, _ := c.GetInt64("id")
  9368. // record_time := c.GetString("record_time")
  9369. // timeLayout := "2006-01-02"
  9370. // loc, _ := time.LoadLocation("Local")
  9371. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9372. // if err != nil {
  9373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9374. // return
  9375. // }
  9376. // recordDateTime := theTime.Unix()
  9377. //
  9378. // adminInfo := c.GetAdminUserInfo()
  9379. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9380. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9381. //
  9382. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9383. //
  9384. // fmt.Println(miConfig.SecretKey)
  9385. //
  9386. // if patient == nil {
  9387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9388. // return
  9389. // }
  9390. // if len(patient.IdCardNo) == 0 {
  9391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9392. // return
  9393. // }
  9394. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9395. // if config.IsOpen == 1 {
  9396. // 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
  9397. // resp, requestErr := http.Get(api)
  9398. // if requestErr != nil {
  9399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9400. // return
  9401. // }
  9402. // defer resp.Body.Close()
  9403. // body, ioErr := ioutil.ReadAll(resp.Body)
  9404. // if ioErr != nil {
  9405. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9407. // return
  9408. // }
  9409. // var respJSON map[string]interface{}
  9410. //
  9411. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9412. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9414. // return
  9415. // }
  9416. //
  9417. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9418. // userJSONBytes, _ := json.Marshal(userJSON)
  9419. // var res ResultTwo
  9420. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9421. // utils.ErrorLog("解析失败:%v", err)
  9422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9423. // return
  9424. // }
  9425. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9426. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9427. // infoStr := string(Iinfos)
  9428. // idetinfoStr := string(Idetinfos)
  9429. //
  9430. // if res.Infcode == 0 {
  9431. // his := models.VMHisPatient{
  9432. // Status: 1,
  9433. // Ctime: time.Now().Unix(),
  9434. // Mtime: time.Now().Unix(),
  9435. // PsnNo: res.Output.Baseinfo.PsnNo,
  9436. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9437. // Certno: res.Output.Baseinfo.Certno,
  9438. // PsnName: res.Output.Baseinfo.PsnName,
  9439. // Gend: res.Output.Baseinfo.Gend,
  9440. // Naty: res.Output.Baseinfo.Naty,
  9441. // Brdy: res.Output.Baseinfo.Brdy,
  9442. // Age: res.Output.Baseinfo.Age,
  9443. // Iinfo: infoStr,
  9444. // Idetinfo: idetinfoStr,
  9445. // PatientId: patient.ID,
  9446. // RecordDate: theTime.Unix(),
  9447. // UserOrgId: adminInfo.CurrentOrgId,
  9448. // AdminUserId: adminInfo.AdminUser.Id,
  9449. // IsReturn: 1,
  9450. // }
  9451. //
  9452. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9453. // //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")
  9454. // //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")
  9455. //
  9456. // //var dat map[string]interface{}
  9457. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9458. // // fmt.Println(dat)
  9459. // //} else {
  9460. // // fmt.Println(err)
  9461. // //}
  9462. //
  9463. // var dat2 map[string]interface{}
  9464. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9465. // fmt.Println(dat2)
  9466. // } else {
  9467. // fmt.Println(err)
  9468. // }
  9469. //
  9470. // } else {
  9471. // adminUser := c.GetAdminUserInfo()
  9472. // errlog := &models.HisOrderError{
  9473. // UserOrgId: adminUser.CurrentOrgId,
  9474. // Ctime: time.Now().Unix(),
  9475. // Mtime: time.Now().Unix(),
  9476. // ErrMsg: res.ErrMsg,
  9477. // Status: 1,
  9478. // PatientId: id,
  9479. // RecordTime: recordDateTime,
  9480. // Stage: 1,
  9481. // }
  9482. // service.CreateErrMsgLog(errlog)
  9483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9484. // return
  9485. // }
  9486. // }
  9487. //
  9488. //}
  9489. //func (c *HisApiController) GetUploadDiag() {
  9490. // id, _ := c.GetInt64("id")
  9491. // record_time := c.GetString("record_time")
  9492. //
  9493. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9494. // sick_type, _ := c.GetInt64("sick_type")
  9495. // reg_type, _ := c.GetInt64("reg_type")
  9496. //
  9497. // timeLayout := "2006-01-02"
  9498. // loc, _ := time.LoadLocation("Local")
  9499. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9500. // if err != nil {
  9501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9502. // return
  9503. // }
  9504. //
  9505. // var patientPrescription models.HisPrescriptionInfo
  9506. // recordDateTime := theTime.Unix()
  9507. // adminInfo := c.GetAdminUserInfo()
  9508. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9509. //
  9510. // if patientPrescription.ID == 0 {
  9511. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9512. // }
  9513. //
  9514. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9515. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9516. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9517. // sickConfig, _ := service.FindSickById(sick_type)
  9518. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9519. //
  9520. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9521. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9522. // "&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 +
  9523. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9524. // resp2, requestErr2 := http.Get(api2)
  9525. // if requestErr2 != nil {
  9526. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9527. // return
  9528. // }
  9529. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9530. // if ioErr2 != nil {
  9531. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9533. // return
  9534. // }
  9535. // var respJSON2 map[string]interface{}
  9536. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9537. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9539. // return
  9540. // }
  9541. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9542. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9543. //
  9544. // var res2 ResultSix
  9545. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9546. // utils.ErrorLog("解析失败:%v", err)
  9547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. // return
  9549. // }
  9550. // if res2.Infcode != 0 {
  9551. // adminUser := c.GetAdminUserInfo()
  9552. // errlog := &models.HisOrderError{
  9553. // UserOrgId: adminUser.CurrentOrgId,
  9554. // Ctime: time.Now().Unix(),
  9555. // Mtime: time.Now().Unix(),
  9556. // ErrMsg: res2.ErrMsg,
  9557. // Status: 1,
  9558. // PatientId: id,
  9559. // RecordTime: recordDateTime,
  9560. // Stage: 3,
  9561. // }
  9562. // service.CreateErrMsgLog(errlog)
  9563. //
  9564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9565. // return
  9566. // }
  9567. //
  9568. // c.ServeSuccessJSON(map[string]interface{}{
  9569. // "msg": "上传成功",
  9570. // })
  9571. //
  9572. //}
  9573. type QueryResult struct {
  9574. ID int64
  9575. Name string
  9576. Code string
  9577. List_type_code string
  9578. }
  9579. func (c *HisApiController) GetCheckCode() {
  9580. ids_str := c.GetString("ids")
  9581. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9582. ids_arr := strings.Split(ids_str, ",")
  9583. var queryResult []QueryResult
  9584. ids := make([]int64, 0)
  9585. for _, item := range ids_arr {
  9586. id, _ := strconv.ParseInt(item, 10, 64)
  9587. ids = append(ids, id)
  9588. }
  9589. if record_type == 1 {
  9590. drugs, _ := service.GetBatchDrugList(ids)
  9591. for _, item := range drugs {
  9592. result := QueryResult{
  9593. ID: item.ID,
  9594. Name: item.DrugName,
  9595. Code: item.MedicalInsuranceNumber,
  9596. List_type_code: "101",
  9597. }
  9598. queryResult = append(queryResult, result)
  9599. }
  9600. } else if record_type == 2 {
  9601. goods, _ := service.GetBatchGoodInformationList(ids)
  9602. for _, item := range goods {
  9603. result := QueryResult{
  9604. ID: item.ID,
  9605. Name: item.GoodName,
  9606. Code: item.MedicalInsuranceNumber,
  9607. List_type_code: "301",
  9608. }
  9609. queryResult = append(queryResult, result)
  9610. }
  9611. } else if record_type == 3 {
  9612. projects, _ := service.GetBathchMyPorjecgList(ids)
  9613. for _, item := range projects {
  9614. result := QueryResult{
  9615. ID: item.ID,
  9616. Name: item.ProjectName,
  9617. Code: item.MedicalCode,
  9618. List_type_code: "201",
  9619. }
  9620. queryResult = append(queryResult, result)
  9621. }
  9622. }
  9623. admin_user_id, _ := c.GetInt64("admin_user_id")
  9624. adminUser := c.GetAdminUserInfo()
  9625. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9626. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9627. var user_name string
  9628. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9629. if role.ID == 0 {
  9630. user_name = "xxx"
  9631. } else {
  9632. user_name = role.UserName
  9633. }
  9634. baseParams := &models.BaseParams{
  9635. SecretKey: miConfig.SecretKey,
  9636. FixmedinsCode: miConfig.Code,
  9637. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9638. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9639. OrgName: miConfig.OrgName,
  9640. Doctor: user_name,
  9641. }
  9642. if config.IsOpen == 1 {
  9643. for _, item := range queryResult {
  9644. var result string
  9645. if record_type == 1 {
  9646. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9647. } else if record_type == 2 {
  9648. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9649. } else if record_type == 3 {
  9650. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9651. }
  9652. var dat map[string]interface{}
  9653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9654. fmt.Println(dat)
  9655. } else {
  9656. fmt.Println(err)
  9657. }
  9658. userJSONBytes, _ := json.Marshal(dat)
  9659. var res ResultSix
  9660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9661. utils.ErrorLog("解析失败:%v", err)
  9662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9663. return
  9664. }
  9665. if res.Infcode == 0 {
  9666. if record_type == 1 {
  9667. service.UpdateBaseDrugById(item.ID)
  9668. } else if record_type == 2 {
  9669. service.UpdateGoodInformaitonByDetail(item.ID)
  9670. } else if record_type == 3 {
  9671. service.UpdateProjectById(item.ID)
  9672. }
  9673. c.ServeSuccessJSON(map[string]interface{}{
  9674. "failed_code": 0,
  9675. "msg": "目录对照成功",
  9676. })
  9677. } else {
  9678. c.ServeSuccessJSON(map[string]interface{}{
  9679. "failed_code": -10,
  9680. "msg": res.ErrMsg,
  9681. })
  9682. }
  9683. }
  9684. }
  9685. }
  9686. func (c *HisApiController) UnCheckCode() {
  9687. ids_str := c.GetString("ids")
  9688. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9689. admin_user_id, _ := c.GetInt64("admin_user_id")
  9690. ids_arr := strings.Split(ids_str, ",")
  9691. var queryResult []QueryResult
  9692. ids := make([]int64, 0)
  9693. for _, item := range ids_arr {
  9694. id, _ := strconv.ParseInt(item, 10, 64)
  9695. ids = append(ids, id)
  9696. }
  9697. if record_type == 1 {
  9698. drugs, _ := service.GetBatchDrugList(ids)
  9699. for _, item := range drugs {
  9700. result := QueryResult{
  9701. ID: item.ID,
  9702. Name: item.DrugName,
  9703. Code: item.MedicalInsuranceNumber,
  9704. List_type_code: "101",
  9705. }
  9706. queryResult = append(queryResult, result)
  9707. }
  9708. } else if record_type == 2 {
  9709. goods, _ := service.GetBatchGoodInformationList(ids)
  9710. for _, item := range goods {
  9711. result := QueryResult{
  9712. ID: item.ID,
  9713. Name: item.GoodName,
  9714. Code: item.MedicalInsuranceNumber,
  9715. List_type_code: "301",
  9716. }
  9717. queryResult = append(queryResult, result)
  9718. }
  9719. } else if record_type == 3 {
  9720. projects, _ := service.GetBathchMyPorjecgList(ids)
  9721. for _, item := range projects {
  9722. result := QueryResult{
  9723. ID: item.ID,
  9724. Name: item.ProjectName,
  9725. Code: item.MedicalCode,
  9726. List_type_code: "201",
  9727. }
  9728. queryResult = append(queryResult, result)
  9729. }
  9730. }
  9731. adminUser := c.GetAdminUserInfo()
  9732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9733. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9734. var user_name string
  9735. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9736. if role.ID == 0 {
  9737. user_name = "xxx"
  9738. } else {
  9739. user_name = role.UserName
  9740. }
  9741. baseParams := &models.BaseParams{
  9742. SecretKey: miConfig.SecretKey,
  9743. FixmedinsCode: miConfig.Code,
  9744. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9745. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9746. OrgName: miConfig.OrgName,
  9747. Doctor: user_name,
  9748. }
  9749. if config.IsOpen == 1 {
  9750. for _, item := range queryResult {
  9751. var result string
  9752. if record_type == 1 {
  9753. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9754. } else if record_type == 2 {
  9755. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9756. } else if record_type == 3 {
  9757. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9758. }
  9759. var dat2 map[string]interface{}
  9760. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9761. fmt.Println(dat2)
  9762. } else {
  9763. fmt.Println(err)
  9764. }
  9765. userJSONBytes, _ := json.Marshal(dat2)
  9766. var res ResultSix
  9767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9768. utils.ErrorLog("解析失败:%v", err)
  9769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9770. return
  9771. }
  9772. if res.Infcode == 0 {
  9773. if record_type == 1 {
  9774. service.UpdateDrugByIdDetail(item.ID)
  9775. } else if record_type == 2 {
  9776. service.UpdateGoodInfoById(item.ID)
  9777. } else if record_type == 3 {
  9778. service.UpdateMyProjectById(item.ID)
  9779. }
  9780. c.ServeSuccessJSON(map[string]interface{}{
  9781. "failed_code": 0,
  9782. "msg": "撤销目录对照成功",
  9783. })
  9784. } else {
  9785. c.ServeSuccessJSON(map[string]interface{}{
  9786. "failed_code": -10,
  9787. "msg": res.ErrMsg,
  9788. })
  9789. }
  9790. }
  9791. }
  9792. }
  9793. func (c *HisApiController) GetPatientInfo() {
  9794. id_card_no := c.GetString("id_card_no")
  9795. admin_user_id, _ := c.GetInt64("admin_user_id")
  9796. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9797. if patient.ID == 0 {
  9798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9799. return
  9800. }
  9801. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9802. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9803. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9804. if config.IsOpen == 1 {
  9805. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9806. var dat map[string]interface{}
  9807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9808. fmt.Println(dat)
  9809. } else {
  9810. fmt.Println(err)
  9811. }
  9812. userJSONBytes, _ := json.Marshal(dat)
  9813. var res ResultTwo
  9814. var res10265 ResultTwo10265
  9815. if miConfig.Code == "H15049901371" {
  9816. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9817. utils.ErrorLog("解析失败:%v", err)
  9818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9819. return
  9820. }
  9821. res.ErrMsg = res10265.ErrMsg
  9822. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9823. res.Infcode = infocode
  9824. res.Output = res10265.Output
  9825. res.InfRefmsgid = res10265.InfRefmsgid
  9826. } else {
  9827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9828. utils.ErrorLog("解析失败:%v", err)
  9829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9830. return
  9831. }
  9832. }
  9833. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9834. // utils.ErrorLog("解析失败:%v", err)
  9835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9836. // return
  9837. //}
  9838. if res.Infcode != 0 {
  9839. c.ServeSuccessJSON(map[string]interface{}{
  9840. "failed_code": -10,
  9841. "msg": res.ErrMsg,
  9842. })
  9843. } else {
  9844. c.ServeSuccessJSON(map[string]interface{}{
  9845. "failed_code": 0,
  9846. "info": res,
  9847. })
  9848. }
  9849. }
  9850. }
  9851. func (c *HisApiController) PsnPutOnRecord() {
  9852. record_type, _ := c.GetInt64("type")
  9853. patient_id, _ := c.GetInt64("patient_id")
  9854. admin_user_id, _ := c.GetInt64("admin_user_id")
  9855. start_time := c.GetString("start_time")
  9856. end_time := c.GetString("end_time")
  9857. adminUser := c.GetAdminUserInfo()
  9858. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9859. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9860. var patients []*models.Patients
  9861. if record_type == 1 { //全部备案
  9862. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9863. patients = append(patients, patient...)
  9864. } else { //单个备案
  9865. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9866. patients = append(patients, patient)
  9867. }
  9868. var user_name string
  9869. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9870. if role.ID == 0 {
  9871. user_name = "xxx"
  9872. } else {
  9873. user_name = role.UserName
  9874. }
  9875. if config.IsOpen == 1 {
  9876. for _, item := range patients {
  9877. 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
  9878. resp, requestErr := http.Get(api)
  9879. if requestErr != nil {
  9880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9881. return
  9882. }
  9883. defer resp.Body.Close()
  9884. body, ioErr := ioutil.ReadAll(resp.Body)
  9885. if ioErr != nil {
  9886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9888. return
  9889. }
  9890. var respJSON map[string]interface{}
  9891. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9894. return
  9895. }
  9896. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9897. userJSONBytes, _ := json.Marshal(userJSON)
  9898. var res ResultTwo
  9899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9900. utils.ErrorLog("解析失败:%v", err)
  9901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9902. return
  9903. }
  9904. if res.Infcode == 0 {
  9905. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9906. var dat map[string]interface{}
  9907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9908. fmt.Println(dat)
  9909. } else {
  9910. fmt.Println(err)
  9911. }
  9912. userJSONBytes, _ := json.Marshal(dat)
  9913. var res2 ResultThirteen
  9914. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9915. utils.ErrorLog("解析失败:%v", err)
  9916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9917. return
  9918. }
  9919. if res2.Infcode == 0 {
  9920. psnResult := &models.GdybPsnRecord{
  9921. UserOrgId: adminUser.CurrentOrgId,
  9922. PatientId: item.ID,
  9923. PsnNo: res.Output.Baseinfo.PsnNo,
  9924. Ctime: time.Now().Unix(),
  9925. Mtime: time.Now().Unix(),
  9926. Status: 1,
  9927. IsCancel: 1,
  9928. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9929. }
  9930. service.CreatePsnRecord(psnResult)
  9931. } else {
  9932. c.ServeSuccessJSON(map[string]interface{}{
  9933. "failed_code": -10,
  9934. "msg": res2.ErrMsg,
  9935. })
  9936. return
  9937. }
  9938. }
  9939. }
  9940. }
  9941. }
  9942. func (c *HisApiController) PsnUnPutOnRecord() {
  9943. id, _ := c.GetInt64("id")
  9944. //record_type, _ := c.GetInt64("type")
  9945. admin_user_id, _ := c.GetInt64("admin_user_id")
  9946. adminUser := c.GetAdminUserInfo()
  9947. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9948. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9949. var user_name string
  9950. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9951. if role.ID == 0 {
  9952. user_name = "xxx"
  9953. } else {
  9954. user_name = role.UserName
  9955. }
  9956. psn_record, _ := service.GetPsnRecordById(id)
  9957. if psn_record.ID == 0 {
  9958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9959. return
  9960. }
  9961. if config.IsOpen == 1 {
  9962. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9963. var dat map[string]interface{}
  9964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9965. fmt.Println(dat)
  9966. } else {
  9967. fmt.Println(err)
  9968. }
  9969. userJSONBytes, _ := json.Marshal(dat)
  9970. var res ResultFourteen
  9971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9972. utils.ErrorLog("解析失败:%v", err)
  9973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9974. return
  9975. }
  9976. if res.Infcode == 0 {
  9977. psn_record.IsCancel = 2
  9978. service.CreatePsnRecord(&psn_record)
  9979. } else {
  9980. c.ServeSuccessJSON(map[string]interface{}{
  9981. "failed_code": -10,
  9982. "msg": res.ErrMsg,
  9983. })
  9984. return
  9985. }
  9986. }
  9987. }
  9988. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9989. patient_id, _ := c.GetInt64("patient_id")
  9990. insutype_two := c.GetString("insutype")
  9991. psn_no := c.GetString("psn_no")
  9992. doctor_id, _ := c.GetInt64("doctor_id")
  9993. sick_id, _ := c.GetInt64("sick_id")
  9994. department_id, _ := c.GetInt64("department_id")
  9995. start_time := c.GetString("start_time")
  9996. end_time := c.GetString("end_time")
  9997. check_time := c.GetString("check_time")
  9998. adminUser := c.GetAdminUserInfo()
  9999. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10000. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10001. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10002. sick, _ := service.FindSickById(sick_id)
  10003. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10004. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10005. var res ResultTwo
  10006. var res10265 ResultTwo10265
  10007. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10008. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10009. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  10010. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10011. "&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
  10012. resp, requestErr := http.Get(api)
  10013. if requestErr != nil {
  10014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10015. return
  10016. }
  10017. body, ioErr := ioutil.ReadAll(resp.Body)
  10018. if ioErr != nil {
  10019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10021. return
  10022. }
  10023. var respJSON map[string]interface{}
  10024. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10027. return
  10028. }
  10029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10030. result, _ := json.Marshal(respJSON)
  10031. fmt.Println("log")
  10032. fmt.Println(string(result))
  10033. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10034. utils.ErrorLog("解析失败:%v", err)
  10035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10036. return
  10037. }
  10038. res.ErrMsg = res10265.ErrMsg
  10039. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10040. res.Infcode = infocode
  10041. res.Output = res10265.Output
  10042. res.InfRefmsgid = res10265.InfRefmsgid
  10043. } else {
  10044. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10045. if miConfig.Code == "H15049901371" {
  10046. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10047. utils.ErrorLog("解析失败:%v", err)
  10048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10049. return
  10050. }
  10051. res.ErrMsg = res10265.ErrMsg
  10052. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10053. res.Infcode = infocode
  10054. res.Output = res10265.Output
  10055. res.InfRefmsgid = res10265.InfRefmsgid
  10056. } else {
  10057. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10058. utils.ErrorLog("解析失败:%v", err)
  10059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10060. return
  10061. }
  10062. }
  10063. }
  10064. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10065. infoStr := string(Iinfos)
  10066. var rf []*ResultFive
  10067. json.Unmarshal([]byte(infoStr), &rf)
  10068. var insuplc_admdvs string
  10069. var insutype string
  10070. var is390 int = 0
  10071. var is310 int = 0
  10072. var insutypes []*ResultFive
  10073. for _, item := range rf {
  10074. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10075. insutypes = append(insutypes, item)
  10076. }
  10077. }
  10078. if len(insutypes) == 1 {
  10079. insutype = insutypes[0].Insutype
  10080. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10081. } else {
  10082. for _, i := range insutypes {
  10083. if i.Insutype == "390" {
  10084. is390 = 1
  10085. }
  10086. if i.Insutype == "310" {
  10087. is310 = 1
  10088. }
  10089. }
  10090. }
  10091. if is390 == 1 {
  10092. insutype = "390"
  10093. }
  10094. if is310 == 1 {
  10095. insutype = "310"
  10096. }
  10097. if len(insutypes) == 2 {
  10098. insutype = insutype_two
  10099. }
  10100. if len(insutypes) == 0 {
  10101. insutype = "310"
  10102. }
  10103. insutype = insutype_two
  10104. fmt.Println(insutype)
  10105. for _, item := range rf {
  10106. fmt.Println(item.Insutype)
  10107. fmt.Println(insutype)
  10108. if item.Insutype == insutype {
  10109. fmt.Println(item.Insutype)
  10110. fmt.Println(insutype)
  10111. insuplc_admdvs = item.InsuplcAdmdvs
  10112. }
  10113. }
  10114. fmt.Println(insuplc_admdvs)
  10115. var res2 ResultThirteen
  10116. var res10265_2 ResultThirteen10265
  10117. if config.IsOpen == 1 {
  10118. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10119. } else {
  10120. 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)
  10121. var dat map[string]interface{}
  10122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10123. fmt.Println(dat)
  10124. } else {
  10125. fmt.Println(err)
  10126. }
  10127. userJSONBytes, _ := json.Marshal(dat)
  10128. if miConfig.Code == "H15049901371" {
  10129. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10130. utils.ErrorLog("解析失败:%v", err)
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10132. return
  10133. }
  10134. res2.ErrMsg = res10265_2.ErrMsg
  10135. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10136. res2.Infcode = infocode
  10137. res2.Output = res10265_2.Output
  10138. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10139. } else {
  10140. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10141. utils.ErrorLog("解析失败:%v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. }
  10146. }
  10147. if res2.Infcode == 0 {
  10148. psnResult := &models.GdybPsnNcdsRecord{
  10149. UserOrgId: adminUser.CurrentOrgId,
  10150. PatientId: patient.ID,
  10151. PsnNo: psn_no,
  10152. DoctorId: doctor.AdminUserId,
  10153. DepartmentId: department_id,
  10154. SickType: sick_id,
  10155. Insutype: insutype,
  10156. Ctime: time.Now().Unix(),
  10157. Mtime: time.Now().Unix(),
  10158. Status: 1,
  10159. IsCancel: 1,
  10160. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10161. }
  10162. service.CreatePsnNCDSRecord(psnResult)
  10163. c.ServeSuccessJSON(map[string]interface{}{
  10164. "failed_code": 0,
  10165. "msg": "备案成功",
  10166. "result": psnResult,
  10167. })
  10168. } else {
  10169. c.ServeSuccessJSON(map[string]interface{}{
  10170. "failed_code": -10,
  10171. "msg": res2.ErrMsg,
  10172. })
  10173. return
  10174. }
  10175. }
  10176. }
  10177. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10178. id, _ := c.GetInt64("id")
  10179. admin_user_id, _ := c.GetInt64("admin_user_id")
  10180. adminUser := c.GetAdminUserInfo()
  10181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10182. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10183. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10184. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10185. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10186. //var user_name string
  10187. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10188. //if role.ID == 0 {
  10189. // user_name = "xxx"
  10190. //} else {
  10191. // user_name = role.UserName
  10192. //}
  10193. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10194. if psn_record.ID == 0 {
  10195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10196. return
  10197. }
  10198. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10199. var res ResultTwo
  10200. var res10265 ResultTwo10265
  10201. if miConfig.Code == "H15049901371" {
  10202. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10203. utils.ErrorLog("解析失败:%v", err)
  10204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10205. return
  10206. }
  10207. res.ErrMsg = res10265.ErrMsg
  10208. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10209. res.Infcode = infocode
  10210. res.Output = res10265.Output
  10211. res.InfRefmsgid = res10265.InfRefmsgid
  10212. } else {
  10213. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10214. utils.ErrorLog("解析失败:%v", err)
  10215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10216. return
  10217. }
  10218. }
  10219. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10220. infoStr := string(Iinfos)
  10221. var rf []*ResultFive
  10222. json.Unmarshal([]byte(infoStr), &rf)
  10223. var insuplc_admdvs string
  10224. var insutype string
  10225. var is390 int = 0
  10226. var is310 int = 0
  10227. var insutypes []*ResultFive
  10228. for _, item := range rf {
  10229. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10230. insutypes = append(insutypes, item)
  10231. }
  10232. }
  10233. if len(insutypes) == 1 {
  10234. insutype = insutypes[0].Insutype
  10235. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10236. } else {
  10237. for _, i := range insutypes {
  10238. if i.Insutype == "390" {
  10239. is390 = 1
  10240. }
  10241. if i.Insutype == "310" {
  10242. is310 = 1
  10243. }
  10244. }
  10245. }
  10246. if is390 == 1 {
  10247. insutype = "390"
  10248. }
  10249. if is310 == 1 {
  10250. insutype = "310"
  10251. }
  10252. if len(insutypes) == 0 {
  10253. insutype = "310"
  10254. }
  10255. insutype = psn_record.Insutype
  10256. for _, item := range rf {
  10257. if item.Insutype == insutype {
  10258. insuplc_admdvs = item.InsuplcAdmdvs
  10259. }
  10260. }
  10261. if config.IsOpen == 1 {
  10262. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10263. var dat map[string]interface{}
  10264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10265. fmt.Println(dat)
  10266. } else {
  10267. fmt.Println(err)
  10268. }
  10269. userJSONBytes, _ := json.Marshal(dat)
  10270. var res ResultFourteen
  10271. var res10265 ResultFourteen10265
  10272. if miConfig.Code == "H15049901371" {
  10273. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10274. utils.ErrorLog("解析失败:%v", err)
  10275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10276. return
  10277. }
  10278. res.ErrMsg = res10265.ErrMsg
  10279. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10280. res.Infcode = infocode
  10281. res.Output = res10265.Output
  10282. res.InfRefmsgid = res10265.InfRefmsgid
  10283. } else {
  10284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10285. utils.ErrorLog("解析失败:%v", err)
  10286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10287. return
  10288. }
  10289. }
  10290. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10291. // utils.ErrorLog("解析失败:%v", err)
  10292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10293. // return
  10294. //}
  10295. if res.Infcode == 0 {
  10296. psn_record.IsCancel = 2
  10297. service.CreatePsnNCDSRecord(&psn_record)
  10298. c.ServeSuccessJSON(map[string]interface{}{
  10299. "failed_code": 0,
  10300. "msg": "撤销备案成功",
  10301. })
  10302. } else {
  10303. c.ServeSuccessJSON(map[string]interface{}{
  10304. "failed_code": -10,
  10305. "msg": res.ErrMsg,
  10306. })
  10307. return
  10308. }
  10309. }
  10310. }
  10311. func (c *HisApiController) TestTest() {
  10312. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10313. fmt.Println(patient.Iinfo)
  10314. }
  10315. type CustomData struct {
  10316. MsgId string
  10317. PsnNo string
  10318. Info string
  10319. }
  10320. func (c *HisApiController) ReversalData() {
  10321. var customData []*CustomData
  10322. custom := &CustomData{
  10323. MsgId: "H44022900158202103301714472004",
  10324. PsnNo: "44020000001101329945",
  10325. Info: "2207",
  10326. }
  10327. customData = append(customData, custom)
  10328. custom1 := &CustomData{
  10329. MsgId: "H4402290015820210330172057803",
  10330. PsnNo: "44020000001101161813",
  10331. Info: "2207",
  10332. }
  10333. customData = append(customData, custom1)
  10334. custom2 := &CustomData{
  10335. MsgId: "H44022900158202103301705198813",
  10336. PsnNo: "44190000133097375417",
  10337. Info: "2207",
  10338. }
  10339. customData = append(customData, custom2)
  10340. custom3 := &CustomData{
  10341. MsgId: "H44022900158202103301715524756",
  10342. PsnNo: "44020000001100187221",
  10343. Info: "2207",
  10344. }
  10345. customData = append(customData, custom3)
  10346. custom4 := &CustomData{
  10347. MsgId: "H44022900158202103301730376224",
  10348. PsnNo: "44020000001101959155",
  10349. Info: "2207",
  10350. }
  10351. customData = append(customData, custom4)
  10352. custom5 := &CustomData{
  10353. MsgId: "H44022900158202103301748008725",
  10354. PsnNo: "44020000001104246641",
  10355. Info: "2207",
  10356. }
  10357. customData = append(customData, custom5)
  10358. custom6 := &CustomData{
  10359. MsgId: "H44022900158202103301718096755",
  10360. PsnNo: "44020000001102211860",
  10361. Info: "2207",
  10362. }
  10363. customData = append(customData, custom6)
  10364. custom7 := &CustomData{
  10365. MsgId: "H44022900158202103301736551640",
  10366. PsnNo: "44020000001102687718",
  10367. Info: "2207",
  10368. }
  10369. customData = append(customData, custom7)
  10370. custom8 := &CustomData{
  10371. MsgId: "H44022900158202103301743097676",
  10372. PsnNo: "44020000001102127785",
  10373. Info: "2207",
  10374. }
  10375. customData = append(customData, custom8)
  10376. custom9 := &CustomData{
  10377. MsgId: "H44022900158202103301712304203",
  10378. PsnNo: "44020000001101518097",
  10379. Info: "2207",
  10380. }
  10381. customData = append(customData, custom9)
  10382. custom10 := &CustomData{
  10383. MsgId: "H44022900158202103301738448785",
  10384. PsnNo: "44020000001100500813",
  10385. Info: "2207",
  10386. }
  10387. customData = append(customData, custom10)
  10388. custom11 := &CustomData{
  10389. MsgId: "H44022900158202103301732455843",
  10390. PsnNo: "44020000001102690557",
  10391. Info: "2207",
  10392. }
  10393. customData = append(customData, custom11)
  10394. custom12 := &CustomData{
  10395. MsgId: "H44022900158202103301745421708",
  10396. PsnNo: "44020000001102211928",
  10397. Info: "2207",
  10398. }
  10399. customData = append(customData, custom12)
  10400. custom1212 := &CustomData{
  10401. MsgId: "H440229001582021033017351627",
  10402. PsnNo: "44020000001102481733",
  10403. Info: "2207",
  10404. }
  10405. customData = append(customData, custom1212)
  10406. custom13 := &CustomData{
  10407. MsgId: "H44022900158202103301740327951",
  10408. PsnNo: "44020000001103174866",
  10409. Info: "2207",
  10410. }
  10411. customData = append(customData, custom13)
  10412. custom14 := &CustomData{
  10413. MsgId: "H4402290015820210330174922668",
  10414. PsnNo: "44020000001102927272",
  10415. Info: "2207",
  10416. }
  10417. customData = append(customData, custom14)
  10418. custom15 := &CustomData{
  10419. MsgId: "H44022900158202103301752362273",
  10420. PsnNo: "44020000001102942890",
  10421. Info: "2207",
  10422. }
  10423. customData = append(customData, custom15)
  10424. custom16 := &CustomData{
  10425. MsgId: "H44022900158202103301751082917",
  10426. PsnNo: "44020000001101662162",
  10427. Info: "2207",
  10428. }
  10429. customData = append(customData, custom16)
  10430. custom17 := &CustomData{
  10431. MsgId: "H44022900158202103301754147728",
  10432. PsnNo: "44020000000229014511",
  10433. Info: "2207",
  10434. }
  10435. customData = append(customData, custom17)
  10436. adminUser := c.GetAdminUserInfo()
  10437. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10438. for _, item := range customData {
  10439. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10440. fmt.Println(result)
  10441. }
  10442. }
  10443. func (c *HisApiController) GetAllopatry() {
  10444. year := c.GetString("year")
  10445. month := c.GetString("month")
  10446. admin_user_id, _ := c.GetInt64("admin_user_id")
  10447. adminUser := c.GetAdminUserInfo()
  10448. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10449. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10450. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10451. var dat map[string]interface{}
  10452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10453. fmt.Println(dat)
  10454. } else {
  10455. fmt.Println(err)
  10456. }
  10457. userJSONBytes, _ := json.Marshal(dat)
  10458. var res models.Result9001
  10459. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10460. utils.ErrorLog("解析失败:%v", err)
  10461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10462. return
  10463. }
  10464. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10465. var dat2 map[string]interface{}
  10466. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10467. fmt.Println(dat)
  10468. } else {
  10469. fmt.Println(err)
  10470. }
  10471. userJSONBytes2, _ := json.Marshal(dat2)
  10472. var res2 models.Result3260
  10473. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10474. utils.ErrorLog("解析失败:%v", err)
  10475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10476. return
  10477. }
  10478. if res2.Infcode == 0 {
  10479. c.ServeSuccessJSON(map[string]interface{}{
  10480. "list": res2.Output.Data,
  10481. })
  10482. return
  10483. } else {
  10484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10485. return
  10486. }
  10487. }
  10488. func (c *HisApiController) ComfirmAllopatry() {
  10489. year := c.GetString("year")
  10490. month := c.GetString("month")
  10491. admin_user_id, _ := c.GetInt64("admin_user_id")
  10492. adminUser := c.GetAdminUserInfo()
  10493. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10494. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10495. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10496. var dat map[string]interface{}
  10497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10498. fmt.Println(dat)
  10499. } else {
  10500. fmt.Println(err)
  10501. }
  10502. userJSONBytes, _ := json.Marshal(dat)
  10503. var res models.Result9001
  10504. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10505. utils.ErrorLog("解析失败:%v", err)
  10506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10507. return
  10508. }
  10509. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10510. var dat2 map[string]interface{}
  10511. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10512. fmt.Println(dat)
  10513. } else {
  10514. fmt.Println(err)
  10515. }
  10516. userJSONBytes2, _ := json.Marshal(dat2)
  10517. var res2 models.Result3260
  10518. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10519. utils.ErrorLog("解析失败:%v", err)
  10520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10521. return
  10522. }
  10523. if res2.Infcode == 0 {
  10524. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10525. var dat map[string]interface{}
  10526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10527. fmt.Println(dat)
  10528. } else {
  10529. fmt.Println(err)
  10530. }
  10531. userJSONBytes, _ := json.Marshal(dat)
  10532. var res3 models.Result3261
  10533. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10534. utils.ErrorLog("解析失败:%v", err)
  10535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10536. return
  10537. }
  10538. if res3.Infcode == 0 {
  10539. record := &models.HisYidiClearRecord{
  10540. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10541. Ctime: time.Now().Unix(),
  10542. Mtime: time.Now().Unix(),
  10543. Status: 1,
  10544. MsgId: msgId,
  10545. }
  10546. service.SaveClearRecord(record)
  10547. c.ServeSuccessJSON(map[string]interface{}{
  10548. "msg": "提取成功",
  10549. })
  10550. }
  10551. }
  10552. }
  10553. func (c *HisApiController) RefundAllopatry() {
  10554. year := c.GetString("year")
  10555. month := c.GetString("month")
  10556. id, _ := c.GetInt64("id")
  10557. admin_user_id, _ := c.GetInt64("admin_user_id")
  10558. adminUser := c.GetAdminUserInfo()
  10559. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10560. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10561. record, _ := service.GetClearRecordById(id)
  10562. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10563. var dat map[string]interface{}
  10564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10565. fmt.Println(dat)
  10566. } else {
  10567. fmt.Println(err)
  10568. }
  10569. userJSONBytes, _ := json.Marshal(dat)
  10570. var empty ResultFourteen
  10571. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10572. utils.ErrorLog("解析失败:%v", err)
  10573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10574. return
  10575. }
  10576. if empty.Infcode == 0 {
  10577. c.ServeSuccessJSON(map[string]interface{}{
  10578. "msg": "撤销成功",
  10579. })
  10580. return
  10581. }
  10582. }
  10583. func (c *HisApiController) ReversalOtherData() {
  10584. var customData []*CustomData
  10585. custom := &CustomData{
  10586. MsgId: "H44022900158202103301714472004",
  10587. PsnNo: "44020000001101329945",
  10588. Info: "2208",
  10589. }
  10590. customData = append(customData, custom)
  10591. custom1 := &CustomData{
  10592. MsgId: "H4402290015820210330172057803",
  10593. PsnNo: "44020000001101161813",
  10594. Info: "2208",
  10595. }
  10596. customData = append(customData, custom1)
  10597. custom2 := &CustomData{
  10598. MsgId: "H44022900158202103301705198813",
  10599. PsnNo: "44190000133097375417",
  10600. Info: "2208",
  10601. }
  10602. customData = append(customData, custom2)
  10603. custom3 := &CustomData{
  10604. MsgId: "H44022900158202103301715524756",
  10605. PsnNo: "44020000001100187221",
  10606. Info: "2208",
  10607. }
  10608. customData = append(customData, custom3)
  10609. custom4 := &CustomData{
  10610. MsgId: "H44022900158202103301730376224",
  10611. PsnNo: "44020000001101959155",
  10612. Info: "2208",
  10613. }
  10614. customData = append(customData, custom4)
  10615. custom5 := &CustomData{
  10616. MsgId: "H44022900158202103301748008725",
  10617. PsnNo: "44020000001104246641",
  10618. Info: "2208",
  10619. }
  10620. customData = append(customData, custom5)
  10621. custom6 := &CustomData{
  10622. MsgId: "H44022900158202103301718096755",
  10623. PsnNo: "44020000001102211860",
  10624. Info: "2208",
  10625. }
  10626. customData = append(customData, custom6)
  10627. custom7 := &CustomData{
  10628. MsgId: "H44022900158202103301736551640",
  10629. PsnNo: "44020000001102687718",
  10630. Info: "2208",
  10631. }
  10632. customData = append(customData, custom7)
  10633. custom8 := &CustomData{
  10634. MsgId: "H44022900158202103301743097676",
  10635. PsnNo: "44020000001102127785",
  10636. Info: "2208",
  10637. }
  10638. customData = append(customData, custom8)
  10639. custom9 := &CustomData{
  10640. MsgId: "H44022900158202103301712304203",
  10641. PsnNo: "44020000001101518097",
  10642. Info: "2208",
  10643. }
  10644. customData = append(customData, custom9)
  10645. custom10 := &CustomData{
  10646. MsgId: "H44022900158202103301738448785",
  10647. PsnNo: "44020000001100500813",
  10648. Info: "2208",
  10649. }
  10650. customData = append(customData, custom10)
  10651. custom11 := &CustomData{
  10652. MsgId: "H44022900158202103301732455843",
  10653. PsnNo: "44020000001102690557",
  10654. Info: "2208",
  10655. }
  10656. customData = append(customData, custom11)
  10657. custom12 := &CustomData{
  10658. MsgId: "H44022900158202103301745421708",
  10659. PsnNo: "44020000001102211928",
  10660. Info: "2208",
  10661. }
  10662. customData = append(customData, custom12)
  10663. custom1212 := &CustomData{
  10664. MsgId: "H440229001582021033017351627",
  10665. PsnNo: "44020000001102481733",
  10666. Info: "2208",
  10667. }
  10668. customData = append(customData, custom1212)
  10669. custom13 := &CustomData{
  10670. MsgId: "H44022900158202103301740327951",
  10671. PsnNo: "44020000001103174866",
  10672. Info: "2208",
  10673. }
  10674. customData = append(customData, custom13)
  10675. custom14 := &CustomData{
  10676. MsgId: "H4402290015820210330174922668",
  10677. PsnNo: "44020000001102927272",
  10678. Info: "2208",
  10679. }
  10680. customData = append(customData, custom14)
  10681. custom15 := &CustomData{
  10682. MsgId: "H44022900158202103301752362273",
  10683. PsnNo: "44020000001102942890",
  10684. Info: "2208",
  10685. }
  10686. customData = append(customData, custom15)
  10687. custom16 := &CustomData{
  10688. MsgId: "H44022900158202103301751082917",
  10689. PsnNo: "44020000001101662162",
  10690. Info: "2208",
  10691. }
  10692. customData = append(customData, custom16)
  10693. custom17 := &CustomData{
  10694. MsgId: "H44022900158202103301754147728",
  10695. PsnNo: "44020000000229014511",
  10696. Info: "2208",
  10697. }
  10698. customData = append(customData, custom17)
  10699. adminUser := c.GetAdminUserInfo()
  10700. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10701. for _, item := range customData {
  10702. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10703. fmt.Println(result)
  10704. }
  10705. }
  10706. func PathExists(path string) (bool, error) {
  10707. _, err := os.Stat(path)
  10708. if err == nil {
  10709. return true, nil
  10710. }
  10711. if os.IsNotExist(err) {
  10712. return false, nil
  10713. }
  10714. return false, err
  10715. }
  10716. //创建文件夹
  10717. func Mkdir(dir string) {
  10718. // 创建文件夹
  10719. exist, err := PathExists(dir)
  10720. if err != nil {
  10721. fmt.Println(err.Error())
  10722. } else {
  10723. if exist {
  10724. fmt.Println(dir + "文件夹已存在!")
  10725. } else {
  10726. // 文件夹名称,权限
  10727. err := os.Mkdir(dir, os.ModePerm)
  10728. if err != nil {
  10729. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10730. } else {
  10731. fmt.Println(dir + "文件夹创建成功!")
  10732. }
  10733. }
  10734. }
  10735. }
  10736. //压缩文件
  10737. func Zip(srcFile string, destZip string) error {
  10738. zipfile, err := os.Create(destZip)
  10739. if err != nil {
  10740. return err
  10741. }
  10742. defer zipfile.Close()
  10743. archive := zip.NewWriter(zipfile)
  10744. defer archive.Close()
  10745. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10746. if err != nil {
  10747. return err
  10748. }
  10749. header, err := zip.FileInfoHeader(info)
  10750. if err != nil {
  10751. return err
  10752. }
  10753. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10754. // header.Name = path
  10755. if info.IsDir() {
  10756. header.Name += "/"
  10757. } else {
  10758. header.Method = zip.Deflate
  10759. }
  10760. writer, err := archive.CreateHeader(header)
  10761. if err != nil {
  10762. return err
  10763. }
  10764. if !info.IsDir() {
  10765. file, err := os.Open(path)
  10766. if err != nil {
  10767. return err
  10768. }
  10769. defer file.Close()
  10770. _, err = io.Copy(writer, file)
  10771. }
  10772. return err
  10773. })
  10774. return err
  10775. }
  10776. func ReadFile(filePath string) []byte {
  10777. f, err := os.Open(filePath)
  10778. if err != nil {
  10779. fmt.Println("read file fail", err)
  10780. return nil
  10781. }
  10782. defer f.Close()
  10783. fd, err := ioutil.ReadAll(f)
  10784. if err != nil {
  10785. fmt.Println("read to fd fail", err)
  10786. return nil
  10787. }
  10788. return fd
  10789. }
  10790. func saveLog(result string, request string, infno string, desc string) {
  10791. org_id, _ := beego.AppConfig.Int64("org_id")
  10792. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10793. dir := miConfig.OrgName + "日志"
  10794. utils.Mkdir(dir)
  10795. month := time.Unix(1557042972, 0).Format("1")
  10796. year := time.Now().Format("2006")
  10797. month = time.Now().Format("01")
  10798. day := time.Now().Format("02")
  10799. hour := time.Now().Format("15")
  10800. min := time.Now().Format("04")
  10801. sec := time.Now().Format("05")
  10802. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10803. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10804. file_name := file + ".txt"
  10805. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10806. exist, _ := utils.PathExists(file_path)
  10807. if exist { //存在
  10808. fmt.Println("存在")
  10809. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10810. if err != nil {
  10811. fmt.Println("read fail")
  10812. }
  10813. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10814. n, _ := f.Seek(0, 2)
  10815. _, err = f.WriteAt([]byte(content), n)
  10816. } else { //不存在
  10817. fmt.Println("文件不存在,创建文件")
  10818. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10819. defer f.Close()
  10820. if err != nil {
  10821. } else {
  10822. _, err = f.Write([]byte("记录日志"))
  10823. }
  10824. }
  10825. }
  10826. type Charset string
  10827. const (
  10828. UTF8 = Charset("UTF-8")
  10829. GB18030 = Charset("GB18030")
  10830. )
  10831. func ConvertToString(src string, srcCode string, tagCode string) string {
  10832. srcCoder := mahonia.NewDecoder(srcCode)
  10833. srcResult := srcCoder.ConvertString(src)
  10834. tagCoder := mahonia.NewDecoder(tagCode)
  10835. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10836. result := string(cdata)
  10837. return result
  10838. }