his_api_controller.go 377KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391
  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. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. 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 +
  93. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  94. resp, requestErr := http.Get(api)
  95. if requestErr != nil {
  96. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  97. return
  98. }
  99. body, ioErr := ioutil.ReadAll(resp.Body)
  100. if ioErr != nil {
  101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. var respJSON map[string]interface{}
  106. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  112. result, _ := json.Marshal(respJSON)
  113. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  114. utils.ErrorLog("解析失败:%v", err)
  115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  116. return
  117. }
  118. res.ErrMsg = res10265.ErrMsg
  119. res.Output = res10265.Output
  120. res.InfRefmsgid = res10265.InfRefmsgid
  121. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  122. res.Infcode = infocode
  123. } else {
  124. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  125. var dat map[string]interface{}
  126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  127. fmt.Println(dat)
  128. } else {
  129. fmt.Println(err)
  130. }
  131. userJSONBytes, _ := json.Marshal(dat)
  132. if miConfig.Code == "H15049901371" {
  133. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  134. utils.ErrorLog("解析失败:%v", err)
  135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  136. return
  137. }
  138. res.InfRefmsgid = res10265.InfRefmsgid
  139. res.Output = res10265.Output
  140. res.ErrMsg = res10265.ErrMsg
  141. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  142. res.Infcode = infocode
  143. } else {
  144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  145. utils.ErrorLog("解析失败:%v", err)
  146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  147. return
  148. }
  149. }
  150. }
  151. if res.Infcode == 0 {
  152. c.ServeSuccessJSON(map[string]interface{}{
  153. "result": res.Output.Result,
  154. })
  155. }
  156. }
  157. func (c *HisApiController) CheckInsutype() {
  158. his_patient_id, _ := c.GetInt64("his_patient_id")
  159. admin_user_id, _ := c.GetInt64("admin_user_id")
  160. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  161. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  162. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  163. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  164. var dat map[string]interface{}
  165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  166. fmt.Println(dat)
  167. } else {
  168. fmt.Println(err)
  169. }
  170. userJSONBytes, _ := json.Marshal(dat)
  171. var res Result90100
  172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  173. utils.ErrorLog("解析失败:%v", err)
  174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  175. return
  176. }
  177. if res.Infcode != 0 {
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "failed_code": -10,
  180. "msg": res.ErrMsg,
  181. })
  182. return
  183. } else {
  184. fmt.Println(res)
  185. }
  186. }
  187. func (c *HisApiController) CheckCardPWD() {
  188. card_pwd := c.GetString("card_pwd")
  189. his_patient_id, _ := c.GetInt64("his_patient_id")
  190. admin_user_id, _ := c.GetInt64("admin_user_id")
  191. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  193. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  194. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  195. var dat map[string]interface{}
  196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  197. fmt.Println(dat)
  198. } else {
  199. fmt.Println(err)
  200. }
  201. userJSONBytes, _ := json.Marshal(dat)
  202. var res Result90991
  203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  204. utils.ErrorLog("解析失败:%v", err)
  205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  206. return
  207. }
  208. if res.Infcode != 0 {
  209. c.ServeSuccessJSON(map[string]interface{}{
  210. "failed_code": -10,
  211. "msg": res.ErrMsg,
  212. })
  213. return
  214. } else {
  215. if res.Output.Result.CheckStat == "0" {
  216. var msg string
  217. switch res.Output.Result.CardStat {
  218. case "00":
  219. msg = "未激活"
  220. break
  221. case "10":
  222. msg = "激活"
  223. break
  224. case "20":
  225. msg = "窗口挂失"
  226. break
  227. case "21":
  228. msg = "电话挂失"
  229. break
  230. case "22":
  231. msg = "单位网上申报挂失"
  232. break
  233. case "23":
  234. msg = "保健办挂失"
  235. break
  236. case "24":
  237. msg = "个人网上挂失"
  238. break
  239. case "25":
  240. msg = "网上服务大厅挂失"
  241. break
  242. case "30":
  243. msg = "注销"
  244. break
  245. case "40":
  246. msg = "回收"
  247. break
  248. case "99":
  249. msg = "制卡中(无效卡)"
  250. break
  251. }
  252. c.ServeSuccessJSON(map[string]interface{}{
  253. "failed_code": -10,
  254. "msg": msg,
  255. })
  256. return
  257. } else {
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "msg": "校验成功",
  260. })
  261. return
  262. }
  263. }
  264. }
  265. func (c *HisApiController) ReadCard() {
  266. id_card_type, _ := c.GetInt64("id_card_type")
  267. admin_user_id, _ := c.GetInt64("admin_user_id")
  268. certificates, _ := c.GetInt64("certificates")
  269. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  270. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  271. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  272. switch id_card_type {
  273. case 1:
  274. if miConfig.MdtrtareaAdmvs == "421300" {
  275. var res ResultTwo
  276. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  277. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  278. "&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)
  279. resp, requestErr := http.Get(api)
  280. if requestErr != nil {
  281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  282. return
  283. }
  284. body, ioErr := ioutil.ReadAll(resp.Body)
  285. if ioErr != nil {
  286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. var respJSON map[string]interface{}
  291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  297. result, _ := json.Marshal(respJSON)
  298. fmt.Println("log")
  299. fmt.Println(string(result))
  300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  301. utils.ErrorLog("解析失败:%v", err)
  302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  303. return
  304. }
  305. if res.Infcode == 0 {
  306. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  307. if err == gorm.ErrRecordNotFound {
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  309. return
  310. } else if err != nil {
  311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  312. return
  313. } else {
  314. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  315. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  316. infoStr := string(Iinfos)
  317. idetinfoStr := string(Idetinfos)
  318. psn := &models.HisPsn{
  319. PsnNo: res.Output.Baseinfo.PsnNo,
  320. Age: res.Output.Baseinfo.Age,
  321. PatientId: patient.ID,
  322. Certno: res.Output.Baseinfo.Certno,
  323. Brdy: res.Output.Baseinfo.Brdy,
  324. Gend: res.Output.Baseinfo.Gend,
  325. Naty: res.Output.Baseinfo.Naty,
  326. PsnCertType: res.Output.Baseinfo.PsnCertType,
  327. PsnName: res.Output.Baseinfo.PsnName,
  328. Idetinfo: idetinfoStr,
  329. Insuinfo: infoStr,
  330. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  331. }
  332. service.CreateHisPsn(psn)
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "patient": patient,
  335. "number": res.Output.Baseinfo.Certno,
  336. })
  337. }
  338. } else {
  339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  340. return
  341. }
  342. } else if miConfig.MdtrtareaAdmvs == "320921" {
  343. 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 +
  344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  345. resp, requestErr := http.Get(api)
  346. if requestErr != nil {
  347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  348. return
  349. }
  350. body, ioErr := ioutil.ReadAll(resp.Body)
  351. if ioErr != nil {
  352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  354. return
  355. }
  356. var respJSON map[string]interface{}
  357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. var status string
  363. status = respJSON["data"].(map[string]interface{})["status"].(string)
  364. if status == "0" { //读卡成功
  365. var card_info string //卡信息
  366. var busi_card_info string
  367. var res ResultTwo //1101结果
  368. var res10265 ResultTwo10265 //1101结果
  369. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  370. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  371. fmt.Println(card_info)
  372. fmt.Println(busi_card_info)
  373. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  374. result, _ := json.Marshal(respJSON)
  375. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  376. utils.ErrorLog("解析失败:%v", err)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return
  379. }
  380. res.ErrMsg = res10265.ErrMsg
  381. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  382. res.Infcode = infocode
  383. res.Output = res10265.Output
  384. res.InfRefmsgid = res10265.InfRefmsgid
  385. if res.Infcode == 0 {
  386. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  387. if err == gorm.ErrRecordNotFound {
  388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  389. return
  390. } else if err != nil {
  391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  392. return
  393. } else {
  394. bas := strings.Split(card_info, "|")
  395. basNumber := bas[2]
  396. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  397. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  398. infoStr := string(Iinfos)
  399. idetinfoStr := string(Idetinfos)
  400. psn := &models.HisPsn{
  401. PsnNo: res.Output.Baseinfo.PsnNo,
  402. Age: res.Output.Baseinfo.Age,
  403. PatientId: patient.ID,
  404. Certno: res.Output.Baseinfo.Certno,
  405. Brdy: res.Output.Baseinfo.Brdy,
  406. Gend: res.Output.Baseinfo.Gend,
  407. Naty: res.Output.Baseinfo.Naty,
  408. PsnCertType: res.Output.Baseinfo.PsnCertType,
  409. PsnName: res.Output.Baseinfo.PsnName,
  410. Idetinfo: idetinfoStr,
  411. Insuinfo: infoStr,
  412. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  413. CardInfo: card_info,
  414. VerifyNumber: busi_card_info,
  415. }
  416. service.CreateHisPsn(psn)
  417. c.ServeSuccessJSON(map[string]interface{}{
  418. "patient": patient,
  419. "number": basNumber,
  420. })
  421. }
  422. } else {
  423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  424. return
  425. }
  426. } else { //读卡失败
  427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  428. return
  429. }
  430. } else {
  431. if initFlag == 0 {
  432. c.TestGetBasBaseInit()
  433. }
  434. basStr := c.GetBasBaseInfo()
  435. if len(basStr) == 0 {
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  437. return
  438. }
  439. fmt.Println(basStr)
  440. bas := strings.Split(basStr, "|")
  441. basNumber := bas[1]
  442. fmt.Println(basNumber)
  443. card_sn := bas[3]
  444. fmt.Println(card_sn)
  445. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  446. var dat map[string]interface{}
  447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  448. fmt.Println(dat)
  449. } else {
  450. fmt.Println(err)
  451. }
  452. userJSONBytes, _ := json.Marshal(dat)
  453. var res ResultTwo
  454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  455. utils.ErrorLog("解析失败:%v", err)
  456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  457. return
  458. }
  459. if res.Infcode == 0 {
  460. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  461. if err == gorm.ErrRecordNotFound {
  462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  463. return
  464. } else if err != nil {
  465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  466. return
  467. } else {
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "patient": patient,
  470. "number": basNumber,
  471. })
  472. }
  473. } else {
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  475. return
  476. }
  477. break
  478. }
  479. case 2:
  480. SFZStr := c.GetSFZBaseInfo()
  481. id_card_str := strings.Split(SFZStr, "^")
  482. id_card_number := id_card_str[0]
  483. card_sn := ""
  484. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  485. var dat map[string]interface{}
  486. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  487. fmt.Println(dat)
  488. } else {
  489. fmt.Println(err)
  490. }
  491. userJSONBytes, _ := json.Marshal(dat)
  492. var res ResultTwo
  493. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  494. utils.ErrorLog("解析失败:%v", err)
  495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  496. return
  497. }
  498. if res.Infcode == 0 {
  499. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  500. if err == gorm.ErrRecordNotFound {
  501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  502. return
  503. } else if err != nil {
  504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  505. return
  506. } else {
  507. c.ServeSuccessJSON(map[string]interface{}{
  508. "patient": patient,
  509. "number": id_card_number,
  510. })
  511. }
  512. } else {
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  514. return
  515. }
  516. break
  517. case 3:
  518. break
  519. }
  520. }
  521. var initFlag int64 = 0
  522. func (c *HisApiController) TestGetBasBaseInit() {
  523. DllDef := syscall.MustLoadDLL("SSCard.dll")
  524. Iinit := DllDef.MustFindProc("Init")
  525. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  526. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  527. if ret != 0 {
  528. fmt.Println("SSCard的报错原因:", err)
  529. fmt.Println("SSCard的运算结果为:", ret)
  530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  531. return
  532. }
  533. result := int(ret)
  534. fmt.Println("SSCard的运算结果为1:", result)
  535. initFlag = 1
  536. return
  537. }
  538. func (c *HisApiController) GetSFZBaseInfo() string {
  539. DllDef := syscall.MustLoadDLL("SSCard.dll")
  540. readCard := DllDef.MustFindProc("ReadSFZ")
  541. if readCard == nil {
  542. fmt.Println("readcard is nil")
  543. readCard = DllDef.MustFindProc("ReadSFZ")
  544. }
  545. str := make([]byte, 256)
  546. str1 := make([]byte, 256)
  547. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  548. fmt.Println(r)
  549. return string(str)
  550. }
  551. func (c *HisApiController) GetBasBaseInfo() string {
  552. DllDef := syscall.MustLoadDLL("SSCard.dll")
  553. readCard := DllDef.MustFindProc("ReadCardBas")
  554. if readCard == nil {
  555. fmt.Println("readcard is nil")
  556. readCard = DllDef.MustFindProc("ReadCardBas")
  557. }
  558. str := make([]byte, 1024)
  559. str1 := make([]byte, 1024)
  560. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  561. fmt.Println(string(str1))
  562. fmt.Println(string(str))
  563. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  564. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  565. if ret2 != 0 {
  566. return ""
  567. }
  568. return string(str)
  569. }
  570. type CustomFundPay struct {
  571. FundPayType string `json:"fund_pay_type"`
  572. FundPayamt float64 `json:"fund_payamt"`
  573. }
  574. func (c *HisApiController) GetSettleList() {
  575. order_id, _ := c.GetInt64("order_id")
  576. admin_user_id, _ := c.GetInt64("admin_user_id")
  577. order, _ := service.GetHisOrderByIDTwo(order_id)
  578. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  579. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  580. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  581. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  582. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  583. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  584. if order.ID == 0 {
  585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  586. return
  587. }
  588. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  589. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  590. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  591. fmt.Println(count)
  592. var zero string
  593. number := count + 1
  594. if number >= 1000 {
  595. zero = "0000" + strconv.FormatInt(number, 10)
  596. } else if number >= 10000 {
  597. zero = "000" + strconv.FormatInt(number, 10)
  598. } else if number >= 100000 {
  599. zero = "00" + strconv.FormatInt(number, 10)
  600. } else if number >= 1000000 {
  601. zero = "0" + strconv.FormatInt(number, 10)
  602. } else {
  603. zero = strconv.FormatInt(number, 10)
  604. }
  605. fmt.Println(zero)
  606. struct4101 := service.Struct4101{
  607. PsnNo: order.PsnNo,
  608. MdtrtId: order.MdtrtId,
  609. SetlId: order.SetlId,
  610. PsnName: order.PsnName,
  611. Gend: order.Gend,
  612. Brdy: his.Brdy,
  613. Age: his.Age,
  614. Naty: order.Naty,
  615. PatnCertType: "01",
  616. Certno: order.Certno,
  617. Prfs: "90",
  618. ConerName: roles[0].UserName,
  619. PatnRlts: "99",
  620. ConerAddr: miConfig.OrgName,
  621. ConerTel: admin.Mobile,
  622. HiType: order.Insutype,
  623. Insuplc: miConfig.InsuplcAdmdvs,
  624. MaindiagFlag: "1",
  625. BillCode: last_order.FaPiaoCode,
  626. BillNo: zero,
  627. BizSn: order.Number,
  628. PsnSelfPay: order.PsnPartAmt,
  629. PsnOwnPay: order.PsnPartAmt,
  630. AcctPay: order.AcctPay,
  631. PsnCashpay: order.PsnCashPay,
  632. HiPaymtd: "1",
  633. Hsorg: miConfig.InsuplcAdmdvs,
  634. HsorgOpter: miConfig.InsuplcAdmdvs,
  635. MedinsFillPsn: curRoles.UserName,
  636. MedinsFillDept: depart.Name,
  637. IptMedType: "2",
  638. }
  639. struct4101.SetlBegnDate = order.SetlTime
  640. struct4101.SetlEndDate = order.SetlTime
  641. time_arr := strings.Split(order.SetlTime, " ")
  642. struct4101.AdmTime = time_arr[0]
  643. struct4101.AdmEndTime = time_arr[0]
  644. var rf []CustomFundPay
  645. json.Unmarshal([]byte(order.SetlDetail), &rf)
  646. var tempFunPays []service.CustomStruct
  647. for _, item := range rf {
  648. var tempFunPay service.CustomStruct
  649. tempFunPay.FundPayamt = item.FundPayamt
  650. tempFunPay.FundPayType = item.FundPayType
  651. tempFunPays = append(tempFunPays, tempFunPay)
  652. }
  653. struct4101.CustomStruct = tempFunPays
  654. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  655. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  656. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  657. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  658. var config []*models.HisXtDiagnoseConfig
  659. for _, item := range diagnosis_ids {
  660. id, _ := strconv.ParseInt(item, 10, 64)
  661. diagnosisConfig, _ := service.FindDiagnoseById(id)
  662. config = append(config, &diagnosisConfig)
  663. }
  664. for _, item := range config {
  665. var tempOpspdiseinfo service.OpspdiseinfoStruct
  666. tempOpspdiseinfo.DiagCode = item.CountryCode
  667. tempOpspdiseinfo.DiagName = item.CountryContentName
  668. tempOpspdiseinfo.MaindiagFlag = "1"
  669. tempOpspdiseinfo.OprnOprtCode = ""
  670. tempOpspdiseinfo.OprnOprtName = ""
  671. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  672. }
  673. sickConfigTwo, _ := service.FindSickById(his.SickType)
  674. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  675. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  676. tempOpspdiseinfo2.MaindiagFlag = "2"
  677. tempOpspdiseinfo2.OprnOprtCode = ""
  678. tempOpspdiseinfo2.OprnOprtName = ""
  679. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  680. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  681. var iteminfo service.IteminfoStruct
  682. var bedCostTotal float64 = 0 //床位总费
  683. var bedCostSelfTotal float64 = 0 //床位自费
  684. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  685. var operationCostTotal float64 = 0 //手术费
  686. var operationCostSelfTotal float64 = 0 //手术费
  687. var operationCostPartSelfTotal float64 = 0 //手术费
  688. var otherCostTotal float64 = 0 //其他费用
  689. var otherCostSelfTotal float64 = 0 //其他费用
  690. var otherCostPartSelfTotal float64 = 0 //其他费用
  691. var materialCostTotal float64 = 0 //材料费
  692. var materialCostSelfTotal float64 = 0 //材料费
  693. var materialCostPartSelfTotal float64 = 0 //材料费
  694. var westernMedicineCostTotal float64 = 0 //西药费
  695. var westernMedicineCostSelfTotal float64 = 0 //西药费
  696. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  697. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  698. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  699. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  700. var checkCostTotal float64 = 0 //检查费
  701. var checkCostSelfTotal float64 = 0 //检查费
  702. var checkCostPartSelfTotal float64 = 0 //检查费
  703. var laboratoryCostTotal float64 = 0 //化验费
  704. var laboratoryCostSelfTotal float64 = 0 //化验费
  705. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  706. var treatCostTotal float64 = 0 //治疗费用
  707. var treatCostSelfTotal float64 = 0 //治疗费用
  708. var treatCostPartSelfTotal float64 = 0 //治疗费用
  709. decimal.DivisionPrecision = 2
  710. var bed_fulamt_ownpay_amt float64 = 0
  711. var operation_fulamt_ownpay_amt float64 = 0
  712. var other_fulamt_ownpay_amt float64 = 0
  713. var westernMedicine_fulamt_ownpay_amt float64 = 0
  714. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  715. var check_fulamt_ownpay_amt float64 = 0
  716. var material_fulamt_ownpay_amt float64 = 0
  717. var laboratory_fulamt_ownpay_amt float64 = 0
  718. var treat_fulamt_ownpay_amt float64 = 0
  719. var bed_claa_sunmfee float64 = 0
  720. var bed_clab_amt float64 = 0
  721. var bed_other_amt float64 = 0
  722. var operation_claa_sunmfee float64 = 0
  723. var operation_clab_amt float64 = 0
  724. var operation_other_amt float64 = 0
  725. var other_claa_sunmfee float64 = 0
  726. var other_clab_amt float64 = 0
  727. var other_other_amt float64 = 0
  728. var westernMedicine_claa_sunmfee float64 = 0
  729. var westernMedicine_clab_amt float64 = 0
  730. var westernMedicine_other_amt float64 = 0
  731. var chineseTraditional_claa_sunmfee float64 = 0
  732. var chineseTraditional_clab_amt float64 = 0
  733. var chineseTraditional_other_amt float64 = 0
  734. var check_claa_sunmfee float64 = 0
  735. var check_clab_amt float64 = 0
  736. var check_other_amt float64 = 0
  737. var material_claa_sunmfee float64 = 0
  738. var material_clab_amt float64 = 0
  739. var material_other_amt float64 = 0
  740. var laboratory_claa_sunmfee float64 = 0
  741. var laboratory_clab_amt float64 = 0
  742. var laboratory_other_amt float64 = 0
  743. var treat_claa_sunmfee float64 = 0
  744. var treat_clab_amt float64 = 0
  745. var treat_other_amt float64 = 0
  746. for _, item := range order.HisOrderInfo {
  747. if item.MedChrgitmType == "01" { //床位费
  748. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  749. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  750. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  751. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  752. if item.ChrgitmLv == "1" {
  753. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  754. }
  755. if item.ChrgitmLv == "2" {
  756. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  757. }
  758. if item.ChrgitmLv == "3" {
  759. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  760. }
  761. }
  762. if item.MedChrgitmType == "03" { //检查费
  763. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  764. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  765. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  766. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  767. if item.ChrgitmLv == "1" {
  768. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  769. }
  770. if item.ChrgitmLv == "2" {
  771. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  772. }
  773. if item.ChrgitmLv == "3" {
  774. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  775. }
  776. }
  777. if item.MedChrgitmType == "04" { //化验费
  778. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  779. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  780. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  781. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  782. if item.ChrgitmLv == "1" {
  783. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  784. }
  785. if item.ChrgitmLv == "2" {
  786. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  787. }
  788. if item.ChrgitmLv == "3" {
  789. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  790. }
  791. }
  792. if item.MedChrgitmType == "05" { //治疗费
  793. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  794. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  795. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  796. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  797. if item.ChrgitmLv == "1" {
  798. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  799. }
  800. if item.ChrgitmLv == "2" {
  801. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  802. }
  803. if item.ChrgitmLv == "3" {
  804. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  805. }
  806. }
  807. if item.MedChrgitmType == "06" { //手术费
  808. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  809. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  810. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  811. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  812. if item.ChrgitmLv == "1" {
  813. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  814. }
  815. if item.ChrgitmLv == "2" {
  816. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  817. }
  818. if item.ChrgitmLv == "3" {
  819. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  820. }
  821. }
  822. if item.MedChrgitmType == "08" { //材料费
  823. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  824. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  825. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  826. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  827. if item.ChrgitmLv == "1" {
  828. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  829. }
  830. if item.ChrgitmLv == "2" {
  831. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  832. }
  833. if item.ChrgitmLv == "3" {
  834. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  835. }
  836. }
  837. if item.MedChrgitmType == "09" { //西药费
  838. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  839. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  840. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  841. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  842. if item.ChrgitmLv == "1" {
  843. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  844. }
  845. if item.ChrgitmLv == "2" {
  846. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  847. }
  848. if item.ChrgitmLv == "3" {
  849. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  850. }
  851. }
  852. if item.MedChrgitmType == "11" { //中成费
  853. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  854. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  855. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  856. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  857. if item.ChrgitmLv == "1" {
  858. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  859. }
  860. if item.ChrgitmLv == "2" {
  861. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  862. }
  863. if item.ChrgitmLv == "3" {
  864. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  865. }
  866. }
  867. if item.MedChrgitmType == "14" { //其他费
  868. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  869. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  870. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  871. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  872. if item.ChrgitmLv == "1" {
  873. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  874. }
  875. if item.ChrgitmLv == "2" {
  876. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  877. }
  878. if item.ChrgitmLv == "3" {
  879. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  880. }
  881. }
  882. }
  883. var iteminfoStructs []service.IteminfoStruct
  884. if bedCostTotal != 0 {
  885. iteminfo.MedChrgitm = "01"
  886. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  887. iteminfo.Amt = bedCostTotal
  888. iteminfo.ClaaSumfee = bed_claa_sunmfee
  889. iteminfo.ClabAmt = bed_clab_amt
  890. iteminfo.OthAmt = bed_other_amt
  891. iteminfoStructs = append(iteminfoStructs, iteminfo)
  892. }
  893. if checkCostTotal != 0 {
  894. iteminfo.MedChrgitm = "03"
  895. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  896. iteminfo.Amt = checkCostTotal
  897. iteminfo.ClaaSumfee = check_claa_sunmfee
  898. iteminfo.ClabAmt = check_clab_amt
  899. iteminfo.OthAmt = check_other_amt
  900. iteminfoStructs = append(iteminfoStructs, iteminfo)
  901. }
  902. if laboratoryCostTotal != 0 {
  903. iteminfo.MedChrgitm = "04"
  904. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  905. iteminfo.Amt = laboratoryCostTotal
  906. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  907. iteminfo.ClabAmt = laboratory_clab_amt
  908. iteminfo.OthAmt = laboratory_other_amt
  909. iteminfoStructs = append(iteminfoStructs, iteminfo)
  910. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  911. }
  912. if treatCostTotal != 0 {
  913. iteminfo.MedChrgitm = "05"
  914. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  915. iteminfo.Amt = treatCostTotal
  916. iteminfo.ClaaSumfee = treat_claa_sunmfee
  917. iteminfo.ClabAmt = treat_clab_amt
  918. iteminfo.OthAmt = treat_other_amt
  919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  920. //(struct4101.IteminfoStruct, iteminfo)
  921. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  922. }
  923. if operationCostTotal != 0 {
  924. iteminfo.MedChrgitm = "06"
  925. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  926. iteminfo.Amt = operationCostTotal
  927. iteminfo.ClaaSumfee = operation_claa_sunmfee
  928. iteminfo.ClabAmt = operation_clab_amt
  929. iteminfo.OthAmt = operation_other_amt
  930. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  931. iteminfoStructs = append(iteminfoStructs, iteminfo)
  932. }
  933. if materialCostTotal != 0 {
  934. iteminfo.MedChrgitm = "08"
  935. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  936. iteminfo.Amt = materialCostTotal
  937. iteminfo.ClaaSumfee = material_claa_sunmfee
  938. iteminfo.ClabAmt = material_clab_amt
  939. iteminfo.OthAmt = material_other_amt
  940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  941. iteminfoStructs = append(iteminfoStructs, iteminfo)
  942. }
  943. if westernMedicineCostTotal != 0 {
  944. iteminfo.MedChrgitm = "09"
  945. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  946. iteminfo.Amt = westernMedicineCostTotal
  947. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  948. iteminfo.ClabAmt = westernMedicine_clab_amt
  949. iteminfo.OthAmt = westernMedicine_other_amt
  950. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  951. iteminfoStructs = append(iteminfoStructs, iteminfo)
  952. }
  953. if chineseTraditionalMedicineCostTotal != 0 {
  954. iteminfo.MedChrgitm = "11"
  955. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  956. iteminfo.Amt = westernMedicineCostTotal
  957. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  958. iteminfo.ClabAmt = westernMedicine_clab_amt
  959. iteminfo.OthAmt = westernMedicine_other_amt
  960. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  961. iteminfoStructs = append(iteminfoStructs, iteminfo)
  962. }
  963. if otherCostTotal != 0 {
  964. iteminfo.MedChrgitm = "14"
  965. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  966. iteminfo.Amt = otherCostTotal
  967. iteminfo.ClaaSumfee = other_claa_sunmfee
  968. iteminfo.ClabAmt = other_clab_amt
  969. iteminfo.OthAmt = other_other_amt
  970. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  971. iteminfoStructs = append(iteminfoStructs, iteminfo)
  972. }
  973. struct4101.IteminfoStruct = iteminfoStructs
  974. struct4101.Ntly = "中国"
  975. struct4101.AdmCaty = "A03.06"
  976. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  977. fmt.Println(result)
  978. var dat map[string]interface{}
  979. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  980. fmt.Println(dat)
  981. } else {
  982. fmt.Println(err)
  983. }
  984. userJSONBytes, _ := json.Marshal(dat)
  985. var res ResultSeventeen
  986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  987. utils.ErrorLog("解析失败:%v", err)
  988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  989. return
  990. }
  991. if res.Infcode != 0 {
  992. c.ServeSuccessJSON(map[string]interface{}{
  993. "failed_code": -10,
  994. "msg": res.ErrMsg,
  995. })
  996. return
  997. } else {
  998. order.FaPiaoNumber = zero
  999. order.FaPiaoCode = last_order.FaPiaoCode
  1000. service.UpdateOrder(order)
  1001. hisFundSettleListResult := &models.HisFundSettleListResult{
  1002. Number: res.Output.SetlListId,
  1003. Status: 1,
  1004. Ctime: time.Now().Unix(),
  1005. Mtime: time.Now().Unix(),
  1006. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1007. IsUpload: 1,
  1008. OrderId: order_id,
  1009. }
  1010. service.CreateUploadRecord(hisFundSettleListResult)
  1011. c.ServeSuccessJSON(map[string]interface{}{
  1012. "msg": "上传成功",
  1013. "result": hisFundSettleListResult,
  1014. })
  1015. return
  1016. }
  1017. }
  1018. func (c *HisApiController) GetSettleListHospital() {
  1019. order_id, _ := c.GetInt64("order_id")
  1020. admin_user_id, _ := c.GetInt64("admin_user_id")
  1021. order, _ := service.GetHisOrderByIDTwo(order_id)
  1022. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1023. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1024. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1025. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1026. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1027. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1028. if order.ID == 0 {
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1030. return
  1031. }
  1032. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1033. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1034. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1035. fmt.Println(count)
  1036. var zero string
  1037. number := count + 1
  1038. if number >= 1000 {
  1039. zero = "0000" + strconv.FormatInt(number, 10)
  1040. } else if number >= 10000 {
  1041. zero = "000" + strconv.FormatInt(number, 10)
  1042. } else if number >= 100000 {
  1043. zero = "00" + strconv.FormatInt(number, 10)
  1044. } else if number >= 1000000 {
  1045. zero = "0" + strconv.FormatInt(number, 10)
  1046. } else {
  1047. zero = strconv.FormatInt(number, 10)
  1048. }
  1049. fmt.Println(zero)
  1050. struct4101 := service.Struct4101{
  1051. PsnNo: order.PsnNo,
  1052. MdtrtId: order.MdtrtId,
  1053. SetlId: order.SetlId,
  1054. PsnName: order.PsnName,
  1055. Gend: order.Gend,
  1056. Brdy: his.Brdy,
  1057. Age: int64(order.Age),
  1058. Naty: order.Naty,
  1059. PatnCertType: "01",
  1060. Certno: order.Certno,
  1061. Prfs: "90",
  1062. ConerName: roles[0].UserName,
  1063. PatnRlts: "99",
  1064. ConerAddr: miConfig.OrgName,
  1065. ConerTel: admin.Mobile,
  1066. HiType: order.Insutype,
  1067. Insuplc: miConfig.InsuplcAdmdvs,
  1068. MaindiagFlag: "1",
  1069. BillCode: last_order.FaPiaoCode,
  1070. BillNo: zero,
  1071. BizSn: order.Number,
  1072. PsnSelfPay: order.PsnPartAmt,
  1073. PsnOwnPay: order.PsnPartAmt,
  1074. AcctPay: order.AcctPay,
  1075. PsnCashpay: order.PsnCashPay,
  1076. HiPaymtd: "1",
  1077. Hsorg: miConfig.InsuplcAdmdvs,
  1078. HsorgOpter: miConfig.InsuplcAdmdvs,
  1079. MedinsFillPsn: curRoles.UserName,
  1080. MedinsFillDept: depart.Name,
  1081. IptMedType: "2",
  1082. }
  1083. struct4101.SetlBegnDate = order.SetlTime
  1084. struct4101.SetlEndDate = order.SetlTime
  1085. var rf []CustomFundPay
  1086. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1087. var tempFunPays []service.CustomStruct
  1088. for _, item := range rf {
  1089. var tempFunPay service.CustomStruct
  1090. tempFunPay.FundPayamt = item.FundPayamt
  1091. tempFunPay.FundPayType = item.FundPayType
  1092. tempFunPays = append(tempFunPays, tempFunPay)
  1093. }
  1094. struct4101.CustomStruct = tempFunPays
  1095. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1096. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1097. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1098. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1099. var config []*models.HisXtDiagnoseConfig
  1100. for _, item := range diagnosis_ids {
  1101. id, _ := strconv.ParseInt(item, 10, 64)
  1102. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1103. config = append(config, &diagnosisConfig)
  1104. }
  1105. for _, item := range config {
  1106. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1107. tempOpspdiseinfo.DiagCode = item.CountryCode
  1108. tempOpspdiseinfo.DiagName = item.CountryContentName
  1109. tempOpspdiseinfo.MaindiagFlag = "1"
  1110. tempOpspdiseinfo.OprnOprtCode = ""
  1111. tempOpspdiseinfo.OprnOprtName = ""
  1112. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1113. }
  1114. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1115. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1116. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1117. tempOpspdiseinfo2.MaindiagFlag = "2"
  1118. tempOpspdiseinfo2.OprnOprtCode = ""
  1119. tempOpspdiseinfo2.OprnOprtName = ""
  1120. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1121. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1122. var iteminfo service.IteminfoStruct
  1123. var bedCostTotal float64 = 0 //床位总费
  1124. var bedCostSelfTotal float64 = 0 //床位自费
  1125. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1126. var operationCostTotal float64 = 0 //手术费
  1127. var operationCostSelfTotal float64 = 0 //手术费
  1128. var operationCostPartSelfTotal float64 = 0 //手术费
  1129. var otherCostTotal float64 = 0 //其他费用
  1130. var otherCostSelfTotal float64 = 0 //其他费用
  1131. var otherCostPartSelfTotal float64 = 0 //其他费用
  1132. var materialCostTotal float64 = 0 //材料费
  1133. var materialCostSelfTotal float64 = 0 //材料费
  1134. var materialCostPartSelfTotal float64 = 0 //材料费
  1135. var westernMedicineCostTotal float64 = 0 //西药费
  1136. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1137. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1138. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1139. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1140. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1141. var checkCostTotal float64 = 0 //检查费
  1142. var checkCostSelfTotal float64 = 0 //检查费
  1143. var checkCostPartSelfTotal float64 = 0 //检查费
  1144. var laboratoryCostTotal float64 = 0 //化验费
  1145. var laboratoryCostSelfTotal float64 = 0 //化验费
  1146. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1147. var treatCostTotal float64 = 0 //治疗费用
  1148. var treatCostSelfTotal float64 = 0 //治疗费用
  1149. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1150. decimal.DivisionPrecision = 2
  1151. var bed_fulamt_ownpay_amt float64 = 0
  1152. var operation_fulamt_ownpay_amt float64 = 0
  1153. var other_fulamt_ownpay_amt float64 = 0
  1154. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1155. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1156. var check_fulamt_ownpay_amt float64 = 0
  1157. var material_fulamt_ownpay_amt float64 = 0
  1158. var laboratory_fulamt_ownpay_amt float64 = 0
  1159. var treat_fulamt_ownpay_amt float64 = 0
  1160. var bed_claa_sunmfee float64 = 0
  1161. var bed_clab_amt float64 = 0
  1162. var bed_other_amt float64 = 0
  1163. var operation_claa_sunmfee float64 = 0
  1164. var operation_clab_amt float64 = 0
  1165. var operation_other_amt float64 = 0
  1166. var other_claa_sunmfee float64 = 0
  1167. var other_clab_amt float64 = 0
  1168. var other_other_amt float64 = 0
  1169. var westernMedicine_claa_sunmfee float64 = 0
  1170. var westernMedicine_clab_amt float64 = 0
  1171. var westernMedicine_other_amt float64 = 0
  1172. var chineseTraditional_claa_sunmfee float64 = 0
  1173. var chineseTraditional_clab_amt float64 = 0
  1174. var chineseTraditional_other_amt float64 = 0
  1175. var check_claa_sunmfee float64 = 0
  1176. var check_clab_amt float64 = 0
  1177. var check_other_amt float64 = 0
  1178. var material_claa_sunmfee float64 = 0
  1179. var material_clab_amt float64 = 0
  1180. var material_other_amt float64 = 0
  1181. var laboratory_claa_sunmfee float64 = 0
  1182. var laboratory_clab_amt float64 = 0
  1183. var laboratory_other_amt float64 = 0
  1184. var treat_claa_sunmfee float64 = 0
  1185. var treat_clab_amt float64 = 0
  1186. var treat_other_amt float64 = 0
  1187. for _, item := range order.HisOrderInfo {
  1188. if item.MedChrgitmType == "01" { //床位费
  1189. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1190. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1191. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1192. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1193. if item.ChrgitmLv == "1" {
  1194. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1195. }
  1196. if item.ChrgitmLv == "2" {
  1197. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1198. }
  1199. if item.ChrgitmLv == "3" {
  1200. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1201. }
  1202. }
  1203. if item.MedChrgitmType == "03" { //检查费
  1204. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1205. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1206. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1207. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1208. if item.ChrgitmLv == "1" {
  1209. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1210. }
  1211. if item.ChrgitmLv == "2" {
  1212. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1213. }
  1214. if item.ChrgitmLv == "3" {
  1215. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1216. }
  1217. }
  1218. if item.MedChrgitmType == "04" { //化验费
  1219. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1220. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1221. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1222. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1223. if item.ChrgitmLv == "1" {
  1224. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1225. }
  1226. if item.ChrgitmLv == "2" {
  1227. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1228. }
  1229. if item.ChrgitmLv == "3" {
  1230. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1231. }
  1232. }
  1233. if item.MedChrgitmType == "05" { //治疗费
  1234. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1235. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1236. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1237. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1238. if item.ChrgitmLv == "1" {
  1239. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1240. }
  1241. if item.ChrgitmLv == "2" {
  1242. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1243. }
  1244. if item.ChrgitmLv == "3" {
  1245. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1246. }
  1247. }
  1248. if item.MedChrgitmType == "06" { //手术费
  1249. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1250. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1251. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1252. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1253. if item.ChrgitmLv == "1" {
  1254. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1255. }
  1256. if item.ChrgitmLv == "2" {
  1257. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1258. }
  1259. if item.ChrgitmLv == "3" {
  1260. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1261. }
  1262. }
  1263. if item.MedChrgitmType == "08" { //材料费
  1264. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1265. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1266. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1267. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1268. if item.ChrgitmLv == "1" {
  1269. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1270. }
  1271. if item.ChrgitmLv == "2" {
  1272. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1273. }
  1274. if item.ChrgitmLv == "3" {
  1275. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1276. }
  1277. }
  1278. if item.MedChrgitmType == "09" { //西药费
  1279. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1280. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1281. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1282. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1283. if item.ChrgitmLv == "1" {
  1284. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1285. }
  1286. if item.ChrgitmLv == "2" {
  1287. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1288. }
  1289. if item.ChrgitmLv == "3" {
  1290. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1291. }
  1292. }
  1293. if item.MedChrgitmType == "11" { //中成费
  1294. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1295. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1296. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1297. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1298. if item.ChrgitmLv == "1" {
  1299. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1300. }
  1301. if item.ChrgitmLv == "2" {
  1302. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1303. }
  1304. if item.ChrgitmLv == "3" {
  1305. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1306. }
  1307. }
  1308. if item.MedChrgitmType == "14" { //其他费
  1309. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1310. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1311. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1312. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1313. if item.ChrgitmLv == "1" {
  1314. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1315. }
  1316. if item.ChrgitmLv == "2" {
  1317. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1318. }
  1319. if item.ChrgitmLv == "3" {
  1320. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1321. }
  1322. }
  1323. }
  1324. var iteminfoStructs []service.IteminfoStruct
  1325. if bedCostTotal != 0 {
  1326. iteminfo.MedChrgitm = "01"
  1327. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1328. iteminfo.Amt = bedCostTotal
  1329. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1330. iteminfo.ClabAmt = bed_clab_amt
  1331. iteminfo.OthAmt = bed_other_amt
  1332. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1333. }
  1334. if checkCostTotal != 0 {
  1335. iteminfo.MedChrgitm = "03"
  1336. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1337. iteminfo.Amt = checkCostTotal
  1338. iteminfo.ClaaSumfee = check_claa_sunmfee
  1339. iteminfo.ClabAmt = check_clab_amt
  1340. iteminfo.OthAmt = check_other_amt
  1341. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1342. }
  1343. if laboratoryCostTotal != 0 {
  1344. iteminfo.MedChrgitm = "04"
  1345. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1346. iteminfo.Amt = laboratoryCostTotal
  1347. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1348. iteminfo.ClabAmt = laboratory_clab_amt
  1349. iteminfo.OthAmt = laboratory_other_amt
  1350. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1351. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1352. }
  1353. if treatCostTotal != 0 {
  1354. iteminfo.MedChrgitm = "05"
  1355. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1356. iteminfo.Amt = treatCostTotal
  1357. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1358. iteminfo.ClabAmt = treat_clab_amt
  1359. iteminfo.OthAmt = treat_other_amt
  1360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1361. //(struct4101.IteminfoStruct, iteminfo)
  1362. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1363. }
  1364. if operationCostTotal != 0 {
  1365. iteminfo.MedChrgitm = "06"
  1366. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1367. iteminfo.Amt = operationCostTotal
  1368. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1369. iteminfo.ClabAmt = operation_clab_amt
  1370. iteminfo.OthAmt = operation_other_amt
  1371. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1372. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1373. }
  1374. if materialCostTotal != 0 {
  1375. iteminfo.MedChrgitm = "08"
  1376. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1377. iteminfo.Amt = materialCostTotal
  1378. iteminfo.ClaaSumfee = material_claa_sunmfee
  1379. iteminfo.ClabAmt = material_clab_amt
  1380. iteminfo.OthAmt = material_other_amt
  1381. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1382. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1383. }
  1384. if westernMedicineCostTotal != 0 {
  1385. iteminfo.MedChrgitm = "09"
  1386. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1387. iteminfo.Amt = westernMedicineCostTotal
  1388. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1389. iteminfo.ClabAmt = westernMedicine_clab_amt
  1390. iteminfo.OthAmt = westernMedicine_other_amt
  1391. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1392. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1393. }
  1394. if chineseTraditionalMedicineCostTotal != 0 {
  1395. iteminfo.MedChrgitm = "11"
  1396. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1397. iteminfo.Amt = westernMedicineCostTotal
  1398. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1399. iteminfo.ClabAmt = westernMedicine_clab_amt
  1400. iteminfo.OthAmt = westernMedicine_other_amt
  1401. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1402. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1403. }
  1404. if otherCostTotal != 0 {
  1405. iteminfo.MedChrgitm = "14"
  1406. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1407. iteminfo.Amt = otherCostTotal
  1408. iteminfo.ClaaSumfee = other_claa_sunmfee
  1409. iteminfo.ClabAmt = other_clab_amt
  1410. iteminfo.OthAmt = other_other_amt
  1411. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1412. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1413. }
  1414. struct4101.IteminfoStruct = iteminfoStructs
  1415. struct4101.Ntly = "中国"
  1416. struct4101.AdmCaty = "A03.06"
  1417. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1418. fmt.Println(result)
  1419. var dat map[string]interface{}
  1420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1421. fmt.Println(dat)
  1422. } else {
  1423. fmt.Println(err)
  1424. }
  1425. userJSONBytes, _ := json.Marshal(dat)
  1426. var res ResultSeventeen
  1427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1428. utils.ErrorLog("解析失败:%v", err)
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1430. return
  1431. }
  1432. if res.Infcode != 0 {
  1433. c.ServeSuccessJSON(map[string]interface{}{
  1434. "failed_code": -10,
  1435. "msg": res.ErrMsg,
  1436. })
  1437. return
  1438. } else {
  1439. order.FaPiaoNumber = zero
  1440. order.FaPiaoCode = last_order.FaPiaoCode
  1441. service.UpdateOrder(order)
  1442. hisFundSettleListResult := &models.HisFundSettleListResult{
  1443. Number: res.Output.SetlListId,
  1444. Status: 1,
  1445. Ctime: time.Now().Unix(),
  1446. Mtime: time.Now().Unix(),
  1447. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1448. IsUpload: 1,
  1449. OrderId: order_id,
  1450. }
  1451. service.CreateUploadRecord(hisFundSettleListResult)
  1452. c.ServeSuccessJSON(map[string]interface{}{
  1453. "msg": "上传成功",
  1454. "result": hisFundSettleListResult,
  1455. })
  1456. return
  1457. }
  1458. }
  1459. func (c *HisApiController) GetBatchSettleList() {
  1460. org_id, _ := beego.AppConfig.Int64("org_id")
  1461. //stage, _ := c.GetInt64("stage")
  1462. orders, _ := service.GetAllHisOrder(org_id)
  1463. for _, item := range orders {
  1464. order_id := item.ID
  1465. order, _ := service.GetHisOrderByIDTwo(order_id)
  1466. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1467. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1468. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1469. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2500)
  1470. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1471. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1472. if order.ID == 0 {
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1474. return
  1475. }
  1476. if his.BalanceAccountsType == 2 {
  1477. continue
  1478. }
  1479. struct4101 := service.Struct4101{
  1480. PsnNo: order.PsnNo,
  1481. MdtrtId: order.MdtrtId,
  1482. SetlId: order.SetlId,
  1483. PsnName: order.PsnName,
  1484. Gend: order.Gend,
  1485. Brdy: his.Brdy,
  1486. Age: his.Age,
  1487. Naty: order.Naty,
  1488. PatnCertType: "01",
  1489. Certno: order.Certno,
  1490. Prfs: "90",
  1491. ConerName: roles[0].UserName,
  1492. PatnRlts: "99",
  1493. ConerAddr: miConfig.OrgName,
  1494. ConerTel: admin.Mobile,
  1495. HiType: order.Insutype,
  1496. Insuplc: his.InsuplcAdmdvs,
  1497. MaindiagFlag: "1",
  1498. BillCode: order.FaPiaoCode,
  1499. BillNo: order.FaPiaoNumber,
  1500. BizSn: order.Number,
  1501. PsnSelfPay: order.PsnPartAmt,
  1502. PsnOwnPay: order.PsnPartAmt,
  1503. AcctPay: order.AcctPay,
  1504. PsnCashpay: order.PsnCashPay,
  1505. HiPaymtd: "1",
  1506. Hsorg: his.InsuplcAdmdvs,
  1507. HsorgOpter: his.InsuplcAdmdvs,
  1508. MedinsFillPsn: curRoles.UserName,
  1509. MedinsFillDept: depart.Name,
  1510. IptMedType: "2",
  1511. }
  1512. struct4101.SetlBegnDate = order.SetlTime
  1513. struct4101.SetlEndDate = order.SetlTime
  1514. //if order.SettleType == 1 {
  1515. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1516. // dateStr := t.Format("2006-01-02")
  1517. // struct4101.SetlBegnDate = dateStr
  1518. // struct4101.SetlEndDate = dateStr
  1519. //} else {
  1520. // t := time.Unix(int64(order.SettleStartTime), 0)
  1521. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1522. // dateStartStr := t.Format("2006-01-02")
  1523. // dateEndStr := t2.Format("2006-01-02")
  1524. // struct4101.SetlBegnDate = dateStartStr
  1525. // struct4101.SetlEndDate = dateEndStr
  1526. //}
  1527. var rf []CustomFundPay
  1528. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1529. var tempFunPays []service.CustomStruct
  1530. var tempFunPay610100 service.CustomStruct
  1531. for _, item := range rf {
  1532. if item.FundPayType == "610100" {
  1533. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1534. tempFunPay610100.FundPayType = item.FundPayType
  1535. } else {
  1536. var tempFunPay service.CustomStruct
  1537. tempFunPay.FundPayamt = item.FundPayamt
  1538. tempFunPay.FundPayType = item.FundPayType
  1539. tempFunPays = append(tempFunPays, tempFunPay)
  1540. }
  1541. }
  1542. tempFunPays = append(tempFunPays, tempFunPay610100)
  1543. struct4101.CustomStruct = tempFunPays
  1544. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1545. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1546. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1547. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1548. var config []*models.HisXtDiagnoseConfig
  1549. for _, item := range diagnosis_ids {
  1550. id, _ := strconv.ParseInt(item, 10, 64)
  1551. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1552. config = append(config, &diagnosisConfig)
  1553. }
  1554. for _, item := range config {
  1555. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1556. tempOpspdiseinfo.DiagCode = item.CountryCode
  1557. tempOpspdiseinfo.DiagName = item.CountryContentName
  1558. tempOpspdiseinfo.MaindiagFlag = "1"
  1559. tempOpspdiseinfo.OprnOprtCode = ""
  1560. tempOpspdiseinfo.OprnOprtName = ""
  1561. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1562. }
  1563. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1564. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1565. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1566. tempOpspdiseinfo2.MaindiagFlag = "2"
  1567. tempOpspdiseinfo2.OprnOprtCode = ""
  1568. tempOpspdiseinfo2.OprnOprtName = ""
  1569. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1570. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1571. var iteminfo service.IteminfoStruct
  1572. var bedCostTotal float64 = 0 //床位总费
  1573. var bedCostSelfTotal float64 = 0 //床位自费
  1574. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1575. var examineCostTotal float64 = 0 //诊查总费
  1576. var examineCostSelfTotal float64 = 0 //诊查自费
  1577. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1578. var nursingCostTotal float64 = 0 //护理总费
  1579. var nursingCostSelfTotal float64 = 0 //护理自费
  1580. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1581. var chineseMedicineCostTotal float64 = 0 //中成药
  1582. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1583. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1584. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1585. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1586. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1587. var registerCostTotal float64 = 0 //一般诊疗费
  1588. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1589. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1590. var operationCostTotal float64 = 0 //手术费
  1591. var operationCostSelfTotal float64 = 0 //手术费
  1592. var operationCostPartSelfTotal float64 = 0 //手术费
  1593. var otherCostTotal float64 = 0 //其他费用
  1594. var otherCostSelfTotal float64 = 0 //其他费用
  1595. var otherCostPartSelfTotal float64 = 0 //其他费用
  1596. var materialCostTotal float64 = 0 //材料费
  1597. var materialCostSelfTotal float64 = 0 //材料费
  1598. var materialCostPartSelfTotal float64 = 0 //材料费
  1599. var westernMedicineCostTotal float64 = 0 //西药费
  1600. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1601. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1602. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1603. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1604. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1605. var checkCostTotal float64 = 0 //检查费
  1606. var checkCostSelfTotal float64 = 0 //检查费
  1607. var checkCostPartSelfTotal float64 = 0 //检查费
  1608. var laboratoryCostTotal float64 = 0 //化验费
  1609. var laboratoryCostSelfTotal float64 = 0 //化验费
  1610. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1611. var treatCostTotal float64 = 0 //治疗费用
  1612. var treatCostSelfTotal float64 = 0 //治疗费用
  1613. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1614. decimal.DivisionPrecision = 2
  1615. var bed_fulamt_ownpay_amt float64 = 0
  1616. var examine_fulamt_ownpay_amt float64 = 0
  1617. var nursing_fulamt_ownpay_amt float64 = 0
  1618. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1619. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1620. var register_fulamt_ownpay_amt float64 = 0
  1621. var operation_fulamt_ownpay_amt float64 = 0
  1622. var other_fulamt_ownpay_amt float64 = 0
  1623. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1624. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1625. var check_fulamt_ownpay_amt float64 = 0
  1626. var material_fulamt_ownpay_amt float64 = 0
  1627. var laboratory_fulamt_ownpay_amt float64 = 0
  1628. var treat_fulamt_ownpay_amt float64 = 0
  1629. var bed_claa_sunmfee float64 = 0
  1630. var bed_clab_amt float64 = 0
  1631. var bed_other_amt float64 = 0
  1632. var examine_claa_sunmfee float64 = 0
  1633. var examine_clab_amt float64 = 0
  1634. var examine_other_amt float64 = 0
  1635. var nursing_claa_sunmfee float64 = 0
  1636. var nursing_clab_amt float64 = 0
  1637. var nursing_other_amt float64 = 0
  1638. var chinese_medicine_claa_sunmfee float64 = 0
  1639. var chinese_medicine_clab_amt float64 = 0
  1640. var chinese_medicine_other_amt float64 = 0
  1641. var commonly_treatment_claa_sunmfee float64 = 0
  1642. var commonly_treatment_clab_amt float64 = 0
  1643. var commonly_treatment_other_amt float64 = 0
  1644. var operation_claa_sunmfee float64 = 0
  1645. var operation_clab_amt float64 = 0
  1646. var operation_other_amt float64 = 0
  1647. var other_claa_sunmfee float64 = 0
  1648. var other_clab_amt float64 = 0
  1649. var other_other_amt float64 = 0
  1650. var westernMedicine_claa_sunmfee float64 = 0
  1651. var westernMedicine_clab_amt float64 = 0
  1652. var westernMedicine_other_amt float64 = 0
  1653. var chineseTraditional_claa_sunmfee float64 = 0
  1654. var chineseTraditional_clab_amt float64 = 0
  1655. var chineseTraditional_other_amt float64 = 0
  1656. var check_claa_sunmfee float64 = 0
  1657. var check_clab_amt float64 = 0
  1658. var check_other_amt float64 = 0
  1659. var material_claa_sunmfee float64 = 0
  1660. var material_clab_amt float64 = 0
  1661. var material_other_amt float64 = 0
  1662. var laboratory_claa_sunmfee float64 = 0
  1663. var laboratory_clab_amt float64 = 0
  1664. var laboratory_other_amt float64 = 0
  1665. var treat_claa_sunmfee float64 = 0
  1666. var treat_clab_amt float64 = 0
  1667. var treat_other_amt float64 = 0
  1668. var register_claa_sunmfee float64 = 0
  1669. var register_clab_amt float64 = 0
  1670. var register_other_amt float64 = 0
  1671. for _, item := range order.HisOrderInfo {
  1672. if item.MedChrgitmType == "01" { //床位费
  1673. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1674. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1675. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1676. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1677. if item.ChrgitmLv == "1" {
  1678. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1679. }
  1680. if item.ChrgitmLv == "2" {
  1681. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1682. }
  1683. if item.ChrgitmLv == "3" {
  1684. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1685. }
  1686. }
  1687. if item.MedChrgitmType == "02" { //诊查
  1688. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1689. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1690. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1691. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1692. if item.ChrgitmLv == "1" {
  1693. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1694. }
  1695. if item.ChrgitmLv == "2" {
  1696. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1697. }
  1698. if item.ChrgitmLv == "3" {
  1699. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1700. }
  1701. }
  1702. if item.MedChrgitmType == "03" { //检查费
  1703. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1704. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1705. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1706. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1707. if item.ChrgitmLv == "1" {
  1708. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1709. }
  1710. if item.ChrgitmLv == "2" {
  1711. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1712. }
  1713. if item.ChrgitmLv == "3" {
  1714. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1715. }
  1716. }
  1717. if item.MedChrgitmType == "04" { //化验费
  1718. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1719. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1720. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1721. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1722. if item.ChrgitmLv == "1" {
  1723. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1724. }
  1725. if item.ChrgitmLv == "2" {
  1726. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1727. }
  1728. if item.ChrgitmLv == "3" {
  1729. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1730. }
  1731. }
  1732. if item.MedChrgitmType == "05" { //治疗费
  1733. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1734. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1735. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1736. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1737. if item.ChrgitmLv == "1" {
  1738. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1739. }
  1740. if item.ChrgitmLv == "2" {
  1741. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1742. }
  1743. if item.ChrgitmLv == "3" {
  1744. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1745. }
  1746. }
  1747. if item.MedChrgitmType == "06" { //手术费
  1748. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1749. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1750. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1751. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1752. if item.ChrgitmLv == "1" {
  1753. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1754. }
  1755. if item.ChrgitmLv == "2" {
  1756. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1757. }
  1758. if item.ChrgitmLv == "3" {
  1759. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1760. }
  1761. }
  1762. if item.MedChrgitmType == "07" { //手术费
  1763. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1764. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1765. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1766. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1767. if item.ChrgitmLv == "1" {
  1768. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1769. }
  1770. if item.ChrgitmLv == "2" {
  1771. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1772. }
  1773. if item.ChrgitmLv == "3" {
  1774. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1775. }
  1776. }
  1777. if item.MedChrgitmType == "08" { //材料费
  1778. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1779. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1780. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1781. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1782. if item.ChrgitmLv == "1" {
  1783. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1784. }
  1785. if item.ChrgitmLv == "2" {
  1786. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1787. }
  1788. if item.ChrgitmLv == "3" {
  1789. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1790. }
  1791. }
  1792. if item.MedChrgitmType == "09" { //西药费
  1793. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1794. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1795. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1796. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1797. if item.ChrgitmLv == "1" {
  1798. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1799. }
  1800. if item.ChrgitmLv == "2" {
  1801. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1802. }
  1803. if item.ChrgitmLv == "3" {
  1804. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1805. }
  1806. }
  1807. if item.MedChrgitmType == "10" { //中药饮片
  1808. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1809. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1810. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1811. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1812. if item.ChrgitmLv == "1" {
  1813. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1814. }
  1815. if item.ChrgitmLv == "2" {
  1816. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1817. }
  1818. if item.ChrgitmLv == "3" {
  1819. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1820. }
  1821. }
  1822. if item.MedChrgitmType == "11" { //中成费
  1823. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1824. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1825. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1826. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1827. if item.ChrgitmLv == "1" {
  1828. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1829. }
  1830. if item.ChrgitmLv == "2" {
  1831. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1832. }
  1833. if item.ChrgitmLv == "3" {
  1834. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1835. }
  1836. }
  1837. if item.MedChrgitmType == "12" { //中成费
  1838. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1839. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1840. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1841. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1842. if item.ChrgitmLv == "1" {
  1843. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1844. }
  1845. if item.ChrgitmLv == "2" {
  1846. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1847. }
  1848. if item.ChrgitmLv == "3" {
  1849. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1850. }
  1851. }
  1852. if item.MedChrgitmType == "13" { //中成费
  1853. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1854. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1855. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1856. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1857. if item.ChrgitmLv == "1" {
  1858. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1859. }
  1860. if item.ChrgitmLv == "2" {
  1861. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1862. }
  1863. if item.ChrgitmLv == "3" {
  1864. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1865. }
  1866. }
  1867. if item.MedChrgitmType == "14" { //其他费
  1868. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1869. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1870. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1871. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1872. if item.ChrgitmLv == "1" {
  1873. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1874. }
  1875. if item.ChrgitmLv == "2" {
  1876. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1877. }
  1878. if item.ChrgitmLv == "3" {
  1879. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1880. }
  1881. }
  1882. }
  1883. var iteminfoStructs []service.IteminfoStruct
  1884. if bedCostTotal != 0 {
  1885. iteminfo.MedChrgitm = "01"
  1886. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1887. iteminfo.Amt = bedCostTotal
  1888. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1889. iteminfo.ClabAmt = bed_clab_amt
  1890. iteminfo.OthAmt = bed_other_amt
  1891. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1892. }
  1893. if examineCostTotal != 0 {
  1894. iteminfo.MedChrgitm = "02"
  1895. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1896. iteminfo.Amt = examineCostTotal
  1897. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1898. iteminfo.ClabAmt = examine_clab_amt
  1899. iteminfo.OthAmt = examine_other_amt
  1900. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1901. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1902. }
  1903. if checkCostTotal != 0 {
  1904. iteminfo.MedChrgitm = "03"
  1905. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1906. iteminfo.Amt = checkCostTotal
  1907. iteminfo.ClaaSumfee = check_claa_sunmfee
  1908. iteminfo.ClabAmt = check_clab_amt
  1909. iteminfo.OthAmt = check_other_amt
  1910. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1911. }
  1912. if laboratoryCostTotal != 0 {
  1913. iteminfo.MedChrgitm = "04"
  1914. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1915. iteminfo.Amt = laboratoryCostTotal
  1916. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1917. iteminfo.ClabAmt = laboratory_clab_amt
  1918. iteminfo.OthAmt = laboratory_other_amt
  1919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1920. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1921. }
  1922. if treatCostTotal != 0 {
  1923. iteminfo.MedChrgitm = "05"
  1924. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1925. iteminfo.Amt = treatCostTotal
  1926. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1927. iteminfo.ClabAmt = treat_clab_amt
  1928. iteminfo.OthAmt = treat_other_amt
  1929. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1930. //(struct4101.IteminfoStruct, iteminfo)
  1931. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1932. }
  1933. if operationCostTotal != 0 {
  1934. iteminfo.MedChrgitm = "06"
  1935. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1936. iteminfo.Amt = operationCostTotal
  1937. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1938. iteminfo.ClabAmt = operation_clab_amt
  1939. iteminfo.OthAmt = operation_other_amt
  1940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1941. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1942. }
  1943. if nursingCostTotal != 0 {
  1944. iteminfo.MedChrgitm = "07"
  1945. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1946. iteminfo.Amt = nursingCostTotal
  1947. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1948. iteminfo.ClabAmt = nursing_clab_amt
  1949. iteminfo.OthAmt = nursing_other_amt
  1950. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1951. }
  1952. if materialCostTotal != 0 {
  1953. iteminfo.MedChrgitm = "08"
  1954. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1955. iteminfo.Amt = materialCostTotal
  1956. iteminfo.ClaaSumfee = material_claa_sunmfee
  1957. iteminfo.ClabAmt = material_clab_amt
  1958. iteminfo.OthAmt = material_other_amt
  1959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1960. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1961. }
  1962. if westernMedicineCostTotal != 0 {
  1963. iteminfo.MedChrgitm = "09"
  1964. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1965. iteminfo.Amt = westernMedicineCostTotal
  1966. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1967. iteminfo.ClabAmt = westernMedicine_clab_amt
  1968. iteminfo.OthAmt = westernMedicine_other_amt
  1969. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1970. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1971. }
  1972. if chineseMedicineCostTotal != 0 {
  1973. iteminfo.MedChrgitm = "10"
  1974. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1975. iteminfo.Amt = chineseMedicineCostTotal
  1976. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1977. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1978. iteminfo.OthAmt = chinese_medicine_other_amt
  1979. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1981. }
  1982. if chineseTraditionalMedicineCostTotal != 0 {
  1983. iteminfo.MedChrgitm = "11"
  1984. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1985. iteminfo.Amt = westernMedicineCostTotal
  1986. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1987. iteminfo.ClabAmt = westernMedicine_clab_amt
  1988. iteminfo.OthAmt = westernMedicine_other_amt
  1989. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1990. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1991. }
  1992. if commonlyTreatmentCostTotal != 0 {
  1993. iteminfo.MedChrgitm = "12"
  1994. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  1995. iteminfo.Amt = commonlyTreatmentCostTotal
  1996. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  1997. iteminfo.ClabAmt = commonly_treatment_clab_amt
  1998. iteminfo.OthAmt = commonly_treatment_other_amt
  1999. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2000. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2001. }
  2002. if registerCostTotal != 0 {
  2003. iteminfo.MedChrgitm = "13"
  2004. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2005. iteminfo.Amt = registerCostTotal
  2006. iteminfo.ClaaSumfee = register_claa_sunmfee
  2007. iteminfo.ClabAmt = register_clab_amt
  2008. iteminfo.OthAmt = register_other_amt
  2009. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2010. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2011. }
  2012. if otherCostTotal != 0 {
  2013. iteminfo.MedChrgitm = "14"
  2014. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2015. iteminfo.Amt = otherCostTotal
  2016. iteminfo.ClaaSumfee = other_claa_sunmfee
  2017. iteminfo.ClabAmt = other_clab_amt
  2018. iteminfo.OthAmt = other_other_amt
  2019. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2020. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2021. }
  2022. struct4101.IteminfoStruct = iteminfoStructs
  2023. struct4101.Ntly = "中国"
  2024. struct4101.AdmCaty = "A03.06"
  2025. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  2026. fmt.Println(result)
  2027. var dat map[string]interface{}
  2028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2029. fmt.Println(dat)
  2030. } else {
  2031. fmt.Println(err)
  2032. }
  2033. userJSONBytes, _ := json.Marshal(dat)
  2034. var res ResultSeventeen
  2035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2036. utils.ErrorLog("解析失败:%v", err)
  2037. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2038. adminUser := c.GetAdminUserInfo()
  2039. errlog := &models.HisOrderError{
  2040. UserOrgId: adminUser.CurrentOrgId,
  2041. Ctime: time.Now().Unix(),
  2042. Mtime: time.Now().Unix(),
  2043. ErrMsg: res.ErrMsg + "解析失败",
  2044. Status: 1,
  2045. PatientId: order_id,
  2046. Stage: 120,
  2047. }
  2048. service.CreateErrMsgLog(errlog)
  2049. continue
  2050. }
  2051. if res.Infcode != 0 {
  2052. adminUser := c.GetAdminUserInfo()
  2053. errlog := &models.HisOrderError{
  2054. UserOrgId: adminUser.CurrentOrgId,
  2055. Ctime: time.Now().Unix(),
  2056. Mtime: time.Now().Unix(),
  2057. ErrMsg: res.ErrMsg,
  2058. Status: 1,
  2059. PatientId: order_id,
  2060. Stage: 200,
  2061. }
  2062. service.CreateErrMsgLog(errlog)
  2063. continue
  2064. } else {
  2065. hisFundSettleListResult := &models.HisFundSettleListResult{
  2066. Number: res.Output.SetlListId,
  2067. Status: 1,
  2068. Ctime: time.Now().Unix(),
  2069. Mtime: time.Now().Unix(),
  2070. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2071. IsUpload: 1,
  2072. OrderId: order_id,
  2073. }
  2074. service.CreateUploadRecord(hisFundSettleListResult)
  2075. continue
  2076. }
  2077. }
  2078. }
  2079. func (c *HisApiController) GetOrgInfo() {
  2080. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2081. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2082. }
  2083. func (c *HisApiController) GetHisPatientInfo() {
  2084. medical_insurance_card := c.GetString("medical_insurance_card")
  2085. id_card_type, _ := c.GetInt64("id_card_type")
  2086. id_card := c.GetString("id_card")
  2087. adminInfo := c.GetAdminUserInfo()
  2088. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2089. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2090. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2091. IdCardNo := ""
  2092. if id_card_type == 1 {
  2093. IdCardNo = medical_insurance_card
  2094. } else if id_card_type == 2 {
  2095. IdCardNo = id_card
  2096. }
  2097. if config.IsOpen == 1 {
  2098. 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
  2099. resp, requestErr := http.Get(api)
  2100. if requestErr != nil {
  2101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2102. return
  2103. }
  2104. defer resp.Body.Close()
  2105. body, ioErr := ioutil.ReadAll(resp.Body)
  2106. if ioErr != nil {
  2107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2109. return
  2110. }
  2111. var respJSON map[string]interface{}
  2112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2115. return
  2116. }
  2117. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2118. userJSONBytes, _ := json.Marshal(userJSON)
  2119. var res ResultTwo
  2120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2121. utils.ErrorLog("解析失败:%v", err)
  2122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2123. return
  2124. }
  2125. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2126. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2127. infoStr := string(Iinfos)
  2128. idetinfoStr := string(Idetinfos)
  2129. if res.Infcode == 0 {
  2130. his := models.VMHisPatient{
  2131. Status: 1,
  2132. Ctime: time.Now().Unix(),
  2133. Mtime: time.Now().Unix(),
  2134. PsnNo: res.Output.Baseinfo.PsnNo,
  2135. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2136. Certno: res.Output.Baseinfo.Certno,
  2137. PsnName: res.Output.Baseinfo.PsnName,
  2138. Gend: res.Output.Baseinfo.Gend,
  2139. Naty: res.Output.Baseinfo.Naty,
  2140. Brdy: res.Output.Baseinfo.Brdy,
  2141. Age: res.Output.Baseinfo.Age,
  2142. Iinfo: infoStr,
  2143. Idetinfo: idetinfoStr,
  2144. UserOrgId: adminInfo.CurrentOrgId,
  2145. IsReturn: 1,
  2146. IdCardType: id_card_type,
  2147. }
  2148. c.ServeSuccessJSON(map[string]interface{}{
  2149. "info": his,
  2150. })
  2151. } else {
  2152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2153. return
  2154. }
  2155. }
  2156. }
  2157. //func GetBasBaseInfo() (jsonStr string, err error) {
  2158. //
  2159. // handle := syscall.NewLazyDLL("SSCard.dll")
  2160. // add := handle.NewProc("ReadCardBas")
  2161. // str := make([]byte, 1024)
  2162. // str1 := make([]byte, 1024)
  2163. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2164. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2165. //
  2166. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2167. //
  2168. // fmt.Println("> Add(4,5)的结果为:", ret)
  2169. // handle.Release()
  2170. //
  2171. // return "", nil
  2172. //
  2173. //}
  2174. //func GetQRBaseInfo() (jsonStr string, err error) {
  2175. // handle := syscall.LoadDLL("SSCard.dll")
  2176. // ReadCardBas := handle.FindProc("GetQRBase")
  2177. //
  2178. // str := make([]byte, 256)
  2179. // str1 := make([]byte, 256)
  2180. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2181. //
  2182. // fmt.Println(string(str))
  2183. // fmt.Println(r)
  2184. // return string(str), nil
  2185. //}
  2186. //func CardInit() int {
  2187. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2188. // add := DllTestDef.MustFindProc("Init")
  2189. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2190. // if err != nil {
  2191. // fmt.Println("SSCard的运算结果为:", ret)
  2192. // }
  2193. // result := int(ret)
  2194. // return result
  2195. //}
  2196. //func CardInit() int {
  2197. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2198. // if err != nil {
  2199. // fmt.Println("SSCard的运算结果为:", ret)
  2200. // }
  2201. // fmt.Println(err)
  2202. // result := int(ret)
  2203. // return result
  2204. //}
  2205. func IntPtr(n int) uintptr {
  2206. return uintptr(n)
  2207. }
  2208. func StrPtr(s string) uintptr {
  2209. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2210. }
  2211. type Result2001 struct {
  2212. Cainfo interface{} `json:"cainfo"`
  2213. ErrMsg string `json:"err_msg"`
  2214. InfRefmsgid string `json:"inf_refmsgid"`
  2215. Infcode int64 `json:"infcode"`
  2216. Output struct {
  2217. Trtinfo struct {
  2218. PsnNo string `json:"psn_no"`
  2219. TrtChkType string `json:"trt_chk_type"`
  2220. FundPayType string `json:"fund_pay_type"`
  2221. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2222. Begndate string `json:"begndate"`
  2223. Enddate string `json:"enddate"`
  2224. TrtChkRslt string `json:"trt_chk_rslt"`
  2225. } `json:"trtinfo"`
  2226. } `json:"output"`
  2227. RefmsgTime string `json:"refmsg_time"`
  2228. RespondTime string `json:"respond_time"`
  2229. Signtype interface{} `json:"signtype"`
  2230. WarnMsg interface{} `json:"warn_msg"`
  2231. }
  2232. type Result2001Org10265 struct {
  2233. Cainfo interface{} `json:"cainfo"`
  2234. ErrMsg string `json:"err_msg"`
  2235. InfRefmsgid string `json:"inf_refmsgid"`
  2236. Infcode string `json:"infcode"`
  2237. Output struct {
  2238. Trtinfo struct {
  2239. PsnNo string `json:"psn_no"`
  2240. TrtChkType string `json:"trt_chk_type"`
  2241. FundPayType string `json:"fund_pay_type"`
  2242. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2243. Begndate string `json:"begndate"`
  2244. Enddate string `json:"enddate"`
  2245. TrtChkRslt string `json:"trt_chk_rslt"`
  2246. } `json:"trtinfo"`
  2247. } `json:"output"`
  2248. RefmsgTime string `json:"refmsg_time"`
  2249. RespondTime string `json:"respond_time"`
  2250. Signtype interface{} `json:"signtype"`
  2251. WarnMsg interface{} `json:"warn_msg"`
  2252. }
  2253. type ResultTwo struct {
  2254. ErrMsg string `json:"err_msg"`
  2255. InfRefmsgid string `json:"inf_refmsgid"`
  2256. Infcode int64 `json:"infcode"`
  2257. Output struct {
  2258. Baseinfo struct {
  2259. Age float64 `json:"age"`
  2260. Brdy string `json:"brdy"`
  2261. Certno string `json:"certno"`
  2262. Gend string `json:"gend"`
  2263. Naty string `json:"naty"`
  2264. PsnCertType string `json:"psn_cert_type"`
  2265. PsnName string `json:"psn_name"`
  2266. PsnNo string `json:"psn_no"`
  2267. } `json:"baseinfo"`
  2268. Idetinfo []interface{} `json:"idetinfo"`
  2269. Iinfo []struct {
  2270. Balc float64 `json:"balc"`
  2271. CvlservFlag string `json:"cvlserv_flag"`
  2272. EmpName string `json:"emp_name"`
  2273. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2274. Insutype string `json:"insutype"`
  2275. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2276. PausInsuDate string `json:"paus_insu_date"`
  2277. PsnInsuDate string `json:"psn_insu_date"`
  2278. PsnInsuStas string `json:"psn_insu_stas"`
  2279. PsnType string `json:"psn_type"`
  2280. } `json:"insuinfo"`
  2281. } `json:"output"`
  2282. RefmsgTime string `json:"refmsg_time"`
  2283. RespondTime string `json:"respond_time"`
  2284. Signtype interface{} `json:"signtype"`
  2285. WarnInfo interface{} `json:"warn_info"`
  2286. }
  2287. type ResultTwo10265 struct {
  2288. ErrMsg string `json:"err_msg"`
  2289. InfRefmsgid string `json:"inf_refmsgid"`
  2290. Infcode string `json:"infcode"`
  2291. Output struct {
  2292. Baseinfo struct {
  2293. Age float64 `json:"age"`
  2294. Brdy string `json:"brdy"`
  2295. Certno string `json:"certno"`
  2296. Gend string `json:"gend"`
  2297. Naty string `json:"naty"`
  2298. PsnCertType string `json:"psn_cert_type"`
  2299. PsnName string `json:"psn_name"`
  2300. PsnNo string `json:"psn_no"`
  2301. } `json:"baseinfo"`
  2302. Idetinfo []interface{} `json:"idetinfo"`
  2303. Iinfo []struct {
  2304. Balc float64 `json:"balc"`
  2305. CvlservFlag string `json:"cvlserv_flag"`
  2306. EmpName string `json:"emp_name"`
  2307. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2308. Insutype string `json:"insutype"`
  2309. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2310. PausInsuDate string `json:"paus_insu_date"`
  2311. PsnInsuDate string `json:"psn_insu_date"`
  2312. PsnInsuStas string `json:"psn_insu_stas"`
  2313. PsnType string `json:"psn_type"`
  2314. } `json:"insuinfo"`
  2315. } `json:"output"`
  2316. RefmsgTime string `json:"refmsg_time"`
  2317. RespondTime string `json:"respond_time"`
  2318. Signtype interface{} `json:"signtype"`
  2319. WarnInfo interface{} `json:"warn_info"`
  2320. }
  2321. type ResultThree struct {
  2322. Cainfo interface{} `json:"cainfo"`
  2323. ErrMsg string `json:"err_msg"`
  2324. InfRefmsgid string `json:"inf_refmsgid"`
  2325. Infcode int64 `json:"infcode"`
  2326. Output struct {
  2327. Data struct {
  2328. IptOtpNo string `json:"ipt_otp_no"`
  2329. MdtrtID string `json:"mdtrt_id"`
  2330. PsnNo string `json:"psn_no"`
  2331. } `json:"data"`
  2332. } `json:"output"`
  2333. RefmsgTime string `json:"refmsg_time"`
  2334. RespondTime string `json:"respond_time"`
  2335. Signtype interface{} `json:"signtype"`
  2336. WarnMsg interface{} `json:"warn_msg"`
  2337. }
  2338. type ResultThree10265 struct {
  2339. Cainfo interface{} `json:"cainfo"`
  2340. ErrMsg string `json:"err_msg"`
  2341. InfRefmsgid string `json:"inf_refmsgid"`
  2342. Infcode string `json:"infcode"`
  2343. Output struct {
  2344. Data struct {
  2345. IptOtpNo string `json:"ipt_otp_no"`
  2346. MdtrtID string `json:"mdtrt_id"`
  2347. PsnNo string `json:"psn_no"`
  2348. } `json:"data"`
  2349. } `json:"output"`
  2350. RefmsgTime string `json:"refmsg_time"`
  2351. RespondTime string `json:"respond_time"`
  2352. Signtype interface{} `json:"signtype"`
  2353. WarnMsg interface{} `json:"warn_msg"`
  2354. }
  2355. type ResultFour struct {
  2356. Cainfo string `json:"cainfo"`
  2357. ErrMsg string `json:"err_msg"`
  2358. InfRefmsgid string `json:"inf_refmsgid"`
  2359. Infcode int64 `json:"infcode"`
  2360. Output struct {
  2361. Result []struct {
  2362. BasMednFlag string `json:"bas_medn_flag"`
  2363. ChldMedcFlag string `json:"chld_medc_flag"`
  2364. ChrgitmLv string `json:"chrgitm_lv"`
  2365. Cnt float64 `json:"cnt"`
  2366. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2367. DrtReimFlag string `json:"drt_reim_flag"`
  2368. FeedetlSn string `json:"feedetl_sn"`
  2369. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2370. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2371. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2372. ListSpItemFlag string `json:"list_sp_item_flag"`
  2373. LmtUsedFlag string `json:"lmt_used_flag"`
  2374. MedChrgitmType string `json:"med_chrgitm_type"`
  2375. Memo string `json:"memo"`
  2376. OverlmtAmt float64 `json:"overlmt_amt"`
  2377. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2378. Pric float64 `json:"pric"`
  2379. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2380. SelfpayProp float64 `json:"selfpay_prop"`
  2381. } `json:"result"`
  2382. } `json:"output"`
  2383. RefmsgTime string `json:"refmsg_time"`
  2384. RespondTime string `json:"respond_time"`
  2385. Signtype string `json:"signtype"`
  2386. WarnMsg string `json:"warn_msg"`
  2387. }
  2388. type ResultFour10265 struct {
  2389. Cainfo string `json:"cainfo"`
  2390. ErrMsg string `json:"err_msg"`
  2391. InfRefmsgid string `json:"inf_refmsgid"`
  2392. Infcode string `json:"infcode"`
  2393. Output struct {
  2394. Result []struct {
  2395. BasMednFlag string `json:"bas_medn_flag"`
  2396. ChldMedcFlag string `json:"chld_medc_flag"`
  2397. ChrgitmLv string `json:"chrgitm_lv"`
  2398. Cnt float64 `json:"cnt"`
  2399. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2400. DrtReimFlag string `json:"drt_reim_flag"`
  2401. FeedetlSn string `json:"feedetl_sn"`
  2402. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2403. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2404. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2405. ListSpItemFlag string `json:"list_sp_item_flag"`
  2406. LmtUsedFlag string `json:"lmt_used_flag"`
  2407. MedChrgitmType string `json:"med_chrgitm_type"`
  2408. Memo string `json:"memo"`
  2409. OverlmtAmt float64 `json:"overlmt_amt"`
  2410. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2411. Pric float64 `json:"pric"`
  2412. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2413. SelfpayProp float64 `json:"selfpay_prop"`
  2414. } `json:"result"`
  2415. } `json:"output"`
  2416. RefmsgTime string `json:"refmsg_time"`
  2417. RespondTime string `json:"respond_time"`
  2418. Signtype string `json:"signtype"`
  2419. WarnMsg string `json:"warn_msg"`
  2420. }
  2421. type ResultFive struct {
  2422. Balc float64 `json:"balc"`
  2423. CvlservFlag string `json:"cvlserv_flag"`
  2424. EmpName string `json:"emp_name"`
  2425. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2426. Insutype string `json:"insutype"`
  2427. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2428. PausInsuDate string `json:"paus_insu_date"`
  2429. PsnInsuDate string `json:"psn_insu_date"`
  2430. PsnInsuStas string `json:"psn_insu_stas"`
  2431. PsnType string `json:"psn_type"`
  2432. }
  2433. type ResultSix struct {
  2434. Cainfo interface{} `json:"cainfo"`
  2435. ErrMsg string `json:"err_msg"`
  2436. InfRefmsgid string `json:"inf_refmsgid"`
  2437. Infcode int64 `json:"infcode"`
  2438. Output struct {
  2439. } `json:"output"`
  2440. RefmsgTime string `json:"refmsg_time"`
  2441. RespondTime string `json:"respond_time"`
  2442. Signtype interface{} `json:"signtype"`
  2443. WarnMsg interface{} `json:"warn_msg"`
  2444. }
  2445. type ResultSix10265 struct {
  2446. Cainfo interface{} `json:"cainfo"`
  2447. ErrMsg string `json:"err_msg"`
  2448. InfRefmsgid string `json:"inf_refmsgid"`
  2449. Infcode string `json:"infcode"`
  2450. Output struct {
  2451. } `json:"output"`
  2452. RefmsgTime string `json:"refmsg_time"`
  2453. RespondTime string `json:"respond_time"`
  2454. Signtype interface{} `json:"signtype"`
  2455. WarnMsg interface{} `json:"warn_msg"`
  2456. }
  2457. type ResultSeven struct {
  2458. Cainfo string `json:"cainfo"`
  2459. ErrMsg string `json:"err_msg"`
  2460. InfRefmsgid string `json:"inf_refmsgid"`
  2461. Infcode int64 `json:"infcode"`
  2462. Output struct {
  2463. Setldetail []interface{} `json:"setldetail"`
  2464. Setlinfo struct {
  2465. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2466. AcctPay float64 `json:"acct_pay"`
  2467. ActPayDedc float64 `json:"act_pay_dedc"`
  2468. Age float64 `json:"age"`
  2469. Balc float64 `json:"balc"`
  2470. Brdy string `json:"brdy"`
  2471. Certno string `json:"certno"`
  2472. ClrOptins string `json:"clr_optins"`
  2473. ClrType string `json:"clr_type"`
  2474. ClrWay string `json:"clr_way"`
  2475. CvlservFlag string `json:"cvlserv_flag"`
  2476. CvlservPay float64 `json:"cvlserv_pay"`
  2477. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2478. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2479. Gend string `json:"gend"`
  2480. HifesPay float64 `json:"hifes_pay"`
  2481. HifmiPay float64 `json:"hifmi_pay"`
  2482. HifpPay float64 `json:"hifp_pay"`
  2483. HospPartAmt float64 `json:"hosp_part_amt"`
  2484. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2485. Insutype string `json:"insutype"`
  2486. MafPay float64 `json:"maf_pay"`
  2487. MdtrtCertType string `json:"mdtrt_cert_type"`
  2488. HifobPay float64 `json:"hifob_pay"`
  2489. MdtrtID string `json:"mdtrt_id"`
  2490. MedType string `json:"med_type"`
  2491. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2492. MedinsSetlID string `json:"medins_setl_id"`
  2493. Naty string `json:"naty"`
  2494. OthPay float64 `json:"oth_pay"`
  2495. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2496. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2497. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2498. PsnCashPay float64 `json:"psn_cash_pay"`
  2499. PsnCertType string `json:"psn_cert_type"`
  2500. PsnName string `json:"psn_name"`
  2501. PsnNo string `json:"psn_no"`
  2502. PsnPartAmt float64 `json:"psn_part_amt"`
  2503. PsnType string `json:"psn_type"`
  2504. SetlID string `json:"setl_id"`
  2505. SetlTime string `json:"setl_time"`
  2506. } `json:"setlinfo"`
  2507. } `json:"output"`
  2508. RefmsgTime string `json:"refmsg_time"`
  2509. RespondTime string `json:"respond_time"`
  2510. Signtype interface{} `json:"signtype"`
  2511. WarnMsg interface{} `json:"warn_msg"`
  2512. }
  2513. type ResultSeven10265 struct {
  2514. Cainfo string `json:"cainfo"`
  2515. ErrMsg string `json:"err_msg"`
  2516. InfRefmsgid string `json:"inf_refmsgid"`
  2517. Infcode string `json:"infcode"`
  2518. Output struct {
  2519. Setldetail []interface{} `json:"setldetail"`
  2520. Setlinfo struct {
  2521. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2522. AcctPay float64 `json:"acct_pay"`
  2523. ActPayDedc float64 `json:"act_pay_dedc"`
  2524. Age float64 `json:"age"`
  2525. Balc float64 `json:"balc"`
  2526. Brdy string `json:"brdy"`
  2527. Certno string `json:"certno"`
  2528. ClrOptins string `json:"clr_optins"`
  2529. ClrType string `json:"clr_type"`
  2530. ClrWay string `json:"clr_way"`
  2531. CvlservFlag string `json:"cvlserv_flag"`
  2532. CvlservPay float64 `json:"cvlserv_pay"`
  2533. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2534. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2535. Gend string `json:"gend"`
  2536. HifesPay float64 `json:"hifes_pay"`
  2537. HifmiPay float64 `json:"hifmi_pay"`
  2538. HifpPay float64 `json:"hifp_pay"`
  2539. HospPartAmt float64 `json:"hosp_part_amt"`
  2540. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2541. Insutype string `json:"insutype"`
  2542. MafPay float64 `json:"maf_pay"`
  2543. MdtrtCertType string `json:"mdtrt_cert_type"`
  2544. HifobPay float64 `json:"hifob_pay"`
  2545. MdtrtID string `json:"mdtrt_id"`
  2546. MedType string `json:"med_type"`
  2547. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2548. MedinsSetlID string `json:"medins_setl_id"`
  2549. Naty string `json:"naty"`
  2550. OthPay float64 `json:"oth_pay"`
  2551. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2552. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2553. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2554. PsnCashPay float64 `json:"psn_cash_pay"`
  2555. PsnCertType string `json:"psn_cert_type"`
  2556. PsnName string `json:"psn_name"`
  2557. PsnNo string `json:"psn_no"`
  2558. PsnPartAmt float64 `json:"psn_part_amt"`
  2559. PsnType string `json:"psn_type"`
  2560. SetlID string `json:"setl_id"`
  2561. SetlTime string `json:"setl_time"`
  2562. } `json:"setlinfo"`
  2563. } `json:"output"`
  2564. RefmsgTime string `json:"refmsg_time"`
  2565. RespondTime string `json:"respond_time"`
  2566. Signtype interface{} `json:"signtype"`
  2567. WarnMsg interface{} `json:"warn_msg"`
  2568. }
  2569. type ResultEight struct {
  2570. Cainfo string `json:"cainfo"`
  2571. ErrMsg string `json:"err_msg"`
  2572. InfRefmsgid string `json:"inf_refmsgid"`
  2573. Infcode int64 `json:"infcode"`
  2574. Output struct {
  2575. Stmtinfo struct {
  2576. SetlOptins string `json:"setl_optins"`
  2577. StmtRslt string `json:"stmt_rslt"`
  2578. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2579. } `json:"stmtinfo"`
  2580. } `json:"output"`
  2581. RefmsgTime string `json:"refmsg_time"`
  2582. RespondTime string `json:"respond_time"`
  2583. Signtype interface{} `json:"signtype"`
  2584. WarnMsg interface{} `json:"warn_msg"`
  2585. }
  2586. type ResultEightFor10188 struct {
  2587. Cainfo string `json:"cainfo"`
  2588. ErrMsg string `json:"err_msg"`
  2589. InfRefmsgid string `json:"inf_refmsgid"`
  2590. Infcode string `json:"infcode"`
  2591. Output struct {
  2592. Stmtinfo struct {
  2593. SetlOptins string `json:"setl_optins"`
  2594. StmtRslt string `json:"stmt_rslt"`
  2595. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2596. } `json:"stmtinfo"`
  2597. } `json:"output"`
  2598. RefmsgTime string `json:"refmsg_time"`
  2599. RespondTime string `json:"respond_time"`
  2600. Signtype interface{} `json:"signtype"`
  2601. WarnMsg interface{} `json:"warn_msg"`
  2602. }
  2603. type ResultNine struct {
  2604. Cainfo string `json:"cainfo"`
  2605. ErrMsg string `json:"err_msg"`
  2606. InfRefmsgid string `json:"inf_refmsgid"`
  2607. Infcode int64 `json:"infcode"`
  2608. Output struct {
  2609. FileQuryNo string `json:"file_qury_no"`
  2610. } `json:"output"`
  2611. RefmsgTime string `json:"refmsg_time"`
  2612. RespondTime string `json:"respond_time"`
  2613. Signtype interface{} `json:"signtype"`
  2614. WarnMsg interface{} `json:"warn_msg"`
  2615. }
  2616. type ResultTen struct {
  2617. Cainfo string `json:"cainfo"`
  2618. ErrMsg string `json:"err_msg"`
  2619. InfRefmsgid string `json:"inf_refmsgid"`
  2620. Infcode int64 `json:"infcode"`
  2621. Output struct {
  2622. DldEndtime string `json:"dld_endtime"`
  2623. FileQuryNo string `json:"file_qury_no"`
  2624. Filename string `json:"filename"`
  2625. } `json:"output"`
  2626. RefmsgTime string `json:"refmsg_time"`
  2627. RespondTime string `json:"respond_time"`
  2628. Signtype interface{} `json:"signtype"`
  2629. WarnMsg interface{} `json:"warn_msg"`
  2630. }
  2631. //type Autogenerated struct {
  2632. // Output struct {
  2633. // Setlinfo struct {
  2634. // SetlTime string `json:"setl_time"`
  2635. // CvlservPay float64 `json:"cvlserv_pay"`
  2636. // Year string `json:"year"`
  2637. // MedType string `json:"med_type"`
  2638. // PsnPay float64 `json:"psn_pay"`
  2639. // OpterID string `json:"opter_id"`
  2640. // Begndate string `json:"begndate"`
  2641. // FlxempeFlag string `json:"flxempe_flag"`
  2642. // HifmiPay float64 `json:"hifmi_pay"`
  2643. // PsnNo string `json:"psn_no"`
  2644. // ActPayDedc float64 `json:"act_pay_dedc"`
  2645. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2646. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2647. // ClrWay string `json:"clr_way"`
  2648. // OthPay float64 `json:"oth_pay"`
  2649. // Gend string `json:"gend"`
  2650. // MdtrtID string `json:"mdtrt_id"`
  2651. // AcctPay float64 `json:"acct_pay"`
  2652. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2653. // Insutype string `json:"insutype"`
  2654. // Invono interface{} `json:"invono"`
  2655. // Enddate string `json:"enddate"`
  2656. // CashPayamt float64 `json:"cash_payamt"`
  2657. // PsnType string `json:"psn_type"`
  2658. // FixmedinsName string `json:"fixmedins_name"`
  2659. // HifpPay float64 `json:"hifp_pay"`
  2660. // NewFlag interface{} `json:"new_flag"`
  2661. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2662. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2663. // PayLoc string `json:"pay_loc"`
  2664. // ClrType string `json:"clr_type"`
  2665. // RefdSetlFlag string `json:"refd_setl_flag"`
  2666. // CvlservFlag string `json:"cvlserv_flag"`
  2667. // EmpName string `json:"emp_name"`
  2668. // Brdy string `json:"brdy"`
  2669. // Naty string `json:"naty"`
  2670. // Certno string `json:"certno"`
  2671. // DiseCode string `json:"dise_code"`
  2672. // FixmedinsCode string `json:"fixmedins_code"`
  2673. // DedcHospLv string `json:"dedc_hosp_lv"`
  2674. // OpterName string `json:"opter_name"`
  2675. // Balc float64 `json:"balc"`
  2676. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2677. // PsnCertType string `json:"psn_cert_type"`
  2678. // HifobPay float64 `json:"hifob_pay"`
  2679. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2680. // HifesPay float64 `json:"hifes_pay"`
  2681. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2682. // OptTime string `json:"opt_time"`
  2683. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2684. // SetlID string `json:"setl_id"`
  2685. // MafPay float64 `json:"maf_pay"`
  2686. // PsnName string `json:"psn_name"`
  2687. // InsuOptins interface{} `json:"insu_optins"`
  2688. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2689. // ClrOptins string `json:"clr_optins"`
  2690. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2691. // DiseName string `json:"dise_name"`
  2692. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2693. // Age float64 `json:"age"`
  2694. // DtrtCertType string `json:"dtrt_cert_type"`
  2695. // HospLv string `json:"hosp_lv"`
  2696. // } `json:"setlinfo"`
  2697. // Setldetail []struct {
  2698. // FundPayType string `json:"fund_pay_type"`
  2699. // FundPayamt float64 `json:"fund_payamt"`
  2700. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2701. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2702. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2703. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2704. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2705. // } `json:"setldetail"`
  2706. // } `json:"output"`
  2707. // Infcode int `json:"infcode"`
  2708. // WarnMsg interface{} `json:"warn_msg"`
  2709. // Cainfo interface{} `json:"cainfo"`
  2710. // ErrMsg interface{} `json:"err_msg"`
  2711. // RefmsgTime string `json:"refmsg_time"`
  2712. // Signtype interface{} `json:"signtype"`
  2713. // RespondTime string `json:"respond_time"`
  2714. // InfRefmsgid string `json:"inf_refmsgid"`
  2715. //}
  2716. type ResultEleven struct {
  2717. Cainfo string `json:"cainfo"`
  2718. ErrMsg string `json:"err_msg"`
  2719. InfRefmsgid string `json:"inf_refmsgid"`
  2720. Infcode int64 `json:"infcode"`
  2721. Output struct {
  2722. Setlinfo struct {
  2723. SetlTime string `json:"setl_time"`
  2724. CvlservPay float64 `json:"cvlserv_pay"`
  2725. Year string `json:"year"`
  2726. MedType string `json:"med_type"`
  2727. PsnPay float64 `json:"psn_pay"`
  2728. OpterID string `json:"opter_id"`
  2729. Begndate string `json:"begndate"`
  2730. FlxempeFlag string `json:"flxempe_flag"`
  2731. HifmiPay float64 `json:"hifmi_pay"`
  2732. PsnNo string `json:"psn_no"`
  2733. ActPayDedc float64 `json:"act_pay_dedc"`
  2734. MedinsSetlID interface{} `json:"medins_setl_id"`
  2735. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2736. ClrWay string `json:"clr_way"`
  2737. OthPay float64 `json:"oth_pay"`
  2738. Gend string `json:"gend"`
  2739. MdtrtID string `json:"mdtrt_id"`
  2740. AcctPay float64 `json:"acct_pay"`
  2741. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2742. Insutype string `json:"insutype"`
  2743. Invono interface{} `json:"invono"`
  2744. Enddate string `json:"enddate"`
  2745. CashPayamt float64 `json:"cash_payamt"`
  2746. PsnType string `json:"psn_type"`
  2747. FixmedinsName string `json:"fixmedins_name"`
  2748. HifpPay float64 `json:"hifp_pay"`
  2749. NewFlag interface{} `json:"new_flag"`
  2750. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2751. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2752. PayLoc string `json:"pay_loc"`
  2753. ClrType string `json:"clr_type"`
  2754. RefdSetlFlag string `json:"refd_setl_flag"`
  2755. CvlservFlag string `json:"cvlserv_flag"`
  2756. EmpName string `json:"emp_name"`
  2757. Brdy string `json:"brdy"`
  2758. Naty string `json:"naty"`
  2759. Certno string `json:"certno"`
  2760. DiseCode string `json:"dise_code"`
  2761. FixmedinsCode string `json:"fixmedins_code"`
  2762. DedcHospLv string `json:"dedc_hosp_lv"`
  2763. OpterName string `json:"opter_name"`
  2764. Balc float64 `json:"balc"`
  2765. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2766. PsnCertType string `json:"psn_cert_type"`
  2767. HifobPay float64 `json:"hifob_pay"`
  2768. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2769. HifesPay float64 `json:"hifes_pay"`
  2770. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2771. OptTime string `json:"opt_time"`
  2772. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2773. SetlID string `json:"setl_id"`
  2774. MafPay float64 `json:"maf_pay"`
  2775. PsnName string `json:"psn_name"`
  2776. InsuOptins interface{} `json:"insu_optins"`
  2777. PrefFundPay interface{} `json:"pref_fund_pay"`
  2778. ClrOptins string `json:"clr_optins"`
  2779. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2780. DiseName string `json:"dise_name"`
  2781. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2782. Age float64 `json:"age"`
  2783. DtrtCertType string `json:"dtrt_cert_type"`
  2784. HospLv string `json:"hosp_lv"`
  2785. } `json:"setlinfo"`
  2786. } `json:"output"`
  2787. RefmsgTime string `json:"refmsg_time"`
  2788. RespondTime string `json:"respond_time"`
  2789. Signtype interface{} `json:"signtype"`
  2790. WarnMsg interface{} `json:"warn_msg"`
  2791. }
  2792. type ResultEleven10265 struct {
  2793. Cainfo string `json:"cainfo"`
  2794. ErrMsg string `json:"err_msg"`
  2795. InfRefmsgid string `json:"inf_refmsgid"`
  2796. Infcode string `json:"infcode"`
  2797. Output struct {
  2798. Setlinfo struct {
  2799. SetlTime string `json:"setl_time"`
  2800. CvlservPay float64 `json:"cvlserv_pay"`
  2801. Year string `json:"year"`
  2802. MedType string `json:"med_type"`
  2803. PsnPay float64 `json:"psn_pay"`
  2804. OpterID string `json:"opter_id"`
  2805. Begndate string `json:"begndate"`
  2806. FlxempeFlag string `json:"flxempe_flag"`
  2807. HifmiPay float64 `json:"hifmi_pay"`
  2808. PsnNo string `json:"psn_no"`
  2809. ActPayDedc float64 `json:"act_pay_dedc"`
  2810. MedinsSetlID interface{} `json:"medins_setl_id"`
  2811. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2812. ClrWay string `json:"clr_way"`
  2813. OthPay float64 `json:"oth_pay"`
  2814. Gend string `json:"gend"`
  2815. MdtrtID string `json:"mdtrt_id"`
  2816. AcctPay float64 `json:"acct_pay"`
  2817. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2818. Insutype string `json:"insutype"`
  2819. Invono interface{} `json:"invono"`
  2820. Enddate string `json:"enddate"`
  2821. CashPayamt float64 `json:"cash_payamt"`
  2822. PsnType string `json:"psn_type"`
  2823. FixmedinsName string `json:"fixmedins_name"`
  2824. HifpPay float64 `json:"hifp_pay"`
  2825. NewFlag interface{} `json:"new_flag"`
  2826. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2827. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2828. PayLoc string `json:"pay_loc"`
  2829. ClrType string `json:"clr_type"`
  2830. RefdSetlFlag string `json:"refd_setl_flag"`
  2831. CvlservFlag string `json:"cvlserv_flag"`
  2832. EmpName string `json:"emp_name"`
  2833. Brdy string `json:"brdy"`
  2834. Naty string `json:"naty"`
  2835. Certno string `json:"certno"`
  2836. DiseCode string `json:"dise_code"`
  2837. FixmedinsCode string `json:"fixmedins_code"`
  2838. DedcHospLv string `json:"dedc_hosp_lv"`
  2839. OpterName string `json:"opter_name"`
  2840. Balc float64 `json:"balc"`
  2841. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2842. PsnCertType string `json:"psn_cert_type"`
  2843. HifobPay float64 `json:"hifob_pay"`
  2844. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2845. HifesPay float64 `json:"hifes_pay"`
  2846. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2847. OptTime string `json:"opt_time"`
  2848. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2849. SetlID string `json:"setl_id"`
  2850. MafPay float64 `json:"maf_pay"`
  2851. PsnName string `json:"psn_name"`
  2852. InsuOptins interface{} `json:"insu_optins"`
  2853. PrefFundPay interface{} `json:"pref_fund_pay"`
  2854. ClrOptins string `json:"clr_optins"`
  2855. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2856. DiseName string `json:"dise_name"`
  2857. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2858. Age float64 `json:"age"`
  2859. DtrtCertType string `json:"dtrt_cert_type"`
  2860. HospLv string `json:"hosp_lv"`
  2861. } `json:"setlinfo"`
  2862. } `json:"output"`
  2863. RefmsgTime string `json:"refmsg_time"`
  2864. RespondTime string `json:"respond_time"`
  2865. Signtype interface{} `json:"signtype"`
  2866. WarnMsg interface{} `json:"warn_msg"`
  2867. }
  2868. type ResultTwelve struct {
  2869. Cainfo string `json:"cainfo"`
  2870. ErrMsg string `json:"err_msg"`
  2871. InfRefmsgid string `json:"inf_refmsgid"`
  2872. Infcode int64 `json:"infcode"`
  2873. Output struct {
  2874. MdtrtId string `json:"mdtrt_id"`
  2875. ChrgBchno string `json:"chrg_bchno"`
  2876. PsnNo string `json:"psn_no"`
  2877. } `json:"output"`
  2878. RefmsgTime string `json:"refmsg_time"`
  2879. RespondTime string `json:"respond_time"`
  2880. Signtype interface{} `json:"signtype"`
  2881. WarnMsg interface{} `json:"warn_msg"`
  2882. }
  2883. type ResultThirteen struct {
  2884. ErrMsg string `json:"err_msg"`
  2885. InfRefmsgid string `json:"inf_refmsgid"`
  2886. Infcode int64 `json:"infcode"`
  2887. Output struct {
  2888. Result struct {
  2889. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2890. } `json:"result"`
  2891. } `json:"output"`
  2892. RefmsgTime string `json:"refmsg_time"`
  2893. RespondTime string `json:"respond_time"`
  2894. Signtype interface{} `json:"signtype"`
  2895. WarnInfo interface{} `json:"warn_info"`
  2896. }
  2897. type ResultThirteen10265 struct {
  2898. ErrMsg string `json:"err_msg"`
  2899. InfRefmsgid string `json:"inf_refmsgid"`
  2900. Infcode string `json:"infcode"`
  2901. Output struct {
  2902. Result struct {
  2903. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2904. } `json:"result"`
  2905. } `json:"output"`
  2906. RefmsgTime string `json:"refmsg_time"`
  2907. RespondTime string `json:"respond_time"`
  2908. Signtype interface{} `json:"signtype"`
  2909. WarnInfo interface{} `json:"warn_info"`
  2910. }
  2911. type ResultFourteen struct {
  2912. ErrMsg string `json:"err_msg"`
  2913. InfRefmsgid string `json:"inf_refmsgid"`
  2914. Infcode int64 `json:"infcode"`
  2915. Output struct {
  2916. } `json:"output"`
  2917. RefmsgTime string `json:"refmsg_time"`
  2918. RespondTime string `json:"respond_time"`
  2919. Signtype interface{} `json:"signtype"`
  2920. WarnInfo interface{} `json:"warn_info"`
  2921. }
  2922. type ResultFourteen10265 struct {
  2923. ErrMsg string `json:"err_msg"`
  2924. InfRefmsgid string `json:"inf_refmsgid"`
  2925. Infcode string `json:"infcode"`
  2926. Output struct {
  2927. } `json:"output"`
  2928. RefmsgTime string `json:"refmsg_time"`
  2929. RespondTime string `json:"respond_time"`
  2930. Signtype interface{} `json:"signtype"`
  2931. WarnInfo interface{} `json:"warn_info"`
  2932. }
  2933. type ResultSixteen struct {
  2934. Cainfo string `json:"cainfo"`
  2935. ErrMsg string `json:"err_msg"`
  2936. InfRefmsgid string `json:"inf_refmsgid"`
  2937. Infcode int64 `json:"infcode"`
  2938. Output struct {
  2939. Setldetail []interface{} `json:"setldetail"`
  2940. Setlinfo struct {
  2941. MdtrtID string `json:"mdtrt_id"`
  2942. SetlID string `json:"setl_id"`
  2943. ClrOptins string `json:"clr_optins"`
  2944. SetlTime string `json:"setl_time"`
  2945. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2946. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2947. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2948. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2949. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2950. ActPayDedc float64 `json:"act_pay_dedc"`
  2951. HifpPay float64 `json:"hifp_pay"`
  2952. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2953. Lfpay float64 `json:"selfpay"`
  2954. CvlservPay float64 `json:"cvlserv_pay"`
  2955. HifesPay float64 `json:"hifes_pay"`
  2956. HifmiPay float64 `json:"hifmi_pay"`
  2957. HifobPay float64 `json:"hifob_pay"`
  2958. MafPay float64 `json:"maf_pay"`
  2959. OthPay float64 `json:"oth_pay"`
  2960. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2961. PsnPartAmt float64 `json:"psn_part_amt"`
  2962. AcctPay float64 `json:"acct_pay"`
  2963. Balc float64 `json:"balc"`
  2964. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2965. HospPartAmt float64 `json:"hosp_part_amt"`
  2966. MedinsSetlID string `json:"medins_setl_id"`
  2967. PdnCashPay string `json:"pdn_cash_pay"`
  2968. } `json:"setlinfo"`
  2969. } `json:"output"`
  2970. RefmsgTime string `json:"refmsg_time"`
  2971. RespondTime string `json:"respond_time"`
  2972. Signtype interface{} `json:"signtype"`
  2973. WarnMsg interface{} `json:"warn_msg"`
  2974. }
  2975. type ResultSixteen10265 struct {
  2976. Cainfo string `json:"cainfo"`
  2977. ErrMsg string `json:"err_msg"`
  2978. InfRefmsgid string `json:"inf_refmsgid"`
  2979. Infcode string `json:"infcode"`
  2980. Output struct {
  2981. Setldetail []interface{} `json:"setldetail"`
  2982. Setlinfo struct {
  2983. MdtrtID string `json:"mdtrt_id"`
  2984. SetlID string `json:"setl_id"`
  2985. ClrOptins string `json:"clr_optins"`
  2986. SetlTime string `json:"setl_time"`
  2987. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2988. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2989. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2990. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2991. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2992. ActPayDedc float64 `json:"act_pay_dedc"`
  2993. HifpPay float64 `json:"hifp_pay"`
  2994. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2995. Lfpay float64 `json:"selfpay"`
  2996. CvlservPay float64 `json:"cvlserv_pay"`
  2997. HifesPay float64 `json:"hifes_pay"`
  2998. HifmiPay float64 `json:"hifmi_pay"`
  2999. HifobPay float64 `json:"hifob_pay"`
  3000. MafPay float64 `json:"maf_pay"`
  3001. OthPay float64 `json:"oth_pay"`
  3002. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3003. PsnPartAmt float64 `json:"psn_part_amt"`
  3004. AcctPay float64 `json:"acct_pay"`
  3005. Balc float64 `json:"balc"`
  3006. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3007. HospPartAmt float64 `json:"hosp_part_amt"`
  3008. MedinsSetlID string `json:"medins_setl_id"`
  3009. PdnCashPay string `json:"pdn_cash_pay"`
  3010. } `json:"setlinfo"`
  3011. } `json:"output"`
  3012. RefmsgTime string `json:"refmsg_time"`
  3013. RespondTime string `json:"respond_time"`
  3014. Signtype interface{} `json:"signtype"`
  3015. WarnMsg interface{} `json:"warn_msg"`
  3016. }
  3017. type ResultSeventeen struct {
  3018. ErrMsg string `json:"err_msg"`
  3019. InfRefmsgid string `json:"inf_refmsgid"`
  3020. Infcode int64 `json:"infcode"`
  3021. Output struct {
  3022. SetlListId string `json:"setl_list_id"`
  3023. } `json:"output"`
  3024. RefmsgTime string `json:"refmsg_time"`
  3025. RespondTime string `json:"respond_time"`
  3026. Signtype string `json:"signtype"`
  3027. WarnInfo string `json:"warn_info"`
  3028. }
  3029. type Result90991 struct {
  3030. ErrMsg string `json:"err_msg"`
  3031. InfRefmsgid string `json:"inf_refmsgid"`
  3032. Infcode int64 `json:"infcode"`
  3033. Output struct {
  3034. Result struct {
  3035. PsnNo string `json:"psn_no"`
  3036. CardStat string `json:"card_stat"`
  3037. Certno string `json:"certno"`
  3038. PsnName string `json:"psn_name"`
  3039. CheckStat string `json:"check_stat"`
  3040. } `json:"result"`
  3041. } `json:"output"`
  3042. RefmsgTime string `json:"refmsg_time"`
  3043. RespondTime string `json:"respond_time"`
  3044. Signtype interface{} `json:"signtype"`
  3045. WarnInfo interface{} `json:"warn_info"`
  3046. }
  3047. type Result90100 struct {
  3048. ErrMsg string `json:"err_msg"`
  3049. InfRefmsgid string `json:"inf_refmsgid"`
  3050. Infcode int64 `json:"infcode"`
  3051. Output struct {
  3052. PoolareaNo string `json:"poolarea_no"`
  3053. PoolareaNoName string `json:"poolarea_no_name"`
  3054. Insutype string `json:"insutype"`
  3055. InsutypeName string `json:"insutype_name"`
  3056. ClctType string `json:"clct_type"`
  3057. ClctTypeName string `json:"clct_type_name"`
  3058. ClctFlag string `json:"clct_flag"`
  3059. ClctFlagName string `json:"clct_flag_name"`
  3060. AccrymBegn string `json:"accrym_begn"`
  3061. AccrymEnd string `json:"accrym_end"`
  3062. ClctTime string `json:"clct_time"`
  3063. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3064. } `json:"output"`
  3065. RefmsgTime string `json:"refmsg_time"`
  3066. RespondTime string `json:"respond_time"`
  3067. Signtype interface{} `json:"signtype"`
  3068. WarnInfo interface{} `json:"warn_info"`
  3069. }
  3070. type Custom struct {
  3071. DetItemFeeSumamt string
  3072. Cut string
  3073. FeedetlSn string
  3074. Price string
  3075. MedListCodg string
  3076. Type int64
  3077. AdviceId int64
  3078. ProjectId int64
  3079. ItemId int64
  3080. }
  3081. type Result5301 struct {
  3082. ErrMsg string `json:"err_msg"`
  3083. InfRefmsgid string `json:"inf_refmsgid"`
  3084. Infcode int64 `json:"infcode"`
  3085. Output struct {
  3086. Result []struct {
  3087. OpspDiseCode string `json:"opsp_dise_code"`
  3088. OpspDiseName string `json:"opsp_dise_name"`
  3089. Begndate string `json:"begndate"`
  3090. Enddate string `json:"enddate"`
  3091. } `json:"feedetail"`
  3092. } `json:"output"`
  3093. RefmsgTime string `json:"refmsg_time"`
  3094. RespondTime string `json:"respond_time"`
  3095. Signtype interface{} `json:"signtype"`
  3096. WarnInfo interface{} `json:"warn_info"`
  3097. }
  3098. type Result5301For10265 struct {
  3099. ErrMsg string `json:"err_msg"`
  3100. InfRefmsgid string `json:"inf_refmsgid"`
  3101. Infcode string `json:"infcode"`
  3102. Output struct {
  3103. Result []struct {
  3104. OpspDiseCode string `json:"opsp_dise_code"`
  3105. OpspDiseName string `json:"opsp_dise_name"`
  3106. Begndate string `json:"begndate"`
  3107. Enddate string `json:"enddate"`
  3108. } `json:"feedetail"`
  3109. } `json:"output"`
  3110. RefmsgTime string `json:"refmsg_time"`
  3111. RespondTime string `json:"respond_time"`
  3112. Signtype interface{} `json:"signtype"`
  3113. WarnInfo interface{} `json:"warn_info"`
  3114. }
  3115. //获取个人信息----挂号-----上传就诊信息
  3116. func (c *HisApiController) GetRegisterInfo() {
  3117. id, _ := c.GetInt64("id")
  3118. record_time := c.GetString("record_time")
  3119. settlementValue, _ := c.GetInt64("settlement_value")
  3120. medical_insurance_card := c.GetString("medical_insurance_card")
  3121. name := c.GetString("name")
  3122. id_card_type, _ := c.GetInt64("id_card_type")
  3123. certificates, _ := c.GetInt64("certificates")
  3124. medical_care, _ := c.GetInt64("medical_care")
  3125. birthday := c.GetString("birthday")
  3126. id_card := c.GetString("id_card")
  3127. register_type, _ := c.GetInt64("register")
  3128. doctor, _ := c.GetInt64("doctor")
  3129. department, _ := c.GetInt64("department")
  3130. gender, _ := c.GetInt64("sex")
  3131. registration_fee, _ := c.GetFloat("registration_fee")
  3132. medical_expenses, _ := c.GetFloat("medical_expenses")
  3133. social_type, _ := c.GetInt64("social_type")
  3134. med_type := c.GetString("social_type")
  3135. admin_user_id, _ := c.GetInt64("admin_user_id")
  3136. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3137. timeLayout := "2006-01-02"
  3138. loc, _ := time.LoadLocation("Local")
  3139. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3140. birthUnix := birthdays.Unix()
  3141. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3142. if err != nil {
  3143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3144. return
  3145. }
  3146. recordDateTime := theTime.Unix()
  3147. adminInfo := c.GetAdminUserInfo()
  3148. var patient service.Patients
  3149. if id == 0 {
  3150. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3151. } else {
  3152. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3153. }
  3154. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3155. if patientPrescription.ID == 0 {
  3156. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3157. }
  3158. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3159. if patient.ID == 0 {
  3160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3161. return
  3162. }
  3163. if len(patient.IdCardNo) == 0 {
  3164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3165. return
  3166. }
  3167. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3168. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3169. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3170. //就诊结算未完成,不能进行二次挂号
  3171. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3172. if len(his) >= 1 {
  3173. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3174. if len(his) >= 1 && order.ID == 0 {
  3175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3176. return
  3177. }
  3178. }
  3179. //var register_log string
  3180. if config.IsOpen == 1 {
  3181. var res ResultTwo
  3182. var res10265 ResultTwo10265
  3183. var PsnNo string
  3184. var PsnCertType string
  3185. var Certno string
  3186. var PsnName string
  3187. var Gend string
  3188. var Naty string
  3189. var Brdy string
  3190. var Age float64
  3191. var infoStr string
  3192. var idetinfoStr string
  3193. var infocode int64
  3194. var verify_number string
  3195. fmt.Println(verify_number)
  3196. if miConfig.MdtrtareaAdmvs == "421300" {
  3197. psn_info, _ := service.GetPsnByPatientId(id)
  3198. PsnNo = psn_info.PsnNo
  3199. PsnCertType = psn_info.PsnCertType
  3200. Certno = psn_info.Certno
  3201. PsnName = psn_info.PsnName
  3202. Gend = psn_info.Gend
  3203. Naty = psn_info.Naty
  3204. Brdy = psn_info.Brdy
  3205. Age = psn_info.Age
  3206. infoStr = psn_info.Insuinfo
  3207. idetinfoStr = psn_info.Idetinfo
  3208. infocode = 0
  3209. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3210. psn_info, _ := service.GetPsnByPatientId(id)
  3211. PsnNo = psn_info.PsnNo
  3212. PsnCertType = psn_info.PsnCertType
  3213. Certno = psn_info.Certno
  3214. PsnName = psn_info.PsnName
  3215. Gend = psn_info.Gend
  3216. Naty = psn_info.Naty
  3217. Brdy = psn_info.Brdy
  3218. Age = psn_info.Age
  3219. infoStr = psn_info.Insuinfo
  3220. idetinfoStr = psn_info.Idetinfo
  3221. infocode = 0
  3222. verify_number = psn_info.VerifyNumber
  3223. } else {
  3224. var result string
  3225. var requestLog string
  3226. if miConfig.UserOrgId == 10138 {
  3227. 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)
  3228. } else {
  3229. 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)
  3230. }
  3231. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3232. if miConfig.Code == "H15049901371" {
  3233. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3234. utils.ErrorLog("解析失败:%v", err)
  3235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. return
  3237. }
  3238. res.ErrMsg = res10265.ErrMsg
  3239. res.Output = res10265.Output
  3240. res.InfRefmsgid = res10265.InfRefmsgid
  3241. } else {
  3242. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3243. utils.ErrorLog("解析失败:%v", err)
  3244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3245. return
  3246. }
  3247. }
  3248. PsnNo = res.Output.Baseinfo.PsnNo
  3249. PsnCertType = res.Output.Baseinfo.PsnCertType
  3250. Certno = res.Output.Baseinfo.Certno
  3251. PsnName = res.Output.Baseinfo.PsnName
  3252. Gend = res.Output.Baseinfo.Gend
  3253. Naty = res.Output.Baseinfo.Naty
  3254. Brdy = res.Output.Baseinfo.Brdy
  3255. Age = res.Output.Baseinfo.Age
  3256. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3257. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3258. infoStr = string(Iinfos)
  3259. idetinfoStr = string(Idetinfos)
  3260. if miConfig.Code == "H15049901371" {
  3261. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3262. } else {
  3263. infocode = res.Infcode
  3264. }
  3265. }
  3266. if infocode == 0 {
  3267. his := models.VMHisPatient{
  3268. Name: name,
  3269. Gender: gender,
  3270. Birthday: birthUnix,
  3271. MedicalTreatmentType: medical_care,
  3272. IdType: certificates,
  3273. IdCardNo: id_card,
  3274. BalanceAccountsType: settlementValue,
  3275. SocialType: social_type,
  3276. MedicalInsuranceNumber: medical_insurance_card,
  3277. RegisterType: register_type,
  3278. RegisterCost: registration_fee,
  3279. TreatmentCost: medical_expenses,
  3280. Status: 1,
  3281. Ctime: time.Now().Unix(),
  3282. Mtime: time.Now().Unix(),
  3283. PsnNo: PsnNo,
  3284. PsnCertType: PsnCertType,
  3285. Certno: Certno,
  3286. PsnName: PsnName,
  3287. Gend: Gend,
  3288. Naty: Naty,
  3289. Brdy: Brdy,
  3290. Age: Age,
  3291. Iinfo: infoStr,
  3292. Idetinfo: idetinfoStr,
  3293. PatientId: patient.ID,
  3294. RecordDate: theTime.Unix(),
  3295. UserOrgId: adminInfo.CurrentOrgId,
  3296. AdminUserId: admin_user_id,
  3297. IsReturn: 1,
  3298. IdCardType: id_card_type,
  3299. Doctor: doctor,
  3300. Departments: department,
  3301. }
  3302. timestamp := time.Now().Unix()
  3303. tempTime := time.Unix(timestamp, 0)
  3304. timeFormat := tempTime.Format("20060102150405")
  3305. chrgBchno := rand.Intn(100000) + 10000
  3306. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3307. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3308. department, _ := service.GetDepartMentDetail(department)
  3309. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3310. IdCardNo := ""
  3311. if id_card_type == 1 {
  3312. // IdCardNo = medical_insurance_card
  3313. IdCardNo = patient.IdCardNo
  3314. } else {
  3315. IdCardNo = patient.IdCardNo
  3316. }
  3317. var rf []*ResultFive
  3318. json.Unmarshal([]byte(his.Iinfo), &rf)
  3319. var insutypes []*ResultFive
  3320. var insutype string
  3321. var insuplc_admdvs_temp string
  3322. var is390 int = 0
  3323. var is310 int = 0
  3324. for _, item := range rf {
  3325. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3326. insutypes = append(insutypes, item)
  3327. }
  3328. }
  3329. if len(insutypes) == 1 {
  3330. insutype = insutypes[0].Insutype
  3331. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3332. } else {
  3333. for _, i := range insutypes {
  3334. if i.Insutype == "390" {
  3335. is390 = 1
  3336. }
  3337. if i.Insutype == "310" {
  3338. is310 = 1
  3339. }
  3340. }
  3341. }
  3342. if is390 == 1 {
  3343. insutype = "390"
  3344. }
  3345. if is310 == 1 {
  3346. insutype = "310"
  3347. }
  3348. if len(insutypes) == 0 {
  3349. insutype = "310"
  3350. }
  3351. if len(insutypes) == 2 {
  3352. insutype = med_type
  3353. }
  3354. if len(med_type) > 0 {
  3355. insutype = med_type
  3356. }
  3357. //for _, item := range rf {
  3358. // if item.Insutype == insutype {
  3359. // insuplc_admdvs = item.InsuplcAdmdvs
  3360. // }
  3361. //}
  3362. var infocode int64
  3363. var resThree ResultThree
  3364. var resThree10265 ResultThree10265
  3365. if len(insuplc_admdvs) == 0 {
  3366. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3367. } else {
  3368. insuplc_admdvs_temp = insuplc_admdvs
  3369. }
  3370. if miConfig.MdtrtareaAdmvs == "421300" {
  3371. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3372. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3373. "&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
  3374. resp, requestErr := http.Get(api)
  3375. if requestErr != nil {
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3377. return
  3378. }
  3379. body, ioErr := ioutil.ReadAll(resp.Body)
  3380. if ioErr != nil {
  3381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3383. return
  3384. }
  3385. var respJSON map[string]interface{}
  3386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3389. return
  3390. }
  3391. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3392. result, _ := json.Marshal(respJSON)
  3393. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3394. utils.ErrorLog("解析失败:%v", err)
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3396. return
  3397. }
  3398. infocode = resThree.Infcode
  3399. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3400. psn_info, _ := service.GetPsnByPatientId(id)
  3401. bas := strings.Split(psn_info.CardInfo, "|")
  3402. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3403. api := "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3404. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3405. "&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
  3406. resp, requestErr := http.Get(api)
  3407. if requestErr != nil {
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3409. return
  3410. }
  3411. body, ioErr := ioutil.ReadAll(resp.Body)
  3412. if ioErr != nil {
  3413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3415. return
  3416. }
  3417. var respJSON map[string]interface{}
  3418. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3421. return
  3422. }
  3423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3424. result, _ := json.Marshal(respJSON)
  3425. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3426. utils.ErrorLog("解析失败:%v", err)
  3427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3428. return
  3429. }
  3430. resThree.ErrMsg = resThree10265.ErrMsg
  3431. resThree.Output = resThree10265.Output
  3432. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3433. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3434. } else {
  3435. result, requestLog := service.Gdyb2201(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)
  3436. saveLog(result, requestLog, "2201", "挂号")
  3437. if miConfig.Code == "H15049901371" {
  3438. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3439. utils.ErrorLog("解析失败:%v", err)
  3440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3441. return
  3442. }
  3443. resThree.ErrMsg = resThree10265.ErrMsg
  3444. resThree.Output = resThree10265.Output
  3445. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3446. } else {
  3447. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3448. utils.ErrorLog("解析失败:%v", err)
  3449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3450. return
  3451. }
  3452. }
  3453. if miConfig.Code == "H15049901371" {
  3454. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3455. } else {
  3456. infocode = resThree.Infcode
  3457. }
  3458. }
  3459. if infocode != 0 {
  3460. adminUser := c.GetAdminUserInfo()
  3461. errlog := &models.HisOrderError{
  3462. UserOrgId: adminUser.CurrentOrgId,
  3463. Ctime: time.Now().Unix(),
  3464. Mtime: time.Now().Unix(),
  3465. ErrMsg: resThree.ErrMsg,
  3466. Status: 1,
  3467. PatientId: id,
  3468. RecordTime: recordDateTime,
  3469. Stage: 2,
  3470. }
  3471. service.CreateErrMsgLog(errlog)
  3472. c.ServeSuccessJSON(map[string]interface{}{
  3473. "failed_code": -10,
  3474. "msg": resThree.ErrMsg,
  3475. })
  3476. return
  3477. }
  3478. his.Number = resThree.Output.Data.MdtrtID
  3479. his.PsnNo = resThree.Output.Data.PsnNo
  3480. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3481. his.IdCardNo = patient.IdCardNo
  3482. his.PhoneNumber = patient.Phone
  3483. his.UserOrgId = adminInfo.CurrentOrgId
  3484. his.Insutype = insutype
  3485. his.Ctime = time.Now().Unix()
  3486. his.Mtime = time.Now().Unix()
  3487. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3488. his.Status = 1
  3489. service.UpdateHisPatientStatus(&his)
  3490. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3491. c.ServeSuccessJSON(map[string]interface{}{
  3492. "his_info": his,
  3493. })
  3494. } else {
  3495. adminUser := c.GetAdminUserInfo()
  3496. errlog := &models.HisOrderError{
  3497. UserOrgId: adminUser.CurrentOrgId,
  3498. Ctime: time.Now().Unix(),
  3499. Mtime: time.Now().Unix(),
  3500. ErrMsg: res.ErrMsg,
  3501. Status: 1,
  3502. PatientId: id,
  3503. RecordTime: recordDateTime,
  3504. Stage: 1,
  3505. }
  3506. service.CreateErrMsgLog(errlog)
  3507. c.ServeSuccessJSON(map[string]interface{}{
  3508. "failed_code": -10,
  3509. "msg": res.ErrMsg,
  3510. })
  3511. return
  3512. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3513. }
  3514. }
  3515. }
  3516. //上传明细----预结算----确认订单
  3517. func (c *HisApiController) GetUploadInfo() {
  3518. id, _ := c.GetInt64("id")
  3519. record_time := c.GetString("record_time")
  3520. his_patient_id, _ := c.GetInt64("his_patient_id")
  3521. order_id, _ := c.GetInt64("order_id")
  3522. pay_way, _ := c.GetInt64("pay_way")
  3523. pay_price, _ := c.GetFloat("pay_price")
  3524. pay_card_no := c.GetString("pay_card_no")
  3525. discount_price, _ := c.GetFloat("discount_price")
  3526. preferential_price, _ := c.GetFloat("preferential_price")
  3527. reality_price, _ := c.GetFloat("reality_price")
  3528. found_price, _ := c.GetFloat("found_price")
  3529. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3530. private_price, _ := c.GetFloat("private_price")
  3531. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3532. admin_user_id, _ := c.GetInt64("admin_user_id")
  3533. fapiao_code := c.GetString("fapiao_code")
  3534. fapiao_number := c.GetString("fapiao_number")
  3535. diagnosis_id := c.GetString("diagnosis")
  3536. sick_type, _ := c.GetInt64("sick_type")
  3537. reg_type, _ := c.GetInt64("p_type")
  3538. begin_time := c.GetString("begin_time")
  3539. id_str := c.GetString("ids")
  3540. ids_arr := strings.Split(id_str, ",")
  3541. timeLayout := "2006-01-02"
  3542. loc, _ := time.LoadLocation("Local")
  3543. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3544. if err != nil {
  3545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3546. return
  3547. }
  3548. recordDateTime := theTime.Unix()
  3549. adminUser := c.GetAdminUserInfo()
  3550. var tempOrder models.HisOrder
  3551. tempOrder, _ = service.GetHisOrderByID(order_id)
  3552. var prescriptions []*models.HisPrescription
  3553. var start_time int64
  3554. var end_time int64
  3555. //if adminUser.CurrentOrgId == 10106{
  3556. // if len(fapiao_code) == 0{
  3557. // fapiao_code = "144072080589"
  3558. // }
  3559. // if len(fapiao_number) == 0{
  3560. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3561. // if order.ID == 0{
  3562. // fapiao_number = "00001520"
  3563. // }else{
  3564. // //fapiao_code = "00001520"
  3565. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3566. // var zero string
  3567. // if fpNumber >= 1000{
  3568. // zero = "0000" + strconv.Itoa(fpNumber)
  3569. // }else if fpNumber >= 10000{
  3570. // zero = "000" + strconv.Itoa(fpNumber)
  3571. // } else if fpNumber >= 100000{
  3572. // zero = "00" + strconv.Itoa(fpNumber)
  3573. // } else if fpNumber >= 1000000{
  3574. // zero = "0" + strconv.Itoa(fpNumber)
  3575. // }else {
  3576. // zero = strconv.Itoa(fpNumber)
  3577. // }
  3578. // fapiao_number = zero
  3579. // }
  3580. // }
  3581. //}
  3582. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3583. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3584. var patientPrescription models.HisPrescriptionInfo
  3585. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3586. if patientPrescription.ID == 0 {
  3587. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3588. }
  3589. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3590. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3591. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3592. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3593. var config []*models.HisXtDiagnoseConfig
  3594. for _, item := range diagnosis_ids {
  3595. id, _ := strconv.ParseInt(item, 10, 64)
  3596. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3597. config = append(config, &diagnosisConfig)
  3598. }
  3599. sickConfig, _ := service.FindSickById(sick_type)
  3600. if tempOrder.ID == 0 {
  3601. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3602. }
  3603. if tempOrder.ID == 0 {
  3604. var result string
  3605. var requestLog string
  3606. var res2 ResultSix
  3607. var ressix10265 ResultSix10265
  3608. if miConfig.MdtrtareaAdmvs == "421300" {
  3609. data := make(map[string]interface{})
  3610. client := &http.Client{}
  3611. data["psn_no"] = his.PsnNo
  3612. data["mdtrt_id"] = his.Number
  3613. data["doctor"] = roles.UserName
  3614. data["department"] = department.Name
  3615. data["org_name"] = miConfig.OrgName
  3616. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3617. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3618. data["fixmedins_code"] = miConfig.Code
  3619. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3620. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3621. data["secret_key"] = miConfig.SecretKey
  3622. data["sick_code"] = sickConfig.CountryCode
  3623. data["sick_name"] = sickConfig.ClassName
  3624. data["dept"] = strconv.FormatInt(department.ID, 10)
  3625. data["config"] = config
  3626. data["begin_time"] = begin_time
  3627. bytesData, _ := json.Marshal(data)
  3628. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3629. resp, _ := client.Do(req)
  3630. defer resp.Body.Close()
  3631. body, ioErr := ioutil.ReadAll(resp.Body)
  3632. if ioErr != nil {
  3633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3635. return
  3636. }
  3637. var respJSON map[string]interface{}
  3638. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3641. return
  3642. }
  3643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3644. userJSONBytes, _ := json.Marshal(respJSON)
  3645. fmt.Println("log")
  3646. fmt.Println(string(userJSONBytes))
  3647. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3648. utils.ErrorLog("解析失败:%v", err)
  3649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3650. return
  3651. }
  3652. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3653. //江苏地区国家医保医疗类别
  3654. //职工透析:医疗类别选特殊情况门诊9933
  3655. //居民血透门慢: 医疗类别选门诊慢病1402
  3656. //var med_type string
  3657. //if his.Insutype == "310" {
  3658. // if reg_type == 14 {
  3659. // med_type = "9933"
  3660. // } else if reg_type == 11 {
  3661. // med_type = "11"
  3662. //
  3663. // }
  3664. //} else if his.Insutype == "390" {
  3665. // if reg_type == 14 {
  3666. // med_type = "1402"
  3667. // } else if reg_type == 11 {
  3668. // med_type = "11"
  3669. // }
  3670. //}
  3671. data := make(map[string]interface{})
  3672. client := &http.Client{}
  3673. data["psn_no"] = his.PsnNo
  3674. data["mdtrt_id"] = his.Number
  3675. data["doctor"] = roles.UserName
  3676. data["department"] = department.Name
  3677. data["org_name"] = miConfig.OrgName
  3678. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3679. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3680. data["fixmedins_code"] = miConfig.Code
  3681. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3682. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3683. data["secret_key"] = miConfig.SecretKey
  3684. data["sick_code"] = sickConfig.CountryCode
  3685. data["sick_name"] = sickConfig.ClassName
  3686. data["url"] = miConfig.Url
  3687. data["ak"] = miConfig.AccessKey
  3688. data["begin_time"] = begin_time
  3689. data["cainfo"] = miConfig.Cainfo
  3690. data["dept"] = strconv.FormatInt(department.ID, 10)
  3691. data["config"] = config
  3692. bytesData, _ := json.Marshal(data)
  3693. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3694. resp, _ := client.Do(req)
  3695. defer resp.Body.Close()
  3696. body, ioErr := ioutil.ReadAll(resp.Body)
  3697. if ioErr != nil {
  3698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3700. return
  3701. }
  3702. var respJSON map[string]interface{}
  3703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3706. return
  3707. }
  3708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3709. userJSONBytes, _ := json.Marshal(respJSON)
  3710. fmt.Println("log")
  3711. fmt.Println(string(userJSONBytes))
  3712. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3713. utils.ErrorLog("解析失败:%v", err)
  3714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3715. return
  3716. }
  3717. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3718. res2.Output = ressix10265.Output
  3719. res2.ErrMsg = ressix10265.ErrMsg
  3720. res2.Cainfo = ressix10265.Cainfo
  3721. res2.WarnMsg = ressix10265.WarnMsg
  3722. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3723. res2.Infcode = infocode
  3724. } else {
  3725. if miConfig.MdtrtareaAdmvs == "440781" { //
  3726. 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)
  3727. } else {
  3728. if miConfig.Code == "H15049901371" {
  3729. //赤峰地区国家医保医疗类别
  3730. //职工透析:医疗类别选特殊情况门诊990502
  3731. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3732. var med_type string
  3733. if his.Insutype == "390" {
  3734. if reg_type == 14 {
  3735. med_type = "9933"
  3736. } else if reg_type == 11 {
  3737. med_type = "11"
  3738. }
  3739. } else if his.Insutype == "310" {
  3740. if reg_type == 14 {
  3741. med_type = "990502"
  3742. } else if reg_type == 11 {
  3743. med_type = "11"
  3744. }
  3745. }
  3746. 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)
  3747. } else {
  3748. 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)
  3749. }
  3750. }
  3751. saveLog(result, requestLog, "2203", "上传就诊信息")
  3752. var respJSON2 map[string]interface{}
  3753. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3756. return
  3757. }
  3758. userJSONBytes2, _ := json.Marshal(respJSON2)
  3759. if miConfig.Code == "H15049901371" {
  3760. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3761. utils.ErrorLog("解析失败:%v", err)
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. return
  3764. }
  3765. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3766. res2.Output = ressix10265.Output
  3767. res2.ErrMsg = ressix10265.ErrMsg
  3768. res2.Cainfo = ressix10265.Cainfo
  3769. res2.WarnMsg = ressix10265.WarnMsg
  3770. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3771. res2.Infcode = infocode
  3772. } else {
  3773. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3774. utils.ErrorLog("解析失败:%v", err)
  3775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3776. return
  3777. }
  3778. }
  3779. }
  3780. if res2.Infcode != 0 {
  3781. adminUser := c.GetAdminUserInfo()
  3782. errlog := &models.HisOrderError{
  3783. UserOrgId: adminUser.CurrentOrgId,
  3784. Ctime: time.Now().Unix(),
  3785. Mtime: time.Now().Unix(),
  3786. ErrMsg: res2.ErrMsg,
  3787. Status: 1,
  3788. PatientId: id,
  3789. RecordTime: recordDateTime,
  3790. Stage: 3,
  3791. }
  3792. service.CreateErrMsgLog(errlog)
  3793. c.ServeSuccessJSON(map[string]interface{}{
  3794. "failed_code": -10,
  3795. "msg": res2.ErrMsg,
  3796. })
  3797. return
  3798. } else {
  3799. his.Diagnosis = diagnosis_id
  3800. his.SickType = sickConfig.ID
  3801. var p_type int64
  3802. if reg_type == 1111 || reg_type == 1112 {
  3803. p_type = 11
  3804. }
  3805. his.PType = fmt.Sprintf("%d", p_type)
  3806. service.UpdateHisPatientThree(&his)
  3807. data := make(map[string]interface{})
  3808. if settle_accounts_type == 1 { //日结
  3809. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3810. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3811. } else {
  3812. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3813. }
  3814. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3815. data["pre"] = prescriptions
  3816. } else { //月结
  3817. start_time_str := c.GetString("start_time")
  3818. end_time_str := c.GetString("end_time")
  3819. timeLayout := "2006-01-02"
  3820. loc, _ := time.LoadLocation("Local")
  3821. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3822. if err != nil {
  3823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3824. return
  3825. }
  3826. recordStartTime := theStartTime.Unix()
  3827. start_time = recordStartTime
  3828. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3829. if err != nil {
  3830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3831. return
  3832. }
  3833. recordEndTime := theEndTime.Unix()
  3834. end_time = recordEndTime
  3835. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3836. data["pre"] = prescriptions
  3837. }
  3838. timestamp := time.Now().Unix()
  3839. tempTime := time.Unix(timestamp, 0)
  3840. timeFormat := tempTime.Format("20060102150405")
  3841. chrgBchno := rand.Intn(100000) + 10000
  3842. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3843. strconv.FormatInt(his.PatientId, 10)
  3844. client := &http.Client{}
  3845. data["psn_no"] = his.PsnNo
  3846. data["mdtrt_id"] = his.Number
  3847. data["chrg_bchno"] = chrg_bchno
  3848. data["org_name"] = miConfig.OrgName
  3849. data["doctor"] = roles.UserName
  3850. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3851. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3852. data["fixmedins_code"] = miConfig.Code
  3853. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3854. // data["dept_code"] = "15"
  3855. //} else {
  3856. data["dept_code"] = department.Number
  3857. //}
  3858. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3859. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3860. data["secret_key"] = miConfig.SecretKey
  3861. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3862. data["url"] = miConfig.Url
  3863. data["ak"] = miConfig.AccessKey
  3864. data["new_doctor_name"] = patientPrescription.Doctor
  3865. data["diag_code"] = sickConfig.CountryCode
  3866. data["cainfo"] = miConfig.Cainfo
  3867. var ids []int64
  3868. for _, item := range prescriptions {
  3869. ids = append(ids, item.ID)
  3870. }
  3871. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3872. if config.IsOpen == 1 { //对接了医保,走医保流程
  3873. var res ResultFour
  3874. var resFour10265 ResultFour10265
  3875. if miConfig.MdtrtareaAdmvs == "421300" {
  3876. bytesData, _ := json.Marshal(data)
  3877. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3878. resp, _ := client.Do(req)
  3879. defer resp.Body.Close()
  3880. body, ioErr := ioutil.ReadAll(resp.Body)
  3881. if ioErr != nil {
  3882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3884. return
  3885. }
  3886. var respJSON map[string]interface{}
  3887. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3890. return
  3891. }
  3892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3893. userJSONBytes, _ := json.Marshal(respJSON)
  3894. fmt.Println("log")
  3895. fmt.Println(string(userJSONBytes))
  3896. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3897. utils.ErrorLog("解析失败:%v", err)
  3898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3899. return
  3900. }
  3901. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3902. bytesData, _ := json.Marshal(data)
  3903. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3904. resp, _ := client.Do(req)
  3905. defer resp.Body.Close()
  3906. body, ioErr := ioutil.ReadAll(resp.Body)
  3907. if ioErr != nil {
  3908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3910. return
  3911. }
  3912. var respJSON map[string]interface{}
  3913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3916. return
  3917. }
  3918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3919. userJSONBytes, _ := json.Marshal(respJSON)
  3920. fmt.Println("log")
  3921. fmt.Println(string(userJSONBytes))
  3922. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3923. utils.ErrorLog("解析失败:%v", err)
  3924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3925. return
  3926. }
  3927. res.InfRefmsgid = resFour10265.InfRefmsgid
  3928. res.Output = resFour10265.Output
  3929. res.ErrMsg = resFour10265.ErrMsg
  3930. res.Cainfo = resFour10265.Cainfo
  3931. res.WarnMsg = resFour10265.WarnMsg
  3932. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3933. res.Infcode = infocode
  3934. } else {
  3935. if miConfig.Code == "H15049901371" {
  3936. 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)
  3937. var dat map[string]interface{}
  3938. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3939. fmt.Println(dat)
  3940. } else {
  3941. fmt.Println(err)
  3942. }
  3943. saveLog(result, request_log, "2204", "上传费用明细")
  3944. userJSONBytes, _ := json.Marshal(dat)
  3945. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3946. utils.ErrorLog("解析失败:%v", err)
  3947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3948. return
  3949. }
  3950. res.InfRefmsgid = resFour10265.InfRefmsgid
  3951. res.Output = resFour10265.Output
  3952. res.ErrMsg = resFour10265.ErrMsg
  3953. res.Cainfo = resFour10265.Cainfo
  3954. res.WarnMsg = resFour10265.WarnMsg
  3955. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3956. res.Infcode = infocode
  3957. } else {
  3958. 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)
  3959. var dat map[string]interface{}
  3960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3961. fmt.Println(dat)
  3962. } else {
  3963. fmt.Println(err)
  3964. }
  3965. saveLog(result, request_log, "2204", "上传费用明细")
  3966. userJSONBytes, _ := json.Marshal(dat)
  3967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3968. utils.ErrorLog("解析失败:%v", err)
  3969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3970. return
  3971. }
  3972. }
  3973. }
  3974. if res.Infcode == 0 {
  3975. order := &models.HisOrder{
  3976. UserOrgId: adminUser.CurrentOrgId,
  3977. HisPatientId: his.ID,
  3978. PatientId: his.PatientId,
  3979. SettleAccountsDate: recordDateTime,
  3980. MdtrtId: his.Number,
  3981. PsnNo: his.PsnNo,
  3982. MedType: strconv.FormatInt(reg_type, 10),
  3983. Ctime: time.Now().Unix(),
  3984. Mtime: time.Now().Unix(),
  3985. Status: 1,
  3986. Number: chrg_bchno,
  3987. Infcode: res.Infcode,
  3988. WarnMsg: res.WarnMsg,
  3989. Cainfo: res.Cainfo,
  3990. ErrMsg: res.ErrMsg,
  3991. RespondTime: res.RefmsgTime,
  3992. InfRefmsgid: res.InfRefmsgid,
  3993. OrderStatus: 1,
  3994. PayWay: pay_way,
  3995. PayPrice: pay_price,
  3996. PayCardNo: pay_card_no,
  3997. DiscountPrice: discount_price,
  3998. PreferentialPrice: preferential_price,
  3999. RealityPrice: reality_price,
  4000. FoundPrice: found_price,
  4001. MedicalInsurancePrice: medical_insurance_price,
  4002. PrivatePrice: private_price,
  4003. IsMedicineInsurance: 1,
  4004. SettleType: settle_accounts_type,
  4005. SettleStartTime: start_time,
  4006. SettleEndTime: end_time,
  4007. Creator: roles.AdminUserId,
  4008. Modify: roles.AdminUserId,
  4009. FaPiaoNumber: fapiao_number,
  4010. FaPiaoCode: fapiao_code,
  4011. PType: 2,
  4012. Diagnosis: diagnosis_id,
  4013. }
  4014. err = service.CreateOrder(order)
  4015. if err != nil {
  4016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4017. return
  4018. }
  4019. for _, item := range res.Output.Result {
  4020. temp := strings.Split(item.FeedetlSn, "-")
  4021. var advice_id int64 = 0
  4022. var project_id int64 = 0
  4023. var types int64 = 0
  4024. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4025. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4026. if temp[1] == "1" {
  4027. advice_id = id
  4028. project_id = 0
  4029. } else if temp[1] == "2" {
  4030. advice_id = 0
  4031. project_id = id
  4032. }
  4033. info := &models.HisOrderInfo{
  4034. OrderNumber: order.Number,
  4035. FeedetlSn: item.FeedetlSn,
  4036. UploadDate: time.Now().Unix(),
  4037. AdviceId: advice_id,
  4038. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4039. Cnt: item.Cnt,
  4040. Pric: float64(item.Pric),
  4041. PatientId: his.PatientId,
  4042. PricUplmtAmt: item.PricUplmtAmt,
  4043. SelfpayProp: item.SelfpayProp,
  4044. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4045. OverlmtAmt: item.OverlmtAmt,
  4046. PreselfpayAmt: item.PreselfpayAmt,
  4047. BasMednFlag: item.BasMednFlag,
  4048. MedChrgitmType: item.MedChrgitmType,
  4049. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4050. Status: 1,
  4051. Memo: item.Memo,
  4052. Mtime: time.Now().Unix(),
  4053. InscpScpAmt: item.InscpScpAmt,
  4054. DrtReimFlag: item.DrtReimFlag,
  4055. Ctime: time.Now().Unix(),
  4056. ListSpItemFlag: item.ListSpItemFlag,
  4057. ChldMedcFlag: item.ChldMedcFlag,
  4058. LmtUsedFlag: item.LmtUsedFlag,
  4059. ChrgitmLv: item.ChrgitmLv,
  4060. UserOrgId: adminUser.CurrentOrgId,
  4061. HisPatientId: his.ID,
  4062. OrderId: order.ID,
  4063. ProjectId: project_id,
  4064. Type: types,
  4065. }
  4066. service.CreateOrderInfo(info)
  4067. }
  4068. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4069. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4070. var total float64
  4071. for _, item := range prescriptions {
  4072. if item.Type == 1 { //药品
  4073. for _, subItem := range item.HisDoctorAdviceInfo {
  4074. total = total + (subItem.Price * subItem.PrescribingNumber)
  4075. }
  4076. }
  4077. if item.Type == 2 { //项目
  4078. for _, subItem := range item.HisPrescriptionProject {
  4079. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4080. total = total + (subItem.Price * cnt)
  4081. }
  4082. }
  4083. }
  4084. for _, item := range prescriptions {
  4085. for _, subItem := range item.HisAdditionalCharge {
  4086. total = total + (subItem.Price * float64(subItem.Count))
  4087. }
  4088. }
  4089. var allTotal string
  4090. if adminUser.CurrentOrgId == 9919 {
  4091. allTotal = fmt.Sprintf("%.4f", total)
  4092. } else {
  4093. allTotal = fmt.Sprintf("%.4f", total)
  4094. }
  4095. if res.Infcode == 0 {
  4096. var rf []*ResultFive
  4097. json.Unmarshal([]byte(his.Iinfo), &rf)
  4098. chrg_bchno := chrg_bchno
  4099. cert_no := his.Certno
  4100. var insutypes []string
  4101. var insutype string
  4102. var is390 int = 0
  4103. var is310 int = 0
  4104. for _, item := range rf {
  4105. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4106. insutypes = append(insutypes, item.Insutype)
  4107. }
  4108. }
  4109. if len(insutypes) == 1 {
  4110. insutype = insutypes[0]
  4111. } else {
  4112. for _, i := range insutypes {
  4113. if i == "390" {
  4114. is390 = 1
  4115. }
  4116. if i == "310" {
  4117. is310 = 1
  4118. }
  4119. }
  4120. }
  4121. if is390 == 1 {
  4122. insutype = "390"
  4123. }
  4124. if is310 == 1 {
  4125. insutype = "310"
  4126. }
  4127. if len(insutypes) == 0 {
  4128. insutype = "310"
  4129. }
  4130. if len(insutypes) == 2 {
  4131. insutype = strconv.FormatInt(his.SocialType, 10)
  4132. }
  4133. insutype = strconv.FormatInt(his.SocialType, 10)
  4134. //insutype = "390"
  4135. if his.IdCardType == 1 {
  4136. // cert_no = his.MedicalInsuranceNumber
  4137. cert_no = his.Certno
  4138. } else {
  4139. cert_no = his.Certno
  4140. }
  4141. var res ResultSeven
  4142. var resSeven10265 ResultSeven10265
  4143. var src_resquest string
  4144. var result2 string
  4145. var acct_used_flag string
  4146. fmt.Println("pay_way")
  4147. fmt.Println(pay_way)
  4148. fmt.Println("pay_way")
  4149. if pay_way == 4 {
  4150. acct_used_flag = "1"
  4151. } else {
  4152. acct_used_flag = "0"
  4153. }
  4154. if miConfig.MdtrtareaAdmvs == "421300" {
  4155. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4156. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4157. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4159. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4160. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4161. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4162. resp, requestErr := http.Get(api)
  4163. if requestErr != nil {
  4164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4165. return
  4166. }
  4167. body, ioErr := ioutil.ReadAll(resp.Body)
  4168. if ioErr != nil {
  4169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4171. return
  4172. }
  4173. var respJSON map[string]interface{}
  4174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4177. return
  4178. }
  4179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4180. result, _ := json.Marshal(respJSON)
  4181. if miConfig.Code == "H15049901371" {
  4182. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4183. utils.ErrorLog("解析失败:%v", err)
  4184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4185. return
  4186. }
  4187. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4188. res.Output = resSeven10265.Output
  4189. res.ErrMsg = resSeven10265.ErrMsg
  4190. res.Cainfo = resSeven10265.Cainfo
  4191. res.WarnMsg = resSeven10265.WarnMsg
  4192. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4193. res.Infcode = infocode
  4194. } else {
  4195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4196. utils.ErrorLog("解析失败:%v", err)
  4197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4198. return
  4199. }
  4200. }
  4201. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4202. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4203. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4204. //psn_info, _ := service.GetPsnByPatientId(id)
  4205. bas := strings.Split(psn_info.CardInfo, "|")
  4206. if his.IdCardType == 1 {
  4207. cert_no = bas[2]
  4208. } else {
  4209. cert_no = bas[1]
  4210. }
  4211. //江苏地区国家医保医疗类别
  4212. //职工透析:医疗类别选特殊情况门诊9933
  4213. //居民血透门慢: 医疗类别选门诊慢病1402
  4214. //var med_type string
  4215. //if his.Insutype == "310" {
  4216. // if reg_type == 14 {
  4217. // med_type = "9933"
  4218. // } else if reg_type == 11 {
  4219. // med_type = "11"
  4220. //
  4221. // }
  4222. //} else if his.Insutype == "390" {
  4223. // if reg_type == 14 {
  4224. // med_type = "1402"
  4225. // } else if reg_type == 11 {
  4226. // med_type = "11"
  4227. // }
  4228. //}
  4229. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4230. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4231. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4232. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4233. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4234. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4235. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4236. "&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
  4237. resp, requestErr := http.Get(api)
  4238. if requestErr != nil {
  4239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4240. return
  4241. }
  4242. body, ioErr := ioutil.ReadAll(resp.Body)
  4243. if ioErr != nil {
  4244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4246. return
  4247. }
  4248. var respJSON map[string]interface{}
  4249. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4252. return
  4253. }
  4254. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4255. result, _ := json.Marshal(respJSON)
  4256. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4257. utils.ErrorLog("解析失败:%v", err)
  4258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4259. return
  4260. }
  4261. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4262. res.Output = resSeven10265.Output
  4263. res.ErrMsg = resSeven10265.ErrMsg
  4264. res.Cainfo = resSeven10265.Cainfo
  4265. res.WarnMsg = resSeven10265.WarnMsg
  4266. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4267. res.Infcode = infocode
  4268. } else {
  4269. if miConfig.Code == "H15049901371" {
  4270. //赤峰地区国家医保医疗类别
  4271. //职工透析:医疗类别选特殊情况门诊990502
  4272. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4273. var med_type string
  4274. if his.Insutype == "390" {
  4275. if reg_type == 14 {
  4276. med_type = "9933"
  4277. } else if reg_type == 11 {
  4278. med_type = "11"
  4279. }
  4280. } else if his.Insutype == "310" {
  4281. if reg_type == 14 {
  4282. med_type = "990502"
  4283. } else if reg_type == 11 {
  4284. med_type = "11"
  4285. }
  4286. }
  4287. 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)
  4288. } else {
  4289. 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)
  4290. }
  4291. //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)
  4292. var dat map[string]interface{}
  4293. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4294. fmt.Println(dat)
  4295. } else {
  4296. fmt.Println(err)
  4297. }
  4298. saveLog(result2, src_resquest, "2207", "结算")
  4299. userJSONBytes, _ := json.Marshal(dat)
  4300. if miConfig.Code == "H15049901371" {
  4301. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4302. utils.ErrorLog("解析失败:%v", err)
  4303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4304. return
  4305. }
  4306. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4307. res.Output = resSeven10265.Output
  4308. res.ErrMsg = resSeven10265.ErrMsg
  4309. res.Cainfo = resSeven10265.Cainfo
  4310. res.WarnMsg = resSeven10265.WarnMsg
  4311. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4312. res.Infcode = infocode
  4313. } else {
  4314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4315. utils.ErrorLog("解析失败:%v", err)
  4316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4317. return
  4318. }
  4319. }
  4320. }
  4321. if res.Infcode != 0 {
  4322. errlog := &models.HisOrderError{
  4323. UserOrgId: adminUser.CurrentOrgId,
  4324. Ctime: time.Now().Unix(),
  4325. Mtime: time.Now().Unix(),
  4326. Number: chrg_bchno,
  4327. ErrMsg: res.ErrMsg,
  4328. Status: 1,
  4329. PatientId: id,
  4330. RecordTime: recordDateTime,
  4331. Stage: 6,
  4332. }
  4333. service.CreateErrMsgLog(errlog)
  4334. c.ServeSuccessJSON(map[string]interface{}{
  4335. "failed_code": -10,
  4336. "msg": res.ErrMsg,
  4337. })
  4338. return
  4339. } else {
  4340. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4341. order.OrderStatus = 2
  4342. order.Status = 1
  4343. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4344. order.SetlId = res.Output.Setlinfo.SetlID
  4345. order.PsnNo = res.Output.Setlinfo.PsnNo
  4346. order.PsnName = res.Output.Setlinfo.PsnName
  4347. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4348. order.Certno = res.Output.Setlinfo.Certno
  4349. order.Gend = res.Output.Setlinfo.Gend
  4350. order.Naty = res.Output.Setlinfo.Naty
  4351. order.Age = res.Output.Setlinfo.Age
  4352. order.Insutype = res.Output.Setlinfo.Insutype
  4353. order.PsnType = res.Output.Setlinfo.PsnType
  4354. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4355. order.SetlTime = res.Output.Setlinfo.SetlTime
  4356. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4357. if res.Output.Setlinfo.MedType == "140101" {
  4358. order.MedType = "14"
  4359. } else {
  4360. order.MedType = res.Output.Setlinfo.MedType
  4361. }
  4362. if reg_type == 1112 {
  4363. order.MedType = "1112"
  4364. }
  4365. if reg_type == 1111 {
  4366. order.MedType = "1111"
  4367. }
  4368. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4369. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4370. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4371. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4372. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4373. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4374. order.HifpPay = res.Output.Setlinfo.HifpPay
  4375. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4376. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4377. order.HifesPay = res.Output.Setlinfo.HifesPay
  4378. order.HifobPay = res.Output.Setlinfo.HifobPay
  4379. order.MafPay = res.Output.Setlinfo.MafPay
  4380. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4381. order.OthPay = res.Output.Setlinfo.OthPay
  4382. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4383. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4384. order.AcctPay = res.Output.Setlinfo.AcctPay
  4385. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4386. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4387. order.Balc = res.Output.Setlinfo.Balc
  4388. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4389. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4390. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4391. order.ClrType = res.Output.Setlinfo.ClrType
  4392. order.ClrWay = res.Output.Setlinfo.ClrWay
  4393. order.Creator = order.Creator
  4394. order.Modify = roles.AdminUserId
  4395. order.RequestLog = src_resquest
  4396. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4397. detailStr := string(setlDetail)
  4398. order.SetlDetail = detailStr
  4399. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4400. err = service.UpDateOrder(order)
  4401. if err == nil {
  4402. c.ServeSuccessJSON(map[string]interface{}{
  4403. "msg": "结算成功",
  4404. })
  4405. } else {
  4406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4407. return
  4408. }
  4409. }
  4410. } else {
  4411. adminUser := c.GetAdminUserInfo()
  4412. errlog := &models.HisOrderError{
  4413. UserOrgId: adminUser.CurrentOrgId,
  4414. Ctime: time.Now().Unix(),
  4415. Mtime: time.Now().Unix(),
  4416. ErrMsg: res.ErrMsg,
  4417. Status: 1,
  4418. PatientId: id,
  4419. RecordTime: recordDateTime,
  4420. Stage: 4,
  4421. }
  4422. service.CreateErrMsgLog(errlog)
  4423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4424. return
  4425. }
  4426. } else {
  4427. adminUser := c.GetAdminUserInfo()
  4428. errlog := &models.HisOrderError{
  4429. UserOrgId: adminUser.CurrentOrgId,
  4430. Ctime: time.Now().Unix(),
  4431. Mtime: time.Now().Unix(),
  4432. ErrMsg: res.ErrMsg,
  4433. Status: 1,
  4434. PatientId: id,
  4435. RecordTime: recordDateTime,
  4436. Stage: 4,
  4437. }
  4438. service.CreateErrMsgLog(errlog)
  4439. c.ServeSuccessJSON(map[string]interface{}{
  4440. "failed_code": -10,
  4441. "msg": res.ErrMsg,
  4442. })
  4443. return
  4444. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4445. //return
  4446. }
  4447. }
  4448. }
  4449. } else if tempOrder.ID > 0 {
  4450. if tempOrder.IsPre == 1 {
  4451. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4452. var rf []*ResultFive
  4453. json.Unmarshal([]byte(his.Iinfo), &rf)
  4454. chrg_bchno := tempOrder.Number
  4455. cert_no := his.Certno
  4456. var insutypes []string
  4457. var insutype string
  4458. var is390 int = 0
  4459. var is310 int = 0
  4460. for _, item := range rf {
  4461. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4462. insutypes = append(insutypes, item.Insutype)
  4463. }
  4464. }
  4465. if len(insutypes) == 1 {
  4466. insutype = insutypes[0]
  4467. } else {
  4468. for _, i := range insutypes {
  4469. if i == "390" {
  4470. is390 = 1
  4471. }
  4472. if i == "310" {
  4473. is310 = 1
  4474. }
  4475. }
  4476. }
  4477. if is390 == 1 {
  4478. insutype = "390"
  4479. }
  4480. if is310 == 1 {
  4481. insutype = "310"
  4482. }
  4483. if len(insutypes) == 0 {
  4484. insutype = "310"
  4485. }
  4486. if len(insutypes) == 2 {
  4487. insutype = strconv.FormatInt(his.SocialType, 64)
  4488. }
  4489. //insutype = "390"
  4490. if his.IdCardType == 1 {
  4491. // cert_no = his.MedicalInsuranceNumber
  4492. cert_no = his.Certno
  4493. } else {
  4494. cert_no = his.Certno
  4495. }
  4496. var res ResultSeven
  4497. var resSeven10265 ResultSeven10265
  4498. var src_resquest string
  4499. var result2 string
  4500. var acct_used_flag string
  4501. fmt.Println("pay_way")
  4502. fmt.Println(pay_way)
  4503. fmt.Println("pay_way")
  4504. if pay_way == 4 {
  4505. acct_used_flag = "1"
  4506. } else {
  4507. acct_used_flag = "0"
  4508. }
  4509. if miConfig.MdtrtareaAdmvs == "421300" {
  4510. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4511. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4512. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4514. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4515. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4516. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4517. resp, requestErr := http.Get(api)
  4518. if requestErr != nil {
  4519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4520. return
  4521. }
  4522. body, ioErr := ioutil.ReadAll(resp.Body)
  4523. if ioErr != nil {
  4524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4526. return
  4527. }
  4528. var respJSON map[string]interface{}
  4529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4532. return
  4533. }
  4534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4535. result, _ := json.Marshal(respJSON)
  4536. fmt.Println("log")
  4537. fmt.Println(string(result))
  4538. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4539. utils.ErrorLog("解析失败:%v", err)
  4540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4541. return
  4542. }
  4543. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4544. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4545. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4546. //psn_info, _ := service.GetPsnByPatientId(id)
  4547. bas := strings.Split(psn_info.CardInfo, "|")
  4548. if his.IdCardType == 1 {
  4549. cert_no = bas[2]
  4550. } else {
  4551. cert_no = bas[1]
  4552. }
  4553. //江苏地区国家医保医疗类别
  4554. //职工透析:医疗类别选特殊情况门诊9933
  4555. //居民血透门慢: 医疗类别选门诊慢病1402
  4556. //var med_type string
  4557. //if his.Insutype == "310" {
  4558. // if reg_type == 14 {
  4559. // med_type = "9933"
  4560. // } else if reg_type == 11 {
  4561. // med_type = "11"
  4562. //
  4563. // }
  4564. //} else if his.Insutype == "390" {
  4565. // if reg_type == 14 {
  4566. // med_type = "1402"
  4567. // } else if reg_type == 11 {
  4568. // med_type = "11"
  4569. // }
  4570. //}
  4571. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4572. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4573. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4574. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4575. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4576. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4577. "&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
  4578. resp, requestErr := http.Get(api)
  4579. if requestErr != nil {
  4580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4581. return
  4582. }
  4583. body, ioErr := ioutil.ReadAll(resp.Body)
  4584. if ioErr != nil {
  4585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. return
  4588. }
  4589. var respJSON map[string]interface{}
  4590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4593. return
  4594. }
  4595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4596. result, _ := json.Marshal(respJSON)
  4597. fmt.Println("log")
  4598. fmt.Println(string(result))
  4599. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4600. utils.ErrorLog("解析失败:%v", err)
  4601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4602. return
  4603. }
  4604. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4605. res.Output = resSeven10265.Output
  4606. res.ErrMsg = resSeven10265.ErrMsg
  4607. res.Cainfo = resSeven10265.Cainfo
  4608. res.WarnMsg = resSeven10265.WarnMsg
  4609. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4610. res.Infcode = infocode
  4611. } else {
  4612. var src_resquest string
  4613. if miConfig.Code == "H15049901371" {
  4614. //赤峰地区国家医保医疗类别
  4615. //职工透析:医疗类别选特殊情况门诊990502
  4616. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4617. var med_type string
  4618. if his.Insutype == "390" {
  4619. if reg_type == 14 {
  4620. med_type = "9933"
  4621. } else if reg_type == 11 {
  4622. med_type = "11"
  4623. }
  4624. } else if his.Insutype == "310" {
  4625. if reg_type == 14 {
  4626. med_type = "990502"
  4627. } else if reg_type == 11 {
  4628. med_type = "11"
  4629. }
  4630. }
  4631. 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)
  4632. } else {
  4633. 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)
  4634. }
  4635. var dat map[string]interface{}
  4636. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4637. fmt.Println(dat)
  4638. } else {
  4639. fmt.Println(err)
  4640. }
  4641. saveLog(result2, src_resquest, "2207", "结算")
  4642. userJSONBytes, _ := json.Marshal(dat)
  4643. if miConfig.Code == "H15049901371" {
  4644. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4645. utils.ErrorLog("解析失败:%v", err)
  4646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4647. return
  4648. }
  4649. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4650. res.Output = resSeven10265.Output
  4651. res.ErrMsg = resSeven10265.ErrMsg
  4652. res.Cainfo = resSeven10265.Cainfo
  4653. res.WarnMsg = resSeven10265.WarnMsg
  4654. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4655. res.Infcode = infocode
  4656. } else {
  4657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4658. utils.ErrorLog("解析失败:%v", err)
  4659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4660. return
  4661. }
  4662. }
  4663. }
  4664. if res.Infcode != 0 {
  4665. errlog := &models.HisOrderError{
  4666. UserOrgId: adminUser.CurrentOrgId,
  4667. Ctime: time.Now().Unix(),
  4668. Mtime: time.Now().Unix(),
  4669. Number: chrg_bchno,
  4670. ErrMsg: res.ErrMsg,
  4671. Status: 1,
  4672. PatientId: id,
  4673. RecordTime: recordDateTime,
  4674. Stage: 6,
  4675. }
  4676. service.CreateErrMsgLog(errlog)
  4677. c.ServeSuccessJSON(map[string]interface{}{
  4678. "failed_code": -10,
  4679. "msg": res.ErrMsg,
  4680. })
  4681. return
  4682. } else {
  4683. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4684. order.OrderStatus = 2
  4685. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4686. order.SetlId = res.Output.Setlinfo.SetlID
  4687. order.PsnNo = res.Output.Setlinfo.PsnNo
  4688. order.PsnName = res.Output.Setlinfo.PsnName
  4689. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4690. order.Certno = res.Output.Setlinfo.Certno
  4691. order.Gend = res.Output.Setlinfo.Gend
  4692. order.Naty = res.Output.Setlinfo.Naty
  4693. order.Age = res.Output.Setlinfo.Age
  4694. order.Insutype = res.Output.Setlinfo.Insutype
  4695. order.PsnType = res.Output.Setlinfo.PsnType
  4696. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4697. order.SetlTime = res.Output.Setlinfo.SetlTime
  4698. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4699. //order.MedType = res.Output.Setlinfo.MedType
  4700. if reg_type == 1112 {
  4701. order.MedType = "1112"
  4702. }
  4703. if reg_type == 1111 {
  4704. order.MedType = "1111"
  4705. }
  4706. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4707. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4708. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4709. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4710. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4711. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4712. order.HifpPay = res.Output.Setlinfo.HifpPay
  4713. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4714. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4715. order.HifesPay = res.Output.Setlinfo.HifesPay
  4716. order.HifobPay = res.Output.Setlinfo.HifobPay
  4717. order.MafPay = res.Output.Setlinfo.MafPay
  4718. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4719. order.OthPay = res.Output.Setlinfo.OthPay
  4720. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4721. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4722. order.AcctPay = res.Output.Setlinfo.AcctPay
  4723. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4724. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4725. order.Balc = res.Output.Setlinfo.Balc
  4726. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4727. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4728. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4729. order.ClrWay = res.Output.Setlinfo.ClrWay
  4730. order.Creator = order.Creator
  4731. order.Modify = roles.AdminUserId
  4732. order.RequestLog = src_resquest
  4733. order.Diagnosis = diagnosis_id
  4734. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4735. detailStr := string(setlDetail)
  4736. order.SetlDetail = detailStr
  4737. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4738. err = service.UpDateOrder(order)
  4739. if err == nil {
  4740. c.ServeSuccessJSON(map[string]interface{}{
  4741. "msg": "结算成功",
  4742. })
  4743. } else {
  4744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4745. return
  4746. }
  4747. }
  4748. }
  4749. }
  4750. }
  4751. //func (c *HisApiController) GetPreUploadInfo() {
  4752. // id, _ := c.GetInt64("id")
  4753. // record_time := c.GetString("record_time")
  4754. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4755. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4756. //
  4757. // timeLayout := "2006-01-02"
  4758. // loc, _ := time.LoadLocation("Local")
  4759. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4760. // if err != nil {
  4761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4762. // return
  4763. // }
  4764. // recordDateTime := theTime.Unix()
  4765. // adminUser := c.GetAdminUserInfo()
  4766. //
  4767. // var prescriptions []*models.HisPrescription
  4768. //
  4769. // var start_time int64
  4770. // var end_time int64
  4771. //
  4772. // data := make(map[string]interface{})
  4773. // if settle_accounts_type == 1 { //日结
  4774. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4775. // data["pre"] = prescriptions
  4776. //
  4777. // } else { //月结
  4778. // start_time_str := c.GetString("start_time")
  4779. // end_time_str := c.GetString("end_time")
  4780. // timeLayout := "2006-01-02"
  4781. // loc, _ := time.LoadLocation("Local")
  4782. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4783. // if err != nil {
  4784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4785. // return
  4786. // }
  4787. // recordStartTime := theStartTime.Unix()
  4788. // start_time = recordStartTime
  4789. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4790. // if err != nil {
  4791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4792. // return
  4793. // }
  4794. // recordEndTime := theEndTime.Unix()
  4795. // end_time = recordEndTime
  4796. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4797. // data["pre"] = prescriptions
  4798. //
  4799. // }
  4800. //
  4801. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4802. //
  4803. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4804. // timestamp := time.Now().Unix()
  4805. // tempTime := time.Unix(timestamp, 0)
  4806. // timeFormat := tempTime.Format("20060102150405")
  4807. // chrgBchno := rand.Intn(100000) + 10000
  4808. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4809. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4810. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4811. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4812. // strconv.FormatInt(his.PatientId, 10)
  4813. // client := &http.Client{}
  4814. // data["psn_no"] = his.PsnNo
  4815. // data["mdtrt_id"] = his.Number
  4816. // data["chrg_bchno"] = chrg_bchno
  4817. // data["org_name"] = miConfig.OrgName
  4818. // data["doctor"] = roles.UserName
  4819. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4820. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4821. // data["fixmedins_code"] = miConfig.Code
  4822. // data["dept_code"] = department.Number
  4823. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4824. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4825. // data["secret_key"] = miConfig.SecretKey
  4826. // var ids []int64
  4827. //
  4828. // for _, item := range prescriptions {
  4829. // ids = append(ids, item.ID)
  4830. // }
  4831. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4832. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4833. // bytesData, _ := json.Marshal(data)
  4834. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4835. // resp, _ := client.Do(req)
  4836. // defer resp.Body.Close()
  4837. // body, ioErr := ioutil.ReadAll(resp.Body)
  4838. // if ioErr != nil {
  4839. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4840. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4841. // return
  4842. // }
  4843. // var respJSON map[string]interface{}
  4844. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4845. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4847. // return
  4848. // }
  4849. //
  4850. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4851. // userJSONBytes, _ := json.Marshal(respJSON)
  4852. // var res ResultFour
  4853. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4854. // utils.ErrorLog("解析失败:%v", err)
  4855. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4856. // return
  4857. // }
  4858. //
  4859. // if res.Infcode == 0 {
  4860. // order := &models.HisOrder{
  4861. // UserOrgId: adminUser.CurrentOrgId,
  4862. // HisPatientId: his.ID,
  4863. // PatientId: his.PatientId,
  4864. // SettleAccountsDate: recordDateTime,
  4865. // Ctime: time.Now().Unix(),
  4866. // Mtime: time.Now().Unix(),
  4867. // Status: 1,
  4868. // Number: chrg_bchno,
  4869. // Infcode: res.Infcode,
  4870. // WarnMsg: res.WarnMsg,
  4871. // Cainfo: res.Cainfo,
  4872. // ErrMsg: res.ErrMsg,
  4873. // RespondTime: res.RefmsgTime,
  4874. // InfRefmsgid: res.InfRefmsgid,
  4875. // OrderStatus: 1,
  4876. // IsMedicineInsurance: 1,
  4877. // SettleType: settle_accounts_type,
  4878. // SettleStartTime: start_time,
  4879. // SettleEndTime: end_time,
  4880. // Creator: roles.ID,
  4881. // Modify: roles.ID,
  4882. // PType: 2,
  4883. // }
  4884. // err = service.CreateOrder(order)
  4885. // if err != nil {
  4886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4887. // return
  4888. // }
  4889. //
  4890. // for _, item := range res.Output.Result {
  4891. // temp := strings.Split(item.FeedetlSn, "-")
  4892. // var advice_id int64 = 0
  4893. // var project_id int64 = 0
  4894. // var types int64 = 0
  4895. //
  4896. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4897. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4898. //
  4899. // if temp[1] == "1" {
  4900. // advice_id = id
  4901. // project_id = 0
  4902. // } else if temp[1] == "2" {
  4903. // advice_id = 0
  4904. // project_id = id
  4905. // }
  4906. //
  4907. // info := &models.HisOrderInfo{
  4908. // OrderNumber: order.Number,
  4909. // FeedetlSn: item.FeedetlSn,
  4910. // UploadDate: time.Now().Unix(),
  4911. // AdviceId: advice_id,
  4912. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4913. // Cnt: item.Cnt,
  4914. // Pric: float64(item.Pric),
  4915. // PatientId: his.PatientId,
  4916. // PricUplmtAmt: item.PricUplmtAmt,
  4917. // SelfpayProp: item.SelfpayProp,
  4918. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4919. // OverlmtAmt: item.OverlmtAmt,
  4920. // PreselfpayAmt: item.PreselfpayAmt,
  4921. // BasMednFlag: item.BasMednFlag,
  4922. // MedChrgitmType: item.MedChrgitmType,
  4923. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4924. // Status: 1,
  4925. // Memo: item.Memo,
  4926. // Mtime: time.Now().Unix(),
  4927. // InscpScpAmt: item.InscpScpAmt,
  4928. // DrtReimFlag: item.DrtReimFlag,
  4929. // Ctime: time.Now().Unix(),
  4930. // ListSpItemFlag: item.ListSpItemFlag,
  4931. // ChldMedcFlag: item.ChldMedcFlag,
  4932. // LmtUsedFlag: item.LmtUsedFlag,
  4933. // ChrgitmLv: item.ChrgitmLv,
  4934. // UserOrgId: adminUser.CurrentOrgId,
  4935. // HisPatientId: his.ID,
  4936. // OrderId: order.ID,
  4937. // ProjectId: project_id,
  4938. // Type: types,
  4939. // }
  4940. // service.CreateOrderInfo(info)
  4941. //
  4942. // }
  4943. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4944. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4945. //
  4946. // var total float64
  4947. // for _, item := range prescriptions {
  4948. // if item.Type == 1 { //药品
  4949. // for _, subItem := range item.HisDoctorAdviceInfo {
  4950. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4951. // }
  4952. // }
  4953. // if item.Type == 2 { //项目
  4954. // for _, subItem := range item.HisPrescriptionProject {
  4955. // total = total + (subItem.Price * float64(subItem.Count))
  4956. // }
  4957. // }
  4958. // }
  4959. //
  4960. // for _, item := range prescriptions {
  4961. // for _, subItem := range item.HisAdditionalCharge {
  4962. // total = total + (subItem.Price * float64(subItem.Count))
  4963. // }
  4964. // }
  4965. //
  4966. // allTotal := fmt.Sprintf("%.2f", total)
  4967. // if res.Infcode == 0 {
  4968. // var rf []*ResultFive
  4969. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4970. // psn_no := his.PsnNo
  4971. // mdtrt_id := his.Number
  4972. // chrg_bchno := chrg_bchno
  4973. // cert_no := his.Certno
  4974. // insutype := rf[0].Insutype
  4975. //
  4976. // if his.IdCardType == 1 {
  4977. // cert_no = his.MedicalInsuranceNumber
  4978. //
  4979. // } else {
  4980. //
  4981. // cert_no = his.Certno
  4982. //
  4983. // }
  4984. //
  4985. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4986. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4987. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4988. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4989. // resp, requestErr := http.Get(api)
  4990. // if requestErr != nil {
  4991. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4992. // return
  4993. // }
  4994. // defer resp.Body.Close()
  4995. // body, ioErr := ioutil.ReadAll(resp.Body)
  4996. // if ioErr != nil {
  4997. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4998. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4999. // return
  5000. // }
  5001. // var respJSON map[string]interface{}
  5002. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5003. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5005. // return
  5006. // }
  5007. // fmt.Println(respJSON)
  5008. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5009. // userJSONBytes, _ := json.Marshal(respJSON)
  5010. // var res ResultSeven
  5011. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5012. // utils.ErrorLog("解析失败:%v", err)
  5013. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5014. // return
  5015. // }
  5016. // if res.Infcode != 0 {
  5017. // errlog := &models.HisOrderError{
  5018. // UserOrgId: adminUser.CurrentOrgId,
  5019. // Ctime: time.Now().Unix(),
  5020. // Mtime: time.Now().Unix(),
  5021. // Number: chrg_bchno,
  5022. // ErrMsg: res.ErrMsg,
  5023. // Status: 1,
  5024. // PatientId: id,
  5025. // RecordTime: recordDateTime,
  5026. // Stage: 7,
  5027. // }
  5028. // service.CreateErrMsgLog(errlog)
  5029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5030. // return
  5031. // } else {
  5032. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5033. // order.OrderStatus = 1
  5034. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5035. // order.SetlId = res.Output.Setlinfo.SetlID
  5036. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5037. // order.PsnName = res.Output.Setlinfo.PsnName
  5038. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5039. // order.Certno = res.Output.Setlinfo.Certno
  5040. // order.Gend = res.Output.Setlinfo.Gend
  5041. // order.Naty = res.Output.Setlinfo.Naty
  5042. // order.Age = res.Output.Setlinfo.Age
  5043. // order.Insutype = res.Output.Setlinfo.Insutype
  5044. // order.PsnType = res.Output.Setlinfo.PsnType
  5045. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5046. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5047. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5048. // order.MedType = res.Output.Setlinfo.MedType
  5049. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5050. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5051. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5052. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5053. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5054. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5055. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5056. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5057. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5058. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5059. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5060. // order.MafPay = res.Output.Setlinfo.MafPay
  5061. // order.OthPay = res.Output.Setlinfo.OthPay
  5062. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5063. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5064. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5065. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5066. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5067. // order.Balc = res.Output.Setlinfo.Balc
  5068. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5069. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5070. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5071. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5072. // order.Creator = order.Creator
  5073. // order.Modify = roles.ID
  5074. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5075. // detailStr := string(setlDetail)
  5076. // order.SetlDetail = detailStr
  5077. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5078. // err = service.UpDateOrder(order)
  5079. // if err == nil {
  5080. // c.ServeSuccessJSON(map[string]interface{}{
  5081. // "msg": "预结算成功",
  5082. // })
  5083. // } else {
  5084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5085. // return
  5086. // }
  5087. // }
  5088. // } else {
  5089. // adminUser := c.GetAdminUserInfo()
  5090. // errlog := &models.HisOrderError{
  5091. // UserOrgId: adminUser.CurrentOrgId,
  5092. // Ctime: time.Now().Unix(),
  5093. // Mtime: time.Now().Unix(),
  5094. // ErrMsg: res.ErrMsg,
  5095. // Status: 1,
  5096. // PatientId: id,
  5097. // RecordTime: recordDateTime,
  5098. // Stage: 4,
  5099. // }
  5100. // service.CreateErrMsgLog(errlog)
  5101. //
  5102. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5103. // return
  5104. // }
  5105. // } else {
  5106. // adminUser := c.GetAdminUserInfo()
  5107. // errlog := &models.HisOrderError{
  5108. // UserOrgId: adminUser.CurrentOrgId,
  5109. // Ctime: time.Now().Unix(),
  5110. // Mtime: time.Now().Unix(),
  5111. // ErrMsg: res.ErrMsg,
  5112. // Status: 1,
  5113. // PatientId: id,
  5114. // RecordTime: recordDateTime,
  5115. // Stage: 4,
  5116. // }
  5117. // service.CreateErrMsgLog(errlog)
  5118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5119. // return
  5120. // }
  5121. //
  5122. // } else {
  5123. // var total float64
  5124. // for _, item := range prescriptions {
  5125. // if item.Type == 1 { //药品
  5126. // for _, subItem := range item.HisDoctorAdviceInfo {
  5127. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5128. // }
  5129. // }
  5130. // if item.Type == 2 { //项目
  5131. // for _, subItem := range item.HisPrescriptionProject {
  5132. // total = total + (subItem.Price * float64(subItem.Count))
  5133. // }
  5134. // }
  5135. //
  5136. // for _, subItem := range item.HisAdditionalCharge {
  5137. // total = total + (subItem.Price * float64(subItem.Count))
  5138. // }
  5139. // }
  5140. //
  5141. // allTotal := fmt.Sprintf("%.2f", total)
  5142. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5143. // order := &models.HisOrder{
  5144. // UserOrgId: adminUser.CurrentOrgId,
  5145. // HisPatientId: his.ID,
  5146. // PatientId: id,
  5147. // SettleAccountsDate: recordDateTime,
  5148. // Ctime: time.Now().Unix(),
  5149. // Mtime: time.Now().Unix(),
  5150. // Status: 1,
  5151. // OrderStatus: 2,
  5152. // Number: chrg_bchno,
  5153. // MedfeeSumamt: totals,
  5154. // }
  5155. // err = service.CreateOrder(order)
  5156. // if err != nil {
  5157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5158. // return
  5159. // }
  5160. //
  5161. // var customs []*Custom
  5162. // for _, item := range prescriptions {
  5163. //
  5164. // if item.Type == 1 { //药品
  5165. // for _, subItem := range item.HisDoctorAdviceInfo {
  5166. // cus := &Custom{
  5167. // AdviceId: subItem.ID,
  5168. // ProjectId: 0,
  5169. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5170. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5171. // FeedetlSn: subItem.FeedetlSn,
  5172. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5173. // MedListCodg: subItem.MedListCodg,
  5174. // Type: 1,
  5175. // }
  5176. // customs = append(customs, cus)
  5177. // }
  5178. // }
  5179. //
  5180. // if item.Type == 2 { //项目
  5181. // for _, subItem := range item.HisPrescriptionProject {
  5182. //
  5183. // cus := &Custom{
  5184. // AdviceId: 0,
  5185. // ProjectId: subItem.ID,
  5186. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5187. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5188. // FeedetlSn: subItem.FeedetlSn,
  5189. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5190. // MedListCodg: subItem.MedListCodg,
  5191. // Type: 2,
  5192. // }
  5193. //
  5194. // customs = append(customs, cus)
  5195. // }
  5196. // }
  5197. //
  5198. // for _, item := range item.HisAdditionalCharge {
  5199. // cus := &Custom{
  5200. // ItemId: item.ID,
  5201. // AdviceId: 0,
  5202. // ProjectId: 0,
  5203. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5204. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5205. // FeedetlSn: item.FeedetlSn,
  5206. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5207. // MedListCodg: item.XtHisAddtionConfig.Code,
  5208. // Type: 3,
  5209. // }
  5210. //
  5211. // customs = append(customs, cus)
  5212. // }
  5213. //
  5214. // }
  5215. //
  5216. // for _, item := range customs {
  5217. // var advice_id int64 = 0
  5218. // var project_id int64 = 0
  5219. // var item_id int64 = 0
  5220. //
  5221. // var types int64 = 0
  5222. //
  5223. // if item.Type == 1 {
  5224. // advice_id = item.AdviceId
  5225. // project_id = 0
  5226. // item_id = 0
  5227. // } else if item.Type == 2 {
  5228. // advice_id = 0
  5229. // item_id = 0
  5230. //
  5231. // project_id = item.ProjectId
  5232. // } else if item.Type == 3 {
  5233. // advice_id = 0
  5234. // item_id = item.ItemId
  5235. // project_id = 0
  5236. // }
  5237. //
  5238. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5239. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5240. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5241. //
  5242. // info := &models.HisOrderInfo{
  5243. // OrderNumber: order.Number,
  5244. // UploadDate: time.Now().Unix(),
  5245. // AdviceId: advice_id,
  5246. // DetItemFeeSumamt: detItemFeeSumamt,
  5247. // Cnt: cut,
  5248. // Pric: pric,
  5249. // PatientId: id,
  5250. // Status: 1,
  5251. // Mtime: time.Now().Unix(),
  5252. // Ctime: time.Now().Unix(),
  5253. // UserOrgId: adminUser.CurrentOrgId,
  5254. // HisPatientId: his.ID,
  5255. // OrderId: order.ID,
  5256. // ProjectId: project_id,
  5257. // Type: types,
  5258. // ItemId: item_id,
  5259. // }
  5260. // service.CreateOrderInfo(info)
  5261. // }
  5262. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5263. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5264. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5265. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5266. // if err == nil {
  5267. // c.ServeSuccessJSON(map[string]interface{}{
  5268. // "msg": "结算成功",
  5269. // })
  5270. // } else {
  5271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5272. // return
  5273. // }
  5274. // }
  5275. //}
  5276. //上传明细-预结算-
  5277. func (c *HisApiController) GetPreUploadInfo() {
  5278. id, _ := c.GetInt64("id")
  5279. record_time := c.GetString("record_time")
  5280. his_patient_id, _ := c.GetInt64("his_patient_id")
  5281. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5282. admin_user_id, _ := c.GetInt64("admin_user_id")
  5283. diagnosis_id := c.GetString("diagnosis")
  5284. sick_type, _ := c.GetInt64("sick_type")
  5285. reg_type, _ := c.GetInt64("p_type")
  5286. begin_time := c.GetString("begin_time")
  5287. id_str := c.GetString("ids")
  5288. ids_arr := strings.Split(id_str, ",")
  5289. timeLayout := "2006-01-02"
  5290. loc, _ := time.LoadLocation("Local")
  5291. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5292. if err != nil {
  5293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5294. return
  5295. }
  5296. recordDateTime := theTime.Unix()
  5297. adminUser := c.GetAdminUserInfo()
  5298. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5299. var config []*models.HisXtDiagnoseConfig
  5300. for _, item := range diagnosis_ids {
  5301. id, _ := strconv.ParseInt(item, 10, 64)
  5302. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5303. config = append(config, &diagnosisConfig)
  5304. }
  5305. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5306. sickConfig, _ := service.FindSickById(sick_type)
  5307. var prescriptions []*models.HisPrescription
  5308. var start_time int64
  5309. var end_time int64
  5310. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5311. fmt.Println(his_patient_id)
  5312. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5313. timestamp := time.Now().Unix()
  5314. tempTime := time.Unix(timestamp, 0)
  5315. timeFormat := tempTime.Format("20060102150405")
  5316. chrgBchno := rand.Intn(100000) + 10000
  5317. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5318. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5319. var patientPrescription models.HisPrescriptionInfo
  5320. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5321. if patientPrescription.ID == 0 {
  5322. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5323. }
  5324. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5325. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5326. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5327. strconv.FormatInt(his.PatientId, 10)
  5328. var res2 ResultSix
  5329. var resSix10265 ResultSix10265
  5330. var time_stamp string
  5331. if miConfig.MdtrtareaAdmvs == "421300" {
  5332. data := make(map[string]interface{})
  5333. client := &http.Client{}
  5334. data["psn_no"] = his.PsnNo
  5335. data["mdtrt_id"] = his.Number
  5336. data["doctor"] = roles.UserName
  5337. data["department"] = department.Name
  5338. data["org_name"] = miConfig.OrgName
  5339. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5340. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5341. data["fixmedins_code"] = miConfig.Code
  5342. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5343. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5344. data["secret_key"] = miConfig.SecretKey
  5345. data["sick_code"] = sickConfig.CountryCode
  5346. data["sick_name"] = sickConfig.ClassName
  5347. data["begin_time"] = begin_time
  5348. data["dept"] = strconv.FormatInt(department.ID, 10)
  5349. data["config"] = config
  5350. fmt.Println(data)
  5351. bytesData, _ := json.Marshal(data)
  5352. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5353. resp, _ := client.Do(req)
  5354. defer resp.Body.Close()
  5355. body, ioErr := ioutil.ReadAll(resp.Body)
  5356. if ioErr != nil {
  5357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5359. return
  5360. }
  5361. var respJSON map[string]interface{}
  5362. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5365. return
  5366. }
  5367. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5368. userJSONBytes, _ := json.Marshal(respJSON)
  5369. fmt.Println("log")
  5370. fmt.Println(string(userJSONBytes))
  5371. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5372. utils.ErrorLog("解析失败:%v", err)
  5373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5374. return
  5375. }
  5376. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5377. //江苏地区国家医保医疗类别
  5378. //职工透析:医疗类别选特殊情况门诊9933
  5379. //居民血透门慢: 医疗类别选门诊慢病1402
  5380. //var med_type string
  5381. //if his.Insutype == "310" {
  5382. // if reg_type == 14 {
  5383. // med_type = "9933"
  5384. // } else if reg_type == 11 {
  5385. // med_type = "11"
  5386. //
  5387. // }
  5388. //} else if his.Insutype == "390" {
  5389. // if reg_type == 14 {
  5390. // med_type = "1402"
  5391. // } else if reg_type == 11 {
  5392. // med_type = "11"
  5393. // }
  5394. //}
  5395. data := make(map[string]interface{})
  5396. client := &http.Client{}
  5397. data["psn_no"] = his.PsnNo
  5398. data["mdtrt_id"] = his.Number
  5399. data["doctor"] = roles.UserName
  5400. data["department"] = department.Name
  5401. data["org_name"] = miConfig.OrgName
  5402. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5403. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5404. data["fixmedins_code"] = miConfig.Code
  5405. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5406. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5407. data["secret_key"] = miConfig.SecretKey
  5408. data["sick_code"] = sickConfig.CountryCode
  5409. data["sick_name"] = sickConfig.ClassName
  5410. data["begin_time"] = begin_time
  5411. data["dept"] = strconv.FormatInt(department.ID, 10)
  5412. data["config"] = config
  5413. data["url"] = miConfig.Url
  5414. data["ak"] = miConfig.AccessKey
  5415. data["cainfo"] = miConfig.Cainfo
  5416. bytesData, _ := json.Marshal(data)
  5417. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5418. resp, _ := client.Do(req)
  5419. defer resp.Body.Close()
  5420. body, ioErr := ioutil.ReadAll(resp.Body)
  5421. if ioErr != nil {
  5422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5424. return
  5425. }
  5426. var respJSON map[string]interface{}
  5427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5430. return
  5431. }
  5432. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5433. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5434. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5436. userJSONBytes, _ := json.Marshal(respJSON)
  5437. fmt.Println("log")
  5438. fmt.Println(string(userJSONBytes))
  5439. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5440. utils.ErrorLog("解析失败:%v", err)
  5441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5442. return
  5443. }
  5444. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5445. res2.Output = resSix10265.Output
  5446. res2.ErrMsg = resSix10265.ErrMsg
  5447. res2.Cainfo = resSix10265.Cainfo
  5448. res2.WarnMsg = resSix10265.WarnMsg
  5449. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5450. res2.Infcode = infocode
  5451. } else {
  5452. var result string
  5453. var requestLog string
  5454. if miConfig.MdtrtareaAdmvs == "440781" { //
  5455. 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)
  5456. } else {
  5457. if miConfig.Code == "H15049901371" {
  5458. //赤峰地区国家医保医疗类别
  5459. //职工透析:医疗类别选特殊情况门诊990502
  5460. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5461. var med_type string
  5462. if his.Insutype == "390" {
  5463. if reg_type == 14 {
  5464. med_type = "9933"
  5465. } else if reg_type == 11 {
  5466. med_type = "11"
  5467. }
  5468. } else if his.Insutype == "310" {
  5469. if reg_type == 14 {
  5470. med_type = "990502"
  5471. } else if reg_type == 11 {
  5472. med_type = "11"
  5473. }
  5474. }
  5475. 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)
  5476. } else {
  5477. 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)
  5478. }
  5479. saveLog(result, requestLog, "2203", "上传就诊信息")
  5480. var respJSON2 map[string]interface{}
  5481. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5484. return
  5485. }
  5486. userJSONBytes2, _ := json.Marshal(respJSON2)
  5487. if miConfig.Code == "H15049901371" {
  5488. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5489. utils.ErrorLog("解析失败:%v", err)
  5490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5491. return
  5492. }
  5493. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5494. res2.Output = resSix10265.Output
  5495. res2.ErrMsg = resSix10265.ErrMsg
  5496. res2.Cainfo = resSix10265.Cainfo
  5497. res2.WarnMsg = resSix10265.WarnMsg
  5498. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5499. res2.Infcode = infocode
  5500. } else {
  5501. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5502. utils.ErrorLog("解析失败:%v", err)
  5503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5504. return
  5505. }
  5506. }
  5507. }
  5508. }
  5509. if res2.Infcode != 0 {
  5510. adminUser := c.GetAdminUserInfo()
  5511. errlog := &models.HisOrderError{
  5512. UserOrgId: adminUser.CurrentOrgId,
  5513. Ctime: time.Now().Unix(),
  5514. Mtime: time.Now().Unix(),
  5515. ErrMsg: res2.ErrMsg,
  5516. Status: 1,
  5517. PatientId: id,
  5518. RecordTime: recordDateTime,
  5519. Stage: 3,
  5520. }
  5521. service.CreateErrMsgLog(errlog)
  5522. c.ServeSuccessJSON(map[string]interface{}{
  5523. "failed_code": -10,
  5524. "msg": res2.ErrMsg,
  5525. })
  5526. return
  5527. } else {
  5528. his.Diagnosis = diagnosis_id
  5529. his.SickType = sickConfig.ID
  5530. his.PType = fmt.Sprintf("%d", reg_type)
  5531. service.UpdateHisPatientThree(&his)
  5532. data := make(map[string]interface{})
  5533. if settle_accounts_type == 1 { //日结
  5534. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5535. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5536. } else {
  5537. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5538. }
  5539. data["pre"] = prescriptions
  5540. } else { //月结
  5541. start_time_str := c.GetString("start_time")
  5542. end_time_str := c.GetString("end_time")
  5543. timeLayout := "2006-01-02"
  5544. loc, _ := time.LoadLocation("Local")
  5545. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5546. if err != nil {
  5547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5548. return
  5549. }
  5550. recordStartTime := theStartTime.Unix()
  5551. start_time = recordStartTime
  5552. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5553. if err != nil {
  5554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5555. return
  5556. }
  5557. recordEndTime := theEndTime.Unix()
  5558. end_time = recordEndTime
  5559. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5560. data["pre"] = prescriptions
  5561. }
  5562. client := &http.Client{}
  5563. data["psn_no"] = his.PsnNo
  5564. data["mdtrt_id"] = his.Number
  5565. data["chrg_bchno"] = chrg_bchno
  5566. data["org_name"] = miConfig.OrgName
  5567. data["doctor"] = roles.UserName
  5568. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5569. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5570. data["fixmedins_code"] = miConfig.Code
  5571. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5572. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5573. data["dept_code"] = "15"
  5574. } else {
  5575. data["dept_code"] = department.Number
  5576. }
  5577. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5578. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5579. data["secret_key"] = miConfig.SecretKey
  5580. data["url"] = miConfig.Url
  5581. data["ak"] = miConfig.AccessKey
  5582. data["new_doctor_name"] = patientPrescription.Doctor
  5583. data["diag_code"] = sickConfig.CountryCode
  5584. data["time_stamp"] = time_stamp
  5585. data["cainfo"] = miConfig.Cainfo
  5586. var ids []int64
  5587. for _, item := range prescriptions {
  5588. ids = append(ids, item.ID)
  5589. }
  5590. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5591. if config.IsOpen == 1 { //对接了医保,走医保流程
  5592. var res ResultFour
  5593. var resFour10265 ResultFour10265
  5594. if miConfig.MdtrtareaAdmvs == "421300" {
  5595. bytesData, _ := json.Marshal(data)
  5596. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5597. resp, _ := client.Do(req)
  5598. defer resp.Body.Close()
  5599. body, ioErr := ioutil.ReadAll(resp.Body)
  5600. if ioErr != nil {
  5601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5603. return
  5604. }
  5605. var respJSON map[string]interface{}
  5606. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5609. return
  5610. }
  5611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5612. userJSONBytes, _ := json.Marshal(respJSON)
  5613. fmt.Println("log")
  5614. fmt.Println(string(userJSONBytes))
  5615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5616. utils.ErrorLog("解析失败:%v", err)
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5618. return
  5619. }
  5620. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5621. bytesData, _ := json.Marshal(data)
  5622. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5623. resp, _ := client.Do(req)
  5624. defer resp.Body.Close()
  5625. body, ioErr := ioutil.ReadAll(resp.Body)
  5626. if ioErr != nil {
  5627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5629. return
  5630. }
  5631. var respJSON map[string]interface{}
  5632. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5635. return
  5636. }
  5637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5638. userJSONBytes, _ := json.Marshal(respJSON)
  5639. fmt.Println("log")
  5640. fmt.Println(string(userJSONBytes))
  5641. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5642. utils.ErrorLog("解析失败:%v", err)
  5643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5644. return
  5645. }
  5646. res.InfRefmsgid = resFour10265.InfRefmsgid
  5647. res.Output = resFour10265.Output
  5648. res.ErrMsg = resFour10265.ErrMsg
  5649. res.Cainfo = resFour10265.Cainfo
  5650. res.WarnMsg = resFour10265.WarnMsg
  5651. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5652. res.Infcode = infocode
  5653. } else {
  5654. if miConfig.Code == "H15049901371" {
  5655. 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)
  5656. var dat map[string]interface{}
  5657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5658. fmt.Println(dat)
  5659. } else {
  5660. fmt.Println(err)
  5661. }
  5662. saveLog(result, request_log, "2204", "上传费用明细")
  5663. userJSONBytes, _ := json.Marshal(dat)
  5664. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5665. utils.ErrorLog("解析失败:%v", err)
  5666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5667. return
  5668. }
  5669. res.InfRefmsgid = resFour10265.InfRefmsgid
  5670. res.Output = resFour10265.Output
  5671. res.ErrMsg = resFour10265.ErrMsg
  5672. res.Cainfo = resFour10265.Cainfo
  5673. res.WarnMsg = resFour10265.WarnMsg
  5674. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5675. res.Infcode = infocode
  5676. } else {
  5677. 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)
  5678. var dat map[string]interface{}
  5679. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5680. fmt.Println(dat)
  5681. } else {
  5682. fmt.Println(err)
  5683. }
  5684. saveLog(result, request_log, "2204", "上传费用明细")
  5685. userJSONBytes, _ := json.Marshal(dat)
  5686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5687. utils.ErrorLog("解析失败:%v", err)
  5688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5689. return
  5690. }
  5691. }
  5692. }
  5693. if res.Infcode == 0 {
  5694. order := &models.HisOrder{
  5695. UserOrgId: adminUser.CurrentOrgId,
  5696. HisPatientId: his.ID,
  5697. PatientId: his.PatientId,
  5698. SettleAccountsDate: recordDateTime,
  5699. Ctime: time.Now().Unix(),
  5700. Mtime: time.Now().Unix(),
  5701. MdtrtId: his.Number,
  5702. PsnNo: his.PsnNo,
  5703. MedType: strconv.FormatInt(reg_type, 10),
  5704. Status: 1,
  5705. Number: chrg_bchno,
  5706. Infcode: res.Infcode,
  5707. WarnMsg: res.WarnMsg,
  5708. Cainfo: res.Cainfo,
  5709. ErrMsg: res.ErrMsg,
  5710. RespondTime: res.RefmsgTime,
  5711. InfRefmsgid: res.InfRefmsgid,
  5712. OrderStatus: 1,
  5713. IsMedicineInsurance: 1,
  5714. SettleType: settle_accounts_type,
  5715. SettleStartTime: start_time,
  5716. SettleEndTime: end_time,
  5717. Creator: roles.AdminUserId,
  5718. Modify: roles.AdminUserId,
  5719. PType: 2,
  5720. Diagnosis: diagnosis_id,
  5721. }
  5722. err = service.CreateOrder(order)
  5723. if err != nil {
  5724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5725. return
  5726. }
  5727. for _, item := range res.Output.Result {
  5728. temp := strings.Split(item.FeedetlSn, "-")
  5729. var advice_id int64 = 0
  5730. var project_id int64 = 0
  5731. var types int64 = 0
  5732. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5733. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5734. if temp[1] == "1" {
  5735. advice_id = id
  5736. project_id = 0
  5737. } else if temp[1] == "2" {
  5738. advice_id = 0
  5739. project_id = id
  5740. }
  5741. info := &models.HisOrderInfo{
  5742. OrderNumber: order.Number,
  5743. FeedetlSn: item.FeedetlSn,
  5744. UploadDate: time.Now().Unix(),
  5745. AdviceId: advice_id,
  5746. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5747. Cnt: item.Cnt,
  5748. Pric: float64(item.Pric),
  5749. PatientId: his.PatientId,
  5750. PricUplmtAmt: item.PricUplmtAmt,
  5751. SelfpayProp: item.SelfpayProp,
  5752. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5753. OverlmtAmt: item.OverlmtAmt,
  5754. PreselfpayAmt: item.PreselfpayAmt,
  5755. BasMednFlag: item.BasMednFlag,
  5756. MedChrgitmType: item.MedChrgitmType,
  5757. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5758. Status: 1,
  5759. Memo: item.Memo,
  5760. Mtime: time.Now().Unix(),
  5761. InscpScpAmt: item.InscpScpAmt,
  5762. DrtReimFlag: item.DrtReimFlag,
  5763. Ctime: time.Now().Unix(),
  5764. ListSpItemFlag: item.ListSpItemFlag,
  5765. ChldMedcFlag: item.ChldMedcFlag,
  5766. LmtUsedFlag: item.LmtUsedFlag,
  5767. ChrgitmLv: item.ChrgitmLv,
  5768. UserOrgId: adminUser.CurrentOrgId,
  5769. HisPatientId: his.ID,
  5770. OrderId: order.ID,
  5771. ProjectId: project_id,
  5772. Type: types,
  5773. }
  5774. service.CreateOrderInfo(info)
  5775. }
  5776. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5777. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5778. var total float64
  5779. for _, item := range prescriptions {
  5780. if item.Type == 1 { //药品
  5781. for _, subItem := range item.HisDoctorAdviceInfo {
  5782. total = total + (subItem.Price * subItem.PrescribingNumber)
  5783. }
  5784. }
  5785. if item.Type == 2 { //项目
  5786. for _, subItem := range item.HisPrescriptionProject {
  5787. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5788. total = total + (subItem.Price * cnt)
  5789. }
  5790. }
  5791. }
  5792. for _, item := range prescriptions {
  5793. for _, subItem := range item.HisAdditionalCharge {
  5794. total = total + (subItem.Price * float64(subItem.Count))
  5795. }
  5796. }
  5797. allTotal := fmt.Sprintf("%.4f", total)
  5798. if res.Infcode == 0 {
  5799. var rf []*ResultFive
  5800. json.Unmarshal([]byte(his.Iinfo), &rf)
  5801. chrg_bchno := chrg_bchno
  5802. cert_no := his.Certno
  5803. var insutypes []string
  5804. var insutype string
  5805. var is390 int = 0
  5806. var is310 int = 0
  5807. for _, item := range rf {
  5808. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5809. insutypes = append(insutypes, item.Insutype)
  5810. }
  5811. }
  5812. if len(insutypes) == 1 {
  5813. insutype = insutypes[0]
  5814. } else {
  5815. for _, i := range insutypes {
  5816. if i == "390" {
  5817. is390 = 1
  5818. }
  5819. if i == "310" {
  5820. is310 = 1
  5821. }
  5822. }
  5823. }
  5824. if is390 == 1 {
  5825. insutype = "390"
  5826. }
  5827. if is310 == 1 {
  5828. insutype = "310"
  5829. }
  5830. if len(insutypes) == 0 {
  5831. insutype = "310"
  5832. }
  5833. if len(insutypes) == 2 {
  5834. insutype = strconv.FormatInt(his.SocialType, 64)
  5835. }
  5836. //insutype = "390"
  5837. if his.IdCardType == 1 {
  5838. cert_no = his.MedicalInsuranceNumber
  5839. } else {
  5840. cert_no = his.Certno
  5841. }
  5842. var res ResultSeven
  5843. var resSeven10265 ResultSeven10265
  5844. if miConfig.MdtrtareaAdmvs == "421300" {
  5845. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5846. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5847. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5848. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5849. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5850. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5851. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5852. resp, requestErr := http.Get(api)
  5853. if requestErr != nil {
  5854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5855. return
  5856. }
  5857. body, ioErr := ioutil.ReadAll(resp.Body)
  5858. if ioErr != nil {
  5859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5861. return
  5862. }
  5863. var respJSON map[string]interface{}
  5864. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5867. return
  5868. }
  5869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5870. result, _ := json.Marshal(respJSON)
  5871. fmt.Println("log")
  5872. fmt.Println(string(result))
  5873. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5874. utils.ErrorLog("解析失败:%v", err)
  5875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5876. return
  5877. }
  5878. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5879. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5880. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5881. bas := strings.Split(psn_info.CardInfo, "|")
  5882. if his.IdCardType == 1 {
  5883. cert_no = bas[2]
  5884. } else {
  5885. cert_no = bas[1]
  5886. }
  5887. //江苏地区国家医保医疗类别
  5888. //职工透析:医疗类别选特殊情况门诊9933
  5889. //居民血透门慢: 医疗类别选门诊慢病1402
  5890. //var med_type string
  5891. //if his.Insutype == "310" {
  5892. // if reg_type == 14 {
  5893. // med_type = "9933"
  5894. // } else if reg_type == 11 {
  5895. // med_type = "11"
  5896. //
  5897. // }
  5898. //} else if his.Insutype == "390" {
  5899. // if reg_type == 14 {
  5900. // med_type = "1402"
  5901. // } else if reg_type == 11 {
  5902. // med_type = "11"
  5903. // }
  5904. //}
  5905. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5906. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5907. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5908. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5909. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5910. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5911. "&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
  5912. resp, requestErr := http.Get(api)
  5913. if requestErr != nil {
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. body, ioErr := ioutil.ReadAll(resp.Body)
  5918. if ioErr != nil {
  5919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. return
  5922. }
  5923. var respJSON map[string]interface{}
  5924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5927. return
  5928. }
  5929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5930. result, _ := json.Marshal(respJSON)
  5931. fmt.Println("log")
  5932. fmt.Println(string(result))
  5933. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5934. utils.ErrorLog("解析失败:%v", err)
  5935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. return
  5937. }
  5938. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5939. res.Output = resSeven10265.Output
  5940. res.ErrMsg = resSeven10265.ErrMsg
  5941. res.Cainfo = resSeven10265.Cainfo
  5942. res.WarnMsg = resSeven10265.WarnMsg
  5943. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5944. res.Infcode = infocode
  5945. } else {
  5946. var result string
  5947. var request_log string
  5948. if miConfig.Code == "H15049901371" {
  5949. //赤峰地区国家医保医疗类别
  5950. //职工透析:医疗类别选特殊情况门诊990502
  5951. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5952. var med_type string
  5953. if his.Insutype == "390" {
  5954. if reg_type == 14 {
  5955. med_type = "9933"
  5956. } else if reg_type == 11 {
  5957. med_type = "11"
  5958. }
  5959. } else if his.Insutype == "310" {
  5960. if reg_type == 14 {
  5961. med_type = "990502"
  5962. } else if reg_type == 11 {
  5963. med_type = "11"
  5964. }
  5965. }
  5966. 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)
  5967. } else {
  5968. 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)
  5969. }
  5970. var dat map[string]interface{}
  5971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5972. fmt.Println(dat)
  5973. } else {
  5974. fmt.Println(err)
  5975. }
  5976. saveLog(result, request_log, "2206", "预结算")
  5977. //userJSONBytes, _ := json.Marshal(dat)
  5978. //
  5979. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5980. // utils.ErrorLog("解析失败:%v", err)
  5981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5982. // return
  5983. //}
  5984. userJSONBytes, _ := json.Marshal(dat)
  5985. if miConfig.Code == "H15049901371" {
  5986. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5987. utils.ErrorLog("解析失败:%v", err)
  5988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5989. return
  5990. }
  5991. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5992. res.Output = resSeven10265.Output
  5993. res.ErrMsg = resSeven10265.ErrMsg
  5994. res.Cainfo = resSeven10265.Cainfo
  5995. res.WarnMsg = resSeven10265.WarnMsg
  5996. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5997. res.Infcode = infocode
  5998. } else {
  5999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6000. utils.ErrorLog("解析失败:%v", err)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. }
  6005. }
  6006. if res.Infcode != 0 {
  6007. errlog := &models.HisOrderError{
  6008. UserOrgId: adminUser.CurrentOrgId,
  6009. Ctime: time.Now().Unix(),
  6010. Mtime: time.Now().Unix(),
  6011. Number: chrg_bchno,
  6012. ErrMsg: res.ErrMsg,
  6013. Status: 1,
  6014. PatientId: id,
  6015. RecordTime: recordDateTime,
  6016. Stage: 20,
  6017. }
  6018. service.CreateErrMsgLog(errlog)
  6019. c.ServeSuccessJSON(map[string]interface{}{
  6020. "failed_code": -10,
  6021. "msg": res.ErrMsg,
  6022. })
  6023. return
  6024. } else {
  6025. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6026. order.OrderStatus = 1
  6027. order.IsPre = 1
  6028. order.Status = 1
  6029. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6030. order.SetlId = res.Output.Setlinfo.SetlID
  6031. order.PsnNo = res.Output.Setlinfo.PsnNo
  6032. order.PsnName = res.Output.Setlinfo.PsnName
  6033. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6034. order.Certno = res.Output.Setlinfo.Certno
  6035. order.Gend = res.Output.Setlinfo.Gend
  6036. order.Naty = res.Output.Setlinfo.Naty
  6037. order.Age = res.Output.Setlinfo.Age
  6038. order.Insutype = res.Output.Setlinfo.Insutype
  6039. order.PsnType = res.Output.Setlinfo.PsnType
  6040. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6041. order.SetlTime = res.Output.Setlinfo.SetlTime
  6042. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6043. if res.Output.Setlinfo.MedType == "140101" {
  6044. order.MedType = "14"
  6045. } else {
  6046. order.MedType = res.Output.Setlinfo.MedType
  6047. }
  6048. if reg_type == 1112 {
  6049. order.MedType = "1112"
  6050. }
  6051. if reg_type == 1111 {
  6052. order.MedType = "1111"
  6053. }
  6054. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6055. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6056. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6057. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6058. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6059. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6060. order.HifpPay = res.Output.Setlinfo.HifpPay
  6061. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6062. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6063. order.HifesPay = res.Output.Setlinfo.HifesPay
  6064. order.HifobPay = res.Output.Setlinfo.HifobPay
  6065. order.MafPay = res.Output.Setlinfo.MafPay
  6066. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6067. order.OthPay = res.Output.Setlinfo.OthPay
  6068. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6069. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6070. order.AcctPay = res.Output.Setlinfo.AcctPay
  6071. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6072. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6073. order.Balc = res.Output.Setlinfo.Balc
  6074. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6075. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6076. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6077. order.ClrWay = res.Output.Setlinfo.ClrWay
  6078. order.Creator = order.Creator
  6079. order.Modify = roles.AdminUserId
  6080. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6081. detailStr := string(setlDetail)
  6082. order.SetlDetail = detailStr
  6083. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6084. err = service.UpDateOrder(order)
  6085. if err == nil {
  6086. c.ServeSuccessJSON(map[string]interface{}{
  6087. "msg": "预结算成功",
  6088. })
  6089. } else {
  6090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6091. return
  6092. }
  6093. }
  6094. } else {
  6095. adminUser := c.GetAdminUserInfo()
  6096. errlog := &models.HisOrderError{
  6097. UserOrgId: adminUser.CurrentOrgId,
  6098. Ctime: time.Now().Unix(),
  6099. Mtime: time.Now().Unix(),
  6100. ErrMsg: res.ErrMsg,
  6101. Status: 1,
  6102. PatientId: id,
  6103. RecordTime: recordDateTime,
  6104. Stage: 4,
  6105. }
  6106. service.CreateErrMsgLog(errlog)
  6107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6108. return
  6109. }
  6110. } else {
  6111. adminUser := c.GetAdminUserInfo()
  6112. errlog := &models.HisOrderError{
  6113. UserOrgId: adminUser.CurrentOrgId,
  6114. Ctime: time.Now().Unix(),
  6115. Mtime: time.Now().Unix(),
  6116. ErrMsg: res.ErrMsg,
  6117. Status: 1,
  6118. PatientId: id,
  6119. RecordTime: recordDateTime,
  6120. Stage: 4,
  6121. }
  6122. service.CreateErrMsgLog(errlog)
  6123. c.ServeSuccessJSON(map[string]interface{}{
  6124. "failed_code": -10,
  6125. "msg": res.ErrMsg,
  6126. })
  6127. return
  6128. }
  6129. }
  6130. }
  6131. }
  6132. //func (c *HisApiController) GetSettleInfo() {
  6133. // id, _ := c.GetInt64("id")
  6134. // order_id, _ := c.GetInt64("order_id")
  6135. //
  6136. // record_time := c.GetString("record_time")
  6137. // pay_way, _ := c.GetInt64("pay_way")
  6138. // pay_price, _ := c.GetFloat("pay_price")
  6139. // pay_card_no := c.GetString("pay_card_no")
  6140. // discount_price, _ := c.GetFloat("discount_price")
  6141. // preferential_price, _ := c.GetFloat("preferential_price")
  6142. // reality_price, _ := c.GetFloat("reality_price")
  6143. // found_price, _ := c.GetFloat("found_price")
  6144. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6145. // private_price, _ := c.GetFloat("private_price")
  6146. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6147. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6148. //
  6149. // timeLayout := "2006-01-02"
  6150. // loc, _ := time.LoadLocation("Local")
  6151. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6152. // if err != nil {
  6153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6154. // return
  6155. // }
  6156. // recordDateTime := theTime.Unix()
  6157. // adminUser := c.GetAdminUserInfo()
  6158. //
  6159. // var prescriptions []*models.HisPrescription
  6160. //
  6161. // data := make(map[string]interface{})
  6162. // if settle_accounts_type == 1 { //日结
  6163. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6164. // data["pre"] = prescriptions
  6165. //
  6166. // } else { //月结
  6167. // start_time_str := c.GetString("start_time")
  6168. // end_time_str := c.GetString("end_time")
  6169. // timeLayout := "2006-01-02"
  6170. // loc, _ := time.LoadLocation("Local")
  6171. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6172. // if err != nil {
  6173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6174. // return
  6175. // }
  6176. // recordStartTime := theStartTime.Unix()
  6177. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6178. // if err != nil {
  6179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6180. // return
  6181. // }
  6182. // recordEndTime := theEndTime.Unix()
  6183. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6184. // data["pre"] = prescriptions
  6185. //
  6186. // }
  6187. //
  6188. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6189. //
  6190. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6191. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6192. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6193. // strconv.FormatInt(his.PatientId, 10)
  6194. //
  6195. // order_src, _ := service.GetHisOrderByID(order_id)
  6196. //
  6197. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6198. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6199. //
  6200. // var total float64
  6201. // for _, item := range prescriptions {
  6202. // if item.Type == 1 { //药品
  6203. // for _, subItem := range item.HisDoctorAdviceInfo {
  6204. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6205. // }
  6206. // }
  6207. // if item.Type == 2 { //项目
  6208. // for _, subItem := range item.HisPrescriptionProject {
  6209. // total = total + (subItem.Price * float64(subItem.Count))
  6210. // }
  6211. // }
  6212. // }
  6213. //
  6214. // for _, item := range prescriptions {
  6215. // for _, subItem := range item.HisAdditionalCharge {
  6216. // total = total + (subItem.Price * float64(subItem.Count))
  6217. // }
  6218. // }
  6219. //
  6220. // allTotal := fmt.Sprintf("%.2f", total)
  6221. // var rf []*ResultFive
  6222. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6223. // psn_no := order_src.PsnNo
  6224. // mdtrt_id := order_src.MdtrtId
  6225. // chrg_bchno := order_src.Number
  6226. // cert_no := order_src.Certno
  6227. // insutype := rf[0].Insutype
  6228. //
  6229. // if his.IdCardType == 1 {
  6230. // cert_no = his.MedicalInsuranceNumber
  6231. // } else {
  6232. // cert_no = his.Certno
  6233. // }
  6234. //
  6235. // 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)
  6236. // var dat map[string]interface{}
  6237. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6238. // fmt.Println(dat)
  6239. // } else {
  6240. // fmt.Println(err)
  6241. // }
  6242. //
  6243. // userJSONBytes, _ := json.Marshal(dat)
  6244. //
  6245. //
  6246. //
  6247. // var res ResultSeven
  6248. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6249. // utils.ErrorLog("解析失败:%v", err)
  6250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6251. // return
  6252. // }
  6253. // if res.Infcode == -1 {
  6254. // errlog := &models.HisOrderError{
  6255. // UserOrgId: adminUser.CurrentOrgId,
  6256. // Ctime: time.Now().Unix(),
  6257. // Mtime: time.Now().Unix(),
  6258. // Number: chrg_bchno,
  6259. // ErrMsg: res.ErrMsg,
  6260. // Status: 1,
  6261. // PatientId: id,
  6262. // RecordTime: recordDateTime,
  6263. // Stage: 6,
  6264. // }
  6265. // service.CreateErrMsgLog(errlog)
  6266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6267. // return
  6268. // } else {
  6269. // order_src.OrderStatus = 2
  6270. // order_src.PayWay = pay_way
  6271. // order_src.PayPrice = pay_price
  6272. // order_src.PayCardNo = pay_card_no
  6273. // order_src.DiscountPrice = discount_price
  6274. // order_src.PreferentialPrice = preferential_price
  6275. // order_src.RealityPrice = reality_price
  6276. // order_src.FoundPrice = found_price
  6277. // order_src.MedicalInsurancePrice = medical_insurance_price
  6278. // order_src.PrivatePrice = private_price
  6279. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6280. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6281. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6282. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6283. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6284. // order_src.Certno = res.Output.Setlinfo.Certno
  6285. // order_src.Gend = res.Output.Setlinfo.Gend
  6286. // order_src.Naty = res.Output.Setlinfo.Naty
  6287. // order_src.Age = res.Output.Setlinfo.Age
  6288. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6289. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6290. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6291. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6292. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6293. // order_src.MedType = res.Output.Setlinfo.MedType
  6294. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6295. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6296. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6297. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6298. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6299. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6300. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6301. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6302. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6303. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6304. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6305. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6306. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6307. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6308. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6309. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6310. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6311. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6312. // order_src.Balc = res.Output.Setlinfo.Balc
  6313. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6314. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6315. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6316. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6317. // order_src.Creator = order_src.Creator
  6318. // order_src.Modify = roles.ID
  6319. // order_src.RequestLog = src_resquest
  6320. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6321. // detailStr := string(setlDetail)
  6322. // order_src.SetlDetail = detailStr
  6323. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6324. // err = service.UpDateOrder(order_src)
  6325. //
  6326. // if err == nil {
  6327. // c.ServeSuccessJSON(map[string]interface{}{
  6328. // "msg": "结算成功",
  6329. // })
  6330. // } else {
  6331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6332. // return
  6333. // }
  6334. // }
  6335. // }
  6336. //}
  6337. //退款
  6338. func (c *HisApiController) Refund() {
  6339. order_id, _ := c.GetInt64("order_id")
  6340. admin_user_id, _ := c.GetInt64("admin_user_id")
  6341. adminUser := c.GetAdminUserInfo()
  6342. var order models.HisOrder
  6343. order, _ = service.GetHisOrderByID(order_id)
  6344. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6345. if order.ID == 0 {
  6346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6347. return
  6348. }
  6349. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6350. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6351. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6352. if config.IsOpen == 1 { //对接了医保,走医保流程
  6353. var res ResultSixteen
  6354. var resSixteen10265 ResultSixteen10265
  6355. var src_resquest string
  6356. var result string
  6357. if miConfig.MdtrtareaAdmvs == "421300" {
  6358. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6359. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6360. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6361. resp3, requestErr3 := http.Get(api3)
  6362. if requestErr3 != nil {
  6363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6364. return
  6365. }
  6366. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6367. if ioErr3 != nil {
  6368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6370. return
  6371. }
  6372. var respJSON3 map[string]interface{}
  6373. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6376. return
  6377. }
  6378. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6379. userJSONBytes3, _ := json.Marshal(respJSON3)
  6380. fmt.Println("log")
  6381. fmt.Println(string(userJSONBytes3))
  6382. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6383. utils.ErrorLog("解析失败:%v", err)
  6384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6385. return
  6386. }
  6387. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6388. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6389. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6390. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6391. resp3, requestErr3 := http.Get(api3)
  6392. if requestErr3 != nil {
  6393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6394. return
  6395. }
  6396. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6397. if ioErr3 != nil {
  6398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6400. return
  6401. }
  6402. var respJSON3 map[string]interface{}
  6403. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6406. return
  6407. }
  6408. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6409. userJSONBytes3, _ := json.Marshal(respJSON3)
  6410. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6411. utils.ErrorLog("解析失败:%v", err)
  6412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6413. return
  6414. }
  6415. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6416. res.Output = resSixteen10265.Output
  6417. res.ErrMsg = resSixteen10265.ErrMsg
  6418. res.Cainfo = resSixteen10265.Cainfo
  6419. res.WarnMsg = resSixteen10265.WarnMsg
  6420. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6421. res.Infcode = infocode
  6422. } else {
  6423. if miConfig.Code == "H15049901371" {
  6424. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6425. var dat map[string]interface{}
  6426. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6427. fmt.Println(dat)
  6428. } else {
  6429. fmt.Println(err)
  6430. }
  6431. saveLog(result, src_resquest, "2208", "退费")
  6432. userJSONBytes, _ := json.Marshal(dat)
  6433. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6434. utils.ErrorLog("解析失败:%v", err)
  6435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6436. return
  6437. }
  6438. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6439. res.Output = resSixteen10265.Output
  6440. res.ErrMsg = resSixteen10265.ErrMsg
  6441. res.Cainfo = resSixteen10265.Cainfo
  6442. res.WarnMsg = resSixteen10265.WarnMsg
  6443. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6444. res.Infcode = infocode
  6445. } else {
  6446. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6447. var dat map[string]interface{}
  6448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6449. fmt.Println(dat)
  6450. } else {
  6451. fmt.Println(err)
  6452. }
  6453. saveLog(result, src_resquest, "2208", "退费")
  6454. userJSONBytes, _ := json.Marshal(dat)
  6455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6456. utils.ErrorLog("解析失败:%v", err)
  6457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6458. return
  6459. }
  6460. }
  6461. }
  6462. if res.Infcode == 0 {
  6463. var res2 ResultSix
  6464. var resSix10265 ResultSix10265
  6465. if miConfig.MdtrtareaAdmvs == "421300" {
  6466. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6467. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6469. resp3, requestErr3 := http.Get(api3)
  6470. if requestErr3 != nil {
  6471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6472. return
  6473. }
  6474. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6475. if ioErr3 != nil {
  6476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6478. return
  6479. }
  6480. var respJSON3 map[string]interface{}
  6481. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6484. return
  6485. }
  6486. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6487. userJSONBytes3, _ := json.Marshal(respJSON3)
  6488. fmt.Println("log")
  6489. fmt.Println(string(userJSONBytes3))
  6490. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6491. utils.ErrorLog("解析失败:%v", err)
  6492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6493. return
  6494. }
  6495. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6496. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6497. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6498. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6499. resp3, requestErr3 := http.Get(api3)
  6500. if requestErr3 != nil {
  6501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6502. return
  6503. }
  6504. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6505. if ioErr3 != nil {
  6506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6508. return
  6509. }
  6510. var respJSON3 map[string]interface{}
  6511. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6514. return
  6515. }
  6516. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6517. userJSONBytes3, _ := json.Marshal(respJSON3)
  6518. fmt.Println("log")
  6519. fmt.Println(string(userJSONBytes3))
  6520. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6521. utils.ErrorLog("解析失败:%v", err)
  6522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6523. return
  6524. }
  6525. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6526. res2.Output = resSix10265.Output
  6527. res2.ErrMsg = resSix10265.ErrMsg
  6528. res2.Cainfo = resSix10265.Cainfo
  6529. res2.WarnMsg = resSix10265.WarnMsg
  6530. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6531. res2.Infcode = infocode
  6532. } else {
  6533. if miConfig.Code == "H15049901371" {
  6534. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6535. var dat map[string]interface{}
  6536. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6537. fmt.Println(dat)
  6538. } else {
  6539. fmt.Println(err)
  6540. }
  6541. saveLog(result2, src_request, "2205", "撤销明细")
  6542. userJSONBytes, _ := json.Marshal(dat)
  6543. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6544. utils.ErrorLog("解析失败:%v", err)
  6545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6546. return
  6547. }
  6548. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6549. res2.Output = resSix10265.Output
  6550. res2.ErrMsg = resSix10265.ErrMsg
  6551. res2.Cainfo = resSix10265.Cainfo
  6552. res2.WarnMsg = resSix10265.WarnMsg
  6553. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6554. res2.Infcode = infocode
  6555. } else {
  6556. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6557. var dat map[string]interface{}
  6558. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6559. fmt.Println(dat)
  6560. } else {
  6561. fmt.Println(err)
  6562. }
  6563. saveLog(result2, src_request, "2205", "撤销明细")
  6564. userJSONBytes, _ := json.Marshal(dat)
  6565. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6566. utils.ErrorLog("解析失败:%v", err)
  6567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6568. return
  6569. }
  6570. }
  6571. }
  6572. if res2.Infcode == 0 {
  6573. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6574. if err == nil {
  6575. c.ServeSuccessJSON(map[string]interface{}{
  6576. "msg": "退费成功",
  6577. })
  6578. } else {
  6579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6580. return
  6581. }
  6582. } else {
  6583. c.ServeSuccessJSON(map[string]interface{}{
  6584. "code": -10,
  6585. "msg": res2.ErrMsg,
  6586. })
  6587. }
  6588. } else {
  6589. c.ServeSuccessJSON(map[string]interface{}{
  6590. "code": -10,
  6591. "msg": res.ErrMsg,
  6592. })
  6593. }
  6594. }
  6595. }
  6596. func (c *HisApiController) RefundNumber() {
  6597. record_time := c.GetString("record_time")
  6598. //patient_id, _ := c.GetInt64("patient_id")
  6599. admin_user_id, _ := c.GetInt64("admin_user_id")
  6600. his_patient_id, _ := c.GetInt64("id")
  6601. timeLayout := "2006-01-02"
  6602. loc, _ := time.LoadLocation("Local")
  6603. adminUser := c.GetAdminUserInfo()
  6604. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6605. fmt.Println(err)
  6606. if err != nil {
  6607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6608. return
  6609. }
  6610. recordDateTime := theTime.Unix()
  6611. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6612. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6613. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6614. //order, _ := service.GetHisOrderByID(order_id)
  6615. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6616. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6617. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6618. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6619. if count > 0 {
  6620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6621. return
  6622. }
  6623. if config.IsOpen == 1 { //对接了医保,走医保流程
  6624. var res2 ResultSix
  6625. var resSix10265 ResultSix10265
  6626. if miConfig.MdtrtareaAdmvs == "421300" {
  6627. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6628. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6629. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6630. resp3, requestErr3 := http.Get(api3)
  6631. if requestErr3 != nil {
  6632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6633. return
  6634. }
  6635. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6636. if ioErr3 != nil {
  6637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6639. return
  6640. }
  6641. var respJSON3 map[string]interface{}
  6642. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6645. return
  6646. }
  6647. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6648. userJSONBytes3, _ := json.Marshal(respJSON3)
  6649. fmt.Println("log")
  6650. fmt.Println(string(userJSONBytes3))
  6651. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6652. utils.ErrorLog("解析失败:%v", err)
  6653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6654. return
  6655. }
  6656. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6657. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6658. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6659. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6660. resp3, requestErr3 := http.Get(api3)
  6661. if requestErr3 != nil {
  6662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6663. return
  6664. }
  6665. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6666. if ioErr3 != nil {
  6667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6669. return
  6670. }
  6671. var respJSON3 map[string]interface{}
  6672. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6675. return
  6676. }
  6677. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6678. userJSONBytes3, _ := json.Marshal(respJSON3)
  6679. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6680. utils.ErrorLog("解析失败:%v", err)
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. return
  6683. }
  6684. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6685. res2.Output = resSix10265.Output
  6686. res2.ErrMsg = resSix10265.ErrMsg
  6687. res2.Cainfo = resSix10265.Cainfo
  6688. res2.WarnMsg = resSix10265.WarnMsg
  6689. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6690. res2.Infcode = infocode
  6691. } else {
  6692. var api3 string
  6693. if miConfig.Code == "H15049901371" {
  6694. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6695. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6697. } else {
  6698. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6699. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6700. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6701. }
  6702. resp3, requestErr3 := http.Get(api3)
  6703. if requestErr3 != nil {
  6704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6705. return
  6706. }
  6707. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6708. if ioErr3 != nil {
  6709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6711. return
  6712. }
  6713. var respJSON3 map[string]interface{}
  6714. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. return
  6718. }
  6719. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6720. userJSONBytes3, _ := json.Marshal(respJSON3)
  6721. if miConfig.Code == "H15049901371" {
  6722. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6723. utils.ErrorLog("解析失败:%v", err)
  6724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6725. return
  6726. }
  6727. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6728. res2.Output = resSix10265.Output
  6729. res2.ErrMsg = resSix10265.ErrMsg
  6730. res2.Cainfo = resSix10265.Cainfo
  6731. res2.WarnMsg = resSix10265.WarnMsg
  6732. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6733. res2.Infcode = infocode
  6734. } else {
  6735. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6736. utils.ErrorLog("解析失败:%v", err)
  6737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6738. return
  6739. }
  6740. }
  6741. }
  6742. if res2.Infcode == 0 {
  6743. if err == nil {
  6744. c.ServeSuccessJSON(map[string]interface{}{
  6745. "msg": "退号成功",
  6746. })
  6747. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6748. } else {
  6749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6750. return
  6751. }
  6752. } else {
  6753. c.ServeSuccessJSON(map[string]interface{}{
  6754. "code": -10,
  6755. "msg": res2.ErrMsg,
  6756. })
  6757. }
  6758. } else {
  6759. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6760. //if err == nil {
  6761. // c.ServeSuccessJSON(map[string]interface{}{
  6762. // "msg": "退费成功",
  6763. // })
  6764. //} else {
  6765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6766. // return
  6767. //}
  6768. }
  6769. }
  6770. func (c *HisApiController) RefundDetail() {
  6771. order_id, _ := c.GetInt64("order_id")
  6772. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6773. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6774. number := c.GetString("number")
  6775. record_time := c.GetString("record_time")
  6776. patient_id, _ := c.GetInt64("patient_id")
  6777. timeLayout := "2006-01-02"
  6778. loc, _ := time.LoadLocation("Local")
  6779. adminUser := c.GetAdminUserInfo()
  6780. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6781. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6782. fmt.Println(err)
  6783. if err != nil {
  6784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6785. return
  6786. }
  6787. recordDateTime := theTime.Unix()
  6788. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6789. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6790. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6791. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6792. var order models.HisOrder
  6793. order, _ = service.GetHisOrderByID(order_id)
  6794. if order.ID == 0 {
  6795. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6796. }
  6797. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6798. if config.IsOpen == 1 { //对接了医保,走医保流程
  6799. var res2 ResultSix
  6800. if miConfig.MdtrtareaAdmvs == "421300" {
  6801. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6802. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6803. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6804. resp3, requestErr3 := http.Get(api3)
  6805. if requestErr3 != nil {
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. return
  6808. }
  6809. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6810. if ioErr3 != nil {
  6811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6813. return
  6814. }
  6815. var respJSON3 map[string]interface{}
  6816. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6819. return
  6820. }
  6821. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6822. userJSONBytes3, _ := json.Marshal(respJSON3)
  6823. fmt.Println("log")
  6824. fmt.Println(string(userJSONBytes3))
  6825. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6826. utils.ErrorLog("解析失败:%v", err)
  6827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6828. return
  6829. }
  6830. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6831. if err == nil {
  6832. c.ServeSuccessJSON(map[string]interface{}{
  6833. "msg": "撤销明细成功",
  6834. })
  6835. return
  6836. } else {
  6837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6838. return
  6839. }
  6840. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6841. var resSix10265 ResultSix10265
  6842. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6843. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6844. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6845. resp3, requestErr3 := http.Get(api3)
  6846. if requestErr3 != nil {
  6847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6848. return
  6849. }
  6850. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6851. if ioErr3 != nil {
  6852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. return
  6855. }
  6856. var respJSON3 map[string]interface{}
  6857. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6860. return
  6861. }
  6862. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6863. userJSONBytes3, _ := json.Marshal(respJSON3)
  6864. fmt.Println("log")
  6865. fmt.Println(string(userJSONBytes3))
  6866. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6867. utils.ErrorLog("解析失败:%v", err)
  6868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6869. return
  6870. }
  6871. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6872. res2.Output = resSix10265.Output
  6873. res2.ErrMsg = resSix10265.ErrMsg
  6874. res2.Cainfo = resSix10265.Cainfo
  6875. res2.WarnMsg = resSix10265.WarnMsg
  6876. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6877. res2.Infcode = infocode
  6878. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6879. if err == nil {
  6880. c.ServeSuccessJSON(map[string]interface{}{
  6881. "msg": "撤销明细成功",
  6882. })
  6883. return
  6884. } else {
  6885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6886. return
  6887. }
  6888. } else {
  6889. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6890. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6891. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6892. resp2, requestErr2 := http.Get(api2)
  6893. if requestErr2 != nil {
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6898. if ioErr2 != nil {
  6899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. var respJSON2 map[string]interface{}
  6904. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6910. if err == nil {
  6911. c.ServeSuccessJSON(map[string]interface{}{
  6912. "msg": "撤销明细成功",
  6913. })
  6914. return
  6915. } else {
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. return
  6918. }
  6919. }
  6920. } else {
  6921. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6922. if err == nil {
  6923. c.ServeSuccessJSON(map[string]interface{}{
  6924. "msg": "退费成功",
  6925. })
  6926. } else {
  6927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6928. return
  6929. }
  6930. }
  6931. }
  6932. //对账
  6933. func (c *HisApiController) GetCheckAccount() {
  6934. start_time := c.GetString("start_time")
  6935. end_time := c.GetString("end_time")
  6936. insutype := c.GetString("insutype")
  6937. clr_type := c.GetString("clr_type")
  6938. clr_org := c.GetString("clr_optins")
  6939. admin_user_id, _ := c.GetInt64("admin_user_id")
  6940. adminUser := c.GetAdminUserInfo()
  6941. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6942. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6943. if len(clr_org) == 0 {
  6944. clr_org = miConfig.MdtrtareaAdmvs
  6945. }
  6946. timeLayout := "2006-01-02"
  6947. loc, _ := time.LoadLocation("Local")
  6948. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6949. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6950. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6951. fixmedins_setl_cnt := int64(len(orders))
  6952. var medfee_sumamt float64
  6953. var acct_pay float64
  6954. var fund_pay_sumamt float64
  6955. for _, item := range orders {
  6956. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6957. acct_pay = acct_pay + item.AcctPay
  6958. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6959. }
  6960. var user_name string
  6961. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6962. if role.ID == 0 {
  6963. user_name = "xxx"
  6964. } else {
  6965. user_name = role.UserName
  6966. }
  6967. var res ResultEight
  6968. var res10188 ResultEightFor10188
  6969. if config.IsOpen == 1 {
  6970. if miConfig.MdtrtareaAdmvs == "320921" {
  6971. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  6972. "insutype=" + insutype +
  6973. "&clr_type=" + clr_type +
  6974. "&setl_optins=" + clr_org +
  6975. "&stmt_begndate=" + start_time +
  6976. "&stm_enddate=" + end_time +
  6977. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6978. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6979. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6980. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6981. "&fixmedins_code=" + miConfig.Code +
  6982. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6983. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6984. "&secret_key=" + miConfig.SecretKey +
  6985. "&org_name=" + miConfig.OrgName +
  6986. "&doctor=" + user_name +
  6987. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6988. fmt.Println(api)
  6989. resp, requestErr := http.Get(api)
  6990. if requestErr != nil {
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. body, ioErr := ioutil.ReadAll(resp.Body)
  6995. fmt.Println(body)
  6996. if ioErr != nil {
  6997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. return
  7000. }
  7001. var respJSON map[string]interface{}
  7002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7008. userJSONBytes, _ := json.Marshal(respJSON)
  7009. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7010. utils.ErrorLog("解析失败:%v", err)
  7011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7012. return
  7013. }
  7014. res.InfRefmsgid = res10188.InfRefmsgid
  7015. res.Output = res10188.Output
  7016. res.ErrMsg = res10188.ErrMsg
  7017. res.Cainfo = res10188.Cainfo
  7018. res.WarnMsg = res10188.WarnMsg
  7019. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7020. res.Infcode = infocode
  7021. } else {
  7022. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7023. "insutype=" + insutype +
  7024. "&clr_type=" + clr_type +
  7025. "&setl_optins=" + clr_org +
  7026. "&stmt_begndate=" + start_time +
  7027. "&stm_enddate=" + end_time +
  7028. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7029. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7030. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7031. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7032. "&fixmedins_code=" + miConfig.Code +
  7033. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7034. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7035. "&secret_key=" + miConfig.SecretKey +
  7036. "&org_name=" + miConfig.OrgName +
  7037. "&doctor=" + user_name
  7038. fmt.Println(api)
  7039. resp, requestErr := http.Get(api)
  7040. if requestErr != nil {
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. return
  7043. }
  7044. body, ioErr := ioutil.ReadAll(resp.Body)
  7045. fmt.Println(body)
  7046. if ioErr != nil {
  7047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7049. return
  7050. }
  7051. var respJSON map[string]interface{}
  7052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. return
  7056. }
  7057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7058. userJSONBytes, _ := json.Marshal(respJSON)
  7059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7060. utils.ErrorLog("解析失败:%v", err)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. return
  7063. }
  7064. }
  7065. if res.Infcode == 0 {
  7066. if res.Output.Stmtinfo.StmtRslt == "0" {
  7067. micc := &models.MedicalInsuranceCostCompare{
  7068. StartTime: startime.Unix(),
  7069. EndTime: endtime.Unix(),
  7070. Insutype: insutype,
  7071. CheckType: 1,
  7072. Num: fixmedins_setl_cnt,
  7073. Mtime: time.Now().Unix(),
  7074. Status: 1,
  7075. UserOrgId: adminUser.CurrentOrgId,
  7076. CostTotal: medfee_sumamt,
  7077. FuncTotal: fund_pay_sumamt,
  7078. PsnPay: acct_pay,
  7079. Creator: admin_user_id,
  7080. Ctime: time.Now().Unix(),
  7081. }
  7082. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7083. if err == nil {
  7084. c.ServeSuccessJSON(map[string]interface{}{
  7085. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7086. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7087. })
  7088. } else {
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. }
  7091. } else {
  7092. c.ServeSuccessJSON(map[string]interface{}{
  7093. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7094. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7095. })
  7096. }
  7097. } else {
  7098. c.ServeSuccessJSON(map[string]interface{}{
  7099. "code": -10,
  7100. "msg": res.ErrMsg,
  7101. })
  7102. }
  7103. }
  7104. }
  7105. func (c *HisApiController) Check310() {
  7106. adminUser := c.GetAdminUserInfo()
  7107. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7108. var user_name string
  7109. user_name = "高慧裕"
  7110. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7111. "insutype=" + "310" +
  7112. "&clr_type=" + "11" +
  7113. "&setl_optins=" + "441202" +
  7114. "&stmt_begndate=" + "2022-02-01" +
  7115. "&stm_enddate=" + "2022-02-28" +
  7116. "&medfee_sumamt=" + "155812.88" +
  7117. "&fund_pay_sumamt=" + "151026.15" +
  7118. "&acct_pay=" + "0" +
  7119. "&fixmedins_setl_cnt=" + "73" +
  7120. "&fixmedins_code=" + miConfig.Code +
  7121. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7122. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7123. "&secret_key=" + miConfig.SecretKey +
  7124. "&org_name=" + miConfig.OrgName +
  7125. "&doctor=" + user_name
  7126. fmt.Println(api)
  7127. resp, requestErr := http.Get(api)
  7128. if requestErr != nil {
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. return
  7131. }
  7132. body, ioErr := ioutil.ReadAll(resp.Body)
  7133. fmt.Println(body)
  7134. if ioErr != nil {
  7135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7137. return
  7138. }
  7139. var respJSON map[string]interface{}
  7140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7143. return
  7144. }
  7145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7146. userJSONBytes, _ := json.Marshal(respJSON)
  7147. var res ResultEight
  7148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7149. utils.ErrorLog("解析失败:%v", err)
  7150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7151. return
  7152. }
  7153. }
  7154. func (c *HisApiController) Check390() {
  7155. adminUser := c.GetAdminUserInfo()
  7156. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7157. var user_name string
  7158. user_name = "高慧裕"
  7159. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7160. "insutype=" + "390" +
  7161. "&clr_type=" + "11" +
  7162. "&setl_optins=" + "441202" +
  7163. "&stmt_begndate=" + "2022-02-01" +
  7164. "&stm_enddate=" + "2022-02-28" +
  7165. "&medfee_sumamt=" + "933920.08" +
  7166. "&fund_pay_sumamt=" + "887153.34" +
  7167. "&acct_pay=" + "0" +
  7168. "&fixmedins_setl_cnt=" + "396" +
  7169. "&fixmedins_code=" + miConfig.Code +
  7170. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7171. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7172. "&secret_key=" + miConfig.SecretKey +
  7173. "&org_name=" + miConfig.OrgName +
  7174. "&doctor=" + user_name
  7175. fmt.Println(api)
  7176. resp, requestErr := http.Get(api)
  7177. if requestErr != nil {
  7178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7179. return
  7180. }
  7181. body, ioErr := ioutil.ReadAll(resp.Body)
  7182. fmt.Println(body)
  7183. if ioErr != nil {
  7184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7186. return
  7187. }
  7188. var respJSON map[string]interface{}
  7189. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. return
  7193. }
  7194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7195. userJSONBytes, _ := json.Marshal(respJSON)
  7196. var res ResultEight
  7197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7198. utils.ErrorLog("解析失败:%v", err)
  7199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7200. return
  7201. }
  7202. }
  7203. //对账明细
  7204. func (c *HisApiController) GetCheckDetailAccount() {
  7205. start_time := c.GetString("start_time")
  7206. end_time := c.GetString("end_time")
  7207. admin_user_id, _ := c.GetInt64("admin_user_id")
  7208. adminUser := c.GetAdminUserInfo()
  7209. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7210. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7211. timeLayout := "2006-01-02"
  7212. loc, _ := time.LoadLocation("Local")
  7213. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7214. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7215. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7216. Mkdir(miConfig.OrgName)
  7217. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7218. file_name := file + ".txt"
  7219. zip_name := file + ".zip"
  7220. zip_path := miConfig.OrgName + "/" + zip_name
  7221. file_path := miConfig.OrgName + "/" + file_name
  7222. decimal.DivisionPrecision = 2
  7223. var medfee_sumamt float64
  7224. var psn_cash_pay float64
  7225. var fund_pay_sumamt float64
  7226. fixmedins_setl_cnt := int64(len(orders))
  7227. for _, item := range orders {
  7228. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7229. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7230. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7231. }
  7232. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7233. defer f.Close()
  7234. if err != nil {
  7235. fmt.Println(err.Error())
  7236. } else {
  7237. for _, item := range orders {
  7238. var refd_setl_flag string
  7239. if item.OrderStatus == 2 {
  7240. refd_setl_flag = "0"
  7241. var str string
  7242. str = item.SetlId + " " +
  7243. item.MdtrtId + " " +
  7244. item.PsnNo + " " +
  7245. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7246. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7247. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7248. _, err = f.Write([]byte(str))
  7249. }
  7250. if item.OrderStatus == 3 {
  7251. var str string
  7252. str = item.SetlId + " " +
  7253. item.MdtrtId + " " +
  7254. item.PsnNo + " " +
  7255. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7256. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7257. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7258. _, err = f.Write([]byte(str))
  7259. var str2 string
  7260. str2 = item.SetlId + " " +
  7261. item.MdtrtId + " " +
  7262. item.PsnNo + " " +
  7263. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7264. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7265. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7266. _, err = f.Write([]byte(str2))
  7267. }
  7268. }
  7269. }
  7270. Zip(file_path, zip_path)
  7271. fmt.Println(ReadFile(zip_path))
  7272. fmt.Println(string(ReadFile(zip_path)))
  7273. if config.IsOpen == 1 {
  7274. var user_name string
  7275. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7276. if role.ID == 0 {
  7277. user_name = "管理员"
  7278. } else {
  7279. user_name = role.UserName
  7280. }
  7281. baseParams := models.BaseParams{
  7282. SecretKey: miConfig.SecretKey,
  7283. FixmedinsCode: miConfig.Code,
  7284. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7285. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7286. OrgName: miConfig.OrgName,
  7287. Doctor: user_name,
  7288. }
  7289. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7290. var dat map[string]interface{}
  7291. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7292. fmt.Println(dat)
  7293. } else {
  7294. fmt.Println(err)
  7295. }
  7296. userJSONBytes, _ := json.Marshal(dat)
  7297. var res ResultNine
  7298. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7299. utils.ErrorLog("解析失败:%v", err)
  7300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7301. return
  7302. }
  7303. if res.Infcode == 0 {
  7304. fileNo := res.Output.FileQuryNo
  7305. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7306. "file_qury_no=" + fileNo +
  7307. "&setl_optins=" + "定点医保中心" +
  7308. "&stmt_begndate=" + start_time +
  7309. "&stm_enddate=" + end_time +
  7310. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7311. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7312. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7313. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7314. "&fixmedins_code=" + miConfig.Code +
  7315. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7316. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7317. "&secret_key=" + miConfig.SecretKey +
  7318. "&org_name=" + miConfig.OrgName +
  7319. "&doctor=" + user_name
  7320. resp, requestErr := http.Get(api)
  7321. if requestErr != nil {
  7322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7323. return
  7324. }
  7325. body, ioErr := ioutil.ReadAll(resp.Body)
  7326. if ioErr != nil {
  7327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7329. return
  7330. }
  7331. var respJSON map[string]interface{}
  7332. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7335. return
  7336. }
  7337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7338. userJSONBytes, _ := json.Marshal(respJSON)
  7339. var res ResultTen
  7340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7341. utils.ErrorLog("解析失败:%v", err)
  7342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7343. return
  7344. }
  7345. if res.Infcode == 0 {
  7346. service.Gdyb9102(baseParams, zip_name, fileNo)
  7347. micc := &models.MedicalInsuranceCostCompare{
  7348. StartTime: startime.Unix(),
  7349. EndTime: endtime.Unix(),
  7350. Insutype: "0",
  7351. CheckType: 2,
  7352. Num: fixmedins_setl_cnt,
  7353. Mtime: time.Now().Unix(),
  7354. Status: 1,
  7355. UserOrgId: adminUser.CurrentOrgId,
  7356. CostTotal: medfee_sumamt,
  7357. FuncTotal: fund_pay_sumamt,
  7358. PsnPay: psn_cash_pay,
  7359. Creator: admin_user_id,
  7360. Ctime: time.Now().Unix(),
  7361. }
  7362. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7363. c.ServeSuccessJSON(map[string]interface{}{
  7364. "msg": "明细对账成功",
  7365. })
  7366. }
  7367. } else {
  7368. }
  7369. }
  7370. }
  7371. type CustomOrderInfo struct {
  7372. Name string
  7373. Spec string
  7374. Unit string
  7375. Count float64
  7376. Price float64
  7377. Total float64
  7378. }
  7379. func (c *HisApiController) GetSettleAccounts() {
  7380. //id, _ := c.GetInt64("id")
  7381. //record_time := c.GetString("record_time")
  7382. order_id, _ := c.GetInt64("order_id")
  7383. admin_user_id, _ := c.GetInt64("admin_user_id")
  7384. //timeLayout := "2006-01-02"
  7385. //loc, _ := time.LoadLocation("Local")
  7386. //
  7387. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7388. //if err != nil {
  7389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7390. // return
  7391. //}
  7392. //recordDateTime := theTime.Unix()
  7393. adminUser := c.GetAdminUserInfo()
  7394. order, _ := service.GetHisOrderByID(order_id)
  7395. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7396. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7397. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7398. orderInfos = append(orderInfos, orderInfos_two...)
  7399. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7400. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7401. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7402. //var config []*models.HisXtDiagnoseConfig
  7403. var name string
  7404. for _, item := range diagnosis_ids {
  7405. id, _ := strconv.ParseInt(item, 10, 64)
  7406. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7407. if len(name) == 0 {
  7408. name = diagnosisConfig.ClassName
  7409. } else {
  7410. name = name + "," + diagnosisConfig.ClassName
  7411. }
  7412. }
  7413. var bedCostTotal float64 = 0 //床位总费
  7414. var bedCostSelfTotal float64 = 0 //床位自费
  7415. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7416. var operationCostTotal float64 = 0 //手术费
  7417. var operationCostSelfTotal float64 = 0 //手术费
  7418. var operationCostPartSelfTotal float64 = 0 //手术费
  7419. var otherCostTotal float64 = 0 //其他费用
  7420. var otherCostSelfTotal float64 = 0 //其他费用
  7421. var otherCostPartSelfTotal float64 = 0 //其他费用
  7422. var materialCostTotal float64 = 0 //材料费
  7423. var materialCostSelfTotal float64 = 0 //材料费
  7424. var materialCostPartSelfTotal float64 = 0 //材料费
  7425. var westernMedicineCostTotal float64 = 0 //西药费
  7426. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7427. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7428. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7429. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7430. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7431. var checkCostTotal float64 = 0 //检查费
  7432. var checkCostSelfTotal float64 = 0 //检查费
  7433. var checkCostPartSelfTotal float64 = 0 //检查费
  7434. var laboratoryCostTotal float64 = 0 //化验费
  7435. var laboratoryCostSelfTotal float64 = 0 //化验费
  7436. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7437. var treatCostTotal float64 = 0 //治疗费用
  7438. var treatCostSelfTotal float64 = 0 //治疗费用
  7439. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7440. decimal.DivisionPrecision = 2
  7441. for _, item := range orderInfos {
  7442. if item.MedChrgitmType == "01" { //床位费
  7443. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7444. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7445. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7446. }
  7447. if item.MedChrgitmType == "03" { //检查费
  7448. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7449. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7450. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7451. }
  7452. if item.MedChrgitmType == "04" { //化验费
  7453. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7454. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7455. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7456. }
  7457. if item.MedChrgitmType == "05" { //治疗费
  7458. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7459. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7460. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7461. }
  7462. if item.MedChrgitmType == "06" { //手术费
  7463. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7464. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7465. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7466. }
  7467. if item.MedChrgitmType == "08" { //材料费
  7468. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7469. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7470. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7471. }
  7472. if item.MedChrgitmType == "09" { //西药费
  7473. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7474. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7475. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7476. }
  7477. if item.MedChrgitmType == "11" { //中成费
  7478. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7479. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7480. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7481. }
  7482. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7483. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7484. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7485. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7486. }
  7487. }
  7488. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7489. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7490. var user_name string
  7491. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7492. if role.ID == 0 {
  7493. user_name = "管理员"
  7494. } else {
  7495. user_name = role.UserName
  7496. }
  7497. baseParams := models.BaseParams{
  7498. SecretKey: miConfig.SecretKey,
  7499. FixmedinsCode: miConfig.Code,
  7500. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7501. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7502. OrgName: miConfig.OrgName,
  7503. Doctor: user_name,
  7504. }
  7505. businessParams := models.BusinessParams{
  7506. PsnNo: order.PsnNo,
  7507. MdtrtId: order.MdtrtId,
  7508. SetlId: order.SetlId,
  7509. }
  7510. var res ResultEleven
  7511. var resEleven10265 ResultEleven10265
  7512. if config.IsOpen == 1 {
  7513. if miConfig.MdtrtareaAdmvs == "421300" {
  7514. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7515. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7516. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7517. resp, requestErr := http.Get(api)
  7518. if requestErr != nil {
  7519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7520. return
  7521. }
  7522. body, ioErr := ioutil.ReadAll(resp.Body)
  7523. if ioErr != nil {
  7524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7526. return
  7527. }
  7528. var respJSON map[string]interface{}
  7529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7532. return
  7533. }
  7534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7535. result, _ := json.Marshal(respJSON)
  7536. fmt.Println("log")
  7537. fmt.Println(string(result))
  7538. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7539. utils.ErrorLog("解析失败:%v", err)
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. return
  7542. }
  7543. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7544. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7545. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7546. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7547. resp, requestErr := http.Get(api)
  7548. if requestErr != nil {
  7549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7550. return
  7551. }
  7552. body, ioErr := ioutil.ReadAll(resp.Body)
  7553. if ioErr != nil {
  7554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7556. return
  7557. }
  7558. var respJSON map[string]interface{}
  7559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7562. return
  7563. }
  7564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7565. result, _ := json.Marshal(respJSON)
  7566. fmt.Println("log")
  7567. fmt.Println(string(result))
  7568. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7569. utils.ErrorLog("解析失败:%v", err)
  7570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7571. return
  7572. }
  7573. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7574. res.Output = resEleven10265.Output
  7575. res.ErrMsg = resEleven10265.ErrMsg
  7576. res.Cainfo = resEleven10265.Cainfo
  7577. res.WarnMsg = resEleven10265.WarnMsg
  7578. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7579. res.Infcode = infocode
  7580. } else {
  7581. result2 := service.Gdyb5204(baseParams, businessParams)
  7582. saveLog(result2, "", "5204", "查询")
  7583. result := service.Gdyb5203(baseParams, businessParams)
  7584. var dat map[string]interface{}
  7585. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7586. fmt.Println(dat)
  7587. } else {
  7588. fmt.Println(err)
  7589. }
  7590. userJSONBytes, _ := json.Marshal(dat)
  7591. if miConfig.Code == "H15049901371" {
  7592. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7593. utils.ErrorLog("解析失败:%v", err)
  7594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7595. return
  7596. }
  7597. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7598. res.Output = resEleven10265.Output
  7599. res.ErrMsg = resEleven10265.ErrMsg
  7600. res.Cainfo = resEleven10265.Cainfo
  7601. res.WarnMsg = resEleven10265.WarnMsg
  7602. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7603. res.Infcode = infocode
  7604. } else {
  7605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7606. utils.ErrorLog("解析失败:%v", err)
  7607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7608. return
  7609. }
  7610. }
  7611. }
  7612. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7613. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7614. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7615. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7616. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7617. var doctor_name string
  7618. if roles.ID == 0 {
  7619. doctor_name = "管理员"
  7620. } else {
  7621. doctor_name = roles.UserName
  7622. }
  7623. yiliao_leibie := ""
  7624. switch order.MedType {
  7625. case "11":
  7626. yiliao_leibie = "普通门诊"
  7627. break
  7628. case "12":
  7629. yiliao_leibie = "门诊挂号"
  7630. break
  7631. case "13":
  7632. yiliao_leibie = "急诊"
  7633. break
  7634. case "14":
  7635. yiliao_leibie = "门诊特殊病"
  7636. break
  7637. case "15":
  7638. yiliao_leibie = "门诊统筹"
  7639. break
  7640. case "16":
  7641. yiliao_leibie = "门诊慢性病"
  7642. break
  7643. case "21":
  7644. yiliao_leibie = "普通住院"
  7645. break
  7646. }
  7647. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7648. if res.Infcode == 0 {
  7649. c.ServeSuccessJSON(map[string]interface{}{
  7650. "diagnosis": name,
  7651. "order_infos": orderInfos,
  7652. "number": order.MdtrtId,
  7653. "date": order.SettleAccountsDate,
  7654. "charge_admin": charge_admin,
  7655. "printor_admin": printor_admin,
  7656. "info": res.Output.Setlinfo,
  7657. "bedCostTotal": bedCostTotal,
  7658. "bedCostSelfTotal": bedCostSelfTotal,
  7659. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7660. "operationCostTotal": operationCostTotal,
  7661. "operationCostSelfTotal": operationCostSelfTotal,
  7662. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7663. "otherCostTotal": otherCostTotal,
  7664. "otherCostSelfTotal": otherCostSelfTotal,
  7665. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7666. "materialCostTotal": materialCostTotal,
  7667. "materialCostSelfTotal": materialCostSelfTotal,
  7668. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7669. "westernMedicineCostTotal": westernMedicineCostTotal,
  7670. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7671. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7672. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7673. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7674. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7675. "checkCostTotal": checkCostTotal,
  7676. "checkCostSelfTotal": checkCostSelfTotal,
  7677. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7678. "laboratoryCostTotal": laboratoryCostTotal,
  7679. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7680. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7681. "treatCostTotal": treatCostTotal,
  7682. "treatCostSelfTotal": treatCostSelfTotal,
  7683. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7684. "doctor_code": adminRole_two.DoctorCode,
  7685. "doctor_name": doctor_name,
  7686. "health_card_no": order.PsnNo,
  7687. "department": departments.Name,
  7688. "yiliao_leibie": yiliao_leibie,
  7689. "after_money": order.AccountPrice,
  7690. "patient": patient,
  7691. "org_name": miConfig.OrgName,
  7692. "org_code": miConfig.Code,
  7693. "order_number": order.Number,
  7694. //"check_order_info": cus_slice,
  7695. })
  7696. }
  7697. }
  7698. }
  7699. func (c *HisApiController) CheckTreatment() {
  7700. patient_id, _ := c.GetInt64("patient_id")
  7701. id_card_no := c.GetString("id_card_no")
  7702. insutype := c.GetString("insutype")
  7703. med_type := c.GetString("med_type")
  7704. admin_user_id, _ := c.GetInt64("admin_user_id")
  7705. adminUser := c.GetAdminUserInfo()
  7706. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7708. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7709. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7710. if miConfig.MdtrtareaAdmvs == "421300" {
  7711. var res ResultTwo
  7712. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7713. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7714. "&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)
  7715. resp, requestErr := http.Get(api)
  7716. if requestErr != nil {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7718. return
  7719. }
  7720. body, ioErr := ioutil.ReadAll(resp.Body)
  7721. if ioErr != nil {
  7722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7724. return
  7725. }
  7726. var respJSON map[string]interface{}
  7727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7730. return
  7731. }
  7732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7733. result, _ := json.Marshal(respJSON)
  7734. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7735. utils.ErrorLog("解析失败:%v", err)
  7736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7737. return
  7738. }
  7739. if res.Infcode == 0 {
  7740. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7741. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7742. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7743. resp, requestErr := http.Get(api)
  7744. if requestErr != nil {
  7745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7746. return
  7747. }
  7748. body, ioErr := ioutil.ReadAll(resp.Body)
  7749. if ioErr != nil {
  7750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. return
  7753. }
  7754. var respJSON map[string]interface{}
  7755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. return
  7759. }
  7760. var res Result2001
  7761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7762. result2, _ := json.Marshal(respJSON)
  7763. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7764. utils.ErrorLog("解析失败:%v", err)
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7766. return
  7767. }
  7768. if res.Infcode == 0 {
  7769. c.ServeSuccessJSON(map[string]interface{}{
  7770. "msg": res.Output.Trtinfo,
  7771. })
  7772. }
  7773. } else {
  7774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7775. return
  7776. }
  7777. } else {
  7778. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7779. var dat map[string]interface{}
  7780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7781. fmt.Println(dat)
  7782. } else {
  7783. fmt.Println(err)
  7784. }
  7785. userJSONBytes, _ := json.Marshal(dat)
  7786. var res ResultTwo
  7787. var res10265 ResultTwo10265
  7788. if miConfig.Code == "H15049901371" {
  7789. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7790. utils.ErrorLog("解析失败:%v", err)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. res.ErrMsg = res10265.ErrMsg
  7795. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7796. res.Infcode = infocode
  7797. res.Output = res10265.Output
  7798. res.InfRefmsgid = res10265.InfRefmsgid
  7799. } else {
  7800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7801. utils.ErrorLog("解析失败:%v", err)
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. return
  7804. }
  7805. }
  7806. var user_name string
  7807. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7808. if role.ID == 0 {
  7809. user_name = "xxx"
  7810. } else {
  7811. user_name = role.UserName
  7812. }
  7813. baseParams := models.BaseParams{
  7814. SecretKey: miConfig.SecretKey,
  7815. FixmedinsCode: miConfig.Code,
  7816. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7817. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7818. OrgName: miConfig.OrgName,
  7819. Doctor: user_name,
  7820. }
  7821. if config.IsOpen == 1 {
  7822. if miConfig.Code == "H15049901371" {
  7823. if med_type == "14" {
  7824. if insutype == "390" {
  7825. med_type = "9933"
  7826. } else if insutype == "310" {
  7827. med_type = "990502"
  7828. }
  7829. } else if med_type == "11" {
  7830. med_type = "11"
  7831. }
  7832. }
  7833. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7834. var dat map[string]interface{}
  7835. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7836. fmt.Println(dat)
  7837. } else {
  7838. fmt.Println(err)
  7839. }
  7840. var res Result2001
  7841. var res10265 Result2001Org10265
  7842. if miConfig.Code == "H15049901371" {
  7843. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7844. utils.ErrorLog("解析失败:%v", err)
  7845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7846. return
  7847. }
  7848. res.ErrMsg = res10265.ErrMsg
  7849. res.Output = res10265.Output
  7850. res.InfRefmsgid = res10265.InfRefmsgid
  7851. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7852. res.Infcode = infocode
  7853. } else {
  7854. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7855. utils.ErrorLog("解析失败:%v", err)
  7856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7857. return
  7858. }
  7859. }
  7860. if res.Infcode == 0 {
  7861. c.ServeSuccessJSON(map[string]interface{}{
  7862. "msg": res.Output.Trtinfo,
  7863. })
  7864. }
  7865. }
  7866. }
  7867. }
  7868. //func (c *HisApiController) PutRecord() {
  7869. // id, _ := c.GetInt64("id")
  7870. // record_time := c.GetString("record_time")
  7871. // timeLayout := "2006-01-02"
  7872. // loc, _ := time.LoadLocation("Local")
  7873. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7874. // if err != nil {
  7875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7876. // return
  7877. // }
  7878. // recordDateTime := theTime.Unix()
  7879. //
  7880. // adminInfo := c.GetAdminUserInfo()
  7881. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7882. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7883. //
  7884. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7885. //
  7886. // fmt.Println(miConfig.SecretKey)
  7887. //
  7888. // if patient == nil {
  7889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7890. // return
  7891. // }
  7892. // if len(patient.IdCardNo) == 0 {
  7893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7894. // return
  7895. // }
  7896. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7897. // if config.IsOpen == 1 {
  7898. // 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
  7899. // resp, requestErr := http.Get(api)
  7900. // if requestErr != nil {
  7901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7902. // return
  7903. // }
  7904. // defer resp.Body.Close()
  7905. // body, ioErr := ioutil.ReadAll(resp.Body)
  7906. // if ioErr != nil {
  7907. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7909. // return
  7910. // }
  7911. // var respJSON map[string]interface{}
  7912. //
  7913. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7914. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7916. // return
  7917. // }
  7918. //
  7919. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7920. // userJSONBytes, _ := json.Marshal(userJSON)
  7921. // var res ResultTwo
  7922. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7923. // utils.ErrorLog("解析失败:%v", err)
  7924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7925. // return
  7926. // }
  7927. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7928. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7929. // infoStr := string(Iinfos)
  7930. // idetinfoStr := string(Idetinfos)
  7931. //
  7932. // if res.Infcode == 0 {
  7933. // his := models.VMHisPatient{
  7934. // Status: 1,
  7935. // Ctime: time.Now().Unix(),
  7936. // Mtime: time.Now().Unix(),
  7937. // PsnNo: res.Output.Baseinfo.PsnNo,
  7938. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7939. // Certno: res.Output.Baseinfo.Certno,
  7940. // PsnName: res.Output.Baseinfo.PsnName,
  7941. // Gend: res.Output.Baseinfo.Gend,
  7942. // Naty: res.Output.Baseinfo.Naty,
  7943. // Brdy: res.Output.Baseinfo.Brdy,
  7944. // Age: res.Output.Baseinfo.Age,
  7945. // Iinfo: infoStr,
  7946. // Idetinfo: idetinfoStr,
  7947. // PatientId: patient.ID,
  7948. // RecordDate: theTime.Unix(),
  7949. // UserOrgId: adminInfo.CurrentOrgId,
  7950. // AdminUserId: adminInfo.AdminUser.Id,
  7951. // IsReturn: 1,
  7952. // }
  7953. //
  7954. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7955. // //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")
  7956. // //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")
  7957. //
  7958. // //var dat map[string]interface{}
  7959. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7960. // // fmt.Println(dat)
  7961. // //} else {
  7962. // // fmt.Println(err)
  7963. // //}
  7964. //
  7965. // var dat2 map[string]interface{}
  7966. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7967. // fmt.Println(dat2)
  7968. // } else {
  7969. // fmt.Println(err)
  7970. // }
  7971. //
  7972. // } else {
  7973. // adminUser := c.GetAdminUserInfo()
  7974. // errlog := &models.HisOrderError{
  7975. // UserOrgId: adminUser.CurrentOrgId,
  7976. // Ctime: time.Now().Unix(),
  7977. // Mtime: time.Now().Unix(),
  7978. // ErrMsg: res.ErrMsg,
  7979. // Status: 1,
  7980. // PatientId: id,
  7981. // RecordTime: recordDateTime,
  7982. // Stage: 1,
  7983. // }
  7984. // service.CreateErrMsgLog(errlog)
  7985. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7986. // return
  7987. // }
  7988. // }
  7989. //
  7990. //}
  7991. //func (c *HisApiController) GetUploadDiag() {
  7992. // id, _ := c.GetInt64("id")
  7993. // record_time := c.GetString("record_time")
  7994. //
  7995. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7996. // sick_type, _ := c.GetInt64("sick_type")
  7997. // reg_type, _ := c.GetInt64("reg_type")
  7998. //
  7999. // timeLayout := "2006-01-02"
  8000. // loc, _ := time.LoadLocation("Local")
  8001. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8002. // if err != nil {
  8003. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8004. // return
  8005. // }
  8006. //
  8007. // var patientPrescription models.HisPrescriptionInfo
  8008. // recordDateTime := theTime.Unix()
  8009. // adminInfo := c.GetAdminUserInfo()
  8010. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8011. //
  8012. // if patientPrescription.ID == 0 {
  8013. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8014. // }
  8015. //
  8016. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8017. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8018. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8019. // sickConfig, _ := service.FindSickById(sick_type)
  8020. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8021. //
  8022. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8023. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8024. // "&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 +
  8025. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8026. // resp2, requestErr2 := http.Get(api2)
  8027. // if requestErr2 != nil {
  8028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8029. // return
  8030. // }
  8031. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8032. // if ioErr2 != nil {
  8033. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8035. // return
  8036. // }
  8037. // var respJSON2 map[string]interface{}
  8038. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8039. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8041. // return
  8042. // }
  8043. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8044. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8045. //
  8046. // var res2 ResultSix
  8047. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8048. // utils.ErrorLog("解析失败:%v", err)
  8049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8050. // return
  8051. // }
  8052. // if res2.Infcode != 0 {
  8053. // adminUser := c.GetAdminUserInfo()
  8054. // errlog := &models.HisOrderError{
  8055. // UserOrgId: adminUser.CurrentOrgId,
  8056. // Ctime: time.Now().Unix(),
  8057. // Mtime: time.Now().Unix(),
  8058. // ErrMsg: res2.ErrMsg,
  8059. // Status: 1,
  8060. // PatientId: id,
  8061. // RecordTime: recordDateTime,
  8062. // Stage: 3,
  8063. // }
  8064. // service.CreateErrMsgLog(errlog)
  8065. //
  8066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8067. // return
  8068. // }
  8069. //
  8070. // c.ServeSuccessJSON(map[string]interface{}{
  8071. // "msg": "上传成功",
  8072. // })
  8073. //
  8074. //}
  8075. type QueryResult struct {
  8076. ID int64
  8077. Name string
  8078. Code string
  8079. List_type_code string
  8080. }
  8081. func (c *HisApiController) GetCheckCode() {
  8082. ids_str := c.GetString("ids")
  8083. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8084. ids_arr := strings.Split(ids_str, ",")
  8085. var queryResult []QueryResult
  8086. ids := make([]int64, 0)
  8087. for _, item := range ids_arr {
  8088. id, _ := strconv.ParseInt(item, 10, 64)
  8089. ids = append(ids, id)
  8090. }
  8091. if record_type == 1 {
  8092. drugs, _ := service.GetBatchDrugList(ids)
  8093. for _, item := range drugs {
  8094. result := QueryResult{
  8095. ID: item.ID,
  8096. Name: item.DrugName,
  8097. Code: item.MedicalInsuranceNumber,
  8098. List_type_code: "101",
  8099. }
  8100. queryResult = append(queryResult, result)
  8101. }
  8102. } else if record_type == 2 {
  8103. goods, _ := service.GetBatchGoodInformationList(ids)
  8104. for _, item := range goods {
  8105. result := QueryResult{
  8106. ID: item.ID,
  8107. Name: item.GoodName,
  8108. Code: item.MedicalInsuranceNumber,
  8109. List_type_code: "301",
  8110. }
  8111. queryResult = append(queryResult, result)
  8112. }
  8113. } else if record_type == 3 {
  8114. projects, _ := service.GetBathchMyPorjecgList(ids)
  8115. for _, item := range projects {
  8116. result := QueryResult{
  8117. ID: item.ID,
  8118. Name: item.ProjectName,
  8119. Code: item.MedicalCode,
  8120. List_type_code: "201",
  8121. }
  8122. queryResult = append(queryResult, result)
  8123. }
  8124. }
  8125. admin_user_id, _ := c.GetInt64("admin_user_id")
  8126. adminUser := c.GetAdminUserInfo()
  8127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8129. var user_name string
  8130. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8131. if role.ID == 0 {
  8132. user_name = "xxx"
  8133. } else {
  8134. user_name = role.UserName
  8135. }
  8136. baseParams := &models.BaseParams{
  8137. SecretKey: miConfig.SecretKey,
  8138. FixmedinsCode: miConfig.Code,
  8139. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8140. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8141. OrgName: miConfig.OrgName,
  8142. Doctor: user_name,
  8143. }
  8144. if config.IsOpen == 1 {
  8145. for _, item := range queryResult {
  8146. var result string
  8147. if record_type == 1 {
  8148. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8149. } else if record_type == 2 {
  8150. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8151. } else if record_type == 3 {
  8152. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8153. }
  8154. var dat map[string]interface{}
  8155. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8156. fmt.Println(dat)
  8157. } else {
  8158. fmt.Println(err)
  8159. }
  8160. userJSONBytes, _ := json.Marshal(dat)
  8161. var res ResultSix
  8162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8163. utils.ErrorLog("解析失败:%v", err)
  8164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8165. return
  8166. }
  8167. if res.Infcode == 0 {
  8168. if record_type == 1 {
  8169. service.UpdateBaseDrugById(item.ID)
  8170. } else if record_type == 2 {
  8171. service.UpdateGoodInformaitonByDetail(item.ID)
  8172. } else if record_type == 3 {
  8173. service.UpdateProjectById(item.ID)
  8174. }
  8175. c.ServeSuccessJSON(map[string]interface{}{
  8176. "failed_code": 0,
  8177. "msg": "目录对照成功",
  8178. })
  8179. } else {
  8180. c.ServeSuccessJSON(map[string]interface{}{
  8181. "failed_code": -10,
  8182. "msg": res.ErrMsg,
  8183. })
  8184. }
  8185. }
  8186. }
  8187. }
  8188. func (c *HisApiController) UnCheckCode() {
  8189. ids_str := c.GetString("ids")
  8190. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8191. admin_user_id, _ := c.GetInt64("admin_user_id")
  8192. ids_arr := strings.Split(ids_str, ",")
  8193. var queryResult []QueryResult
  8194. ids := make([]int64, 0)
  8195. for _, item := range ids_arr {
  8196. id, _ := strconv.ParseInt(item, 10, 64)
  8197. ids = append(ids, id)
  8198. }
  8199. if record_type == 1 {
  8200. drugs, _ := service.GetBatchDrugList(ids)
  8201. for _, item := range drugs {
  8202. result := QueryResult{
  8203. ID: item.ID,
  8204. Name: item.DrugName,
  8205. Code: item.MedicalInsuranceNumber,
  8206. List_type_code: "101",
  8207. }
  8208. queryResult = append(queryResult, result)
  8209. }
  8210. } else if record_type == 2 {
  8211. goods, _ := service.GetBatchGoodInformationList(ids)
  8212. for _, item := range goods {
  8213. result := QueryResult{
  8214. ID: item.ID,
  8215. Name: item.GoodName,
  8216. Code: item.MedicalInsuranceNumber,
  8217. List_type_code: "301",
  8218. }
  8219. queryResult = append(queryResult, result)
  8220. }
  8221. } else if record_type == 3 {
  8222. projects, _ := service.GetBathchMyPorjecgList(ids)
  8223. for _, item := range projects {
  8224. result := QueryResult{
  8225. ID: item.ID,
  8226. Name: item.ProjectName,
  8227. Code: item.MedicalCode,
  8228. List_type_code: "201",
  8229. }
  8230. queryResult = append(queryResult, result)
  8231. }
  8232. }
  8233. adminUser := c.GetAdminUserInfo()
  8234. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8235. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8236. var user_name string
  8237. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8238. if role.ID == 0 {
  8239. user_name = "xxx"
  8240. } else {
  8241. user_name = role.UserName
  8242. }
  8243. baseParams := &models.BaseParams{
  8244. SecretKey: miConfig.SecretKey,
  8245. FixmedinsCode: miConfig.Code,
  8246. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8247. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8248. OrgName: miConfig.OrgName,
  8249. Doctor: user_name,
  8250. }
  8251. if config.IsOpen == 1 {
  8252. for _, item := range queryResult {
  8253. var result string
  8254. if record_type == 1 {
  8255. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8256. } else if record_type == 2 {
  8257. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8258. } else if record_type == 3 {
  8259. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8260. }
  8261. var dat2 map[string]interface{}
  8262. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8263. fmt.Println(dat2)
  8264. } else {
  8265. fmt.Println(err)
  8266. }
  8267. userJSONBytes, _ := json.Marshal(dat2)
  8268. var res ResultSix
  8269. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8270. utils.ErrorLog("解析失败:%v", err)
  8271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8272. return
  8273. }
  8274. if res.Infcode == 0 {
  8275. if record_type == 1 {
  8276. service.UpdateDrugByIdDetail(item.ID)
  8277. } else if record_type == 2 {
  8278. service.UpdateGoodInfoById(item.ID)
  8279. } else if record_type == 3 {
  8280. service.UpdateMyProjectById(item.ID)
  8281. }
  8282. c.ServeSuccessJSON(map[string]interface{}{
  8283. "failed_code": 0,
  8284. "msg": "撤销目录对照成功",
  8285. })
  8286. } else {
  8287. c.ServeSuccessJSON(map[string]interface{}{
  8288. "failed_code": -10,
  8289. "msg": res.ErrMsg,
  8290. })
  8291. }
  8292. }
  8293. }
  8294. }
  8295. func (c *HisApiController) GetPatientInfo() {
  8296. id_card_no := c.GetString("id_card_no")
  8297. admin_user_id, _ := c.GetInt64("admin_user_id")
  8298. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8299. if patient.ID == 0 {
  8300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8301. return
  8302. }
  8303. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8304. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8305. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8306. if config.IsOpen == 1 {
  8307. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8308. var dat map[string]interface{}
  8309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8310. fmt.Println(dat)
  8311. } else {
  8312. fmt.Println(err)
  8313. }
  8314. userJSONBytes, _ := json.Marshal(dat)
  8315. var res ResultTwo
  8316. var res10265 ResultTwo10265
  8317. if miConfig.Code == "H15049901371" {
  8318. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8319. utils.ErrorLog("解析失败:%v", err)
  8320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8321. return
  8322. }
  8323. res.ErrMsg = res10265.ErrMsg
  8324. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8325. res.Infcode = infocode
  8326. res.Output = res10265.Output
  8327. res.InfRefmsgid = res10265.InfRefmsgid
  8328. } else {
  8329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8330. utils.ErrorLog("解析失败:%v", err)
  8331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. return
  8333. }
  8334. }
  8335. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8336. // utils.ErrorLog("解析失败:%v", err)
  8337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8338. // return
  8339. //}
  8340. if res.Infcode != 0 {
  8341. c.ServeSuccessJSON(map[string]interface{}{
  8342. "failed_code": -10,
  8343. "msg": res.ErrMsg,
  8344. })
  8345. } else {
  8346. c.ServeSuccessJSON(map[string]interface{}{
  8347. "failed_code": 0,
  8348. "info": res,
  8349. })
  8350. }
  8351. }
  8352. }
  8353. func (c *HisApiController) PsnPutOnRecord() {
  8354. record_type, _ := c.GetInt64("type")
  8355. patient_id, _ := c.GetInt64("patient_id")
  8356. admin_user_id, _ := c.GetInt64("admin_user_id")
  8357. start_time := c.GetString("start_time")
  8358. end_time := c.GetString("end_time")
  8359. adminUser := c.GetAdminUserInfo()
  8360. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8361. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8362. var patients []*models.Patients
  8363. if record_type == 1 { //全部备案
  8364. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8365. patients = append(patients, patient...)
  8366. } else { //单个备案
  8367. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8368. patients = append(patients, patient)
  8369. }
  8370. var user_name string
  8371. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8372. if role.ID == 0 {
  8373. user_name = "xxx"
  8374. } else {
  8375. user_name = role.UserName
  8376. }
  8377. if config.IsOpen == 1 {
  8378. for _, item := range patients {
  8379. 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
  8380. resp, requestErr := http.Get(api)
  8381. if requestErr != nil {
  8382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8383. return
  8384. }
  8385. defer resp.Body.Close()
  8386. body, ioErr := ioutil.ReadAll(resp.Body)
  8387. if ioErr != nil {
  8388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8390. return
  8391. }
  8392. var respJSON map[string]interface{}
  8393. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8399. userJSONBytes, _ := json.Marshal(userJSON)
  8400. var res ResultTwo
  8401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8402. utils.ErrorLog("解析失败:%v", err)
  8403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8404. return
  8405. }
  8406. if res.Infcode == 0 {
  8407. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8408. var dat map[string]interface{}
  8409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8410. fmt.Println(dat)
  8411. } else {
  8412. fmt.Println(err)
  8413. }
  8414. userJSONBytes, _ := json.Marshal(dat)
  8415. var res2 ResultThirteen
  8416. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8417. utils.ErrorLog("解析失败:%v", err)
  8418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8419. return
  8420. }
  8421. if res2.Infcode == 0 {
  8422. psnResult := &models.GdybPsnRecord{
  8423. UserOrgId: adminUser.CurrentOrgId,
  8424. PatientId: item.ID,
  8425. PsnNo: res.Output.Baseinfo.PsnNo,
  8426. Ctime: time.Now().Unix(),
  8427. Mtime: time.Now().Unix(),
  8428. Status: 1,
  8429. IsCancel: 1,
  8430. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8431. }
  8432. service.CreatePsnRecord(psnResult)
  8433. } else {
  8434. c.ServeSuccessJSON(map[string]interface{}{
  8435. "failed_code": -10,
  8436. "msg": res2.ErrMsg,
  8437. })
  8438. return
  8439. }
  8440. }
  8441. }
  8442. }
  8443. }
  8444. func (c *HisApiController) PsnUnPutOnRecord() {
  8445. id, _ := c.GetInt64("id")
  8446. //record_type, _ := c.GetInt64("type")
  8447. admin_user_id, _ := c.GetInt64("admin_user_id")
  8448. adminUser := c.GetAdminUserInfo()
  8449. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8450. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8451. var user_name string
  8452. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8453. if role.ID == 0 {
  8454. user_name = "xxx"
  8455. } else {
  8456. user_name = role.UserName
  8457. }
  8458. psn_record, _ := service.GetPsnRecordById(id)
  8459. if psn_record.ID == 0 {
  8460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8461. return
  8462. }
  8463. if config.IsOpen == 1 {
  8464. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8465. var dat map[string]interface{}
  8466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8467. fmt.Println(dat)
  8468. } else {
  8469. fmt.Println(err)
  8470. }
  8471. userJSONBytes, _ := json.Marshal(dat)
  8472. var res ResultFourteen
  8473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8474. utils.ErrorLog("解析失败:%v", err)
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. if res.Infcode == 0 {
  8479. psn_record.IsCancel = 2
  8480. service.CreatePsnRecord(&psn_record)
  8481. } else {
  8482. c.ServeSuccessJSON(map[string]interface{}{
  8483. "failed_code": -10,
  8484. "msg": res.ErrMsg,
  8485. })
  8486. return
  8487. }
  8488. }
  8489. }
  8490. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8491. patient_id, _ := c.GetInt64("patient_id")
  8492. insutype_two := c.GetString("insutype")
  8493. psn_no := c.GetString("psn_no")
  8494. doctor_id, _ := c.GetInt64("doctor_id")
  8495. sick_id, _ := c.GetInt64("sick_id")
  8496. department_id, _ := c.GetInt64("department_id")
  8497. start_time := c.GetString("start_time")
  8498. end_time := c.GetString("end_time")
  8499. check_time := c.GetString("check_time")
  8500. adminUser := c.GetAdminUserInfo()
  8501. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8502. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8503. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8504. sick, _ := service.FindSickById(sick_id)
  8505. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8506. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8507. var res ResultTwo
  8508. var res10265 ResultTwo10265
  8509. if miConfig.MdtrtareaAdmvs == "320921" {
  8510. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8511. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8512. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8513. "&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
  8514. resp, requestErr := http.Get(api)
  8515. if requestErr != nil {
  8516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8517. return
  8518. }
  8519. body, ioErr := ioutil.ReadAll(resp.Body)
  8520. if ioErr != nil {
  8521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8523. return
  8524. }
  8525. var respJSON map[string]interface{}
  8526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8529. return
  8530. }
  8531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8532. result, _ := json.Marshal(respJSON)
  8533. fmt.Println("log")
  8534. fmt.Println(string(result))
  8535. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8536. utils.ErrorLog("解析失败:%v", err)
  8537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8538. return
  8539. }
  8540. res.ErrMsg = res10265.ErrMsg
  8541. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8542. res.Infcode = infocode
  8543. res.Output = res10265.Output
  8544. res.InfRefmsgid = res10265.InfRefmsgid
  8545. } else {
  8546. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8547. if miConfig.Code == "H15049901371" {
  8548. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8549. utils.ErrorLog("解析失败:%v", err)
  8550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8551. return
  8552. }
  8553. res.ErrMsg = res10265.ErrMsg
  8554. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8555. res.Infcode = infocode
  8556. res.Output = res10265.Output
  8557. res.InfRefmsgid = res10265.InfRefmsgid
  8558. } else {
  8559. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8560. utils.ErrorLog("解析失败:%v", err)
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8562. return
  8563. }
  8564. }
  8565. }
  8566. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8567. infoStr := string(Iinfos)
  8568. var rf []*ResultFive
  8569. json.Unmarshal([]byte(infoStr), &rf)
  8570. var insuplc_admdvs string
  8571. var insutype string
  8572. var is390 int = 0
  8573. var is310 int = 0
  8574. var insutypes []*ResultFive
  8575. for _, item := range rf {
  8576. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8577. insutypes = append(insutypes, item)
  8578. }
  8579. }
  8580. if len(insutypes) == 1 {
  8581. insutype = insutypes[0].Insutype
  8582. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8583. } else {
  8584. for _, i := range insutypes {
  8585. if i.Insutype == "390" {
  8586. is390 = 1
  8587. }
  8588. if i.Insutype == "310" {
  8589. is310 = 1
  8590. }
  8591. }
  8592. }
  8593. if is390 == 1 {
  8594. insutype = "390"
  8595. }
  8596. if is310 == 1 {
  8597. insutype = "310"
  8598. }
  8599. if len(insutypes) == 2 {
  8600. insutype = insutype_two
  8601. }
  8602. if len(insutypes) == 0 {
  8603. insutype = "310"
  8604. }
  8605. insutype = insutype_two
  8606. fmt.Println(insutype)
  8607. for _, item := range rf {
  8608. fmt.Println(item.Insutype)
  8609. fmt.Println(insutype)
  8610. if item.Insutype == insutype {
  8611. fmt.Println(item.Insutype)
  8612. fmt.Println(insutype)
  8613. insuplc_admdvs = item.InsuplcAdmdvs
  8614. }
  8615. }
  8616. fmt.Println(insuplc_admdvs)
  8617. var res2 ResultThirteen
  8618. var res10265_2 ResultThirteen10265
  8619. if config.IsOpen == 1 {
  8620. if miConfig.MdtrtareaAdmvs == "320921" {
  8621. } else {
  8622. 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)
  8623. var dat map[string]interface{}
  8624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8625. fmt.Println(dat)
  8626. } else {
  8627. fmt.Println(err)
  8628. }
  8629. userJSONBytes, _ := json.Marshal(dat)
  8630. if miConfig.Code == "H15049901371" {
  8631. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8632. utils.ErrorLog("解析失败:%v", err)
  8633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8634. return
  8635. }
  8636. res2.ErrMsg = res10265_2.ErrMsg
  8637. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8638. res2.Infcode = infocode
  8639. res2.Output = res10265_2.Output
  8640. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8641. } else {
  8642. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8643. utils.ErrorLog("解析失败:%v", err)
  8644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8645. return
  8646. }
  8647. }
  8648. }
  8649. if res2.Infcode == 0 {
  8650. psnResult := &models.GdybPsnNcdsRecord{
  8651. UserOrgId: adminUser.CurrentOrgId,
  8652. PatientId: patient.ID,
  8653. PsnNo: psn_no,
  8654. DoctorId: doctor.AdminUserId,
  8655. DepartmentId: department_id,
  8656. SickType: sick_id,
  8657. Insutype: insutype,
  8658. Ctime: time.Now().Unix(),
  8659. Mtime: time.Now().Unix(),
  8660. Status: 1,
  8661. IsCancel: 1,
  8662. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8663. }
  8664. service.CreatePsnNCDSRecord(psnResult)
  8665. c.ServeSuccessJSON(map[string]interface{}{
  8666. "failed_code": 0,
  8667. "msg": "备案成功",
  8668. "result": psnResult,
  8669. })
  8670. } else {
  8671. c.ServeSuccessJSON(map[string]interface{}{
  8672. "failed_code": -10,
  8673. "msg": res2.ErrMsg,
  8674. })
  8675. return
  8676. }
  8677. }
  8678. }
  8679. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8680. id, _ := c.GetInt64("id")
  8681. admin_user_id, _ := c.GetInt64("admin_user_id")
  8682. adminUser := c.GetAdminUserInfo()
  8683. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8684. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8685. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8686. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8687. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8688. //var user_name string
  8689. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8690. //if role.ID == 0 {
  8691. // user_name = "xxx"
  8692. //} else {
  8693. // user_name = role.UserName
  8694. //}
  8695. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8696. if psn_record.ID == 0 {
  8697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8698. return
  8699. }
  8700. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8701. var res ResultTwo
  8702. var res10265 ResultTwo10265
  8703. if miConfig.Code == "H15049901371" {
  8704. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8705. utils.ErrorLog("解析失败:%v", err)
  8706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8707. return
  8708. }
  8709. res.ErrMsg = res10265.ErrMsg
  8710. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8711. res.Infcode = infocode
  8712. res.Output = res10265.Output
  8713. res.InfRefmsgid = res10265.InfRefmsgid
  8714. } else {
  8715. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8716. utils.ErrorLog("解析失败:%v", err)
  8717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8718. return
  8719. }
  8720. }
  8721. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8722. infoStr := string(Iinfos)
  8723. var rf []*ResultFive
  8724. json.Unmarshal([]byte(infoStr), &rf)
  8725. var insuplc_admdvs string
  8726. var insutype string
  8727. var is390 int = 0
  8728. var is310 int = 0
  8729. var insutypes []*ResultFive
  8730. for _, item := range rf {
  8731. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8732. insutypes = append(insutypes, item)
  8733. }
  8734. }
  8735. if len(insutypes) == 1 {
  8736. insutype = insutypes[0].Insutype
  8737. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8738. } else {
  8739. for _, i := range insutypes {
  8740. if i.Insutype == "390" {
  8741. is390 = 1
  8742. }
  8743. if i.Insutype == "310" {
  8744. is310 = 1
  8745. }
  8746. }
  8747. }
  8748. if is390 == 1 {
  8749. insutype = "390"
  8750. }
  8751. if is310 == 1 {
  8752. insutype = "310"
  8753. }
  8754. if len(insutypes) == 0 {
  8755. insutype = "310"
  8756. }
  8757. insutype = psn_record.Insutype
  8758. for _, item := range rf {
  8759. if item.Insutype == insutype {
  8760. insuplc_admdvs = item.InsuplcAdmdvs
  8761. }
  8762. }
  8763. if config.IsOpen == 1 {
  8764. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8765. var dat map[string]interface{}
  8766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8767. fmt.Println(dat)
  8768. } else {
  8769. fmt.Println(err)
  8770. }
  8771. userJSONBytes, _ := json.Marshal(dat)
  8772. var res ResultFourteen
  8773. var res10265 ResultFourteen10265
  8774. if miConfig.Code == "H15049901371" {
  8775. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8776. utils.ErrorLog("解析失败:%v", err)
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8778. return
  8779. }
  8780. res.ErrMsg = res10265.ErrMsg
  8781. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8782. res.Infcode = infocode
  8783. res.Output = res10265.Output
  8784. res.InfRefmsgid = res10265.InfRefmsgid
  8785. } else {
  8786. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8787. utils.ErrorLog("解析失败:%v", err)
  8788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8789. return
  8790. }
  8791. }
  8792. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8793. // utils.ErrorLog("解析失败:%v", err)
  8794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8795. // return
  8796. //}
  8797. if res.Infcode == 0 {
  8798. psn_record.IsCancel = 2
  8799. service.CreatePsnNCDSRecord(&psn_record)
  8800. c.ServeSuccessJSON(map[string]interface{}{
  8801. "failed_code": 0,
  8802. "msg": "撤销备案成功",
  8803. })
  8804. } else {
  8805. c.ServeSuccessJSON(map[string]interface{}{
  8806. "failed_code": -10,
  8807. "msg": res.ErrMsg,
  8808. })
  8809. return
  8810. }
  8811. }
  8812. }
  8813. func (c *HisApiController) TestTest() {
  8814. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8815. fmt.Println(patient.Iinfo)
  8816. }
  8817. type CustomData struct {
  8818. MsgId string
  8819. PsnNo string
  8820. Info string
  8821. }
  8822. func (c *HisApiController) ReversalData() {
  8823. var customData []*CustomData
  8824. custom := &CustomData{
  8825. MsgId: "H44022900158202103301714472004",
  8826. PsnNo: "44020000001101329945",
  8827. Info: "2207",
  8828. }
  8829. customData = append(customData, custom)
  8830. custom1 := &CustomData{
  8831. MsgId: "H4402290015820210330172057803",
  8832. PsnNo: "44020000001101161813",
  8833. Info: "2207",
  8834. }
  8835. customData = append(customData, custom1)
  8836. custom2 := &CustomData{
  8837. MsgId: "H44022900158202103301705198813",
  8838. PsnNo: "44190000133097375417",
  8839. Info: "2207",
  8840. }
  8841. customData = append(customData, custom2)
  8842. custom3 := &CustomData{
  8843. MsgId: "H44022900158202103301715524756",
  8844. PsnNo: "44020000001100187221",
  8845. Info: "2207",
  8846. }
  8847. customData = append(customData, custom3)
  8848. custom4 := &CustomData{
  8849. MsgId: "H44022900158202103301730376224",
  8850. PsnNo: "44020000001101959155",
  8851. Info: "2207",
  8852. }
  8853. customData = append(customData, custom4)
  8854. custom5 := &CustomData{
  8855. MsgId: "H44022900158202103301748008725",
  8856. PsnNo: "44020000001104246641",
  8857. Info: "2207",
  8858. }
  8859. customData = append(customData, custom5)
  8860. custom6 := &CustomData{
  8861. MsgId: "H44022900158202103301718096755",
  8862. PsnNo: "44020000001102211860",
  8863. Info: "2207",
  8864. }
  8865. customData = append(customData, custom6)
  8866. custom7 := &CustomData{
  8867. MsgId: "H44022900158202103301736551640",
  8868. PsnNo: "44020000001102687718",
  8869. Info: "2207",
  8870. }
  8871. customData = append(customData, custom7)
  8872. custom8 := &CustomData{
  8873. MsgId: "H44022900158202103301743097676",
  8874. PsnNo: "44020000001102127785",
  8875. Info: "2207",
  8876. }
  8877. customData = append(customData, custom8)
  8878. custom9 := &CustomData{
  8879. MsgId: "H44022900158202103301712304203",
  8880. PsnNo: "44020000001101518097",
  8881. Info: "2207",
  8882. }
  8883. customData = append(customData, custom9)
  8884. custom10 := &CustomData{
  8885. MsgId: "H44022900158202103301738448785",
  8886. PsnNo: "44020000001100500813",
  8887. Info: "2207",
  8888. }
  8889. customData = append(customData, custom10)
  8890. custom11 := &CustomData{
  8891. MsgId: "H44022900158202103301732455843",
  8892. PsnNo: "44020000001102690557",
  8893. Info: "2207",
  8894. }
  8895. customData = append(customData, custom11)
  8896. custom12 := &CustomData{
  8897. MsgId: "H44022900158202103301745421708",
  8898. PsnNo: "44020000001102211928",
  8899. Info: "2207",
  8900. }
  8901. customData = append(customData, custom12)
  8902. custom1212 := &CustomData{
  8903. MsgId: "H440229001582021033017351627",
  8904. PsnNo: "44020000001102481733",
  8905. Info: "2207",
  8906. }
  8907. customData = append(customData, custom1212)
  8908. custom13 := &CustomData{
  8909. MsgId: "H44022900158202103301740327951",
  8910. PsnNo: "44020000001103174866",
  8911. Info: "2207",
  8912. }
  8913. customData = append(customData, custom13)
  8914. custom14 := &CustomData{
  8915. MsgId: "H4402290015820210330174922668",
  8916. PsnNo: "44020000001102927272",
  8917. Info: "2207",
  8918. }
  8919. customData = append(customData, custom14)
  8920. custom15 := &CustomData{
  8921. MsgId: "H44022900158202103301752362273",
  8922. PsnNo: "44020000001102942890",
  8923. Info: "2207",
  8924. }
  8925. customData = append(customData, custom15)
  8926. custom16 := &CustomData{
  8927. MsgId: "H44022900158202103301751082917",
  8928. PsnNo: "44020000001101662162",
  8929. Info: "2207",
  8930. }
  8931. customData = append(customData, custom16)
  8932. custom17 := &CustomData{
  8933. MsgId: "H44022900158202103301754147728",
  8934. PsnNo: "44020000000229014511",
  8935. Info: "2207",
  8936. }
  8937. customData = append(customData, custom17)
  8938. adminUser := c.GetAdminUserInfo()
  8939. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8940. for _, item := range customData {
  8941. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8942. fmt.Println(result)
  8943. }
  8944. }
  8945. func (c *HisApiController) GetAllopatry() {
  8946. year := c.GetString("year")
  8947. month := c.GetString("month")
  8948. admin_user_id, _ := c.GetInt64("admin_user_id")
  8949. adminUser := c.GetAdminUserInfo()
  8950. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8951. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8952. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8953. var dat map[string]interface{}
  8954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8955. fmt.Println(dat)
  8956. } else {
  8957. fmt.Println(err)
  8958. }
  8959. userJSONBytes, _ := json.Marshal(dat)
  8960. var res models.Result9001
  8961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8962. utils.ErrorLog("解析失败:%v", err)
  8963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8964. return
  8965. }
  8966. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  8967. var dat2 map[string]interface{}
  8968. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8969. fmt.Println(dat)
  8970. } else {
  8971. fmt.Println(err)
  8972. }
  8973. userJSONBytes2, _ := json.Marshal(dat2)
  8974. var res2 models.Result3260
  8975. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8976. utils.ErrorLog("解析失败:%v", err)
  8977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8978. return
  8979. }
  8980. if res2.Infcode == 0 {
  8981. c.ServeSuccessJSON(map[string]interface{}{
  8982. "list": res2.Output.Data,
  8983. })
  8984. return
  8985. } else {
  8986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8987. return
  8988. }
  8989. }
  8990. func (c *HisApiController) ComfirmAllopatry() {
  8991. year := c.GetString("year")
  8992. month := c.GetString("month")
  8993. admin_user_id, _ := c.GetInt64("admin_user_id")
  8994. adminUser := c.GetAdminUserInfo()
  8995. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8996. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8997. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8998. var dat map[string]interface{}
  8999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9000. fmt.Println(dat)
  9001. } else {
  9002. fmt.Println(err)
  9003. }
  9004. userJSONBytes, _ := json.Marshal(dat)
  9005. var res models.Result9001
  9006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9007. utils.ErrorLog("解析失败:%v", err)
  9008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9009. return
  9010. }
  9011. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9012. var dat2 map[string]interface{}
  9013. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9014. fmt.Println(dat)
  9015. } else {
  9016. fmt.Println(err)
  9017. }
  9018. userJSONBytes2, _ := json.Marshal(dat2)
  9019. var res2 models.Result3260
  9020. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9021. utils.ErrorLog("解析失败:%v", err)
  9022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9023. return
  9024. }
  9025. if res2.Infcode == 0 {
  9026. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9027. var dat map[string]interface{}
  9028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9029. fmt.Println(dat)
  9030. } else {
  9031. fmt.Println(err)
  9032. }
  9033. userJSONBytes, _ := json.Marshal(dat)
  9034. var res3 models.Result3261
  9035. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9036. utils.ErrorLog("解析失败:%v", err)
  9037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9038. return
  9039. }
  9040. if res3.Infcode == 0 {
  9041. record := &models.HisYidiClearRecord{
  9042. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9043. Ctime: time.Now().Unix(),
  9044. Mtime: time.Now().Unix(),
  9045. Status: 1,
  9046. MsgId: msgId,
  9047. }
  9048. service.SaveClearRecord(record)
  9049. c.ServeSuccessJSON(map[string]interface{}{
  9050. "msg": "提取成功",
  9051. })
  9052. }
  9053. }
  9054. }
  9055. func (c *HisApiController) RefundAllopatry() {
  9056. year := c.GetString("year")
  9057. month := c.GetString("month")
  9058. id, _ := c.GetInt64("id")
  9059. admin_user_id, _ := c.GetInt64("admin_user_id")
  9060. adminUser := c.GetAdminUserInfo()
  9061. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9062. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9063. record, _ := service.GetClearRecordById(id)
  9064. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9065. var dat map[string]interface{}
  9066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9067. fmt.Println(dat)
  9068. } else {
  9069. fmt.Println(err)
  9070. }
  9071. userJSONBytes, _ := json.Marshal(dat)
  9072. var empty ResultFourteen
  9073. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9074. utils.ErrorLog("解析失败:%v", err)
  9075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9076. return
  9077. }
  9078. if empty.Infcode == 0 {
  9079. c.ServeSuccessJSON(map[string]interface{}{
  9080. "msg": "撤销成功",
  9081. })
  9082. return
  9083. }
  9084. }
  9085. func (c *HisApiController) ReversalOtherData() {
  9086. var customData []*CustomData
  9087. custom := &CustomData{
  9088. MsgId: "H44022900158202103301714472004",
  9089. PsnNo: "44020000001101329945",
  9090. Info: "2208",
  9091. }
  9092. customData = append(customData, custom)
  9093. custom1 := &CustomData{
  9094. MsgId: "H4402290015820210330172057803",
  9095. PsnNo: "44020000001101161813",
  9096. Info: "2208",
  9097. }
  9098. customData = append(customData, custom1)
  9099. custom2 := &CustomData{
  9100. MsgId: "H44022900158202103301705198813",
  9101. PsnNo: "44190000133097375417",
  9102. Info: "2208",
  9103. }
  9104. customData = append(customData, custom2)
  9105. custom3 := &CustomData{
  9106. MsgId: "H44022900158202103301715524756",
  9107. PsnNo: "44020000001100187221",
  9108. Info: "2208",
  9109. }
  9110. customData = append(customData, custom3)
  9111. custom4 := &CustomData{
  9112. MsgId: "H44022900158202103301730376224",
  9113. PsnNo: "44020000001101959155",
  9114. Info: "2208",
  9115. }
  9116. customData = append(customData, custom4)
  9117. custom5 := &CustomData{
  9118. MsgId: "H44022900158202103301748008725",
  9119. PsnNo: "44020000001104246641",
  9120. Info: "2208",
  9121. }
  9122. customData = append(customData, custom5)
  9123. custom6 := &CustomData{
  9124. MsgId: "H44022900158202103301718096755",
  9125. PsnNo: "44020000001102211860",
  9126. Info: "2208",
  9127. }
  9128. customData = append(customData, custom6)
  9129. custom7 := &CustomData{
  9130. MsgId: "H44022900158202103301736551640",
  9131. PsnNo: "44020000001102687718",
  9132. Info: "2208",
  9133. }
  9134. customData = append(customData, custom7)
  9135. custom8 := &CustomData{
  9136. MsgId: "H44022900158202103301743097676",
  9137. PsnNo: "44020000001102127785",
  9138. Info: "2208",
  9139. }
  9140. customData = append(customData, custom8)
  9141. custom9 := &CustomData{
  9142. MsgId: "H44022900158202103301712304203",
  9143. PsnNo: "44020000001101518097",
  9144. Info: "2208",
  9145. }
  9146. customData = append(customData, custom9)
  9147. custom10 := &CustomData{
  9148. MsgId: "H44022900158202103301738448785",
  9149. PsnNo: "44020000001100500813",
  9150. Info: "2208",
  9151. }
  9152. customData = append(customData, custom10)
  9153. custom11 := &CustomData{
  9154. MsgId: "H44022900158202103301732455843",
  9155. PsnNo: "44020000001102690557",
  9156. Info: "2208",
  9157. }
  9158. customData = append(customData, custom11)
  9159. custom12 := &CustomData{
  9160. MsgId: "H44022900158202103301745421708",
  9161. PsnNo: "44020000001102211928",
  9162. Info: "2208",
  9163. }
  9164. customData = append(customData, custom12)
  9165. custom1212 := &CustomData{
  9166. MsgId: "H440229001582021033017351627",
  9167. PsnNo: "44020000001102481733",
  9168. Info: "2208",
  9169. }
  9170. customData = append(customData, custom1212)
  9171. custom13 := &CustomData{
  9172. MsgId: "H44022900158202103301740327951",
  9173. PsnNo: "44020000001103174866",
  9174. Info: "2208",
  9175. }
  9176. customData = append(customData, custom13)
  9177. custom14 := &CustomData{
  9178. MsgId: "H4402290015820210330174922668",
  9179. PsnNo: "44020000001102927272",
  9180. Info: "2208",
  9181. }
  9182. customData = append(customData, custom14)
  9183. custom15 := &CustomData{
  9184. MsgId: "H44022900158202103301752362273",
  9185. PsnNo: "44020000001102942890",
  9186. Info: "2208",
  9187. }
  9188. customData = append(customData, custom15)
  9189. custom16 := &CustomData{
  9190. MsgId: "H44022900158202103301751082917",
  9191. PsnNo: "44020000001101662162",
  9192. Info: "2208",
  9193. }
  9194. customData = append(customData, custom16)
  9195. custom17 := &CustomData{
  9196. MsgId: "H44022900158202103301754147728",
  9197. PsnNo: "44020000000229014511",
  9198. Info: "2208",
  9199. }
  9200. customData = append(customData, custom17)
  9201. adminUser := c.GetAdminUserInfo()
  9202. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9203. for _, item := range customData {
  9204. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9205. fmt.Println(result)
  9206. }
  9207. }
  9208. func PathExists(path string) (bool, error) {
  9209. _, err := os.Stat(path)
  9210. if err == nil {
  9211. return true, nil
  9212. }
  9213. if os.IsNotExist(err) {
  9214. return false, nil
  9215. }
  9216. return false, err
  9217. }
  9218. //创建文件夹
  9219. func Mkdir(dir string) {
  9220. // 创建文件夹
  9221. exist, err := PathExists(dir)
  9222. if err != nil {
  9223. fmt.Println(err.Error())
  9224. } else {
  9225. if exist {
  9226. fmt.Println(dir + "文件夹已存在!")
  9227. } else {
  9228. // 文件夹名称,权限
  9229. err := os.Mkdir(dir, os.ModePerm)
  9230. if err != nil {
  9231. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9232. } else {
  9233. fmt.Println(dir + "文件夹创建成功!")
  9234. }
  9235. }
  9236. }
  9237. }
  9238. //压缩文件
  9239. func Zip(srcFile string, destZip string) error {
  9240. zipfile, err := os.Create(destZip)
  9241. if err != nil {
  9242. return err
  9243. }
  9244. defer zipfile.Close()
  9245. archive := zip.NewWriter(zipfile)
  9246. defer archive.Close()
  9247. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9248. if err != nil {
  9249. return err
  9250. }
  9251. header, err := zip.FileInfoHeader(info)
  9252. if err != nil {
  9253. return err
  9254. }
  9255. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9256. // header.Name = path
  9257. if info.IsDir() {
  9258. header.Name += "/"
  9259. } else {
  9260. header.Method = zip.Deflate
  9261. }
  9262. writer, err := archive.CreateHeader(header)
  9263. if err != nil {
  9264. return err
  9265. }
  9266. if !info.IsDir() {
  9267. file, err := os.Open(path)
  9268. if err != nil {
  9269. return err
  9270. }
  9271. defer file.Close()
  9272. _, err = io.Copy(writer, file)
  9273. }
  9274. return err
  9275. })
  9276. return err
  9277. }
  9278. func ReadFile(filePath string) []byte {
  9279. f, err := os.Open(filePath)
  9280. if err != nil {
  9281. fmt.Println("read file fail", err)
  9282. return nil
  9283. }
  9284. defer f.Close()
  9285. fd, err := ioutil.ReadAll(f)
  9286. if err != nil {
  9287. fmt.Println("read to fd fail", err)
  9288. return nil
  9289. }
  9290. return fd
  9291. }
  9292. func saveLog(result string, request string, infno string, desc string) {
  9293. org_id, _ := beego.AppConfig.Int64("org_id")
  9294. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9295. dir := miConfig.OrgName + "日志"
  9296. utils.Mkdir(dir)
  9297. month := time.Unix(1557042972, 0).Format("1")
  9298. year := time.Now().Format("2006")
  9299. month = time.Now().Format("01")
  9300. day := time.Now().Format("02")
  9301. hour := time.Now().Format("15")
  9302. min := time.Now().Format("04")
  9303. sec := time.Now().Format("05")
  9304. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9305. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9306. file_name := file + ".txt"
  9307. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9308. exist, _ := utils.PathExists(file_path)
  9309. if exist { //存在
  9310. fmt.Println("存在")
  9311. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9312. if err != nil {
  9313. fmt.Println("read fail")
  9314. }
  9315. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9316. n, _ := f.Seek(0, 2)
  9317. _, err = f.WriteAt([]byte(content), n)
  9318. } else { //不存在
  9319. fmt.Println("文件不存在,创建文件")
  9320. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9321. defer f.Close()
  9322. if err != nil {
  9323. } else {
  9324. _, err = f.Write([]byte("记录日志"))
  9325. }
  9326. }
  9327. }
  9328. type Charset string
  9329. const (
  9330. UTF8 = Charset("UTF-8")
  9331. GB18030 = Charset("GB18030")
  9332. )
  9333. func ConvertToString(src string, srcCode string, tagCode string) string {
  9334. srcCoder := mahonia.NewDecoder(srcCode)
  9335. srcResult := srcCoder.ConvertString(src)
  9336. tagCoder := mahonia.NewDecoder(tagCode)
  9337. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9338. result := string(cdata)
  9339. return result
  9340. }