his_api_controller.go 302KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503
  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. fmt.Println("----------")
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  37. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  38. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  39. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  40. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  41. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  42. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  43. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  44. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  45. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  46. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  47. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  48. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  49. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  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. //备案撤销相关接口
  56. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  57. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  58. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  59. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  60. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  61. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  62. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  63. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  64. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  67. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  68. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  69. //beego.Router("/api/checkdetailaccount/handle", &HisApiController{}, "get:HandleCheckDetailAccount")
  70. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  71. //beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
  72. //beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  73. }
  74. func (c *HisApiController) CheckInsutype() {
  75. his_patient_id, _ := c.GetInt64("his_patient_id")
  76. admin_user_id, _ := c.GetInt64("admin_user_id")
  77. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  78. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  79. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  80. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  81. var dat map[string]interface{}
  82. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  83. fmt.Println(dat)
  84. } else {
  85. fmt.Println(err)
  86. }
  87. userJSONBytes, _ := json.Marshal(dat)
  88. var res Result90100
  89. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  90. utils.ErrorLog("解析失败:%v", err)
  91. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  92. return
  93. }
  94. if res.Infcode != 0 {
  95. c.ServeSuccessJSON(map[string]interface{}{
  96. "failed_code": -10,
  97. "msg": res.ErrMsg,
  98. })
  99. return
  100. } else {
  101. fmt.Println(res)
  102. }
  103. }
  104. func (c *HisApiController) CheckCardPWD() {
  105. card_pwd := c.GetString("card_pwd")
  106. his_patient_id, _ := c.GetInt64("his_patient_id")
  107. admin_user_id, _ := c.GetInt64("admin_user_id")
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  110. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  111. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  112. var dat map[string]interface{}
  113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  114. fmt.Println(dat)
  115. } else {
  116. fmt.Println(err)
  117. }
  118. userJSONBytes, _ := json.Marshal(dat)
  119. var res Result90991
  120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  121. utils.ErrorLog("解析失败:%v", err)
  122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  123. return
  124. }
  125. if res.Infcode != 0 {
  126. c.ServeSuccessJSON(map[string]interface{}{
  127. "failed_code": -10,
  128. "msg": res.ErrMsg,
  129. })
  130. return
  131. } else {
  132. if res.Output.Result.CheckStat == "0" {
  133. var msg string
  134. switch res.Output.Result.CardStat {
  135. case "00":
  136. msg = "未激活"
  137. break
  138. case "10":
  139. msg = "激活"
  140. break
  141. case "20":
  142. msg = "窗口挂失"
  143. break
  144. case "21":
  145. msg = "电话挂失"
  146. break
  147. case "22":
  148. msg = "单位网上申报挂失"
  149. break
  150. case "23":
  151. msg = "保健办挂失"
  152. break
  153. case "24":
  154. msg = "个人网上挂失"
  155. break
  156. case "25":
  157. msg = "网上服务大厅挂失"
  158. break
  159. case "30":
  160. msg = "注销"
  161. break
  162. case "40":
  163. msg = "回收"
  164. break
  165. case "99":
  166. msg = "制卡中(无效卡)"
  167. break
  168. }
  169. c.ServeSuccessJSON(map[string]interface{}{
  170. "failed_code": -10,
  171. "msg": msg,
  172. })
  173. return
  174. } else {
  175. c.ServeSuccessJSON(map[string]interface{}{
  176. "msg": "校验成功",
  177. })
  178. return
  179. }
  180. }
  181. }
  182. func (c *HisApiController) ReadCard() {
  183. id_card_type, _ := c.GetInt64("id_card_type")
  184. admin_user_id, _ := c.GetInt64("admin_user_id")
  185. certificates, _ := c.GetInt64("certificates")
  186. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  187. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  189. switch id_card_type {
  190. case 1:
  191. if miConfig.MdtrtareaAdmvs == "421300" {
  192. var res ResultTwo
  193. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  194. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  195. "&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)
  196. resp, requestErr := http.Get(api)
  197. if requestErr != nil {
  198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  199. return
  200. }
  201. body, ioErr := ioutil.ReadAll(resp.Body)
  202. if ioErr != nil {
  203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  205. return
  206. }
  207. var respJSON map[string]interface{}
  208. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  211. return
  212. }
  213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  214. result, _ := json.Marshal(respJSON)
  215. fmt.Println("log")
  216. fmt.Println(string(result))
  217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  218. utils.ErrorLog("解析失败:%v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. if res.Infcode == 0 {
  223. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  224. if err == gorm.ErrRecordNotFound {
  225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  226. return
  227. } else if err != nil {
  228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  229. return
  230. } else {
  231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  233. infoStr := string(Iinfos)
  234. idetinfoStr := string(Idetinfos)
  235. psn := &models.HisPsn{
  236. PsnNo: res.Output.Baseinfo.PsnNo,
  237. Age: res.Output.Baseinfo.Age,
  238. PatientId: patient.ID,
  239. Certno: res.Output.Baseinfo.Certno,
  240. Brdy: res.Output.Baseinfo.Brdy,
  241. Gend: res.Output.Baseinfo.Gend,
  242. Naty: res.Output.Baseinfo.Naty,
  243. PsnCertType: res.Output.Baseinfo.PsnCertType,
  244. PsnName: res.Output.Baseinfo.PsnName,
  245. Idetinfo: idetinfoStr,
  246. Insuinfo: infoStr,
  247. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  248. }
  249. service.CreateHisPsn(psn)
  250. c.ServeSuccessJSON(map[string]interface{}{
  251. "patient": patient,
  252. "number": res.Output.Baseinfo.Certno,
  253. })
  254. }
  255. } else {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  257. return
  258. }
  259. } else {
  260. if initFlag == 0 {
  261. c.TestGetBasBaseInit()
  262. }
  263. basStr := c.GetBasBaseInfo()
  264. if len(basStr) == 0 {
  265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  266. return
  267. }
  268. fmt.Println(basStr)
  269. bas := strings.Split(basStr, "|")
  270. basNumber := bas[1]
  271. fmt.Println(basNumber)
  272. card_sn := bas[3]
  273. fmt.Println(card_sn)
  274. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  275. var dat map[string]interface{}
  276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  277. fmt.Println(dat)
  278. } else {
  279. fmt.Println(err)
  280. }
  281. userJSONBytes, _ := json.Marshal(dat)
  282. var res ResultTwo
  283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  284. utils.ErrorLog("解析失败:%v", err)
  285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  286. return
  287. }
  288. if res.Infcode == 0 {
  289. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  290. if err == gorm.ErrRecordNotFound {
  291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  292. return
  293. } else if err != nil {
  294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  295. return
  296. } else {
  297. c.ServeSuccessJSON(map[string]interface{}{
  298. "patient": patient,
  299. "number": basNumber,
  300. })
  301. }
  302. } else {
  303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  304. return
  305. }
  306. break
  307. }
  308. case 2:
  309. SFZStr := c.GetSFZBaseInfo()
  310. id_card_str := strings.Split(SFZStr, "^")
  311. id_card_number := id_card_str[0]
  312. card_sn := ""
  313. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  314. var dat map[string]interface{}
  315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  316. fmt.Println(dat)
  317. } else {
  318. fmt.Println(err)
  319. }
  320. userJSONBytes, _ := json.Marshal(dat)
  321. var res ResultTwo
  322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  323. utils.ErrorLog("解析失败:%v", err)
  324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  325. return
  326. }
  327. if res.Infcode == 0 {
  328. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  329. if err == gorm.ErrRecordNotFound {
  330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  331. return
  332. } else if err != nil {
  333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  334. return
  335. } else {
  336. c.ServeSuccessJSON(map[string]interface{}{
  337. "patient": patient,
  338. "number": id_card_number,
  339. })
  340. }
  341. } else {
  342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  343. return
  344. }
  345. break
  346. case 3:
  347. break
  348. }
  349. }
  350. var initFlag int64 = 0
  351. func (c *HisApiController) TestGetBasBaseInit() {
  352. DllDef := syscall.MustLoadDLL("SSCard.dll")
  353. Iinit := DllDef.MustFindProc("Init")
  354. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  355. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  356. if ret != 0 {
  357. fmt.Println("SSCard的报错原因:", err)
  358. fmt.Println("SSCard的运算结果为:", ret)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  360. return
  361. }
  362. result := int(ret)
  363. fmt.Println("SSCard的运算结果为1:", result)
  364. initFlag = 1
  365. return
  366. }
  367. func (c *HisApiController) GetSFZBaseInfo() string {
  368. DllDef := syscall.MustLoadDLL("SSCard.dll")
  369. readCard := DllDef.MustFindProc("ReadSFZ")
  370. if readCard == nil {
  371. fmt.Println("readcard is nil")
  372. readCard = DllDef.MustFindProc("ReadSFZ")
  373. }
  374. str := make([]byte, 256)
  375. str1 := make([]byte, 256)
  376. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  377. fmt.Println(r)
  378. return string(str)
  379. }
  380. func (c *HisApiController) GetBasBaseInfo() string {
  381. DllDef := syscall.MustLoadDLL("SSCard.dll")
  382. readCard := DllDef.MustFindProc("ReadCardBas")
  383. if readCard == nil {
  384. fmt.Println("readcard is nil")
  385. readCard = DllDef.MustFindProc("ReadCardBas")
  386. }
  387. str := make([]byte, 1024)
  388. str1 := make([]byte, 1024)
  389. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  390. fmt.Println(string(str1))
  391. fmt.Println(string(str))
  392. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  393. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  394. if ret2 != 0 {
  395. return ""
  396. }
  397. return string(str)
  398. }
  399. func prttostr(vcode uintptr) string {
  400. var vbyte []byte
  401. for i := 0; i < 10; i++ {
  402. sbyte := *((*byte)(unsafe.Pointer(vcode)))
  403. if sbyte == 0 {
  404. break
  405. }
  406. vbyte = append(vbyte, sbyte)
  407. vcode += 1
  408. }
  409. return string(vbyte)
  410. }
  411. type CustomFundPay struct {
  412. FundPayType string `json:"fund_pay_type"`
  413. FundPayamt float64 `json:"fund_payamt"`
  414. }
  415. func (c *HisApiController) GetSettleList() {
  416. order_id, _ := c.GetInt64("order_id")
  417. admin_user_id, _ := c.GetInt64("admin_user_id")
  418. order, _ := service.GetHisOrderByIDTwo(order_id)
  419. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  420. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  421. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  422. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  423. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  424. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  425. if order.ID == 0 {
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  427. return
  428. }
  429. struct4101 := service.Struct4101{
  430. PsnNo: order.PsnNo,
  431. MdtrtId: order.MdtrtId,
  432. SetlId: order.SetlId,
  433. PsnName: order.PsnName,
  434. Gend: order.Gend,
  435. Brdy: his.Brdy,
  436. Age: his.Age,
  437. Naty: order.Naty,
  438. PatnCertType: "01",
  439. Certno: order.Certno,
  440. Prfs: "90",
  441. ConerName: roles[0].UserName,
  442. PatnRlts: "99",
  443. ConerAddr: miConfig.OrgName,
  444. ConerTel: admin.Mobile,
  445. HiType: order.Insutype,
  446. Insuplc: miConfig.InsuplcAdmdvs,
  447. MaindiagFlag: "1",
  448. BillCode: order.FaPiaoCode,
  449. BillNo: order.FaPiaoNumber,
  450. BizSn: order.Number,
  451. PsnSelfPay: order.PsnPartAmt,
  452. PsnOwnPay: order.PsnPartAmt,
  453. AcctPay: order.AcctPay,
  454. PsnCashpay: order.PsnCashPay,
  455. HiPaymtd: "1",
  456. Hsorg: miConfig.InsuplcAdmdvs,
  457. HsorgOpter: miConfig.InsuplcAdmdvs,
  458. MedinsFillPsn: curRoles.UserName,
  459. MedinsFillDept: depart.Name,
  460. IptMedType: "2",
  461. }
  462. struct4101.SetlBegnDate = order.SetlTime
  463. struct4101.SetlEndDate = order.SetlTime
  464. //if order.SettleType == 1 {
  465. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  466. // dateStr := t.Format("2006-01-02")
  467. // struct4101.SetlBegnDate = dateStr
  468. // struct4101.SetlEndDate = dateStr
  469. //} else {
  470. // t := time.Unix(int64(order.SettleStartTime), 0)
  471. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  472. // dateStartStr := t.Format("2006-01-02")
  473. // dateEndStr := t2.Format("2006-01-02")
  474. // struct4101.SetlBegnDate = dateStartStr
  475. // struct4101.SetlEndDate = dateEndStr
  476. //}
  477. var rf []CustomFundPay
  478. json.Unmarshal([]byte(order.SetlDetail), &rf)
  479. var tempFunPays []service.CustomStruct
  480. for _, item := range rf {
  481. var tempFunPay service.CustomStruct
  482. tempFunPay.FundPayamt = item.FundPayamt
  483. tempFunPay.FundPayType = item.FundPayType
  484. tempFunPays = append(tempFunPays, tempFunPay)
  485. }
  486. struct4101.CustomStruct = tempFunPays
  487. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  488. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  489. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  490. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  491. var config []*models.HisXtDiagnoseConfig
  492. for _, item := range diagnosis_ids {
  493. id, _ := strconv.ParseInt(item, 10, 64)
  494. diagnosisConfig, _ := service.FindDiagnoseById(id)
  495. config = append(config, &diagnosisConfig)
  496. }
  497. for _, item := range config {
  498. var tempOpspdiseinfo service.OpspdiseinfoStruct
  499. tempOpspdiseinfo.DiagCode = item.CountryCode
  500. tempOpspdiseinfo.DiagName = item.CountryContentName
  501. tempOpspdiseinfo.MaindiagFlag = "1"
  502. tempOpspdiseinfo.OprnOprtCode = ""
  503. tempOpspdiseinfo.OprnOprtName = ""
  504. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  505. }
  506. sickConfigTwo, _ := service.FindSickById(his.SickType)
  507. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  508. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  509. tempOpspdiseinfo2.MaindiagFlag = "2"
  510. tempOpspdiseinfo2.OprnOprtCode = ""
  511. tempOpspdiseinfo2.OprnOprtName = ""
  512. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  513. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  514. var iteminfo service.IteminfoStruct
  515. var bedCostTotal float64 = 0 //床位总费
  516. var bedCostSelfTotal float64 = 0 //床位自费
  517. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  518. var operationCostTotal float64 = 0 //手术费
  519. var operationCostSelfTotal float64 = 0 //手术费
  520. var operationCostPartSelfTotal float64 = 0 //手术费
  521. var otherCostTotal float64 = 0 //其他费用
  522. var otherCostSelfTotal float64 = 0 //其他费用
  523. var otherCostPartSelfTotal float64 = 0 //其他费用
  524. var materialCostTotal float64 = 0 //材料费
  525. var materialCostSelfTotal float64 = 0 //材料费
  526. var materialCostPartSelfTotal float64 = 0 //材料费
  527. var westernMedicineCostTotal float64 = 0 //西药费
  528. var westernMedicineCostSelfTotal float64 = 0 //西药费
  529. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  530. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  531. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  532. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  533. var checkCostTotal float64 = 0 //检查费
  534. var checkCostSelfTotal float64 = 0 //检查费
  535. var checkCostPartSelfTotal float64 = 0 //检查费
  536. var laboratoryCostTotal float64 = 0 //化验费
  537. var laboratoryCostSelfTotal float64 = 0 //化验费
  538. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  539. var treatCostTotal float64 = 0 //治疗费用
  540. var treatCostSelfTotal float64 = 0 //治疗费用
  541. var treatCostPartSelfTotal float64 = 0 //治疗费用
  542. decimal.DivisionPrecision = 2
  543. var bed_fulamt_ownpay_amt float64 = 0
  544. var operation_fulamt_ownpay_amt float64 = 0
  545. var other_fulamt_ownpay_amt float64 = 0
  546. var westernMedicine_fulamt_ownpay_amt float64 = 0
  547. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  548. var check_fulamt_ownpay_amt float64 = 0
  549. var material_fulamt_ownpay_amt float64 = 0
  550. var laboratory_fulamt_ownpay_amt float64 = 0
  551. var treat_fulamt_ownpay_amt float64 = 0
  552. var bed_claa_sunmfee float64 = 0
  553. var bed_clab_amt float64 = 0
  554. var bed_other_amt float64 = 0
  555. var operation_claa_sunmfee float64 = 0
  556. var operation_clab_amt float64 = 0
  557. var operation_other_amt float64 = 0
  558. var other_claa_sunmfee float64 = 0
  559. var other_clab_amt float64 = 0
  560. var other_other_amt float64 = 0
  561. var westernMedicine_claa_sunmfee float64 = 0
  562. var westernMedicine_clab_amt float64 = 0
  563. var westernMedicine_other_amt float64 = 0
  564. var chineseTraditional_claa_sunmfee float64 = 0
  565. var chineseTraditional_clab_amt float64 = 0
  566. var chineseTraditional_other_amt float64 = 0
  567. var check_claa_sunmfee float64 = 0
  568. var check_clab_amt float64 = 0
  569. var check_other_amt float64 = 0
  570. var material_claa_sunmfee float64 = 0
  571. var material_clab_amt float64 = 0
  572. var material_other_amt float64 = 0
  573. var laboratory_claa_sunmfee float64 = 0
  574. var laboratory_clab_amt float64 = 0
  575. var laboratory_other_amt float64 = 0
  576. var treat_claa_sunmfee float64 = 0
  577. var treat_clab_amt float64 = 0
  578. var treat_other_amt float64 = 0
  579. for _, item := range order.HisOrderInfo {
  580. if item.MedChrgitmType == "01" { //床位费
  581. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  582. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  583. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  584. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  585. if item.ChrgitmLv == "1" {
  586. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  587. }
  588. if item.ChrgitmLv == "2" {
  589. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  590. }
  591. if item.ChrgitmLv == "3" {
  592. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  593. }
  594. }
  595. if item.MedChrgitmType == "03" { //检查费
  596. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  597. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  598. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  599. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  600. if item.ChrgitmLv == "1" {
  601. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  602. }
  603. if item.ChrgitmLv == "2" {
  604. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  605. }
  606. if item.ChrgitmLv == "3" {
  607. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  608. }
  609. }
  610. if item.MedChrgitmType == "04" { //化验费
  611. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  612. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  613. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  614. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  615. if item.ChrgitmLv == "1" {
  616. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  617. }
  618. if item.ChrgitmLv == "2" {
  619. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  620. }
  621. if item.ChrgitmLv == "3" {
  622. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  623. }
  624. }
  625. if item.MedChrgitmType == "05" { //治疗费
  626. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  627. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  628. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  629. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  630. if item.ChrgitmLv == "1" {
  631. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  632. }
  633. if item.ChrgitmLv == "2" {
  634. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  635. }
  636. if item.ChrgitmLv == "3" {
  637. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  638. }
  639. }
  640. if item.MedChrgitmType == "06" { //手术费
  641. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  642. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  643. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  644. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  645. if item.ChrgitmLv == "1" {
  646. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  647. }
  648. if item.ChrgitmLv == "2" {
  649. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  650. }
  651. if item.ChrgitmLv == "3" {
  652. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  653. }
  654. }
  655. if item.MedChrgitmType == "08" { //材料费
  656. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  657. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  658. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  659. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  660. if item.ChrgitmLv == "1" {
  661. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  662. }
  663. if item.ChrgitmLv == "2" {
  664. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  665. }
  666. if item.ChrgitmLv == "3" {
  667. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  668. }
  669. }
  670. if item.MedChrgitmType == "09" { //西药费
  671. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  672. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  673. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  674. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  675. if item.ChrgitmLv == "1" {
  676. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  677. }
  678. if item.ChrgitmLv == "2" {
  679. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  680. }
  681. if item.ChrgitmLv == "3" {
  682. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  683. }
  684. }
  685. if item.MedChrgitmType == "11" { //中成费
  686. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  687. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  688. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  689. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  690. if item.ChrgitmLv == "1" {
  691. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  692. }
  693. if item.ChrgitmLv == "2" {
  694. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  695. }
  696. if item.ChrgitmLv == "3" {
  697. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  698. }
  699. }
  700. if item.MedChrgitmType == "14" { //其他费
  701. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  702. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  703. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  704. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  705. if item.ChrgitmLv == "1" {
  706. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  707. }
  708. if item.ChrgitmLv == "2" {
  709. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  710. }
  711. if item.ChrgitmLv == "3" {
  712. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  713. }
  714. }
  715. }
  716. var iteminfoStructs []service.IteminfoStruct
  717. if bedCostTotal != 0 {
  718. iteminfo.MedChrgitm = "01"
  719. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  720. iteminfo.Amt = bedCostTotal
  721. iteminfo.ClaaSumfee = bed_claa_sunmfee
  722. iteminfo.ClabAmt = bed_clab_amt
  723. iteminfo.OthAmt = bed_other_amt
  724. iteminfoStructs = append(iteminfoStructs, iteminfo)
  725. }
  726. if checkCostTotal != 0 {
  727. iteminfo.MedChrgitm = "03"
  728. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  729. iteminfo.Amt = checkCostTotal
  730. iteminfo.ClaaSumfee = check_claa_sunmfee
  731. iteminfo.ClabAmt = check_clab_amt
  732. iteminfo.OthAmt = check_other_amt
  733. iteminfoStructs = append(iteminfoStructs, iteminfo)
  734. }
  735. if laboratoryCostTotal != 0 {
  736. iteminfo.MedChrgitm = "04"
  737. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  738. iteminfo.Amt = laboratoryCostTotal
  739. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  740. iteminfo.ClabAmt = laboratory_clab_amt
  741. iteminfo.OthAmt = laboratory_other_amt
  742. iteminfoStructs = append(iteminfoStructs, iteminfo)
  743. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  744. }
  745. if treatCostTotal != 0 {
  746. iteminfo.MedChrgitm = "05"
  747. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  748. iteminfo.Amt = treatCostTotal
  749. iteminfo.ClaaSumfee = treat_claa_sunmfee
  750. iteminfo.ClabAmt = treat_clab_amt
  751. iteminfo.OthAmt = treat_other_amt
  752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  753. //(struct4101.IteminfoStruct, iteminfo)
  754. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  755. }
  756. if operationCostTotal != 0 {
  757. iteminfo.MedChrgitm = "06"
  758. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  759. iteminfo.Amt = operationCostTotal
  760. iteminfo.ClaaSumfee = operation_claa_sunmfee
  761. iteminfo.ClabAmt = operation_clab_amt
  762. iteminfo.OthAmt = operation_other_amt
  763. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  764. iteminfoStructs = append(iteminfoStructs, iteminfo)
  765. }
  766. if materialCostTotal != 0 {
  767. iteminfo.MedChrgitm = "08"
  768. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  769. iteminfo.Amt = materialCostTotal
  770. iteminfo.ClaaSumfee = material_claa_sunmfee
  771. iteminfo.ClabAmt = material_clab_amt
  772. iteminfo.OthAmt = material_other_amt
  773. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  774. iteminfoStructs = append(iteminfoStructs, iteminfo)
  775. }
  776. if westernMedicineCostTotal != 0 {
  777. iteminfo.MedChrgitm = "09"
  778. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  779. iteminfo.Amt = westernMedicineCostTotal
  780. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  781. iteminfo.ClabAmt = westernMedicine_clab_amt
  782. iteminfo.OthAmt = westernMedicine_other_amt
  783. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  784. iteminfoStructs = append(iteminfoStructs, iteminfo)
  785. }
  786. if chineseTraditionalMedicineCostTotal != 0 {
  787. iteminfo.MedChrgitm = "11"
  788. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  789. iteminfo.Amt = westernMedicineCostTotal
  790. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  791. iteminfo.ClabAmt = westernMedicine_clab_amt
  792. iteminfo.OthAmt = westernMedicine_other_amt
  793. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  794. iteminfoStructs = append(iteminfoStructs, iteminfo)
  795. }
  796. if otherCostTotal != 0 {
  797. iteminfo.MedChrgitm = "14"
  798. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  799. iteminfo.Amt = otherCostTotal
  800. iteminfo.ClaaSumfee = other_claa_sunmfee
  801. iteminfo.ClabAmt = other_clab_amt
  802. iteminfo.OthAmt = other_other_amt
  803. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  805. }
  806. struct4101.IteminfoStruct = iteminfoStructs
  807. struct4101.Ntly = "中国"
  808. struct4101.AdmCaty = "A03.06"
  809. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  810. fmt.Println(result)
  811. var dat map[string]interface{}
  812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  813. fmt.Println(dat)
  814. } else {
  815. fmt.Println(err)
  816. }
  817. userJSONBytes, _ := json.Marshal(dat)
  818. var res ResultSeventeen
  819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  820. utils.ErrorLog("解析失败:%v", err)
  821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  822. return
  823. }
  824. if res.Infcode != 0 {
  825. c.ServeSuccessJSON(map[string]interface{}{
  826. "failed_code": -10,
  827. "msg": res.ErrMsg,
  828. })
  829. return
  830. } else {
  831. hisFundSettleListResult := &models.HisFundSettleListResult{
  832. Number: res.Output.SetlListId,
  833. Status: 1,
  834. Ctime: time.Now().Unix(),
  835. Mtime: time.Now().Unix(),
  836. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  837. IsUpload: 1,
  838. OrderId: order_id,
  839. }
  840. service.CreateUploadRecord(hisFundSettleListResult)
  841. c.ServeSuccessJSON(map[string]interface{}{
  842. "msg": "上传成功",
  843. "result": hisFundSettleListResult,
  844. })
  845. return
  846. }
  847. }
  848. func (c *HisApiController) GetBatchSettleList() {
  849. org_id, _ := beego.AppConfig.Int64("org_id")
  850. //stage, _ := c.GetInt64("stage")
  851. orders, _ := service.GetAllHisOrder(org_id)
  852. for _, item := range orders {
  853. order_id := item.ID
  854. order, _ := service.GetHisOrderByIDTwo(order_id)
  855. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  856. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  857. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  858. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  859. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  860. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  861. if order.ID == 0 {
  862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  863. return
  864. }
  865. if his.BalanceAccountsType == 2 {
  866. continue
  867. }
  868. struct4101 := service.Struct4101{
  869. PsnNo: order.PsnNo,
  870. MdtrtId: order.MdtrtId,
  871. SetlId: order.SetlId,
  872. PsnName: order.PsnName,
  873. Gend: order.Gend,
  874. Brdy: his.Brdy,
  875. Age: his.Age,
  876. Naty: order.Naty,
  877. PatnCertType: "01",
  878. Certno: order.Certno,
  879. Prfs: "90",
  880. ConerName: roles[0].UserName,
  881. PatnRlts: "99",
  882. ConerAddr: miConfig.OrgName,
  883. ConerTel: admin.Mobile,
  884. HiType: order.Insutype,
  885. Insuplc: miConfig.InsuplcAdmdvs,
  886. MaindiagFlag: "1",
  887. BillCode: order.FaPiaoCode,
  888. BillNo: order.FaPiaoNumber,
  889. BizSn: order.Number,
  890. PsnSelfPay: order.PsnPartAmt,
  891. PsnOwnPay: order.PsnPartAmt,
  892. AcctPay: order.AcctPay,
  893. PsnCashpay: order.PsnCashPay,
  894. HiPaymtd: "1",
  895. Hsorg: miConfig.InsuplcAdmdvs,
  896. HsorgOpter: miConfig.InsuplcAdmdvs,
  897. MedinsFillPsn: curRoles.UserName,
  898. MedinsFillDept: depart.Name,
  899. IptMedType: "2",
  900. }
  901. struct4101.SetlBegnDate = order.SetlTime
  902. struct4101.SetlEndDate = order.SetlTime
  903. //if order.SettleType == 1 {
  904. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  905. // dateStr := t.Format("2006-01-02")
  906. // struct4101.SetlBegnDate = dateStr
  907. // struct4101.SetlEndDate = dateStr
  908. //} else {
  909. // t := time.Unix(int64(order.SettleStartTime), 0)
  910. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  911. // dateStartStr := t.Format("2006-01-02")
  912. // dateEndStr := t2.Format("2006-01-02")
  913. // struct4101.SetlBegnDate = dateStartStr
  914. // struct4101.SetlEndDate = dateEndStr
  915. //}
  916. var rf []CustomFundPay
  917. json.Unmarshal([]byte(order.SetlDetail), &rf)
  918. var tempFunPays []service.CustomStruct
  919. var tempFunPay610100 service.CustomStruct
  920. for _, item := range rf {
  921. if item.FundPayType == "610100" {
  922. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  923. tempFunPay610100.FundPayType = item.FundPayType
  924. } else {
  925. var tempFunPay service.CustomStruct
  926. tempFunPay.FundPayamt = item.FundPayamt
  927. tempFunPay.FundPayType = item.FundPayType
  928. tempFunPays = append(tempFunPays, tempFunPay)
  929. }
  930. }
  931. tempFunPays = append(tempFunPays, tempFunPay610100)
  932. struct4101.CustomStruct = tempFunPays
  933. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  934. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  935. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  936. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  937. var config []*models.HisXtDiagnoseConfig
  938. for _, item := range diagnosis_ids {
  939. id, _ := strconv.ParseInt(item, 10, 64)
  940. diagnosisConfig, _ := service.FindDiagnoseById(id)
  941. config = append(config, &diagnosisConfig)
  942. }
  943. for _, item := range config {
  944. var tempOpspdiseinfo service.OpspdiseinfoStruct
  945. tempOpspdiseinfo.DiagCode = item.CountryCode
  946. tempOpspdiseinfo.DiagName = item.CountryContentName
  947. tempOpspdiseinfo.MaindiagFlag = "1"
  948. tempOpspdiseinfo.OprnOprtCode = ""
  949. tempOpspdiseinfo.OprnOprtName = ""
  950. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  951. }
  952. sickConfigTwo, _ := service.FindSickById(his.SickType)
  953. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  954. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  955. tempOpspdiseinfo2.MaindiagFlag = "2"
  956. tempOpspdiseinfo2.OprnOprtCode = ""
  957. tempOpspdiseinfo2.OprnOprtName = ""
  958. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  959. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  960. var iteminfo service.IteminfoStruct
  961. var bedCostTotal float64 = 0 //床位总费
  962. var bedCostSelfTotal float64 = 0 //床位自费
  963. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  964. var examineCostTotal float64 = 0 //诊查总费
  965. var examineCostSelfTotal float64 = 0 //诊查自费
  966. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  967. var nursingCostTotal float64 = 0 //护理总费
  968. var nursingCostSelfTotal float64 = 0 //护理自费
  969. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  970. var chineseMedicineCostTotal float64 = 0 //中成药
  971. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  972. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  973. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  974. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  975. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  976. var registerCostTotal float64 = 0 //一般诊疗费
  977. var registerCostSelfTotal float64 = 0 //一般诊疗费
  978. var registerPartSelfTotal float64 = 0 //一般诊疗费
  979. var operationCostTotal float64 = 0 //手术费
  980. var operationCostSelfTotal float64 = 0 //手术费
  981. var operationCostPartSelfTotal float64 = 0 //手术费
  982. var otherCostTotal float64 = 0 //其他费用
  983. var otherCostSelfTotal float64 = 0 //其他费用
  984. var otherCostPartSelfTotal float64 = 0 //其他费用
  985. var materialCostTotal float64 = 0 //材料费
  986. var materialCostSelfTotal float64 = 0 //材料费
  987. var materialCostPartSelfTotal float64 = 0 //材料费
  988. var westernMedicineCostTotal float64 = 0 //西药费
  989. var westernMedicineCostSelfTotal float64 = 0 //西药费
  990. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  991. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  992. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  993. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  994. var checkCostTotal float64 = 0 //检查费
  995. var checkCostSelfTotal float64 = 0 //检查费
  996. var checkCostPartSelfTotal float64 = 0 //检查费
  997. var laboratoryCostTotal float64 = 0 //化验费
  998. var laboratoryCostSelfTotal float64 = 0 //化验费
  999. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1000. var treatCostTotal float64 = 0 //治疗费用
  1001. var treatCostSelfTotal float64 = 0 //治疗费用
  1002. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1003. decimal.DivisionPrecision = 2
  1004. var bed_fulamt_ownpay_amt float64 = 0
  1005. var examine_fulamt_ownpay_amt float64 = 0
  1006. var nursing_fulamt_ownpay_amt float64 = 0
  1007. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1008. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1009. var register_fulamt_ownpay_amt float64 = 0
  1010. var operation_fulamt_ownpay_amt float64 = 0
  1011. var other_fulamt_ownpay_amt float64 = 0
  1012. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1013. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1014. var check_fulamt_ownpay_amt float64 = 0
  1015. var material_fulamt_ownpay_amt float64 = 0
  1016. var laboratory_fulamt_ownpay_amt float64 = 0
  1017. var treat_fulamt_ownpay_amt float64 = 0
  1018. var bed_claa_sunmfee float64 = 0
  1019. var bed_clab_amt float64 = 0
  1020. var bed_other_amt float64 = 0
  1021. var examine_claa_sunmfee float64 = 0
  1022. var examine_clab_amt float64 = 0
  1023. var examine_other_amt float64 = 0
  1024. var nursing_claa_sunmfee float64 = 0
  1025. var nursing_clab_amt float64 = 0
  1026. var nursing_other_amt float64 = 0
  1027. var chinese_medicine_claa_sunmfee float64 = 0
  1028. var chinese_medicine_clab_amt float64 = 0
  1029. var chinese_medicine_other_amt float64 = 0
  1030. var commonly_treatment_claa_sunmfee float64 = 0
  1031. var commonly_treatment_clab_amt float64 = 0
  1032. var commonly_treatment_other_amt float64 = 0
  1033. var operation_claa_sunmfee float64 = 0
  1034. var operation_clab_amt float64 = 0
  1035. var operation_other_amt float64 = 0
  1036. var other_claa_sunmfee float64 = 0
  1037. var other_clab_amt float64 = 0
  1038. var other_other_amt float64 = 0
  1039. var westernMedicine_claa_sunmfee float64 = 0
  1040. var westernMedicine_clab_amt float64 = 0
  1041. var westernMedicine_other_amt float64 = 0
  1042. var chineseTraditional_claa_sunmfee float64 = 0
  1043. var chineseTraditional_clab_amt float64 = 0
  1044. var chineseTraditional_other_amt float64 = 0
  1045. var check_claa_sunmfee float64 = 0
  1046. var check_clab_amt float64 = 0
  1047. var check_other_amt float64 = 0
  1048. var material_claa_sunmfee float64 = 0
  1049. var material_clab_amt float64 = 0
  1050. var material_other_amt float64 = 0
  1051. var laboratory_claa_sunmfee float64 = 0
  1052. var laboratory_clab_amt float64 = 0
  1053. var laboratory_other_amt float64 = 0
  1054. var treat_claa_sunmfee float64 = 0
  1055. var treat_clab_amt float64 = 0
  1056. var treat_other_amt float64 = 0
  1057. var register_claa_sunmfee float64 = 0
  1058. var register_clab_amt float64 = 0
  1059. var register_other_amt float64 = 0
  1060. for _, item := range order.HisOrderInfo {
  1061. if item.MedChrgitmType == "01" { //床位费
  1062. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1063. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1064. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1065. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1066. if item.ChrgitmLv == "1" {
  1067. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1068. }
  1069. if item.ChrgitmLv == "2" {
  1070. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1071. }
  1072. if item.ChrgitmLv == "3" {
  1073. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1074. }
  1075. }
  1076. if item.MedChrgitmType == "02" { //诊查
  1077. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1078. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1079. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1080. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1081. if item.ChrgitmLv == "1" {
  1082. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1083. }
  1084. if item.ChrgitmLv == "2" {
  1085. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1086. }
  1087. if item.ChrgitmLv == "3" {
  1088. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1089. }
  1090. }
  1091. if item.MedChrgitmType == "03" { //检查费
  1092. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1093. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1094. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1095. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1096. if item.ChrgitmLv == "1" {
  1097. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1098. }
  1099. if item.ChrgitmLv == "2" {
  1100. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1101. }
  1102. if item.ChrgitmLv == "3" {
  1103. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1104. }
  1105. }
  1106. if item.MedChrgitmType == "04" { //化验费
  1107. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1108. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1109. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1110. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1111. if item.ChrgitmLv == "1" {
  1112. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1113. }
  1114. if item.ChrgitmLv == "2" {
  1115. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1116. }
  1117. if item.ChrgitmLv == "3" {
  1118. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1119. }
  1120. }
  1121. if item.MedChrgitmType == "05" { //治疗费
  1122. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1123. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1124. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1125. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1126. if item.ChrgitmLv == "1" {
  1127. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1128. }
  1129. if item.ChrgitmLv == "2" {
  1130. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1131. }
  1132. if item.ChrgitmLv == "3" {
  1133. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1134. }
  1135. }
  1136. if item.MedChrgitmType == "06" { //手术费
  1137. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1138. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1139. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1140. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1141. if item.ChrgitmLv == "1" {
  1142. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1143. }
  1144. if item.ChrgitmLv == "2" {
  1145. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1146. }
  1147. if item.ChrgitmLv == "3" {
  1148. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1149. }
  1150. }
  1151. if item.MedChrgitmType == "07" { //手术费
  1152. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1153. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1154. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1155. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1156. if item.ChrgitmLv == "1" {
  1157. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1158. }
  1159. if item.ChrgitmLv == "2" {
  1160. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1161. }
  1162. if item.ChrgitmLv == "3" {
  1163. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1164. }
  1165. }
  1166. if item.MedChrgitmType == "08" { //材料费
  1167. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1168. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1169. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1170. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1171. if item.ChrgitmLv == "1" {
  1172. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1173. }
  1174. if item.ChrgitmLv == "2" {
  1175. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1176. }
  1177. if item.ChrgitmLv == "3" {
  1178. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1179. }
  1180. }
  1181. if item.MedChrgitmType == "09" { //西药费
  1182. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1183. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1184. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1185. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1186. if item.ChrgitmLv == "1" {
  1187. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1188. }
  1189. if item.ChrgitmLv == "2" {
  1190. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1191. }
  1192. if item.ChrgitmLv == "3" {
  1193. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1194. }
  1195. }
  1196. if item.MedChrgitmType == "10" { //中药饮片
  1197. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1198. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1199. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1200. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1201. if item.ChrgitmLv == "1" {
  1202. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1203. }
  1204. if item.ChrgitmLv == "2" {
  1205. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1206. }
  1207. if item.ChrgitmLv == "3" {
  1208. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1209. }
  1210. }
  1211. if item.MedChrgitmType == "11" { //中成费
  1212. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1213. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1214. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1215. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1216. if item.ChrgitmLv == "1" {
  1217. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1218. }
  1219. if item.ChrgitmLv == "2" {
  1220. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1221. }
  1222. if item.ChrgitmLv == "3" {
  1223. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1224. }
  1225. }
  1226. if item.MedChrgitmType == "12" { //中成费
  1227. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1228. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1229. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1230. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1231. if item.ChrgitmLv == "1" {
  1232. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1233. }
  1234. if item.ChrgitmLv == "2" {
  1235. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1236. }
  1237. if item.ChrgitmLv == "3" {
  1238. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1239. }
  1240. }
  1241. if item.MedChrgitmType == "13" { //中成费
  1242. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1243. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1244. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1245. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1246. if item.ChrgitmLv == "1" {
  1247. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1248. }
  1249. if item.ChrgitmLv == "2" {
  1250. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1251. }
  1252. if item.ChrgitmLv == "3" {
  1253. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1254. }
  1255. }
  1256. if item.MedChrgitmType == "14" { //其他费
  1257. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1258. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1259. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1260. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1261. if item.ChrgitmLv == "1" {
  1262. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1263. }
  1264. if item.ChrgitmLv == "2" {
  1265. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1266. }
  1267. if item.ChrgitmLv == "3" {
  1268. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1269. }
  1270. }
  1271. }
  1272. var iteminfoStructs []service.IteminfoStruct
  1273. if bedCostTotal != 0 {
  1274. iteminfo.MedChrgitm = "01"
  1275. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1276. iteminfo.Amt = bedCostTotal
  1277. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1278. iteminfo.ClabAmt = bed_clab_amt
  1279. iteminfo.OthAmt = bed_other_amt
  1280. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1281. }
  1282. if examineCostTotal != 0 {
  1283. iteminfo.MedChrgitm = "02"
  1284. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1285. iteminfo.Amt = examineCostTotal
  1286. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1287. iteminfo.ClabAmt = examine_clab_amt
  1288. iteminfo.OthAmt = examine_other_amt
  1289. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1290. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1291. }
  1292. if checkCostTotal != 0 {
  1293. iteminfo.MedChrgitm = "03"
  1294. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1295. iteminfo.Amt = checkCostTotal
  1296. iteminfo.ClaaSumfee = check_claa_sunmfee
  1297. iteminfo.ClabAmt = check_clab_amt
  1298. iteminfo.OthAmt = check_other_amt
  1299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1300. }
  1301. if laboratoryCostTotal != 0 {
  1302. iteminfo.MedChrgitm = "04"
  1303. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1304. iteminfo.Amt = laboratoryCostTotal
  1305. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1306. iteminfo.ClabAmt = laboratory_clab_amt
  1307. iteminfo.OthAmt = laboratory_other_amt
  1308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1309. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1310. }
  1311. if treatCostTotal != 0 {
  1312. iteminfo.MedChrgitm = "05"
  1313. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1314. iteminfo.Amt = treatCostTotal
  1315. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1316. iteminfo.ClabAmt = treat_clab_amt
  1317. iteminfo.OthAmt = treat_other_amt
  1318. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1319. //(struct4101.IteminfoStruct, iteminfo)
  1320. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1321. }
  1322. if operationCostTotal != 0 {
  1323. iteminfo.MedChrgitm = "06"
  1324. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1325. iteminfo.Amt = operationCostTotal
  1326. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1327. iteminfo.ClabAmt = operation_clab_amt
  1328. iteminfo.OthAmt = operation_other_amt
  1329. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1330. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1331. }
  1332. if nursingCostTotal != 0 {
  1333. iteminfo.MedChrgitm = "07"
  1334. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1335. iteminfo.Amt = nursingCostTotal
  1336. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1337. iteminfo.ClabAmt = nursing_clab_amt
  1338. iteminfo.OthAmt = nursing_other_amt
  1339. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1340. }
  1341. if materialCostTotal != 0 {
  1342. iteminfo.MedChrgitm = "08"
  1343. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1344. iteminfo.Amt = materialCostTotal
  1345. iteminfo.ClaaSumfee = material_claa_sunmfee
  1346. iteminfo.ClabAmt = material_clab_amt
  1347. iteminfo.OthAmt = material_other_amt
  1348. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1349. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1350. }
  1351. if westernMedicineCostTotal != 0 {
  1352. iteminfo.MedChrgitm = "09"
  1353. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1354. iteminfo.Amt = westernMedicineCostTotal
  1355. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1356. iteminfo.ClabAmt = westernMedicine_clab_amt
  1357. iteminfo.OthAmt = westernMedicine_other_amt
  1358. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1359. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1360. }
  1361. if chineseMedicineCostTotal != 0 {
  1362. iteminfo.MedChrgitm = "10"
  1363. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1364. iteminfo.Amt = chineseMedicineCostTotal
  1365. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1366. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1367. iteminfo.OthAmt = chinese_medicine_other_amt
  1368. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1369. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1370. }
  1371. if chineseTraditionalMedicineCostTotal != 0 {
  1372. iteminfo.MedChrgitm = "11"
  1373. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1374. iteminfo.Amt = westernMedicineCostTotal
  1375. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1376. iteminfo.ClabAmt = westernMedicine_clab_amt
  1377. iteminfo.OthAmt = westernMedicine_other_amt
  1378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1380. }
  1381. if commonlyTreatmentCostTotal != 0 {
  1382. iteminfo.MedChrgitm = "12"
  1383. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  1384. iteminfo.Amt = commonlyTreatmentCostTotal
  1385. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  1386. iteminfo.ClabAmt = commonly_treatment_clab_amt
  1387. iteminfo.OthAmt = commonly_treatment_other_amt
  1388. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1389. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1390. }
  1391. if registerCostTotal != 0 {
  1392. iteminfo.MedChrgitm = "13"
  1393. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  1394. iteminfo.Amt = registerCostTotal
  1395. iteminfo.ClaaSumfee = register_claa_sunmfee
  1396. iteminfo.ClabAmt = register_clab_amt
  1397. iteminfo.OthAmt = register_other_amt
  1398. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1399. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1400. }
  1401. if otherCostTotal != 0 {
  1402. iteminfo.MedChrgitm = "14"
  1403. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1404. iteminfo.Amt = otherCostTotal
  1405. iteminfo.ClaaSumfee = other_claa_sunmfee
  1406. iteminfo.ClabAmt = other_clab_amt
  1407. iteminfo.OthAmt = other_other_amt
  1408. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1409. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1410. }
  1411. struct4101.IteminfoStruct = iteminfoStructs
  1412. struct4101.Ntly = "中国"
  1413. struct4101.AdmCaty = "A03.06"
  1414. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1415. fmt.Println(result)
  1416. var dat map[string]interface{}
  1417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1418. fmt.Println(dat)
  1419. } else {
  1420. fmt.Println(err)
  1421. }
  1422. userJSONBytes, _ := json.Marshal(dat)
  1423. var res ResultSeventeen
  1424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1425. utils.ErrorLog("解析失败:%v", err)
  1426. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1427. adminUser := c.GetAdminUserInfo()
  1428. errlog := &models.HisOrderError{
  1429. UserOrgId: adminUser.CurrentOrgId,
  1430. Ctime: time.Now().Unix(),
  1431. Mtime: time.Now().Unix(),
  1432. ErrMsg: res.ErrMsg + "解析失败",
  1433. Status: 1,
  1434. PatientId: order_id,
  1435. Stage: 40,
  1436. }
  1437. service.CreateErrMsgLog(errlog)
  1438. continue
  1439. }
  1440. if res.Infcode != 0 {
  1441. adminUser := c.GetAdminUserInfo()
  1442. errlog := &models.HisOrderError{
  1443. UserOrgId: adminUser.CurrentOrgId,
  1444. Ctime: time.Now().Unix(),
  1445. Mtime: time.Now().Unix(),
  1446. ErrMsg: res.ErrMsg,
  1447. Status: 1,
  1448. PatientId: order_id,
  1449. Stage: 40,
  1450. }
  1451. service.CreateErrMsgLog(errlog)
  1452. continue
  1453. } else {
  1454. hisFundSettleListResult := &models.HisFundSettleListResult{
  1455. Number: res.Output.SetlListId,
  1456. Status: 1,
  1457. Ctime: time.Now().Unix(),
  1458. Mtime: time.Now().Unix(),
  1459. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1460. IsUpload: 1,
  1461. OrderId: order_id,
  1462. }
  1463. service.CreateUploadRecord(hisFundSettleListResult)
  1464. continue
  1465. }
  1466. }
  1467. }
  1468. //func (c *HisApiController) TestPay() {
  1469. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1470. // readCards := DllDef2.MustFindProc("BankTrans")
  1471. // inputData := make(map[string]interface{})
  1472. // inputData["transId"] = "05"
  1473. // inputData["amount"] = "0.01"
  1474. // inputData["traceNo"] = "20210227093601325405377"
  1475. // inputData["cardNo"] = "F36084348"
  1476. // inputData["id"] = "44022919620927046X"
  1477. // //jsonStr := `
  1478. // // {
  1479. // // "transId": "05",
  1480. // // "amount":"1.00",
  1481. // // "traceNo":"20210227093601325405377",
  1482. // // "cardNo":"F36084348",
  1483. // // "id":"44022919620927046X"
  1484. // //
  1485. // // }
  1486. // //`
  1487. //
  1488. // bytes_arr, _ := json.Marshal(inputData)
  1489. // str3 := make([]byte, 256)
  1490. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  1491. // fmt.Println(":", string(str3))
  1492. //
  1493. // if err4 != nil {
  1494. // fmt.Println("SSCard的运算结果为:", ret4)
  1495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1496. // return
  1497. // }
  1498. //
  1499. //}
  1500. //func (c *HisApiController) TestGetBasBaseInfo() {
  1501. //
  1502. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1503. // //fmt.Println(result)
  1504. // //cs1 := C.CString("")
  1505. // //cs2 := C.CString("")
  1506. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  1507. // //fmt.Println(cs1)
  1508. // //fmt.Println(cs2)
  1509. // //C.free(unsafe.Pointer(cs1))
  1510. // //C.free(unsafe.Pointer(cs2))
  1511. //
  1512. // //
  1513. //
  1514. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1515. // Iinit := DllDef.MustFindProc("Init")
  1516. // readCard := DllDef.MustFindProc("ReadCardBas")
  1517. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1518. // if ret != 0 {
  1519. // fmt.Println("SSCard的报错原因:", err)
  1520. // fmt.Println("SSCard的运算结果为:", ret)
  1521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1522. // return
  1523. // }
  1524. //
  1525. // result := int(ret)
  1526. // fmt.Println("SSCard的运算结果为1:", result)
  1527. //
  1528. // //path := ""
  1529. // //bytePath := []byte( "\x00")
  1530. // //bytePath2 := []byte( "\x00")
  1531. // //ssss
  1532. //
  1533. // str := make([]byte, 256)
  1534. // str1 := make([]byte, 256)
  1535. // s2 := []byte(string(str))
  1536. // s3 := []byte(string(str1))
  1537. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  1538. // fmt.Println(" Add(4,5)的结果为:", ret2)
  1539. // fmt.Println(" str:", s2)
  1540. // fmt.Println(" str1:", s3)
  1541. // if err2 != nil {
  1542. // fmt.Println("SSCard的运算结果为:", ret2)
  1543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1544. // return
  1545. // }
  1546. //
  1547. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  1548. //
  1549. //}
  1550. func (c *HisApiController) GetOrgInfo() {
  1551. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  1552. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  1553. }
  1554. func (c *HisApiController) GetHisPatientInfo() {
  1555. medical_insurance_card := c.GetString("medical_insurance_card")
  1556. id_card_type, _ := c.GetInt64("id_card_type")
  1557. id_card := c.GetString("id_card")
  1558. adminInfo := c.GetAdminUserInfo()
  1559. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1560. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1561. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  1562. IdCardNo := ""
  1563. if id_card_type == 1 {
  1564. IdCardNo = medical_insurance_card
  1565. } else if id_card_type == 2 {
  1566. IdCardNo = id_card
  1567. }
  1568. if config.IsOpen == 1 {
  1569. 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
  1570. resp, requestErr := http.Get(api)
  1571. if requestErr != nil {
  1572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1573. return
  1574. }
  1575. defer resp.Body.Close()
  1576. body, ioErr := ioutil.ReadAll(resp.Body)
  1577. if ioErr != nil {
  1578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1580. return
  1581. }
  1582. var respJSON map[string]interface{}
  1583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. return
  1587. }
  1588. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1589. userJSONBytes, _ := json.Marshal(userJSON)
  1590. var res ResultTwo
  1591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1592. utils.ErrorLog("解析失败:%v", err)
  1593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1594. return
  1595. }
  1596. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1597. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1598. infoStr := string(Iinfos)
  1599. idetinfoStr := string(Idetinfos)
  1600. if res.Infcode == 0 {
  1601. his := models.VMHisPatient{
  1602. Status: 1,
  1603. Ctime: time.Now().Unix(),
  1604. Mtime: time.Now().Unix(),
  1605. PsnNo: res.Output.Baseinfo.PsnNo,
  1606. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1607. Certno: res.Output.Baseinfo.Certno,
  1608. PsnName: res.Output.Baseinfo.PsnName,
  1609. Gend: res.Output.Baseinfo.Gend,
  1610. Naty: res.Output.Baseinfo.Naty,
  1611. Brdy: res.Output.Baseinfo.Brdy,
  1612. Age: res.Output.Baseinfo.Age,
  1613. Iinfo: infoStr,
  1614. Idetinfo: idetinfoStr,
  1615. UserOrgId: adminInfo.CurrentOrgId,
  1616. IsReturn: 1,
  1617. IdCardType: id_card_type,
  1618. }
  1619. c.ServeSuccessJSON(map[string]interface{}{
  1620. "info": his,
  1621. })
  1622. } else {
  1623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1624. return
  1625. }
  1626. }
  1627. }
  1628. //func GetBasBaseInfo() (jsonStr string, err error) {
  1629. //
  1630. // handle := syscall.NewLazyDLL("SSCard.dll")
  1631. // add := handle.NewProc("ReadCardBas")
  1632. // str := make([]byte, 1024)
  1633. // str1 := make([]byte, 1024)
  1634. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1635. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  1636. //
  1637. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  1638. //
  1639. // fmt.Println("> Add(4,5)的结果为:", ret)
  1640. // handle.Release()
  1641. //
  1642. // return "", nil
  1643. //
  1644. //}
  1645. //func GetQRBaseInfo() (jsonStr string, err error) {
  1646. // handle := syscall.LoadDLL("SSCard.dll")
  1647. // ReadCardBas := handle.FindProc("GetQRBase")
  1648. //
  1649. // str := make([]byte, 256)
  1650. // str1 := make([]byte, 256)
  1651. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1652. //
  1653. // fmt.Println(string(str))
  1654. // fmt.Println(r)
  1655. // return string(str), nil
  1656. //}
  1657. //func CardInit() int {
  1658. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  1659. // add := DllTestDef.MustFindProc("Init")
  1660. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1661. // if err != nil {
  1662. // fmt.Println("SSCard的运算结果为:", ret)
  1663. // }
  1664. // result := int(ret)
  1665. // return result
  1666. //}
  1667. //func CardInit() int {
  1668. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1669. // if err != nil {
  1670. // fmt.Println("SSCard的运算结果为:", ret)
  1671. // }
  1672. // fmt.Println(err)
  1673. // result := int(ret)
  1674. // return result
  1675. //}
  1676. func IntPtr(n int) uintptr {
  1677. return uintptr(n)
  1678. }
  1679. func StrPtr(s string) uintptr {
  1680. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1681. }
  1682. type ResultTwo struct {
  1683. ErrMsg string `json:"err_msg"`
  1684. InfRefmsgid string `json:"inf_refmsgid"`
  1685. Infcode int64 `json:"infcode"`
  1686. Output struct {
  1687. Baseinfo struct {
  1688. Age float64 `json:"age"`
  1689. Brdy string `json:"brdy"`
  1690. Certno string `json:"certno"`
  1691. Gend string `json:"gend"`
  1692. Naty string `json:"naty"`
  1693. PsnCertType string `json:"psn_cert_type"`
  1694. PsnName string `json:"psn_name"`
  1695. PsnNo string `json:"psn_no"`
  1696. } `json:"baseinfo"`
  1697. Idetinfo []interface{} `json:"idetinfo"`
  1698. Iinfo []struct {
  1699. Balc float64 `json:"balc"`
  1700. CvlservFlag string `json:"cvlserv_flag"`
  1701. EmpName string `json:"emp_name"`
  1702. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1703. Insutype string `json:"insutype"`
  1704. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1705. PausInsuDate string `json:"paus_insu_date"`
  1706. PsnInsuDate string `json:"psn_insu_date"`
  1707. PsnInsuStas string `json:"psn_insu_stas"`
  1708. PsnType string `json:"psn_type"`
  1709. } `json:"insuinfo"`
  1710. } `json:"output"`
  1711. RefmsgTime string `json:"refmsg_time"`
  1712. RespondTime string `json:"respond_time"`
  1713. Signtype interface{} `json:"signtype"`
  1714. WarnInfo interface{} `json:"warn_info"`
  1715. }
  1716. type ResultTwo10265 struct {
  1717. ErrMsg string `json:"err_msg"`
  1718. InfRefmsgid string `json:"inf_refmsgid"`
  1719. Infcode string `json:"infcode"`
  1720. Output struct {
  1721. Baseinfo struct {
  1722. Age float64 `json:"age"`
  1723. Brdy string `json:"brdy"`
  1724. Certno string `json:"certno"`
  1725. Gend string `json:"gend"`
  1726. Naty string `json:"naty"`
  1727. PsnCertType string `json:"psn_cert_type"`
  1728. PsnName string `json:"psn_name"`
  1729. PsnNo string `json:"psn_no"`
  1730. } `json:"baseinfo"`
  1731. Idetinfo []interface{} `json:"idetinfo"`
  1732. Iinfo []struct {
  1733. Balc float64 `json:"balc"`
  1734. CvlservFlag string `json:"cvlserv_flag"`
  1735. EmpName string `json:"emp_name"`
  1736. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1737. Insutype string `json:"insutype"`
  1738. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1739. PausInsuDate string `json:"paus_insu_date"`
  1740. PsnInsuDate string `json:"psn_insu_date"`
  1741. PsnInsuStas string `json:"psn_insu_stas"`
  1742. PsnType string `json:"psn_type"`
  1743. } `json:"insuinfo"`
  1744. } `json:"output"`
  1745. RefmsgTime string `json:"refmsg_time"`
  1746. RespondTime string `json:"respond_time"`
  1747. Signtype interface{} `json:"signtype"`
  1748. WarnInfo interface{} `json:"warn_info"`
  1749. }
  1750. type ResultThree struct {
  1751. Cainfo interface{} `json:"cainfo"`
  1752. ErrMsg string `json:"err_msg"`
  1753. InfRefmsgid string `json:"inf_refmsgid"`
  1754. Infcode int64 `json:"infcode"`
  1755. Output struct {
  1756. Data struct {
  1757. IptOtpNo string `json:"ipt_otp_no"`
  1758. MdtrtID string `json:"mdtrt_id"`
  1759. PsnNo string `json:"psn_no"`
  1760. } `json:"data"`
  1761. } `json:"output"`
  1762. RefmsgTime string `json:"refmsg_time"`
  1763. RespondTime string `json:"respond_time"`
  1764. Signtype interface{} `json:"signtype"`
  1765. WarnMsg interface{} `json:"warn_msg"`
  1766. }
  1767. type ResultThree10265 struct {
  1768. Cainfo interface{} `json:"cainfo"`
  1769. ErrMsg string `json:"err_msg"`
  1770. InfRefmsgid string `json:"inf_refmsgid"`
  1771. Infcode string `json:"infcode"`
  1772. Output struct {
  1773. Data struct {
  1774. IptOtpNo string `json:"ipt_otp_no"`
  1775. MdtrtID string `json:"mdtrt_id"`
  1776. PsnNo string `json:"psn_no"`
  1777. } `json:"data"`
  1778. } `json:"output"`
  1779. RefmsgTime string `json:"refmsg_time"`
  1780. RespondTime string `json:"respond_time"`
  1781. Signtype interface{} `json:"signtype"`
  1782. WarnMsg interface{} `json:"warn_msg"`
  1783. }
  1784. type ResultFour struct {
  1785. Cainfo string `json:"cainfo"`
  1786. ErrMsg string `json:"err_msg"`
  1787. InfRefmsgid string `json:"inf_refmsgid"`
  1788. Infcode int64 `json:"infcode"`
  1789. Output struct {
  1790. Result []struct {
  1791. BasMednFlag string `json:"bas_medn_flag"`
  1792. ChldMedcFlag string `json:"chld_medc_flag"`
  1793. ChrgitmLv string `json:"chrgitm_lv"`
  1794. Cnt float64 `json:"cnt"`
  1795. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1796. DrtReimFlag string `json:"drt_reim_flag"`
  1797. FeedetlSn string `json:"feedetl_sn"`
  1798. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1799. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1800. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1801. ListSpItemFlag string `json:"list_sp_item_flag"`
  1802. LmtUsedFlag string `json:"lmt_used_flag"`
  1803. MedChrgitmType string `json:"med_chrgitm_type"`
  1804. Memo string `json:"memo"`
  1805. OverlmtAmt float64 `json:"overlmt_amt"`
  1806. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1807. Pric float64 `json:"pric"`
  1808. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1809. SelfpayProp float64 `json:"selfpay_prop"`
  1810. } `json:"result"`
  1811. } `json:"output"`
  1812. RefmsgTime string `json:"refmsg_time"`
  1813. RespondTime string `json:"respond_time"`
  1814. Signtype string `json:"signtype"`
  1815. WarnMsg string `json:"warn_msg"`
  1816. }
  1817. type ResultFour10265 struct {
  1818. Cainfo string `json:"cainfo"`
  1819. ErrMsg string `json:"err_msg"`
  1820. InfRefmsgid string `json:"inf_refmsgid"`
  1821. Infcode string `json:"infcode"`
  1822. Output struct {
  1823. Result []struct {
  1824. BasMednFlag string `json:"bas_medn_flag"`
  1825. ChldMedcFlag string `json:"chld_medc_flag"`
  1826. ChrgitmLv string `json:"chrgitm_lv"`
  1827. Cnt float64 `json:"cnt"`
  1828. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1829. DrtReimFlag string `json:"drt_reim_flag"`
  1830. FeedetlSn string `json:"feedetl_sn"`
  1831. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1832. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1833. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1834. ListSpItemFlag string `json:"list_sp_item_flag"`
  1835. LmtUsedFlag string `json:"lmt_used_flag"`
  1836. MedChrgitmType string `json:"med_chrgitm_type"`
  1837. Memo string `json:"memo"`
  1838. OverlmtAmt float64 `json:"overlmt_amt"`
  1839. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1840. Pric float64 `json:"pric"`
  1841. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1842. SelfpayProp float64 `json:"selfpay_prop"`
  1843. } `json:"result"`
  1844. } `json:"output"`
  1845. RefmsgTime string `json:"refmsg_time"`
  1846. RespondTime string `json:"respond_time"`
  1847. Signtype string `json:"signtype"`
  1848. WarnMsg string `json:"warn_msg"`
  1849. }
  1850. type ResultFive struct {
  1851. Balc float64 `json:"balc"`
  1852. CvlservFlag string `json:"cvlserv_flag"`
  1853. EmpName string `json:"emp_name"`
  1854. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1855. Insutype string `json:"insutype"`
  1856. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1857. PausInsuDate string `json:"paus_insu_date"`
  1858. PsnInsuDate string `json:"psn_insu_date"`
  1859. PsnInsuStas string `json:"psn_insu_stas"`
  1860. PsnType string `json:"psn_type"`
  1861. }
  1862. type ResultSix struct {
  1863. Cainfo interface{} `json:"cainfo"`
  1864. ErrMsg string `json:"err_msg"`
  1865. InfRefmsgid string `json:"inf_refmsgid"`
  1866. Infcode int64 `json:"infcode"`
  1867. Output struct {
  1868. } `json:"output"`
  1869. RefmsgTime string `json:"refmsg_time"`
  1870. RespondTime string `json:"respond_time"`
  1871. Signtype interface{} `json:"signtype"`
  1872. WarnMsg interface{} `json:"warn_msg"`
  1873. }
  1874. type ResultSix10265 struct {
  1875. Cainfo interface{} `json:"cainfo"`
  1876. ErrMsg string `json:"err_msg"`
  1877. InfRefmsgid string `json:"inf_refmsgid"`
  1878. Infcode string `json:"infcode"`
  1879. Output struct {
  1880. } `json:"output"`
  1881. RefmsgTime string `json:"refmsg_time"`
  1882. RespondTime string `json:"respond_time"`
  1883. Signtype interface{} `json:"signtype"`
  1884. WarnMsg interface{} `json:"warn_msg"`
  1885. }
  1886. type ResultSeven struct {
  1887. Cainfo string `json:"cainfo"`
  1888. ErrMsg string `json:"err_msg"`
  1889. InfRefmsgid string `json:"inf_refmsgid"`
  1890. Infcode int64 `json:"infcode"`
  1891. Output struct {
  1892. Setldetail []interface{} `json:"setldetail"`
  1893. Setlinfo struct {
  1894. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1895. AcctPay float64 `json:"acct_pay"`
  1896. ActPayDedc float64 `json:"act_pay_dedc"`
  1897. Age float64 `json:"age"`
  1898. Balc float64 `json:"balc"`
  1899. Brdy string `json:"brdy"`
  1900. Certno string `json:"certno"`
  1901. ClrOptins string `json:"clr_optins"`
  1902. ClrType string `json:"clr_type"`
  1903. ClrWay string `json:"clr_way"`
  1904. CvlservFlag string `json:"cvlserv_flag"`
  1905. CvlservPay float64 `json:"cvlserv_pay"`
  1906. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1907. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1908. Gend string `json:"gend"`
  1909. HifesPay float64 `json:"hifes_pay"`
  1910. HifmiPay float64 `json:"hifmi_pay"`
  1911. HifpPay float64 `json:"hifp_pay"`
  1912. HospPartAmt float64 `json:"hosp_part_amt"`
  1913. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1914. Insutype string `json:"insutype"`
  1915. MafPay float64 `json:"maf_pay"`
  1916. MdtrtCertType string `json:"mdtrt_cert_type"`
  1917. HifobPay float64 `json:"hifob_pay"`
  1918. MdtrtID string `json:"mdtrt_id"`
  1919. MedType string `json:"med_type"`
  1920. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1921. MedinsSetlID string `json:"medins_setl_id"`
  1922. Naty string `json:"naty"`
  1923. OthPay float64 `json:"oth_pay"`
  1924. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1925. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1926. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1927. PsnCashPay float64 `json:"psn_cash_pay"`
  1928. PsnCertType string `json:"psn_cert_type"`
  1929. PsnName string `json:"psn_name"`
  1930. PsnNo string `json:"psn_no"`
  1931. PsnPartAmt float64 `json:"psn_part_amt"`
  1932. PsnType string `json:"psn_type"`
  1933. SetlID string `json:"setl_id"`
  1934. SetlTime string `json:"setl_time"`
  1935. } `json:"setlinfo"`
  1936. } `json:"output"`
  1937. RefmsgTime string `json:"refmsg_time"`
  1938. RespondTime string `json:"respond_time"`
  1939. Signtype interface{} `json:"signtype"`
  1940. WarnMsg interface{} `json:"warn_msg"`
  1941. }
  1942. type ResultSeven10265 struct {
  1943. Cainfo string `json:"cainfo"`
  1944. ErrMsg string `json:"err_msg"`
  1945. InfRefmsgid string `json:"inf_refmsgid"`
  1946. Infcode string `json:"infcode"`
  1947. Output struct {
  1948. Setldetail []interface{} `json:"setldetail"`
  1949. Setlinfo struct {
  1950. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1951. AcctPay float64 `json:"acct_pay"`
  1952. ActPayDedc float64 `json:"act_pay_dedc"`
  1953. Age float64 `json:"age"`
  1954. Balc float64 `json:"balc"`
  1955. Brdy string `json:"brdy"`
  1956. Certno string `json:"certno"`
  1957. ClrOptins string `json:"clr_optins"`
  1958. ClrType string `json:"clr_type"`
  1959. ClrWay string `json:"clr_way"`
  1960. CvlservFlag string `json:"cvlserv_flag"`
  1961. CvlservPay float64 `json:"cvlserv_pay"`
  1962. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1963. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1964. Gend string `json:"gend"`
  1965. HifesPay float64 `json:"hifes_pay"`
  1966. HifmiPay float64 `json:"hifmi_pay"`
  1967. HifpPay float64 `json:"hifp_pay"`
  1968. HospPartAmt float64 `json:"hosp_part_amt"`
  1969. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1970. Insutype string `json:"insutype"`
  1971. MafPay float64 `json:"maf_pay"`
  1972. MdtrtCertType string `json:"mdtrt_cert_type"`
  1973. HifobPay float64 `json:"hifob_pay"`
  1974. MdtrtID string `json:"mdtrt_id"`
  1975. MedType string `json:"med_type"`
  1976. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1977. MedinsSetlID string `json:"medins_setl_id"`
  1978. Naty string `json:"naty"`
  1979. OthPay float64 `json:"oth_pay"`
  1980. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1981. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1982. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1983. PsnCashPay float64 `json:"psn_cash_pay"`
  1984. PsnCertType string `json:"psn_cert_type"`
  1985. PsnName string `json:"psn_name"`
  1986. PsnNo string `json:"psn_no"`
  1987. PsnPartAmt float64 `json:"psn_part_amt"`
  1988. PsnType string `json:"psn_type"`
  1989. SetlID string `json:"setl_id"`
  1990. SetlTime string `json:"setl_time"`
  1991. } `json:"setlinfo"`
  1992. } `json:"output"`
  1993. RefmsgTime string `json:"refmsg_time"`
  1994. RespondTime string `json:"respond_time"`
  1995. Signtype interface{} `json:"signtype"`
  1996. WarnMsg interface{} `json:"warn_msg"`
  1997. }
  1998. type ResultEight struct {
  1999. Cainfo string `json:"cainfo"`
  2000. ErrMsg string `json:"err_msg"`
  2001. InfRefmsgid string `json:"inf_refmsgid"`
  2002. Infcode int64 `json:"infcode"`
  2003. Output struct {
  2004. Stmtinfo struct {
  2005. SetlOptins string `json:"setl_optins"`
  2006. StmtRslt string `json:"stmt_rslt"`
  2007. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2008. } `json:"stmtinfo"`
  2009. } `json:"output"`
  2010. RefmsgTime string `json:"refmsg_time"`
  2011. RespondTime string `json:"respond_time"`
  2012. Signtype interface{} `json:"signtype"`
  2013. WarnMsg interface{} `json:"warn_msg"`
  2014. }
  2015. type ResultNine struct {
  2016. Cainfo string `json:"cainfo"`
  2017. ErrMsg string `json:"err_msg"`
  2018. InfRefmsgid string `json:"inf_refmsgid"`
  2019. Infcode int64 `json:"infcode"`
  2020. Output struct {
  2021. FileQuryNo string `json:"file_qury_no"`
  2022. } `json:"output"`
  2023. RefmsgTime string `json:"refmsg_time"`
  2024. RespondTime string `json:"respond_time"`
  2025. Signtype interface{} `json:"signtype"`
  2026. WarnMsg interface{} `json:"warn_msg"`
  2027. }
  2028. type ResultTen struct {
  2029. Cainfo string `json:"cainfo"`
  2030. ErrMsg string `json:"err_msg"`
  2031. InfRefmsgid string `json:"inf_refmsgid"`
  2032. Infcode int64 `json:"infcode"`
  2033. Output struct {
  2034. DldEndtime string `json:"dld_endtime"`
  2035. FileQuryNo string `json:"file_qury_no"`
  2036. Filename string `json:"filename"`
  2037. } `json:"output"`
  2038. RefmsgTime string `json:"refmsg_time"`
  2039. RespondTime string `json:"respond_time"`
  2040. Signtype interface{} `json:"signtype"`
  2041. WarnMsg interface{} `json:"warn_msg"`
  2042. }
  2043. //type Autogenerated struct {
  2044. // Output struct {
  2045. // Setlinfo struct {
  2046. // SetlTime string `json:"setl_time"`
  2047. // CvlservPay float64 `json:"cvlserv_pay"`
  2048. // Year string `json:"year"`
  2049. // MedType string `json:"med_type"`
  2050. // PsnPay float64 `json:"psn_pay"`
  2051. // OpterID string `json:"opter_id"`
  2052. // Begndate string `json:"begndate"`
  2053. // FlxempeFlag string `json:"flxempe_flag"`
  2054. // HifmiPay float64 `json:"hifmi_pay"`
  2055. // PsnNo string `json:"psn_no"`
  2056. // ActPayDedc float64 `json:"act_pay_dedc"`
  2057. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2058. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2059. // ClrWay string `json:"clr_way"`
  2060. // OthPay float64 `json:"oth_pay"`
  2061. // Gend string `json:"gend"`
  2062. // MdtrtID string `json:"mdtrt_id"`
  2063. // AcctPay float64 `json:"acct_pay"`
  2064. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2065. // Insutype string `json:"insutype"`
  2066. // Invono interface{} `json:"invono"`
  2067. // Enddate string `json:"enddate"`
  2068. // CashPayamt float64 `json:"cash_payamt"`
  2069. // PsnType string `json:"psn_type"`
  2070. // FixmedinsName string `json:"fixmedins_name"`
  2071. // HifpPay float64 `json:"hifp_pay"`
  2072. // NewFlag interface{} `json:"new_flag"`
  2073. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2074. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2075. // PayLoc string `json:"pay_loc"`
  2076. // ClrType string `json:"clr_type"`
  2077. // RefdSetlFlag string `json:"refd_setl_flag"`
  2078. // CvlservFlag string `json:"cvlserv_flag"`
  2079. // EmpName string `json:"emp_name"`
  2080. // Brdy string `json:"brdy"`
  2081. // Naty string `json:"naty"`
  2082. // Certno string `json:"certno"`
  2083. // DiseCode string `json:"dise_code"`
  2084. // FixmedinsCode string `json:"fixmedins_code"`
  2085. // DedcHospLv string `json:"dedc_hosp_lv"`
  2086. // OpterName string `json:"opter_name"`
  2087. // Balc float64 `json:"balc"`
  2088. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2089. // PsnCertType string `json:"psn_cert_type"`
  2090. // HifobPay float64 `json:"hifob_pay"`
  2091. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2092. // HifesPay float64 `json:"hifes_pay"`
  2093. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2094. // OptTime string `json:"opt_time"`
  2095. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2096. // SetlID string `json:"setl_id"`
  2097. // MafPay float64 `json:"maf_pay"`
  2098. // PsnName string `json:"psn_name"`
  2099. // InsuOptins interface{} `json:"insu_optins"`
  2100. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2101. // ClrOptins string `json:"clr_optins"`
  2102. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2103. // DiseName string `json:"dise_name"`
  2104. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2105. // Age float64 `json:"age"`
  2106. // DtrtCertType string `json:"dtrt_cert_type"`
  2107. // HospLv string `json:"hosp_lv"`
  2108. // } `json:"setlinfo"`
  2109. // Setldetail []struct {
  2110. // FundPayType string `json:"fund_pay_type"`
  2111. // FundPayamt float64 `json:"fund_payamt"`
  2112. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2113. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2114. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2115. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2116. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2117. // } `json:"setldetail"`
  2118. // } `json:"output"`
  2119. // Infcode int `json:"infcode"`
  2120. // WarnMsg interface{} `json:"warn_msg"`
  2121. // Cainfo interface{} `json:"cainfo"`
  2122. // ErrMsg interface{} `json:"err_msg"`
  2123. // RefmsgTime string `json:"refmsg_time"`
  2124. // Signtype interface{} `json:"signtype"`
  2125. // RespondTime string `json:"respond_time"`
  2126. // InfRefmsgid string `json:"inf_refmsgid"`
  2127. //}
  2128. type ResultEleven struct {
  2129. Cainfo string `json:"cainfo"`
  2130. ErrMsg string `json:"err_msg"`
  2131. InfRefmsgid string `json:"inf_refmsgid"`
  2132. Infcode int64 `json:"infcode"`
  2133. Output struct {
  2134. Setlinfo struct {
  2135. SetlTime string `json:"setl_time"`
  2136. CvlservPay float64 `json:"cvlserv_pay"`
  2137. Year string `json:"year"`
  2138. MedType string `json:"med_type"`
  2139. PsnPay float64 `json:"psn_pay"`
  2140. OpterID string `json:"opter_id"`
  2141. Begndate string `json:"begndate"`
  2142. FlxempeFlag string `json:"flxempe_flag"`
  2143. HifmiPay float64 `json:"hifmi_pay"`
  2144. PsnNo string `json:"psn_no"`
  2145. ActPayDedc float64 `json:"act_pay_dedc"`
  2146. MedinsSetlID interface{} `json:"medins_setl_id"`
  2147. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2148. ClrWay string `json:"clr_way"`
  2149. OthPay float64 `json:"oth_pay"`
  2150. Gend string `json:"gend"`
  2151. MdtrtID string `json:"mdtrt_id"`
  2152. AcctPay float64 `json:"acct_pay"`
  2153. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2154. Insutype string `json:"insutype"`
  2155. Invono interface{} `json:"invono"`
  2156. Enddate string `json:"enddate"`
  2157. CashPayamt float64 `json:"cash_payamt"`
  2158. PsnType string `json:"psn_type"`
  2159. FixmedinsName string `json:"fixmedins_name"`
  2160. HifpPay float64 `json:"hifp_pay"`
  2161. NewFlag interface{} `json:"new_flag"`
  2162. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2163. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2164. PayLoc string `json:"pay_loc"`
  2165. ClrType string `json:"clr_type"`
  2166. RefdSetlFlag string `json:"refd_setl_flag"`
  2167. CvlservFlag string `json:"cvlserv_flag"`
  2168. EmpName string `json:"emp_name"`
  2169. Brdy string `json:"brdy"`
  2170. Naty string `json:"naty"`
  2171. Certno string `json:"certno"`
  2172. DiseCode string `json:"dise_code"`
  2173. FixmedinsCode string `json:"fixmedins_code"`
  2174. DedcHospLv string `json:"dedc_hosp_lv"`
  2175. OpterName string `json:"opter_name"`
  2176. Balc float64 `json:"balc"`
  2177. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2178. PsnCertType string `json:"psn_cert_type"`
  2179. HifobPay float64 `json:"hifob_pay"`
  2180. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2181. HifesPay float64 `json:"hifes_pay"`
  2182. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2183. OptTime string `json:"opt_time"`
  2184. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2185. SetlID string `json:"setl_id"`
  2186. MafPay float64 `json:"maf_pay"`
  2187. PsnName string `json:"psn_name"`
  2188. InsuOptins interface{} `json:"insu_optins"`
  2189. PrefFundPay interface{} `json:"pref_fund_pay"`
  2190. ClrOptins string `json:"clr_optins"`
  2191. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2192. DiseName string `json:"dise_name"`
  2193. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2194. Age float64 `json:"age"`
  2195. DtrtCertType string `json:"dtrt_cert_type"`
  2196. HospLv string `json:"hosp_lv"`
  2197. } `json:"setlinfo"`
  2198. } `json:"output"`
  2199. RefmsgTime string `json:"refmsg_time"`
  2200. RespondTime string `json:"respond_time"`
  2201. Signtype interface{} `json:"signtype"`
  2202. WarnMsg interface{} `json:"warn_msg"`
  2203. }
  2204. type ResultEleven10265 struct {
  2205. Cainfo string `json:"cainfo"`
  2206. ErrMsg string `json:"err_msg"`
  2207. InfRefmsgid string `json:"inf_refmsgid"`
  2208. Infcode string `json:"infcode"`
  2209. Output struct {
  2210. Setlinfo struct {
  2211. SetlTime string `json:"setl_time"`
  2212. CvlservPay float64 `json:"cvlserv_pay"`
  2213. Year string `json:"year"`
  2214. MedType string `json:"med_type"`
  2215. PsnPay float64 `json:"psn_pay"`
  2216. OpterID string `json:"opter_id"`
  2217. Begndate string `json:"begndate"`
  2218. FlxempeFlag string `json:"flxempe_flag"`
  2219. HifmiPay float64 `json:"hifmi_pay"`
  2220. PsnNo string `json:"psn_no"`
  2221. ActPayDedc float64 `json:"act_pay_dedc"`
  2222. MedinsSetlID interface{} `json:"medins_setl_id"`
  2223. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2224. ClrWay string `json:"clr_way"`
  2225. OthPay float64 `json:"oth_pay"`
  2226. Gend string `json:"gend"`
  2227. MdtrtID string `json:"mdtrt_id"`
  2228. AcctPay float64 `json:"acct_pay"`
  2229. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2230. Insutype string `json:"insutype"`
  2231. Invono interface{} `json:"invono"`
  2232. Enddate string `json:"enddate"`
  2233. CashPayamt float64 `json:"cash_payamt"`
  2234. PsnType string `json:"psn_type"`
  2235. FixmedinsName string `json:"fixmedins_name"`
  2236. HifpPay float64 `json:"hifp_pay"`
  2237. NewFlag interface{} `json:"new_flag"`
  2238. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2239. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2240. PayLoc string `json:"pay_loc"`
  2241. ClrType string `json:"clr_type"`
  2242. RefdSetlFlag string `json:"refd_setl_flag"`
  2243. CvlservFlag string `json:"cvlserv_flag"`
  2244. EmpName string `json:"emp_name"`
  2245. Brdy string `json:"brdy"`
  2246. Naty string `json:"naty"`
  2247. Certno string `json:"certno"`
  2248. DiseCode string `json:"dise_code"`
  2249. FixmedinsCode string `json:"fixmedins_code"`
  2250. DedcHospLv string `json:"dedc_hosp_lv"`
  2251. OpterName string `json:"opter_name"`
  2252. Balc float64 `json:"balc"`
  2253. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2254. PsnCertType string `json:"psn_cert_type"`
  2255. HifobPay float64 `json:"hifob_pay"`
  2256. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2257. HifesPay float64 `json:"hifes_pay"`
  2258. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2259. OptTime string `json:"opt_time"`
  2260. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2261. SetlID string `json:"setl_id"`
  2262. MafPay float64 `json:"maf_pay"`
  2263. PsnName string `json:"psn_name"`
  2264. InsuOptins interface{} `json:"insu_optins"`
  2265. PrefFundPay interface{} `json:"pref_fund_pay"`
  2266. ClrOptins string `json:"clr_optins"`
  2267. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2268. DiseName string `json:"dise_name"`
  2269. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2270. Age float64 `json:"age"`
  2271. DtrtCertType string `json:"dtrt_cert_type"`
  2272. HospLv string `json:"hosp_lv"`
  2273. } `json:"setlinfo"`
  2274. } `json:"output"`
  2275. RefmsgTime string `json:"refmsg_time"`
  2276. RespondTime string `json:"respond_time"`
  2277. Signtype interface{} `json:"signtype"`
  2278. WarnMsg interface{} `json:"warn_msg"`
  2279. }
  2280. type ResultTwelve struct {
  2281. Cainfo string `json:"cainfo"`
  2282. ErrMsg string `json:"err_msg"`
  2283. InfRefmsgid string `json:"inf_refmsgid"`
  2284. Infcode int64 `json:"infcode"`
  2285. Output struct {
  2286. MdtrtId string `json:"mdtrt_id"`
  2287. ChrgBchno string `json:"chrg_bchno"`
  2288. PsnNo string `json:"psn_no"`
  2289. } `json:"output"`
  2290. RefmsgTime string `json:"refmsg_time"`
  2291. RespondTime string `json:"respond_time"`
  2292. Signtype interface{} `json:"signtype"`
  2293. WarnMsg interface{} `json:"warn_msg"`
  2294. }
  2295. type ResultThirteen struct {
  2296. ErrMsg string `json:"err_msg"`
  2297. InfRefmsgid string `json:"inf_refmsgid"`
  2298. Infcode int64 `json:"infcode"`
  2299. Output struct {
  2300. Result struct {
  2301. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2302. } `json:"result"`
  2303. } `json:"output"`
  2304. RefmsgTime string `json:"refmsg_time"`
  2305. RespondTime string `json:"respond_time"`
  2306. Signtype interface{} `json:"signtype"`
  2307. WarnInfo interface{} `json:"warn_info"`
  2308. }
  2309. type ResultThirteen10265 struct {
  2310. ErrMsg string `json:"err_msg"`
  2311. InfRefmsgid string `json:"inf_refmsgid"`
  2312. Infcode string `json:"infcode"`
  2313. Output struct {
  2314. Result struct {
  2315. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2316. } `json:"result"`
  2317. } `json:"output"`
  2318. RefmsgTime string `json:"refmsg_time"`
  2319. RespondTime string `json:"respond_time"`
  2320. Signtype interface{} `json:"signtype"`
  2321. WarnInfo interface{} `json:"warn_info"`
  2322. }
  2323. type ResultFourteen struct {
  2324. ErrMsg string `json:"err_msg"`
  2325. InfRefmsgid string `json:"inf_refmsgid"`
  2326. Infcode int64 `json:"infcode"`
  2327. Output struct {
  2328. } `json:"output"`
  2329. RefmsgTime string `json:"refmsg_time"`
  2330. RespondTime string `json:"respond_time"`
  2331. Signtype interface{} `json:"signtype"`
  2332. WarnInfo interface{} `json:"warn_info"`
  2333. }
  2334. type ResultSixteen struct {
  2335. Cainfo string `json:"cainfo"`
  2336. ErrMsg string `json:"err_msg"`
  2337. InfRefmsgid string `json:"inf_refmsgid"`
  2338. Infcode int64 `json:"infcode"`
  2339. Output struct {
  2340. Setldetail []interface{} `json:"setldetail"`
  2341. Setlinfo struct {
  2342. MdtrtID string `json:"mdtrt_id"`
  2343. SetlID string `json:"setl_id"`
  2344. ClrOptins string `json:"clr_optins"`
  2345. SetlTime string `json:"setl_time"`
  2346. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2347. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2348. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2349. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2350. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2351. ActPayDedc float64 `json:"act_pay_dedc"`
  2352. HifpPay float64 `json:"hifp_pay"`
  2353. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2354. Lfpay float64 `json:"selfpay"`
  2355. CvlservPay float64 `json:"cvlserv_pay"`
  2356. HifesPay float64 `json:"hifes_pay"`
  2357. HifmiPay float64 `json:"hifmi_pay"`
  2358. HifobPay float64 `json:"hifob_pay"`
  2359. MafPay float64 `json:"maf_pay"`
  2360. OthPay float64 `json:"oth_pay"`
  2361. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2362. PsnPartAmt float64 `json:"psn_part_amt"`
  2363. AcctPay float64 `json:"acct_pay"`
  2364. Balc float64 `json:"balc"`
  2365. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2366. HospPartAmt float64 `json:"hosp_part_amt"`
  2367. MedinsSetlID string `json:"medins_setl_id"`
  2368. PdnCashPay string `json:"pdn_cash_pay"`
  2369. } `json:"setlinfo"`
  2370. } `json:"output"`
  2371. RefmsgTime string `json:"refmsg_time"`
  2372. RespondTime string `json:"respond_time"`
  2373. Signtype interface{} `json:"signtype"`
  2374. WarnMsg interface{} `json:"warn_msg"`
  2375. }
  2376. type ResultSixteen10265 struct {
  2377. Cainfo string `json:"cainfo"`
  2378. ErrMsg string `json:"err_msg"`
  2379. InfRefmsgid string `json:"inf_refmsgid"`
  2380. Infcode string `json:"infcode"`
  2381. Output struct {
  2382. Setldetail []interface{} `json:"setldetail"`
  2383. Setlinfo struct {
  2384. MdtrtID string `json:"mdtrt_id"`
  2385. SetlID string `json:"setl_id"`
  2386. ClrOptins string `json:"clr_optins"`
  2387. SetlTime string `json:"setl_time"`
  2388. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2389. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2390. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2391. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2392. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2393. ActPayDedc float64 `json:"act_pay_dedc"`
  2394. HifpPay float64 `json:"hifp_pay"`
  2395. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2396. Lfpay float64 `json:"selfpay"`
  2397. CvlservPay float64 `json:"cvlserv_pay"`
  2398. HifesPay float64 `json:"hifes_pay"`
  2399. HifmiPay float64 `json:"hifmi_pay"`
  2400. HifobPay float64 `json:"hifob_pay"`
  2401. MafPay float64 `json:"maf_pay"`
  2402. OthPay float64 `json:"oth_pay"`
  2403. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2404. PsnPartAmt float64 `json:"psn_part_amt"`
  2405. AcctPay float64 `json:"acct_pay"`
  2406. Balc float64 `json:"balc"`
  2407. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2408. HospPartAmt float64 `json:"hosp_part_amt"`
  2409. MedinsSetlID string `json:"medins_setl_id"`
  2410. PdnCashPay string `json:"pdn_cash_pay"`
  2411. } `json:"setlinfo"`
  2412. } `json:"output"`
  2413. RefmsgTime string `json:"refmsg_time"`
  2414. RespondTime string `json:"respond_time"`
  2415. Signtype interface{} `json:"signtype"`
  2416. WarnMsg interface{} `json:"warn_msg"`
  2417. }
  2418. type ResultSeventeen struct {
  2419. ErrMsg string `json:"err_msg"`
  2420. InfRefmsgid string `json:"inf_refmsgid"`
  2421. Infcode int64 `json:"infcode"`
  2422. Output struct {
  2423. SetlListId string `json:"setl_list_id"`
  2424. } `json:"output"`
  2425. RefmsgTime string `json:"refmsg_time"`
  2426. RespondTime string `json:"respond_time"`
  2427. Signtype string `json:"signtype"`
  2428. WarnInfo string `json:"warn_info"`
  2429. }
  2430. type Result90991 struct {
  2431. ErrMsg string `json:"err_msg"`
  2432. InfRefmsgid string `json:"inf_refmsgid"`
  2433. Infcode int64 `json:"infcode"`
  2434. Output struct {
  2435. Result struct {
  2436. PsnNo string `json:"psn_no"`
  2437. CardStat string `json:"card_stat"`
  2438. Certno string `json:"certno"`
  2439. PsnName string `json:"psn_name"`
  2440. CheckStat string `json:"check_stat"`
  2441. } `json:"result"`
  2442. } `json:"output"`
  2443. RefmsgTime string `json:"refmsg_time"`
  2444. RespondTime string `json:"respond_time"`
  2445. Signtype interface{} `json:"signtype"`
  2446. WarnInfo interface{} `json:"warn_info"`
  2447. }
  2448. type Result90100 struct {
  2449. ErrMsg string `json:"err_msg"`
  2450. InfRefmsgid string `json:"inf_refmsgid"`
  2451. Infcode int64 `json:"infcode"`
  2452. Output struct {
  2453. PoolareaNo string `json:"poolarea_no"`
  2454. PoolareaNoName string `json:"poolarea_no_name"`
  2455. Insutype string `json:"insutype"`
  2456. InsutypeName string `json:"insutype_name"`
  2457. ClctType string `json:"clct_type"`
  2458. ClctTypeName string `json:"clct_type_name"`
  2459. ClctFlag string `json:"clct_flag"`
  2460. ClctFlagName string `json:"clct_flag_name"`
  2461. AccrymBegn string `json:"accrym_begn"`
  2462. AccrymEnd string `json:"accrym_end"`
  2463. ClctTime string `json:"clct_time"`
  2464. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  2465. } `json:"output"`
  2466. RefmsgTime string `json:"refmsg_time"`
  2467. RespondTime string `json:"respond_time"`
  2468. Signtype interface{} `json:"signtype"`
  2469. WarnInfo interface{} `json:"warn_info"`
  2470. }
  2471. type Custom struct {
  2472. DetItemFeeSumamt string
  2473. Cut string
  2474. FeedetlSn string
  2475. Price string
  2476. MedListCodg string
  2477. Type int64
  2478. AdviceId int64
  2479. ProjectId int64
  2480. ItemId int64
  2481. }
  2482. //获取个人信息----挂号-----上传就诊信息
  2483. func (c *HisApiController) GetRegisterInfo() {
  2484. fmt.Println("~~~~~~~~")
  2485. id, _ := c.GetInt64("id")
  2486. record_time := c.GetString("record_time")
  2487. settlementValue, _ := c.GetInt64("settlement_value")
  2488. medical_insurance_card := c.GetString("medical_insurance_card")
  2489. name := c.GetString("name")
  2490. id_card_type, _ := c.GetInt64("id_card_type")
  2491. certificates, _ := c.GetInt64("certificates")
  2492. medical_care, _ := c.GetInt64("medical_care")
  2493. birthday := c.GetString("birthday")
  2494. //age, _ := c.GetInt64("age")
  2495. id_card := c.GetString("id_card")
  2496. register_type, _ := c.GetInt64("register")
  2497. doctor, _ := c.GetInt64("doctor")
  2498. department, _ := c.GetInt64("department")
  2499. gender, _ := c.GetInt64("sex")
  2500. //phone := c.GetString("phone")
  2501. registration_fee, _ := c.GetFloat("registration_fee")
  2502. medical_expenses, _ := c.GetFloat("medical_expenses")
  2503. social_type, _ := c.GetInt64("social_type")
  2504. med_type := c.GetString("social_type")
  2505. admin_user_id, _ := c.GetInt64("admin_user_id")
  2506. timeLayout := "2006-01-02"
  2507. loc, _ := time.LoadLocation("Local")
  2508. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2509. birthUnix := birthdays.Unix()
  2510. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2511. if err != nil {
  2512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2513. return
  2514. }
  2515. recordDateTime := theTime.Unix()
  2516. adminInfo := c.GetAdminUserInfo()
  2517. var patient service.Patients
  2518. if id == 0 {
  2519. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2520. } else {
  2521. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2522. }
  2523. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2524. if patientPrescription.ID == 0 {
  2525. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2526. }
  2527. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  2528. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2529. //sickConfig, _ := service.FindSickById(sick_type)
  2530. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2531. if patient.ID == 0 {
  2532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2533. return
  2534. }
  2535. if len(patient.IdCardNo) == 0 {
  2536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2537. return
  2538. }
  2539. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2540. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2541. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2542. //就诊结算未完成,不能进行二次挂号
  2543. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2544. if len(his) >= 1 {
  2545. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2546. if len(his) >= 1 && order.ID == 0 {
  2547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2548. return
  2549. }
  2550. }
  2551. //var register_log string
  2552. if config.IsOpen == 1 {
  2553. var res ResultTwo
  2554. var res10265 ResultTwo10265
  2555. var PsnNo string
  2556. var PsnCertType string
  2557. var Certno string
  2558. var PsnName string
  2559. var Gend string
  2560. var Naty string
  2561. var Brdy string
  2562. var Age float64
  2563. var infoStr string
  2564. var idetinfoStr string
  2565. var infocode int64
  2566. if miConfig.MdtrtareaAdmvs == "421300" {
  2567. psn_info, _ := service.GetPsnByPatientId(id)
  2568. PsnNo = psn_info.PsnNo
  2569. PsnCertType = psn_info.PsnCertType
  2570. Certno = psn_info.Certno
  2571. PsnName = psn_info.PsnName
  2572. Gend = psn_info.Gend
  2573. Naty = psn_info.Naty
  2574. Brdy = psn_info.Brdy
  2575. Age = psn_info.Age
  2576. infoStr = psn_info.Insuinfo
  2577. idetinfoStr = psn_info.Idetinfo
  2578. } else {
  2579. 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)
  2580. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2581. if miConfig.Code == "H15049901371" {
  2582. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2583. utils.ErrorLog("解析失败:%v", err)
  2584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2585. return
  2586. }
  2587. res.ErrMsg = res10265.ErrMsg
  2588. res.Output = res10265.Output
  2589. res.InfRefmsgid = res10265.InfRefmsgid
  2590. } else {
  2591. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2592. utils.ErrorLog("解析失败:%v", err)
  2593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2594. return
  2595. }
  2596. }
  2597. PsnNo = res.Output.Baseinfo.PsnNo
  2598. PsnCertType = res.Output.Baseinfo.PsnCertType
  2599. Certno = res.Output.Baseinfo.Certno
  2600. PsnName = res.Output.Baseinfo.PsnName
  2601. Gend = res.Output.Baseinfo.Gend
  2602. Naty = res.Output.Baseinfo.Naty
  2603. Brdy = res.Output.Baseinfo.Brdy
  2604. Age = res.Output.Baseinfo.Age
  2605. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2606. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2607. infoStr = string(Iinfos)
  2608. idetinfoStr = string(Idetinfos)
  2609. if miConfig.Code == "H15049901371" {
  2610. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  2611. } else {
  2612. infocode = res.Infcode
  2613. }
  2614. }
  2615. if infocode == 0 {
  2616. his := models.VMHisPatient{
  2617. Name: name,
  2618. Gender: gender,
  2619. Birthday: birthUnix,
  2620. MedicalTreatmentType: medical_care,
  2621. IdType: certificates,
  2622. IdCardNo: id_card,
  2623. BalanceAccountsType: settlementValue,
  2624. SocialType: social_type,
  2625. MedicalInsuranceNumber: medical_insurance_card,
  2626. RegisterType: register_type,
  2627. RegisterCost: registration_fee,
  2628. TreatmentCost: medical_expenses,
  2629. Status: 1,
  2630. Ctime: time.Now().Unix(),
  2631. Mtime: time.Now().Unix(),
  2632. PsnNo: PsnNo,
  2633. PsnCertType: PsnCertType,
  2634. Certno: Certno,
  2635. PsnName: PsnName,
  2636. Gend: Gend,
  2637. Naty: Naty,
  2638. Brdy: Brdy,
  2639. Age: Age,
  2640. Iinfo: infoStr,
  2641. Idetinfo: idetinfoStr,
  2642. PatientId: patient.ID,
  2643. RecordDate: theTime.Unix(),
  2644. UserOrgId: adminInfo.CurrentOrgId,
  2645. AdminUserId: admin_user_id,
  2646. IsReturn: 1,
  2647. IdCardType: id_card_type,
  2648. Doctor: doctor,
  2649. Departments: department,
  2650. }
  2651. timestamp := time.Now().Unix()
  2652. tempTime := time.Unix(timestamp, 0)
  2653. timeFormat := tempTime.Format("20060102150405")
  2654. chrgBchno := rand.Intn(100000) + 10000
  2655. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2656. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2657. department, _ := service.GetDepartMentDetail(department)
  2658. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2659. IdCardNo := ""
  2660. if id_card_type == 1 {
  2661. // IdCardNo = medical_insurance_card
  2662. IdCardNo = patient.IdCardNo
  2663. } else {
  2664. IdCardNo = patient.IdCardNo
  2665. }
  2666. var rf []*ResultFive
  2667. json.Unmarshal([]byte(his.Iinfo), &rf)
  2668. var insutypes []*ResultFive
  2669. var insutype string
  2670. var insuplc_admdvs string
  2671. var is390 int = 0
  2672. var is310 int = 0
  2673. for _, item := range rf {
  2674. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2675. insutypes = append(insutypes, item)
  2676. }
  2677. }
  2678. if len(insutypes) == 1 {
  2679. insutype = insutypes[0].Insutype
  2680. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2681. } else {
  2682. for _, i := range insutypes {
  2683. if i.Insutype == "390" {
  2684. is390 = 1
  2685. }
  2686. if i.Insutype == "310" {
  2687. is310 = 1
  2688. }
  2689. }
  2690. }
  2691. if is390 == 1 {
  2692. insutype = "390"
  2693. }
  2694. if is310 == 1 {
  2695. insutype = "310"
  2696. }
  2697. if len(insutypes) == 0 {
  2698. insutype = "310"
  2699. }
  2700. if len(insutypes) == 2 {
  2701. insutype = med_type
  2702. }
  2703. for _, item := range rf {
  2704. if item.Insutype == insutype {
  2705. insuplc_admdvs = item.InsuplcAdmdvs
  2706. }
  2707. }
  2708. var infocode int64
  2709. var resThree ResultThree
  2710. var resThree10265 ResultThree10265
  2711. if miConfig.MdtrtareaAdmvs == "421300" {
  2712. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2713. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2714. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&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
  2715. resp, requestErr := http.Get(api)
  2716. if requestErr != nil {
  2717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2718. return
  2719. }
  2720. body, ioErr := ioutil.ReadAll(resp.Body)
  2721. if ioErr != nil {
  2722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2724. return
  2725. }
  2726. var respJSON map[string]interface{}
  2727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2730. return
  2731. }
  2732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2733. result, _ := json.Marshal(respJSON)
  2734. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2735. utils.ErrorLog("解析失败:%v", err)
  2736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2737. return
  2738. }
  2739. infocode = resThree.Infcode
  2740. } else {
  2741. 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, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  2742. saveLog(result, requestLog, "2201", "挂号")
  2743. if miConfig.Code == "H15049901371" {
  2744. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2745. utils.ErrorLog("解析失败:%v", err)
  2746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2747. return
  2748. }
  2749. resThree.ErrMsg = resThree10265.ErrMsg
  2750. resThree.Output = resThree10265.Output
  2751. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2752. } else {
  2753. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2754. utils.ErrorLog("解析失败:%v", err)
  2755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2756. return
  2757. }
  2758. }
  2759. if miConfig.Code == "H15049901371" {
  2760. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2761. } else {
  2762. infocode = resThree.Infcode
  2763. }
  2764. }
  2765. if infocode != 0 {
  2766. adminUser := c.GetAdminUserInfo()
  2767. errlog := &models.HisOrderError{
  2768. UserOrgId: adminUser.CurrentOrgId,
  2769. Ctime: time.Now().Unix(),
  2770. Mtime: time.Now().Unix(),
  2771. ErrMsg: resThree.ErrMsg,
  2772. Status: 1,
  2773. PatientId: id,
  2774. RecordTime: recordDateTime,
  2775. Stage: 2,
  2776. }
  2777. service.CreateErrMsgLog(errlog)
  2778. c.ServeSuccessJSON(map[string]interface{}{
  2779. "failed_code": -10,
  2780. "msg": resThree.ErrMsg,
  2781. })
  2782. return
  2783. }
  2784. his.Number = resThree.Output.Data.MdtrtID
  2785. his.PsnNo = resThree.Output.Data.PsnNo
  2786. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  2787. his.IdCardNo = patient.IdCardNo
  2788. his.PhoneNumber = patient.Phone
  2789. his.UserOrgId = adminInfo.CurrentOrgId
  2790. his.Insutype = insutype
  2791. his.Ctime = time.Now().Unix()
  2792. his.Mtime = time.Now().Unix()
  2793. his.InsuplcAdmdvs = insuplc_admdvs
  2794. his.Status = 1
  2795. service.UpdateHisPatientStatus(&his)
  2796. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  2797. c.ServeSuccessJSON(map[string]interface{}{
  2798. "his_info": his,
  2799. })
  2800. } else {
  2801. adminUser := c.GetAdminUserInfo()
  2802. errlog := &models.HisOrderError{
  2803. UserOrgId: adminUser.CurrentOrgId,
  2804. Ctime: time.Now().Unix(),
  2805. Mtime: time.Now().Unix(),
  2806. ErrMsg: res.ErrMsg,
  2807. Status: 1,
  2808. PatientId: id,
  2809. RecordTime: recordDateTime,
  2810. Stage: 1,
  2811. }
  2812. service.CreateErrMsgLog(errlog)
  2813. c.ServeSuccessJSON(map[string]interface{}{
  2814. "failed_code": -10,
  2815. "msg": res.ErrMsg,
  2816. })
  2817. return
  2818. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  2819. }
  2820. }
  2821. }
  2822. //上传明细----预结算----确认订单
  2823. func (c *HisApiController) GetUploadInfo() {
  2824. id, _ := c.GetInt64("id")
  2825. record_time := c.GetString("record_time")
  2826. his_patient_id, _ := c.GetInt64("his_patient_id")
  2827. order_id, _ := c.GetInt64("order_id")
  2828. pay_way, _ := c.GetInt64("pay_way")
  2829. pay_price, _ := c.GetFloat("pay_price")
  2830. pay_card_no := c.GetString("pay_card_no")
  2831. discount_price, _ := c.GetFloat("discount_price")
  2832. preferential_price, _ := c.GetFloat("preferential_price")
  2833. reality_price, _ := c.GetFloat("reality_price")
  2834. found_price, _ := c.GetFloat("found_price")
  2835. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2836. private_price, _ := c.GetFloat("private_price")
  2837. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2838. admin_user_id, _ := c.GetInt64("admin_user_id")
  2839. fapiao_code := c.GetString("fapiao_code")
  2840. fapiao_number := c.GetString("fapiao_number")
  2841. diagnosis_id := c.GetString("diagnosis")
  2842. sick_type, _ := c.GetInt64("sick_type")
  2843. reg_type, _ := c.GetInt64("p_type")
  2844. id_str := c.GetString("ids")
  2845. ids_arr := strings.Split(id_str, ",")
  2846. timeLayout := "2006-01-02"
  2847. loc, _ := time.LoadLocation("Local")
  2848. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2849. if err != nil {
  2850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2851. return
  2852. }
  2853. recordDateTime := theTime.Unix()
  2854. adminUser := c.GetAdminUserInfo()
  2855. var tempOrder models.HisOrder
  2856. tempOrder, _ = service.GetHisOrderByID(order_id)
  2857. var prescriptions []*models.HisPrescription
  2858. var start_time int64
  2859. var end_time int64
  2860. //if adminUser.CurrentOrgId == 10106{
  2861. // if len(fapiao_code) == 0{
  2862. // fapiao_code = "144072080589"
  2863. // }
  2864. // if len(fapiao_number) == 0{
  2865. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  2866. // if order.ID == 0{
  2867. // fapiao_number = "00001520"
  2868. // }else{
  2869. // //fapiao_code = "00001520"
  2870. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  2871. // var zero string
  2872. // if fpNumber >= 1000{
  2873. // zero = "0000" + strconv.Itoa(fpNumber)
  2874. // }else if fpNumber >= 10000{
  2875. // zero = "000" + strconv.Itoa(fpNumber)
  2876. // } else if fpNumber >= 100000{
  2877. // zero = "00" + strconv.Itoa(fpNumber)
  2878. // } else if fpNumber >= 1000000{
  2879. // zero = "0" + strconv.Itoa(fpNumber)
  2880. // }else {
  2881. // zero = strconv.Itoa(fpNumber)
  2882. // }
  2883. // fapiao_number = zero
  2884. // }
  2885. // }
  2886. //}
  2887. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2888. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2889. var patientPrescription models.HisPrescriptionInfo
  2890. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2891. if patientPrescription.ID == 0 {
  2892. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2893. }
  2894. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2895. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2896. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2897. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2898. var config []*models.HisXtDiagnoseConfig
  2899. for _, item := range diagnosis_ids {
  2900. id, _ := strconv.ParseInt(item, 10, 64)
  2901. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2902. config = append(config, &diagnosisConfig)
  2903. }
  2904. sickConfig, _ := service.FindSickById(sick_type)
  2905. if tempOrder.ID == 0 {
  2906. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  2907. }
  2908. if tempOrder.ID == 0 {
  2909. var result string
  2910. var requestLog string
  2911. var res2 ResultSix
  2912. var ressix10265 ResultSix10265
  2913. if miConfig.InsuplcAdmdvs == "421300" {
  2914. data := make(map[string]interface{})
  2915. client := &http.Client{}
  2916. data["psn_no"] = his.PsnNo
  2917. data["mdtrt_id"] = his.Number
  2918. data["doctor"] = roles.UserName
  2919. data["department"] = department.Name
  2920. data["org_name"] = miConfig.OrgName
  2921. data["med_type"] = strconv.FormatInt(reg_type, 10)
  2922. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  2923. data["fixmedins_code"] = miConfig.Code
  2924. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2925. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2926. data["secret_key"] = miConfig.SecretKey
  2927. data["sick_code"] = sickConfig.CountryCode
  2928. data["sick_name"] = sickConfig.ClassName
  2929. data["dept"] = strconv.FormatInt(department.ID, 10)
  2930. data["config"] = config
  2931. bytesData, _ := json.Marshal(data)
  2932. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  2933. resp, _ := client.Do(req)
  2934. defer resp.Body.Close()
  2935. body, ioErr := ioutil.ReadAll(resp.Body)
  2936. if ioErr != nil {
  2937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2939. return
  2940. }
  2941. var respJSON map[string]interface{}
  2942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2945. return
  2946. }
  2947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2948. userJSONBytes, _ := json.Marshal(respJSON)
  2949. fmt.Println("log")
  2950. fmt.Println(string(userJSONBytes))
  2951. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2952. utils.ErrorLog("解析失败:%v", err)
  2953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2954. return
  2955. }
  2956. } else {
  2957. if miConfig.InsuplcAdmdvs == "440781" { //
  2958. 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)
  2959. } else {
  2960. if miConfig.Code == "H15049901371" {
  2961. //赤峰地区国家医保医疗类别
  2962. //职工透析:医疗类别选特殊情况门诊990502
  2963. //居民定额血透门慢: 医疗类别选门诊慢病140104
  2964. var med_type string
  2965. if his.Insutype == "390" {
  2966. if reg_type == 14 {
  2967. med_type = "9933"
  2968. } else if reg_type == 11 {
  2969. med_type = "11"
  2970. }
  2971. } else if his.Insutype == "310" {
  2972. if reg_type == 14 {
  2973. med_type = "990502"
  2974. } else if reg_type == 11 {
  2975. med_type = "11"
  2976. }
  2977. }
  2978. 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)
  2979. } else {
  2980. 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)
  2981. }
  2982. }
  2983. saveLog(result, requestLog, "2203", "上传就诊信息")
  2984. var respJSON2 map[string]interface{}
  2985. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2988. return
  2989. }
  2990. userJSONBytes2, _ := json.Marshal(respJSON2)
  2991. if miConfig.Code == "H15049901371" {
  2992. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  2993. utils.ErrorLog("解析失败:%v", err)
  2994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2995. return
  2996. }
  2997. res2.InfRefmsgid = ressix10265.InfRefmsgid
  2998. res2.Output = ressix10265.Output
  2999. res2.ErrMsg = ressix10265.ErrMsg
  3000. res2.Cainfo = ressix10265.Cainfo
  3001. res2.WarnMsg = ressix10265.WarnMsg
  3002. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3003. res2.Infcode = infocode
  3004. } else {
  3005. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3006. utils.ErrorLog("解析失败:%v", err)
  3007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3008. return
  3009. }
  3010. }
  3011. }
  3012. if res2.Infcode != 0 {
  3013. adminUser := c.GetAdminUserInfo()
  3014. errlog := &models.HisOrderError{
  3015. UserOrgId: adminUser.CurrentOrgId,
  3016. Ctime: time.Now().Unix(),
  3017. Mtime: time.Now().Unix(),
  3018. ErrMsg: res2.ErrMsg,
  3019. Status: 1,
  3020. PatientId: id,
  3021. RecordTime: recordDateTime,
  3022. Stage: 3,
  3023. }
  3024. service.CreateErrMsgLog(errlog)
  3025. c.ServeSuccessJSON(map[string]interface{}{
  3026. "failed_code": -10,
  3027. "msg": res2.ErrMsg,
  3028. })
  3029. return
  3030. } else {
  3031. his.Diagnosis = diagnosis_id
  3032. his.SickType = sickConfig.ID
  3033. var p_type int64
  3034. if reg_type == 1111 || reg_type == 1112 {
  3035. p_type = 11
  3036. }
  3037. his.PType = fmt.Sprintf("%d", p_type)
  3038. service.UpdateHisPatientThree(&his)
  3039. data := make(map[string]interface{})
  3040. if settle_accounts_type == 1 { //日结
  3041. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3042. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3043. } else {
  3044. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3045. }
  3046. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3047. data["pre"] = prescriptions
  3048. } else { //月结
  3049. start_time_str := c.GetString("start_time")
  3050. end_time_str := c.GetString("end_time")
  3051. timeLayout := "2006-01-02"
  3052. loc, _ := time.LoadLocation("Local")
  3053. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3054. if err != nil {
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3056. return
  3057. }
  3058. recordStartTime := theStartTime.Unix()
  3059. start_time = recordStartTime
  3060. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3061. if err != nil {
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3063. return
  3064. }
  3065. recordEndTime := theEndTime.Unix()
  3066. end_time = recordEndTime
  3067. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3068. data["pre"] = prescriptions
  3069. }
  3070. timestamp := time.Now().Unix()
  3071. tempTime := time.Unix(timestamp, 0)
  3072. timeFormat := tempTime.Format("20060102150405")
  3073. chrgBchno := rand.Intn(100000) + 10000
  3074. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3075. strconv.FormatInt(his.PatientId, 10)
  3076. client := &http.Client{}
  3077. data["psn_no"] = his.PsnNo
  3078. data["mdtrt_id"] = his.Number
  3079. data["chrg_bchno"] = chrg_bchno
  3080. data["org_name"] = miConfig.OrgName
  3081. data["doctor"] = roles.UserName
  3082. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3083. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3084. data["fixmedins_code"] = miConfig.Code
  3085. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3086. data["dept_code"] = "15"
  3087. } else {
  3088. data["dept_code"] = department.Number
  3089. }
  3090. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3091. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3092. data["secret_key"] = miConfig.SecretKey
  3093. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3094. var ids []int64
  3095. for _, item := range prescriptions {
  3096. ids = append(ids, item.ID)
  3097. }
  3098. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3099. if config.IsOpen == 1 { //对接了医保,走医保流程
  3100. var res ResultFour
  3101. var resFour10265 ResultFour10265
  3102. if miConfig.MdtrtareaAdmvs == "421300" {
  3103. bytesData, _ := json.Marshal(data)
  3104. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3105. resp, _ := client.Do(req)
  3106. defer resp.Body.Close()
  3107. body, ioErr := ioutil.ReadAll(resp.Body)
  3108. if ioErr != nil {
  3109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3111. return
  3112. }
  3113. var respJSON map[string]interface{}
  3114. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3117. return
  3118. }
  3119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3120. userJSONBytes, _ := json.Marshal(respJSON)
  3121. fmt.Println("log")
  3122. fmt.Println(string(userJSONBytes))
  3123. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3124. utils.ErrorLog("解析失败:%v", err)
  3125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3126. return
  3127. }
  3128. } else {
  3129. if miConfig.Code == "H15049901371" {
  3130. 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)
  3131. var dat map[string]interface{}
  3132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3133. fmt.Println(dat)
  3134. } else {
  3135. fmt.Println(err)
  3136. }
  3137. saveLog(result, request_log, "2204", "上传费用明细")
  3138. userJSONBytes, _ := json.Marshal(dat)
  3139. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3140. utils.ErrorLog("解析失败:%v", err)
  3141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3142. return
  3143. }
  3144. res.InfRefmsgid = resFour10265.InfRefmsgid
  3145. res.Output = resFour10265.Output
  3146. res.ErrMsg = resFour10265.ErrMsg
  3147. res.Cainfo = resFour10265.Cainfo
  3148. res.WarnMsg = resFour10265.WarnMsg
  3149. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3150. res.Infcode = infocode
  3151. } else {
  3152. 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)
  3153. var dat map[string]interface{}
  3154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3155. fmt.Println(dat)
  3156. } else {
  3157. fmt.Println(err)
  3158. }
  3159. saveLog(result, request_log, "2204", "上传费用明细")
  3160. userJSONBytes, _ := json.Marshal(dat)
  3161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3162. utils.ErrorLog("解析失败:%v", err)
  3163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3164. return
  3165. }
  3166. }
  3167. }
  3168. if res.Infcode == 0 {
  3169. order := &models.HisOrder{
  3170. UserOrgId: adminUser.CurrentOrgId,
  3171. HisPatientId: his.ID,
  3172. PatientId: his.PatientId,
  3173. SettleAccountsDate: recordDateTime,
  3174. Ctime: time.Now().Unix(),
  3175. Mtime: time.Now().Unix(),
  3176. Status: 1,
  3177. Number: chrg_bchno,
  3178. Infcode: res.Infcode,
  3179. WarnMsg: res.WarnMsg,
  3180. Cainfo: res.Cainfo,
  3181. ErrMsg: res.ErrMsg,
  3182. RespondTime: res.RefmsgTime,
  3183. InfRefmsgid: res.InfRefmsgid,
  3184. OrderStatus: 1,
  3185. PayWay: pay_way,
  3186. PayPrice: pay_price,
  3187. PayCardNo: pay_card_no,
  3188. DiscountPrice: discount_price,
  3189. PreferentialPrice: preferential_price,
  3190. RealityPrice: reality_price,
  3191. FoundPrice: found_price,
  3192. MedicalInsurancePrice: medical_insurance_price,
  3193. PrivatePrice: private_price,
  3194. IsMedicineInsurance: 1,
  3195. SettleType: settle_accounts_type,
  3196. SettleStartTime: start_time,
  3197. SettleEndTime: end_time,
  3198. Creator: roles.AdminUserId,
  3199. Modify: roles.AdminUserId,
  3200. FaPiaoNumber: fapiao_number,
  3201. FaPiaoCode: fapiao_code,
  3202. PType: 2,
  3203. Diagnosis: diagnosis_id,
  3204. }
  3205. err = service.CreateOrder(order)
  3206. if err != nil {
  3207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3208. return
  3209. }
  3210. for _, item := range res.Output.Result {
  3211. temp := strings.Split(item.FeedetlSn, "-")
  3212. var advice_id int64 = 0
  3213. var project_id int64 = 0
  3214. var types int64 = 0
  3215. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3216. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3217. if temp[1] == "1" {
  3218. advice_id = id
  3219. project_id = 0
  3220. } else if temp[1] == "2" {
  3221. advice_id = 0
  3222. project_id = id
  3223. }
  3224. info := &models.HisOrderInfo{
  3225. OrderNumber: order.Number,
  3226. FeedetlSn: item.FeedetlSn,
  3227. UploadDate: time.Now().Unix(),
  3228. AdviceId: advice_id,
  3229. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3230. Cnt: item.Cnt,
  3231. Pric: float64(item.Pric),
  3232. PatientId: his.PatientId,
  3233. PricUplmtAmt: item.PricUplmtAmt,
  3234. SelfpayProp: item.SelfpayProp,
  3235. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3236. OverlmtAmt: item.OverlmtAmt,
  3237. PreselfpayAmt: item.PreselfpayAmt,
  3238. BasMednFlag: item.BasMednFlag,
  3239. MedChrgitmType: item.MedChrgitmType,
  3240. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3241. Status: 1,
  3242. Memo: item.Memo,
  3243. Mtime: time.Now().Unix(),
  3244. InscpScpAmt: item.InscpScpAmt,
  3245. DrtReimFlag: item.DrtReimFlag,
  3246. Ctime: time.Now().Unix(),
  3247. ListSpItemFlag: item.ListSpItemFlag,
  3248. ChldMedcFlag: item.ChldMedcFlag,
  3249. LmtUsedFlag: item.LmtUsedFlag,
  3250. ChrgitmLv: item.ChrgitmLv,
  3251. UserOrgId: adminUser.CurrentOrgId,
  3252. HisPatientId: his.ID,
  3253. OrderId: order.ID,
  3254. ProjectId: project_id,
  3255. Type: types,
  3256. }
  3257. service.CreateOrderInfo(info)
  3258. }
  3259. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3260. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3261. var total float64
  3262. for _, item := range prescriptions {
  3263. if item.Type == 1 { //药品
  3264. for _, subItem := range item.HisDoctorAdviceInfo {
  3265. total = total + (subItem.Price * subItem.PrescribingNumber)
  3266. }
  3267. }
  3268. if item.Type == 2 { //项目
  3269. for _, subItem := range item.HisPrescriptionProject {
  3270. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3271. total = total + (subItem.Price * cnt)
  3272. }
  3273. }
  3274. }
  3275. for _, item := range prescriptions {
  3276. for _, subItem := range item.HisAdditionalCharge {
  3277. total = total + (subItem.Price * float64(subItem.Count))
  3278. }
  3279. }
  3280. var allTotal string
  3281. if adminUser.CurrentOrgId == 9919 {
  3282. allTotal = fmt.Sprintf("%.4f", total)
  3283. } else {
  3284. allTotal = fmt.Sprintf("%.4f", total)
  3285. }
  3286. if res.Infcode == 0 {
  3287. var rf []*ResultFive
  3288. json.Unmarshal([]byte(his.Iinfo), &rf)
  3289. chrg_bchno := chrg_bchno
  3290. cert_no := his.Certno
  3291. var insutypes []string
  3292. var insutype string
  3293. var is390 int = 0
  3294. var is310 int = 0
  3295. for _, item := range rf {
  3296. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3297. insutypes = append(insutypes, item.Insutype)
  3298. }
  3299. }
  3300. if len(insutypes) == 1 {
  3301. insutype = insutypes[0]
  3302. } else {
  3303. for _, i := range insutypes {
  3304. if i == "390" {
  3305. is390 = 1
  3306. }
  3307. if i == "310" {
  3308. is310 = 1
  3309. }
  3310. }
  3311. }
  3312. if is390 == 1 {
  3313. insutype = "390"
  3314. }
  3315. if is310 == 1 {
  3316. insutype = "310"
  3317. }
  3318. if len(insutypes) == 0 {
  3319. insutype = "310"
  3320. }
  3321. if len(insutypes) == 2 {
  3322. insutype = strconv.FormatInt(his.SocialType, 10)
  3323. }
  3324. //insutype = "390"
  3325. if his.IdCardType == 1 {
  3326. // cert_no = his.MedicalInsuranceNumber
  3327. cert_no = his.Certno
  3328. } else {
  3329. cert_no = his.Certno
  3330. }
  3331. var res ResultSeven
  3332. var resSeven10265 ResultSeven10265
  3333. var src_resquest string
  3334. var result2 string
  3335. var acct_used_flag string
  3336. fmt.Println("pay_way")
  3337. fmt.Println(pay_way)
  3338. fmt.Println("pay_way")
  3339. if pay_way == 4 {
  3340. acct_used_flag = "1"
  3341. } else {
  3342. acct_used_flag = "0"
  3343. }
  3344. if miConfig.MdtrtareaAdmvs == "421300" {
  3345. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3346. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3347. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3348. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3349. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3350. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3351. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3352. resp, requestErr := http.Get(api)
  3353. if requestErr != nil {
  3354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3355. return
  3356. }
  3357. body, ioErr := ioutil.ReadAll(resp.Body)
  3358. if ioErr != nil {
  3359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return
  3362. }
  3363. var respJSON map[string]interface{}
  3364. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3370. result, _ := json.Marshal(respJSON)
  3371. if miConfig.Code == "H15049901371" {
  3372. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3373. utils.ErrorLog("解析失败:%v", err)
  3374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3375. return
  3376. }
  3377. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3378. res.Output = resSeven10265.Output
  3379. res.ErrMsg = resSeven10265.ErrMsg
  3380. res.Cainfo = resSeven10265.Cainfo
  3381. res.WarnMsg = resSeven10265.WarnMsg
  3382. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3383. res.Infcode = infocode
  3384. } else {
  3385. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3386. utils.ErrorLog("解析失败:%v", err)
  3387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3388. return
  3389. }
  3390. }
  3391. } else {
  3392. if miConfig.Code == "H15049901371" {
  3393. //赤峰地区国家医保医疗类别
  3394. //职工透析:医疗类别选特殊情况门诊990502
  3395. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3396. var med_type string
  3397. if his.Insutype == "390" {
  3398. if reg_type == 14 {
  3399. med_type = "9933"
  3400. } else if reg_type == 11 {
  3401. med_type = "11"
  3402. }
  3403. } else if his.Insutype == "310" {
  3404. if reg_type == 14 {
  3405. med_type = "990502"
  3406. } else if reg_type == 11 {
  3407. med_type = "11"
  3408. }
  3409. }
  3410. 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)
  3411. } else {
  3412. 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)
  3413. }
  3414. //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)
  3415. var dat map[string]interface{}
  3416. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3417. fmt.Println(dat)
  3418. } else {
  3419. fmt.Println(err)
  3420. }
  3421. saveLog(result2, src_resquest, "2207", "结算")
  3422. userJSONBytes, _ := json.Marshal(dat)
  3423. if miConfig.Code == "H15049901371" {
  3424. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3425. utils.ErrorLog("解析失败:%v", err)
  3426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3427. return
  3428. }
  3429. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3430. res.Output = resSeven10265.Output
  3431. res.ErrMsg = resSeven10265.ErrMsg
  3432. res.Cainfo = resSeven10265.Cainfo
  3433. res.WarnMsg = resSeven10265.WarnMsg
  3434. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3435. res.Infcode = infocode
  3436. } else {
  3437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3438. utils.ErrorLog("解析失败:%v", err)
  3439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3440. return
  3441. }
  3442. }
  3443. }
  3444. if res.Infcode != 0 {
  3445. errlog := &models.HisOrderError{
  3446. UserOrgId: adminUser.CurrentOrgId,
  3447. Ctime: time.Now().Unix(),
  3448. Mtime: time.Now().Unix(),
  3449. Number: chrg_bchno,
  3450. ErrMsg: res.ErrMsg,
  3451. Status: 1,
  3452. PatientId: id,
  3453. RecordTime: recordDateTime,
  3454. Stage: 6,
  3455. }
  3456. service.CreateErrMsgLog(errlog)
  3457. c.ServeSuccessJSON(map[string]interface{}{
  3458. "failed_code": -10,
  3459. "msg": res.ErrMsg,
  3460. })
  3461. return
  3462. } else {
  3463. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3464. order.OrderStatus = 2
  3465. order.Status = 1
  3466. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3467. order.SetlId = res.Output.Setlinfo.SetlID
  3468. order.PsnNo = res.Output.Setlinfo.PsnNo
  3469. order.PsnName = res.Output.Setlinfo.PsnName
  3470. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3471. order.Certno = res.Output.Setlinfo.Certno
  3472. order.Gend = res.Output.Setlinfo.Gend
  3473. order.Naty = res.Output.Setlinfo.Naty
  3474. order.Age = res.Output.Setlinfo.Age
  3475. order.Insutype = res.Output.Setlinfo.Insutype
  3476. order.PsnType = res.Output.Setlinfo.PsnType
  3477. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3478. order.SetlTime = res.Output.Setlinfo.SetlTime
  3479. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3480. if res.Output.Setlinfo.MedType == "140101" {
  3481. order.MedType = "14"
  3482. } else {
  3483. order.MedType = res.Output.Setlinfo.MedType
  3484. }
  3485. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3486. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3487. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3488. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3489. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3490. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3491. order.HifpPay = res.Output.Setlinfo.HifpPay
  3492. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3493. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3494. order.HifesPay = res.Output.Setlinfo.HifesPay
  3495. order.HifobPay = res.Output.Setlinfo.HifobPay
  3496. order.MafPay = res.Output.Setlinfo.MafPay
  3497. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3498. order.OthPay = res.Output.Setlinfo.OthPay
  3499. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3500. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3501. order.AcctPay = res.Output.Setlinfo.AcctPay
  3502. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3503. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3504. order.Balc = res.Output.Setlinfo.Balc
  3505. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3506. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3507. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3508. order.ClrWay = res.Output.Setlinfo.ClrWay
  3509. order.Creator = order.Creator
  3510. order.Modify = roles.AdminUserId
  3511. order.RequestLog = src_resquest
  3512. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3513. detailStr := string(setlDetail)
  3514. order.SetlDetail = detailStr
  3515. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3516. err = service.UpDateOrder(order)
  3517. if err == nil {
  3518. c.ServeSuccessJSON(map[string]interface{}{
  3519. "msg": "结算成功",
  3520. })
  3521. } else {
  3522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3523. return
  3524. }
  3525. }
  3526. } else {
  3527. adminUser := c.GetAdminUserInfo()
  3528. errlog := &models.HisOrderError{
  3529. UserOrgId: adminUser.CurrentOrgId,
  3530. Ctime: time.Now().Unix(),
  3531. Mtime: time.Now().Unix(),
  3532. ErrMsg: res.ErrMsg,
  3533. Status: 1,
  3534. PatientId: id,
  3535. RecordTime: recordDateTime,
  3536. Stage: 4,
  3537. }
  3538. service.CreateErrMsgLog(errlog)
  3539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3540. return
  3541. }
  3542. } else {
  3543. adminUser := c.GetAdminUserInfo()
  3544. errlog := &models.HisOrderError{
  3545. UserOrgId: adminUser.CurrentOrgId,
  3546. Ctime: time.Now().Unix(),
  3547. Mtime: time.Now().Unix(),
  3548. ErrMsg: res.ErrMsg,
  3549. Status: 1,
  3550. PatientId: id,
  3551. RecordTime: recordDateTime,
  3552. Stage: 4,
  3553. }
  3554. service.CreateErrMsgLog(errlog)
  3555. c.ServeSuccessJSON(map[string]interface{}{
  3556. "failed_code": -10,
  3557. "msg": res.ErrMsg,
  3558. })
  3559. return
  3560. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3561. //return
  3562. }
  3563. }
  3564. }
  3565. } else if tempOrder.ID > 0 {
  3566. if tempOrder.IsPre == 1 {
  3567. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3568. var rf []*ResultFive
  3569. json.Unmarshal([]byte(his.Iinfo), &rf)
  3570. chrg_bchno := tempOrder.Number
  3571. cert_no := his.Certno
  3572. var insutypes []string
  3573. var insutype string
  3574. var is390 int = 0
  3575. var is310 int = 0
  3576. for _, item := range rf {
  3577. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3578. insutypes = append(insutypes, item.Insutype)
  3579. }
  3580. }
  3581. if len(insutypes) == 1 {
  3582. insutype = insutypes[0]
  3583. } else {
  3584. for _, i := range insutypes {
  3585. if i == "390" {
  3586. is390 = 1
  3587. }
  3588. if i == "310" {
  3589. is310 = 1
  3590. }
  3591. }
  3592. }
  3593. if is390 == 1 {
  3594. insutype = "390"
  3595. }
  3596. if is310 == 1 {
  3597. insutype = "310"
  3598. }
  3599. if len(insutypes) == 0 {
  3600. insutype = "310"
  3601. }
  3602. if len(insutypes) == 2 {
  3603. insutype = strconv.FormatInt(his.SocialType, 64)
  3604. }
  3605. //insutype = "390"
  3606. if his.IdCardType == 1 {
  3607. // cert_no = his.MedicalInsuranceNumber
  3608. cert_no = his.Certno
  3609. } else {
  3610. cert_no = his.Certno
  3611. }
  3612. var res ResultSeven
  3613. var resSeven10265 ResultSeven10265
  3614. var src_resquest string
  3615. var result2 string
  3616. var acct_used_flag string
  3617. fmt.Println("pay_way")
  3618. fmt.Println(pay_way)
  3619. fmt.Println("pay_way")
  3620. if pay_way == 4 {
  3621. acct_used_flag = "1"
  3622. } else {
  3623. acct_used_flag = "0"
  3624. }
  3625. if miConfig.MdtrtareaAdmvs == "421300" {
  3626. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3627. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3628. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3629. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3630. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3631. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3632. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3633. resp, requestErr := http.Get(api)
  3634. if requestErr != nil {
  3635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3636. return
  3637. }
  3638. body, ioErr := ioutil.ReadAll(resp.Body)
  3639. if ioErr != nil {
  3640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3642. return
  3643. }
  3644. var respJSON map[string]interface{}
  3645. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3648. return
  3649. }
  3650. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3651. result, _ := json.Marshal(respJSON)
  3652. fmt.Println("log")
  3653. fmt.Println(string(result))
  3654. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3655. utils.ErrorLog("解析失败:%v", err)
  3656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3657. return
  3658. }
  3659. } else {
  3660. var src_resquest string
  3661. if miConfig.Code == "H15049901371" {
  3662. //赤峰地区国家医保医疗类别
  3663. //职工透析:医疗类别选特殊情况门诊990502
  3664. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3665. var med_type string
  3666. if his.Insutype == "390" {
  3667. if reg_type == 14 {
  3668. med_type = "9933"
  3669. } else if reg_type == 11 {
  3670. med_type = "11"
  3671. }
  3672. } else if his.Insutype == "310" {
  3673. if reg_type == 14 {
  3674. med_type = "990502"
  3675. } else if reg_type == 11 {
  3676. med_type = "11"
  3677. }
  3678. }
  3679. 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)
  3680. } else {
  3681. 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)
  3682. }
  3683. var dat map[string]interface{}
  3684. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3685. fmt.Println(dat)
  3686. } else {
  3687. fmt.Println(err)
  3688. }
  3689. saveLog(result2, src_resquest, "2207", "结算")
  3690. userJSONBytes, _ := json.Marshal(dat)
  3691. if miConfig.Code == "H15049901371" {
  3692. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3693. utils.ErrorLog("解析失败:%v", err)
  3694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3695. return
  3696. }
  3697. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3698. res.Output = resSeven10265.Output
  3699. res.ErrMsg = resSeven10265.ErrMsg
  3700. res.Cainfo = resSeven10265.Cainfo
  3701. res.WarnMsg = resSeven10265.WarnMsg
  3702. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3703. res.Infcode = infocode
  3704. } else {
  3705. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3706. utils.ErrorLog("解析失败:%v", err)
  3707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3708. return
  3709. }
  3710. }
  3711. }
  3712. if res.Infcode != 0 {
  3713. errlog := &models.HisOrderError{
  3714. UserOrgId: adminUser.CurrentOrgId,
  3715. Ctime: time.Now().Unix(),
  3716. Mtime: time.Now().Unix(),
  3717. Number: chrg_bchno,
  3718. ErrMsg: res.ErrMsg,
  3719. Status: 1,
  3720. PatientId: id,
  3721. RecordTime: recordDateTime,
  3722. Stage: 6,
  3723. }
  3724. service.CreateErrMsgLog(errlog)
  3725. c.ServeSuccessJSON(map[string]interface{}{
  3726. "failed_code": -10,
  3727. "msg": res.ErrMsg,
  3728. })
  3729. return
  3730. } else {
  3731. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3732. order.OrderStatus = 2
  3733. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3734. order.SetlId = res.Output.Setlinfo.SetlID
  3735. order.PsnNo = res.Output.Setlinfo.PsnNo
  3736. order.PsnName = res.Output.Setlinfo.PsnName
  3737. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3738. order.Certno = res.Output.Setlinfo.Certno
  3739. order.Gend = res.Output.Setlinfo.Gend
  3740. order.Naty = res.Output.Setlinfo.Naty
  3741. order.Age = res.Output.Setlinfo.Age
  3742. order.Insutype = res.Output.Setlinfo.Insutype
  3743. order.PsnType = res.Output.Setlinfo.PsnType
  3744. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3745. order.SetlTime = res.Output.Setlinfo.SetlTime
  3746. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3747. order.MedType = res.Output.Setlinfo.MedType
  3748. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3749. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3750. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3751. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3752. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3753. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3754. order.HifpPay = res.Output.Setlinfo.HifpPay
  3755. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3756. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3757. order.HifesPay = res.Output.Setlinfo.HifesPay
  3758. order.HifobPay = res.Output.Setlinfo.HifobPay
  3759. order.MafPay = res.Output.Setlinfo.MafPay
  3760. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3761. order.OthPay = res.Output.Setlinfo.OthPay
  3762. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3763. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3764. order.AcctPay = res.Output.Setlinfo.AcctPay
  3765. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3766. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3767. order.Balc = res.Output.Setlinfo.Balc
  3768. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3769. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3770. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3771. order.ClrWay = res.Output.Setlinfo.ClrWay
  3772. order.Creator = order.Creator
  3773. order.Modify = roles.AdminUserId
  3774. order.RequestLog = src_resquest
  3775. order.Diagnosis = diagnosis_id
  3776. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3777. detailStr := string(setlDetail)
  3778. order.SetlDetail = detailStr
  3779. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3780. err = service.UpDateOrder(order)
  3781. if err == nil {
  3782. c.ServeSuccessJSON(map[string]interface{}{
  3783. "msg": "结算成功",
  3784. })
  3785. } else {
  3786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3787. return
  3788. }
  3789. }
  3790. }
  3791. }
  3792. }
  3793. //func (c *HisApiController) GetPreUploadInfo() {
  3794. // id, _ := c.GetInt64("id")
  3795. // record_time := c.GetString("record_time")
  3796. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3797. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3798. //
  3799. // timeLayout := "2006-01-02"
  3800. // loc, _ := time.LoadLocation("Local")
  3801. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3802. // if err != nil {
  3803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3804. // return
  3805. // }
  3806. // recordDateTime := theTime.Unix()
  3807. // adminUser := c.GetAdminUserInfo()
  3808. //
  3809. // var prescriptions []*models.HisPrescription
  3810. //
  3811. // var start_time int64
  3812. // var end_time int64
  3813. //
  3814. // data := make(map[string]interface{})
  3815. // if settle_accounts_type == 1 { //日结
  3816. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3817. // data["pre"] = prescriptions
  3818. //
  3819. // } else { //月结
  3820. // start_time_str := c.GetString("start_time")
  3821. // end_time_str := c.GetString("end_time")
  3822. // timeLayout := "2006-01-02"
  3823. // loc, _ := time.LoadLocation("Local")
  3824. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3825. // if err != nil {
  3826. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3827. // return
  3828. // }
  3829. // recordStartTime := theStartTime.Unix()
  3830. // start_time = recordStartTime
  3831. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3832. // if err != nil {
  3833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3834. // return
  3835. // }
  3836. // recordEndTime := theEndTime.Unix()
  3837. // end_time = recordEndTime
  3838. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3839. // data["pre"] = prescriptions
  3840. //
  3841. // }
  3842. //
  3843. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3844. //
  3845. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3846. // timestamp := time.Now().Unix()
  3847. // tempTime := time.Unix(timestamp, 0)
  3848. // timeFormat := tempTime.Format("20060102150405")
  3849. // chrgBchno := rand.Intn(100000) + 10000
  3850. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3851. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3852. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3853. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3854. // strconv.FormatInt(his.PatientId, 10)
  3855. // client := &http.Client{}
  3856. // data["psn_no"] = his.PsnNo
  3857. // data["mdtrt_id"] = his.Number
  3858. // data["chrg_bchno"] = chrg_bchno
  3859. // data["org_name"] = miConfig.OrgName
  3860. // data["doctor"] = roles.UserName
  3861. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3862. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3863. // data["fixmedins_code"] = miConfig.Code
  3864. // data["dept_code"] = department.Number
  3865. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3866. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3867. // data["secret_key"] = miConfig.SecretKey
  3868. // var ids []int64
  3869. //
  3870. // for _, item := range prescriptions {
  3871. // ids = append(ids, item.ID)
  3872. // }
  3873. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3874. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3875. // bytesData, _ := json.Marshal(data)
  3876. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3877. // resp, _ := client.Do(req)
  3878. // defer resp.Body.Close()
  3879. // body, ioErr := ioutil.ReadAll(resp.Body)
  3880. // if ioErr != nil {
  3881. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3883. // return
  3884. // }
  3885. // var respJSON map[string]interface{}
  3886. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3887. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3889. // return
  3890. // }
  3891. //
  3892. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3893. // userJSONBytes, _ := json.Marshal(respJSON)
  3894. // var res ResultFour
  3895. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3896. // utils.ErrorLog("解析失败:%v", err)
  3897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3898. // return
  3899. // }
  3900. //
  3901. // if res.Infcode == 0 {
  3902. // order := &models.HisOrder{
  3903. // UserOrgId: adminUser.CurrentOrgId,
  3904. // HisPatientId: his.ID,
  3905. // PatientId: his.PatientId,
  3906. // SettleAccountsDate: recordDateTime,
  3907. // Ctime: time.Now().Unix(),
  3908. // Mtime: time.Now().Unix(),
  3909. // Status: 1,
  3910. // Number: chrg_bchno,
  3911. // Infcode: res.Infcode,
  3912. // WarnMsg: res.WarnMsg,
  3913. // Cainfo: res.Cainfo,
  3914. // ErrMsg: res.ErrMsg,
  3915. // RespondTime: res.RefmsgTime,
  3916. // InfRefmsgid: res.InfRefmsgid,
  3917. // OrderStatus: 1,
  3918. // IsMedicineInsurance: 1,
  3919. // SettleType: settle_accounts_type,
  3920. // SettleStartTime: start_time,
  3921. // SettleEndTime: end_time,
  3922. // Creator: roles.ID,
  3923. // Modify: roles.ID,
  3924. // PType: 2,
  3925. // }
  3926. // err = service.CreateOrder(order)
  3927. // if err != nil {
  3928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3929. // return
  3930. // }
  3931. //
  3932. // for _, item := range res.Output.Result {
  3933. // temp := strings.Split(item.FeedetlSn, "-")
  3934. // var advice_id int64 = 0
  3935. // var project_id int64 = 0
  3936. // var types int64 = 0
  3937. //
  3938. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  3939. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  3940. //
  3941. // if temp[1] == "1" {
  3942. // advice_id = id
  3943. // project_id = 0
  3944. // } else if temp[1] == "2" {
  3945. // advice_id = 0
  3946. // project_id = id
  3947. // }
  3948. //
  3949. // info := &models.HisOrderInfo{
  3950. // OrderNumber: order.Number,
  3951. // FeedetlSn: item.FeedetlSn,
  3952. // UploadDate: time.Now().Unix(),
  3953. // AdviceId: advice_id,
  3954. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  3955. // Cnt: item.Cnt,
  3956. // Pric: float64(item.Pric),
  3957. // PatientId: his.PatientId,
  3958. // PricUplmtAmt: item.PricUplmtAmt,
  3959. // SelfpayProp: item.SelfpayProp,
  3960. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3961. // OverlmtAmt: item.OverlmtAmt,
  3962. // PreselfpayAmt: item.PreselfpayAmt,
  3963. // BasMednFlag: item.BasMednFlag,
  3964. // MedChrgitmType: item.MedChrgitmType,
  3965. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  3966. // Status: 1,
  3967. // Memo: item.Memo,
  3968. // Mtime: time.Now().Unix(),
  3969. // InscpScpAmt: item.InscpScpAmt,
  3970. // DrtReimFlag: item.DrtReimFlag,
  3971. // Ctime: time.Now().Unix(),
  3972. // ListSpItemFlag: item.ListSpItemFlag,
  3973. // ChldMedcFlag: item.ChldMedcFlag,
  3974. // LmtUsedFlag: item.LmtUsedFlag,
  3975. // ChrgitmLv: item.ChrgitmLv,
  3976. // UserOrgId: adminUser.CurrentOrgId,
  3977. // HisPatientId: his.ID,
  3978. // OrderId: order.ID,
  3979. // ProjectId: project_id,
  3980. // Type: types,
  3981. // }
  3982. // service.CreateOrderInfo(info)
  3983. //
  3984. // }
  3985. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3986. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  3987. //
  3988. // var total float64
  3989. // for _, item := range prescriptions {
  3990. // if item.Type == 1 { //药品
  3991. // for _, subItem := range item.HisDoctorAdviceInfo {
  3992. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3993. // }
  3994. // }
  3995. // if item.Type == 2 { //项目
  3996. // for _, subItem := range item.HisPrescriptionProject {
  3997. // total = total + (subItem.Price * float64(subItem.Count))
  3998. // }
  3999. // }
  4000. // }
  4001. //
  4002. // for _, item := range prescriptions {
  4003. // for _, subItem := range item.HisAdditionalCharge {
  4004. // total = total + (subItem.Price * float64(subItem.Count))
  4005. // }
  4006. // }
  4007. //
  4008. // allTotal := fmt.Sprintf("%.2f", total)
  4009. // if res.Infcode == 0 {
  4010. // var rf []*ResultFive
  4011. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4012. // psn_no := his.PsnNo
  4013. // mdtrt_id := his.Number
  4014. // chrg_bchno := chrg_bchno
  4015. // cert_no := his.Certno
  4016. // insutype := rf[0].Insutype
  4017. //
  4018. // if his.IdCardType == 1 {
  4019. // cert_no = his.MedicalInsuranceNumber
  4020. //
  4021. // } else {
  4022. //
  4023. // cert_no = his.Certno
  4024. //
  4025. // }
  4026. //
  4027. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4028. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4029. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4030. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4031. // resp, requestErr := http.Get(api)
  4032. // if requestErr != nil {
  4033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4034. // return
  4035. // }
  4036. // defer resp.Body.Close()
  4037. // body, ioErr := ioutil.ReadAll(resp.Body)
  4038. // if ioErr != nil {
  4039. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4041. // return
  4042. // }
  4043. // var respJSON map[string]interface{}
  4044. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4045. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4047. // return
  4048. // }
  4049. // fmt.Println(respJSON)
  4050. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4051. // userJSONBytes, _ := json.Marshal(respJSON)
  4052. // var res ResultSeven
  4053. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4054. // utils.ErrorLog("解析失败:%v", err)
  4055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4056. // return
  4057. // }
  4058. // if res.Infcode != 0 {
  4059. // errlog := &models.HisOrderError{
  4060. // UserOrgId: adminUser.CurrentOrgId,
  4061. // Ctime: time.Now().Unix(),
  4062. // Mtime: time.Now().Unix(),
  4063. // Number: chrg_bchno,
  4064. // ErrMsg: res.ErrMsg,
  4065. // Status: 1,
  4066. // PatientId: id,
  4067. // RecordTime: recordDateTime,
  4068. // Stage: 7,
  4069. // }
  4070. // service.CreateErrMsgLog(errlog)
  4071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4072. // return
  4073. // } else {
  4074. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4075. // order.OrderStatus = 1
  4076. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4077. // order.SetlId = res.Output.Setlinfo.SetlID
  4078. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4079. // order.PsnName = res.Output.Setlinfo.PsnName
  4080. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4081. // order.Certno = res.Output.Setlinfo.Certno
  4082. // order.Gend = res.Output.Setlinfo.Gend
  4083. // order.Naty = res.Output.Setlinfo.Naty
  4084. // order.Age = res.Output.Setlinfo.Age
  4085. // order.Insutype = res.Output.Setlinfo.Insutype
  4086. // order.PsnType = res.Output.Setlinfo.PsnType
  4087. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4088. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4089. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4090. // order.MedType = res.Output.Setlinfo.MedType
  4091. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4092. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4093. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4094. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4095. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4096. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4097. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4098. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4099. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4100. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4101. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4102. // order.MafPay = res.Output.Setlinfo.MafPay
  4103. // order.OthPay = res.Output.Setlinfo.OthPay
  4104. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4105. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4106. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4107. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4108. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4109. // order.Balc = res.Output.Setlinfo.Balc
  4110. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4111. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4112. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4113. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4114. // order.Creator = order.Creator
  4115. // order.Modify = roles.ID
  4116. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4117. // detailStr := string(setlDetail)
  4118. // order.SetlDetail = detailStr
  4119. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4120. // err = service.UpDateOrder(order)
  4121. // if err == nil {
  4122. // c.ServeSuccessJSON(map[string]interface{}{
  4123. // "msg": "预结算成功",
  4124. // })
  4125. // } else {
  4126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4127. // return
  4128. // }
  4129. // }
  4130. // } else {
  4131. // adminUser := c.GetAdminUserInfo()
  4132. // errlog := &models.HisOrderError{
  4133. // UserOrgId: adminUser.CurrentOrgId,
  4134. // Ctime: time.Now().Unix(),
  4135. // Mtime: time.Now().Unix(),
  4136. // ErrMsg: res.ErrMsg,
  4137. // Status: 1,
  4138. // PatientId: id,
  4139. // RecordTime: recordDateTime,
  4140. // Stage: 4,
  4141. // }
  4142. // service.CreateErrMsgLog(errlog)
  4143. //
  4144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4145. // return
  4146. // }
  4147. // } else {
  4148. // adminUser := c.GetAdminUserInfo()
  4149. // errlog := &models.HisOrderError{
  4150. // UserOrgId: adminUser.CurrentOrgId,
  4151. // Ctime: time.Now().Unix(),
  4152. // Mtime: time.Now().Unix(),
  4153. // ErrMsg: res.ErrMsg,
  4154. // Status: 1,
  4155. // PatientId: id,
  4156. // RecordTime: recordDateTime,
  4157. // Stage: 4,
  4158. // }
  4159. // service.CreateErrMsgLog(errlog)
  4160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4161. // return
  4162. // }
  4163. //
  4164. // } else {
  4165. // var total float64
  4166. // for _, item := range prescriptions {
  4167. // if item.Type == 1 { //药品
  4168. // for _, subItem := range item.HisDoctorAdviceInfo {
  4169. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4170. // }
  4171. // }
  4172. // if item.Type == 2 { //项目
  4173. // for _, subItem := range item.HisPrescriptionProject {
  4174. // total = total + (subItem.Price * float64(subItem.Count))
  4175. // }
  4176. // }
  4177. //
  4178. // for _, subItem := range item.HisAdditionalCharge {
  4179. // total = total + (subItem.Price * float64(subItem.Count))
  4180. // }
  4181. // }
  4182. //
  4183. // allTotal := fmt.Sprintf("%.2f", total)
  4184. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4185. // order := &models.HisOrder{
  4186. // UserOrgId: adminUser.CurrentOrgId,
  4187. // HisPatientId: his.ID,
  4188. // PatientId: id,
  4189. // SettleAccountsDate: recordDateTime,
  4190. // Ctime: time.Now().Unix(),
  4191. // Mtime: time.Now().Unix(),
  4192. // Status: 1,
  4193. // OrderStatus: 2,
  4194. // Number: chrg_bchno,
  4195. // MedfeeSumamt: totals,
  4196. // }
  4197. // err = service.CreateOrder(order)
  4198. // if err != nil {
  4199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4200. // return
  4201. // }
  4202. //
  4203. // var customs []*Custom
  4204. // for _, item := range prescriptions {
  4205. //
  4206. // if item.Type == 1 { //药品
  4207. // for _, subItem := range item.HisDoctorAdviceInfo {
  4208. // cus := &Custom{
  4209. // AdviceId: subItem.ID,
  4210. // ProjectId: 0,
  4211. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4212. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4213. // FeedetlSn: subItem.FeedetlSn,
  4214. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4215. // MedListCodg: subItem.MedListCodg,
  4216. // Type: 1,
  4217. // }
  4218. // customs = append(customs, cus)
  4219. // }
  4220. // }
  4221. //
  4222. // if item.Type == 2 { //项目
  4223. // for _, subItem := range item.HisPrescriptionProject {
  4224. //
  4225. // cus := &Custom{
  4226. // AdviceId: 0,
  4227. // ProjectId: subItem.ID,
  4228. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4229. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4230. // FeedetlSn: subItem.FeedetlSn,
  4231. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4232. // MedListCodg: subItem.MedListCodg,
  4233. // Type: 2,
  4234. // }
  4235. //
  4236. // customs = append(customs, cus)
  4237. // }
  4238. // }
  4239. //
  4240. // for _, item := range item.HisAdditionalCharge {
  4241. // cus := &Custom{
  4242. // ItemId: item.ID,
  4243. // AdviceId: 0,
  4244. // ProjectId: 0,
  4245. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4246. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4247. // FeedetlSn: item.FeedetlSn,
  4248. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4249. // MedListCodg: item.XtHisAddtionConfig.Code,
  4250. // Type: 3,
  4251. // }
  4252. //
  4253. // customs = append(customs, cus)
  4254. // }
  4255. //
  4256. // }
  4257. //
  4258. // for _, item := range customs {
  4259. // var advice_id int64 = 0
  4260. // var project_id int64 = 0
  4261. // var item_id int64 = 0
  4262. //
  4263. // var types int64 = 0
  4264. //
  4265. // if item.Type == 1 {
  4266. // advice_id = item.AdviceId
  4267. // project_id = 0
  4268. // item_id = 0
  4269. // } else if item.Type == 2 {
  4270. // advice_id = 0
  4271. // item_id = 0
  4272. //
  4273. // project_id = item.ProjectId
  4274. // } else if item.Type == 3 {
  4275. // advice_id = 0
  4276. // item_id = item.ItemId
  4277. // project_id = 0
  4278. // }
  4279. //
  4280. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4281. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4282. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4283. //
  4284. // info := &models.HisOrderInfo{
  4285. // OrderNumber: order.Number,
  4286. // UploadDate: time.Now().Unix(),
  4287. // AdviceId: advice_id,
  4288. // DetItemFeeSumamt: detItemFeeSumamt,
  4289. // Cnt: cut,
  4290. // Pric: pric,
  4291. // PatientId: id,
  4292. // Status: 1,
  4293. // Mtime: time.Now().Unix(),
  4294. // Ctime: time.Now().Unix(),
  4295. // UserOrgId: adminUser.CurrentOrgId,
  4296. // HisPatientId: his.ID,
  4297. // OrderId: order.ID,
  4298. // ProjectId: project_id,
  4299. // Type: types,
  4300. // ItemId: item_id,
  4301. // }
  4302. // service.CreateOrderInfo(info)
  4303. // }
  4304. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4305. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4306. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4307. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4308. // if err == nil {
  4309. // c.ServeSuccessJSON(map[string]interface{}{
  4310. // "msg": "结算成功",
  4311. // })
  4312. // } else {
  4313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4314. // return
  4315. // }
  4316. // }
  4317. //}
  4318. //上传明细-预结算-
  4319. func (c *HisApiController) GetPreUploadInfo() {
  4320. id, _ := c.GetInt64("id")
  4321. record_time := c.GetString("record_time")
  4322. his_patient_id, _ := c.GetInt64("his_patient_id")
  4323. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4324. admin_user_id, _ := c.GetInt64("admin_user_id")
  4325. diagnosis_id := c.GetString("diagnosis")
  4326. sick_type, _ := c.GetInt64("sick_type")
  4327. reg_type, _ := c.GetInt64("p_type")
  4328. id_str := c.GetString("ids")
  4329. ids_arr := strings.Split(id_str, ",")
  4330. timeLayout := "2006-01-02"
  4331. loc, _ := time.LoadLocation("Local")
  4332. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4333. if err != nil {
  4334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4335. return
  4336. }
  4337. recordDateTime := theTime.Unix()
  4338. adminUser := c.GetAdminUserInfo()
  4339. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4340. var config []*models.HisXtDiagnoseConfig
  4341. for _, item := range diagnosis_ids {
  4342. id, _ := strconv.ParseInt(item, 10, 64)
  4343. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4344. config = append(config, &diagnosisConfig)
  4345. }
  4346. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4347. sickConfig, _ := service.FindSickById(sick_type)
  4348. var prescriptions []*models.HisPrescription
  4349. var start_time int64
  4350. var end_time int64
  4351. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4352. fmt.Println(his_patient_id)
  4353. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4354. timestamp := time.Now().Unix()
  4355. tempTime := time.Unix(timestamp, 0)
  4356. timeFormat := tempTime.Format("20060102150405")
  4357. chrgBchno := rand.Intn(100000) + 10000
  4358. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4359. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4360. var patientPrescription models.HisPrescriptionInfo
  4361. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4362. if patientPrescription.ID == 0 {
  4363. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4364. }
  4365. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4366. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4367. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4368. strconv.FormatInt(his.PatientId, 10)
  4369. var res2 ResultSix
  4370. var resSix10265 ResultSix10265
  4371. if miConfig.InsuplcAdmdvs == "421300" {
  4372. data := make(map[string]interface{})
  4373. client := &http.Client{}
  4374. data["psn_no"] = his.PsnNo
  4375. data["mdtrt_id"] = his.Number
  4376. data["doctor"] = roles.UserName
  4377. data["department"] = department.Name
  4378. data["org_name"] = miConfig.OrgName
  4379. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4380. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4381. data["fixmedins_code"] = miConfig.Code
  4382. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4383. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4384. data["secret_key"] = miConfig.SecretKey
  4385. data["sick_code"] = sickConfig.CountryCode
  4386. data["sick_name"] = sickConfig.ClassName
  4387. data["dept"] = strconv.FormatInt(department.ID, 10)
  4388. data["config"] = config
  4389. fmt.Println(data)
  4390. bytesData, _ := json.Marshal(data)
  4391. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4392. resp, _ := client.Do(req)
  4393. defer resp.Body.Close()
  4394. body, ioErr := ioutil.ReadAll(resp.Body)
  4395. if ioErr != nil {
  4396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. return
  4399. }
  4400. var respJSON map[string]interface{}
  4401. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4407. userJSONBytes, _ := json.Marshal(respJSON)
  4408. fmt.Println("log")
  4409. fmt.Println(string(userJSONBytes))
  4410. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4411. utils.ErrorLog("解析失败:%v", err)
  4412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4413. return
  4414. }
  4415. } else {
  4416. var result string
  4417. var requestLog string
  4418. if miConfig.InsuplcAdmdvs == "440781" { //
  4419. 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)
  4420. } else {
  4421. if miConfig.Code == "H15049901371" {
  4422. //赤峰地区国家医保医疗类别
  4423. //职工透析:医疗类别选特殊情况门诊990502
  4424. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4425. var med_type string
  4426. if his.Insutype == "390" {
  4427. if reg_type == 14 {
  4428. med_type = "9933"
  4429. } else if reg_type == 11 {
  4430. med_type = "11"
  4431. }
  4432. } else if his.Insutype == "310" {
  4433. if reg_type == 14 {
  4434. med_type = "990502"
  4435. } else if reg_type == 11 {
  4436. med_type = "11"
  4437. }
  4438. }
  4439. 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)
  4440. } else {
  4441. 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)
  4442. }
  4443. saveLog(result, requestLog, "2203", "上传就诊信息")
  4444. var respJSON2 map[string]interface{}
  4445. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4448. return
  4449. }
  4450. //userJSONBytes2, _ := json.Marshal(respJSON2)
  4451. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4452. // utils.ErrorLog("解析失败:%v", err)
  4453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4454. // return
  4455. //}
  4456. userJSONBytes2, _ := json.Marshal(respJSON2)
  4457. if miConfig.Code == "H15049901371" {
  4458. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4459. utils.ErrorLog("解析失败:%v", err)
  4460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4461. return
  4462. }
  4463. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4464. res2.Output = resSix10265.Output
  4465. res2.ErrMsg = resSix10265.ErrMsg
  4466. res2.Cainfo = resSix10265.Cainfo
  4467. res2.WarnMsg = resSix10265.WarnMsg
  4468. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4469. res2.Infcode = infocode
  4470. } else {
  4471. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4472. utils.ErrorLog("解析失败:%v", err)
  4473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4474. return
  4475. }
  4476. }
  4477. }
  4478. }
  4479. if res2.Infcode != 0 {
  4480. adminUser := c.GetAdminUserInfo()
  4481. errlog := &models.HisOrderError{
  4482. UserOrgId: adminUser.CurrentOrgId,
  4483. Ctime: time.Now().Unix(),
  4484. Mtime: time.Now().Unix(),
  4485. ErrMsg: res2.ErrMsg,
  4486. Status: 1,
  4487. PatientId: id,
  4488. RecordTime: recordDateTime,
  4489. Stage: 3,
  4490. }
  4491. service.CreateErrMsgLog(errlog)
  4492. c.ServeSuccessJSON(map[string]interface{}{
  4493. "failed_code": -10,
  4494. "msg": res2.ErrMsg,
  4495. })
  4496. return
  4497. } else {
  4498. his.Diagnosis = diagnosis_id
  4499. his.SickType = sickConfig.ID
  4500. his.PType = fmt.Sprintf("%d", reg_type)
  4501. service.UpdateHisPatientThree(&his)
  4502. data := make(map[string]interface{})
  4503. if settle_accounts_type == 1 { //日结
  4504. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4505. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4506. } else {
  4507. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4508. }
  4509. data["pre"] = prescriptions
  4510. } else { //月结
  4511. start_time_str := c.GetString("start_time")
  4512. end_time_str := c.GetString("end_time")
  4513. timeLayout := "2006-01-02"
  4514. loc, _ := time.LoadLocation("Local")
  4515. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4516. if err != nil {
  4517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4518. return
  4519. }
  4520. recordStartTime := theStartTime.Unix()
  4521. start_time = recordStartTime
  4522. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4523. if err != nil {
  4524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4525. return
  4526. }
  4527. recordEndTime := theEndTime.Unix()
  4528. end_time = recordEndTime
  4529. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4530. data["pre"] = prescriptions
  4531. }
  4532. client := &http.Client{}
  4533. data["psn_no"] = his.PsnNo
  4534. data["mdtrt_id"] = his.Number
  4535. data["chrg_bchno"] = chrg_bchno
  4536. data["org_name"] = miConfig.OrgName
  4537. data["doctor"] = roles.UserName
  4538. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4539. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4540. data["fixmedins_code"] = miConfig.Code
  4541. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4542. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4543. data["dept_code"] = "15"
  4544. } else {
  4545. data["dept_code"] = department.Number
  4546. }
  4547. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4548. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4549. data["secret_key"] = miConfig.SecretKey
  4550. var ids []int64
  4551. for _, item := range prescriptions {
  4552. ids = append(ids, item.ID)
  4553. }
  4554. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4555. if config.IsOpen == 1 { //对接了医保,走医保流程
  4556. var res ResultFour
  4557. var resFour10265 ResultFour10265
  4558. if miConfig.MdtrtareaAdmvs == "421300" {
  4559. bytesData, _ := json.Marshal(data)
  4560. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4561. resp, _ := client.Do(req)
  4562. defer resp.Body.Close()
  4563. body, ioErr := ioutil.ReadAll(resp.Body)
  4564. if ioErr != nil {
  4565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4567. return
  4568. }
  4569. var respJSON map[string]interface{}
  4570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. return
  4574. }
  4575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4576. userJSONBytes, _ := json.Marshal(respJSON)
  4577. fmt.Println("log")
  4578. fmt.Println(string(userJSONBytes))
  4579. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4580. utils.ErrorLog("解析失败:%v", err)
  4581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4582. return
  4583. }
  4584. } else {
  4585. if miConfig.Code == "H15049901371" {
  4586. 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)
  4587. var dat map[string]interface{}
  4588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4589. fmt.Println(dat)
  4590. } else {
  4591. fmt.Println(err)
  4592. }
  4593. saveLog(result, request_log, "2204", "上传费用明细")
  4594. userJSONBytes, _ := json.Marshal(dat)
  4595. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4596. utils.ErrorLog("解析失败:%v", err)
  4597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4598. return
  4599. }
  4600. res.InfRefmsgid = resFour10265.InfRefmsgid
  4601. res.Output = resFour10265.Output
  4602. res.ErrMsg = resFour10265.ErrMsg
  4603. res.Cainfo = resFour10265.Cainfo
  4604. res.WarnMsg = resFour10265.WarnMsg
  4605. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4606. res.Infcode = infocode
  4607. } else {
  4608. 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)
  4609. var dat map[string]interface{}
  4610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4611. fmt.Println(dat)
  4612. } else {
  4613. fmt.Println(err)
  4614. }
  4615. saveLog(result, request_log, "2204", "上传费用明细")
  4616. userJSONBytes, _ := json.Marshal(dat)
  4617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4618. utils.ErrorLog("解析失败:%v", err)
  4619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4620. return
  4621. }
  4622. }
  4623. }
  4624. if res.Infcode == 0 {
  4625. order := &models.HisOrder{
  4626. UserOrgId: adminUser.CurrentOrgId,
  4627. HisPatientId: his.ID,
  4628. PatientId: his.PatientId,
  4629. SettleAccountsDate: recordDateTime,
  4630. Ctime: time.Now().Unix(),
  4631. Mtime: time.Now().Unix(),
  4632. Status: 1,
  4633. Number: chrg_bchno,
  4634. Infcode: res.Infcode,
  4635. WarnMsg: res.WarnMsg,
  4636. Cainfo: res.Cainfo,
  4637. ErrMsg: res.ErrMsg,
  4638. RespondTime: res.RefmsgTime,
  4639. InfRefmsgid: res.InfRefmsgid,
  4640. OrderStatus: 1,
  4641. IsMedicineInsurance: 1,
  4642. SettleType: settle_accounts_type,
  4643. SettleStartTime: start_time,
  4644. SettleEndTime: end_time,
  4645. Creator: roles.AdminUserId,
  4646. Modify: roles.AdminUserId,
  4647. PType: 2,
  4648. Diagnosis: diagnosis_id,
  4649. }
  4650. err = service.CreateOrder(order)
  4651. if err != nil {
  4652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4653. return
  4654. }
  4655. for _, item := range res.Output.Result {
  4656. temp := strings.Split(item.FeedetlSn, "-")
  4657. var advice_id int64 = 0
  4658. var project_id int64 = 0
  4659. var types int64 = 0
  4660. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4661. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4662. if temp[1] == "1" {
  4663. advice_id = id
  4664. project_id = 0
  4665. } else if temp[1] == "2" {
  4666. advice_id = 0
  4667. project_id = id
  4668. }
  4669. info := &models.HisOrderInfo{
  4670. OrderNumber: order.Number,
  4671. FeedetlSn: item.FeedetlSn,
  4672. UploadDate: time.Now().Unix(),
  4673. AdviceId: advice_id,
  4674. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4675. Cnt: item.Cnt,
  4676. Pric: float64(item.Pric),
  4677. PatientId: his.PatientId,
  4678. PricUplmtAmt: item.PricUplmtAmt,
  4679. SelfpayProp: item.SelfpayProp,
  4680. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4681. OverlmtAmt: item.OverlmtAmt,
  4682. PreselfpayAmt: item.PreselfpayAmt,
  4683. BasMednFlag: item.BasMednFlag,
  4684. MedChrgitmType: item.MedChrgitmType,
  4685. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4686. Status: 1,
  4687. Memo: item.Memo,
  4688. Mtime: time.Now().Unix(),
  4689. InscpScpAmt: item.InscpScpAmt,
  4690. DrtReimFlag: item.DrtReimFlag,
  4691. Ctime: time.Now().Unix(),
  4692. ListSpItemFlag: item.ListSpItemFlag,
  4693. ChldMedcFlag: item.ChldMedcFlag,
  4694. LmtUsedFlag: item.LmtUsedFlag,
  4695. ChrgitmLv: item.ChrgitmLv,
  4696. UserOrgId: adminUser.CurrentOrgId,
  4697. HisPatientId: his.ID,
  4698. OrderId: order.ID,
  4699. ProjectId: project_id,
  4700. Type: types,
  4701. }
  4702. service.CreateOrderInfo(info)
  4703. }
  4704. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4705. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4706. var total float64
  4707. for _, item := range prescriptions {
  4708. if item.Type == 1 { //药品
  4709. for _, subItem := range item.HisDoctorAdviceInfo {
  4710. total = total + (subItem.Price * subItem.PrescribingNumber)
  4711. }
  4712. }
  4713. if item.Type == 2 { //项目
  4714. for _, subItem := range item.HisPrescriptionProject {
  4715. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4716. total = total + (subItem.Price * cnt)
  4717. }
  4718. }
  4719. }
  4720. for _, item := range prescriptions {
  4721. for _, subItem := range item.HisAdditionalCharge {
  4722. total = total + (subItem.Price * float64(subItem.Count))
  4723. }
  4724. }
  4725. allTotal := fmt.Sprintf("%.4f", total)
  4726. if res.Infcode == 0 {
  4727. var rf []*ResultFive
  4728. json.Unmarshal([]byte(his.Iinfo), &rf)
  4729. chrg_bchno := chrg_bchno
  4730. cert_no := his.Certno
  4731. var insutypes []string
  4732. var insutype string
  4733. var is390 int = 0
  4734. var is310 int = 0
  4735. for _, item := range rf {
  4736. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4737. insutypes = append(insutypes, item.Insutype)
  4738. }
  4739. }
  4740. if len(insutypes) == 1 {
  4741. insutype = insutypes[0]
  4742. } else {
  4743. for _, i := range insutypes {
  4744. if i == "390" {
  4745. is390 = 1
  4746. }
  4747. if i == "310" {
  4748. is310 = 1
  4749. }
  4750. }
  4751. }
  4752. if is390 == 1 {
  4753. insutype = "390"
  4754. }
  4755. if is310 == 1 {
  4756. insutype = "310"
  4757. }
  4758. if len(insutypes) == 0 {
  4759. insutype = "310"
  4760. }
  4761. if len(insutypes) == 2 {
  4762. insutype = strconv.FormatInt(his.SocialType, 64)
  4763. }
  4764. //insutype = "390"
  4765. if his.IdCardType == 1 {
  4766. cert_no = his.MedicalInsuranceNumber
  4767. } else {
  4768. cert_no = his.Certno
  4769. }
  4770. var res ResultSeven
  4771. var resSeven10265 ResultSeven10265
  4772. if miConfig.MdtrtareaAdmvs == "421300" {
  4773. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4774. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4775. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4776. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4777. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4778. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4779. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  4780. resp, requestErr := http.Get(api)
  4781. if requestErr != nil {
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. body, ioErr := ioutil.ReadAll(resp.Body)
  4786. if ioErr != nil {
  4787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4789. return
  4790. }
  4791. var respJSON map[string]interface{}
  4792. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4795. return
  4796. }
  4797. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4798. result, _ := json.Marshal(respJSON)
  4799. fmt.Println("log")
  4800. fmt.Println(string(result))
  4801. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4802. utils.ErrorLog("解析失败:%v", err)
  4803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4804. return
  4805. }
  4806. } else {
  4807. var result string
  4808. var request_log string
  4809. if miConfig.Code == "H15049901371" {
  4810. //赤峰地区国家医保医疗类别
  4811. //职工透析:医疗类别选特殊情况门诊990502
  4812. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4813. var med_type string
  4814. if his.Insutype == "390" {
  4815. if reg_type == 14 {
  4816. med_type = "9933"
  4817. } else if reg_type == 11 {
  4818. med_type = "11"
  4819. }
  4820. } else if his.Insutype == "310" {
  4821. if reg_type == 14 {
  4822. med_type = "990502"
  4823. } else if reg_type == 11 {
  4824. med_type = "11"
  4825. }
  4826. }
  4827. 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)
  4828. } else {
  4829. 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)
  4830. }
  4831. var dat map[string]interface{}
  4832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4833. fmt.Println(dat)
  4834. } else {
  4835. fmt.Println(err)
  4836. }
  4837. saveLog(result, request_log, "2206", "预结算")
  4838. //userJSONBytes, _ := json.Marshal(dat)
  4839. //
  4840. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4841. // utils.ErrorLog("解析失败:%v", err)
  4842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4843. // return
  4844. //}
  4845. userJSONBytes, _ := json.Marshal(dat)
  4846. if miConfig.Code == "H15049901371" {
  4847. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4848. utils.ErrorLog("解析失败:%v", err)
  4849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4850. return
  4851. }
  4852. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4853. res.Output = resSeven10265.Output
  4854. res.ErrMsg = resSeven10265.ErrMsg
  4855. res.Cainfo = resSeven10265.Cainfo
  4856. res.WarnMsg = resSeven10265.WarnMsg
  4857. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4858. res.Infcode = infocode
  4859. } else {
  4860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4861. utils.ErrorLog("解析失败:%v", err)
  4862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4863. return
  4864. }
  4865. }
  4866. }
  4867. if res.Infcode != 0 {
  4868. errlog := &models.HisOrderError{
  4869. UserOrgId: adminUser.CurrentOrgId,
  4870. Ctime: time.Now().Unix(),
  4871. Mtime: time.Now().Unix(),
  4872. Number: chrg_bchno,
  4873. ErrMsg: res.ErrMsg,
  4874. Status: 1,
  4875. PatientId: id,
  4876. RecordTime: recordDateTime,
  4877. Stage: 20,
  4878. }
  4879. service.CreateErrMsgLog(errlog)
  4880. c.ServeSuccessJSON(map[string]interface{}{
  4881. "failed_code": -10,
  4882. "msg": res.ErrMsg,
  4883. })
  4884. return
  4885. } else {
  4886. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4887. order.OrderStatus = 1
  4888. order.IsPre = 1
  4889. order.Status = 1
  4890. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4891. order.SetlId = res.Output.Setlinfo.SetlID
  4892. order.PsnNo = res.Output.Setlinfo.PsnNo
  4893. order.PsnName = res.Output.Setlinfo.PsnName
  4894. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4895. order.Certno = res.Output.Setlinfo.Certno
  4896. order.Gend = res.Output.Setlinfo.Gend
  4897. order.Naty = res.Output.Setlinfo.Naty
  4898. order.Age = res.Output.Setlinfo.Age
  4899. order.Insutype = res.Output.Setlinfo.Insutype
  4900. order.PsnType = res.Output.Setlinfo.PsnType
  4901. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4902. order.SetlTime = res.Output.Setlinfo.SetlTime
  4903. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4904. if res.Output.Setlinfo.MedType == "140101" {
  4905. order.MedType = "14"
  4906. } else {
  4907. order.MedType = res.Output.Setlinfo.MedType
  4908. }
  4909. if reg_type == 1112 {
  4910. order.MedType = "1112"
  4911. }
  4912. if reg_type == 1111 {
  4913. order.MedType = "1111"
  4914. }
  4915. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4916. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4917. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4918. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4919. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4920. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4921. order.HifpPay = res.Output.Setlinfo.HifpPay
  4922. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4923. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4924. order.HifesPay = res.Output.Setlinfo.HifesPay
  4925. order.HifobPay = res.Output.Setlinfo.HifobPay
  4926. order.MafPay = res.Output.Setlinfo.MafPay
  4927. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4928. order.OthPay = res.Output.Setlinfo.OthPay
  4929. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4930. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4931. order.AcctPay = res.Output.Setlinfo.AcctPay
  4932. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4933. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4934. order.Balc = res.Output.Setlinfo.Balc
  4935. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4936. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4937. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4938. order.ClrWay = res.Output.Setlinfo.ClrWay
  4939. order.Creator = order.Creator
  4940. order.Modify = roles.AdminUserId
  4941. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4942. detailStr := string(setlDetail)
  4943. order.SetlDetail = detailStr
  4944. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4945. err = service.UpDateOrder(order)
  4946. if err == nil {
  4947. c.ServeSuccessJSON(map[string]interface{}{
  4948. "msg": "预结算成功",
  4949. })
  4950. } else {
  4951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4952. return
  4953. }
  4954. }
  4955. } else {
  4956. adminUser := c.GetAdminUserInfo()
  4957. errlog := &models.HisOrderError{
  4958. UserOrgId: adminUser.CurrentOrgId,
  4959. Ctime: time.Now().Unix(),
  4960. Mtime: time.Now().Unix(),
  4961. ErrMsg: res.ErrMsg,
  4962. Status: 1,
  4963. PatientId: id,
  4964. RecordTime: recordDateTime,
  4965. Stage: 4,
  4966. }
  4967. service.CreateErrMsgLog(errlog)
  4968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4969. return
  4970. }
  4971. } else {
  4972. adminUser := c.GetAdminUserInfo()
  4973. errlog := &models.HisOrderError{
  4974. UserOrgId: adminUser.CurrentOrgId,
  4975. Ctime: time.Now().Unix(),
  4976. Mtime: time.Now().Unix(),
  4977. ErrMsg: res.ErrMsg,
  4978. Status: 1,
  4979. PatientId: id,
  4980. RecordTime: recordDateTime,
  4981. Stage: 4,
  4982. }
  4983. service.CreateErrMsgLog(errlog)
  4984. c.ServeSuccessJSON(map[string]interface{}{
  4985. "failed_code": -10,
  4986. "msg": res.ErrMsg,
  4987. })
  4988. return
  4989. }
  4990. }
  4991. }
  4992. }
  4993. //func (c *HisApiController) GetSettleInfo() {
  4994. // id, _ := c.GetInt64("id")
  4995. // order_id, _ := c.GetInt64("order_id")
  4996. //
  4997. // record_time := c.GetString("record_time")
  4998. // pay_way, _ := c.GetInt64("pay_way")
  4999. // pay_price, _ := c.GetFloat("pay_price")
  5000. // pay_card_no := c.GetString("pay_card_no")
  5001. // discount_price, _ := c.GetFloat("discount_price")
  5002. // preferential_price, _ := c.GetFloat("preferential_price")
  5003. // reality_price, _ := c.GetFloat("reality_price")
  5004. // found_price, _ := c.GetFloat("found_price")
  5005. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5006. // private_price, _ := c.GetFloat("private_price")
  5007. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5008. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5009. //
  5010. // timeLayout := "2006-01-02"
  5011. // loc, _ := time.LoadLocation("Local")
  5012. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5013. // if err != nil {
  5014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5015. // return
  5016. // }
  5017. // recordDateTime := theTime.Unix()
  5018. // adminUser := c.GetAdminUserInfo()
  5019. //
  5020. // var prescriptions []*models.HisPrescription
  5021. //
  5022. // data := make(map[string]interface{})
  5023. // if settle_accounts_type == 1 { //日结
  5024. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5025. // data["pre"] = prescriptions
  5026. //
  5027. // } else { //月结
  5028. // start_time_str := c.GetString("start_time")
  5029. // end_time_str := c.GetString("end_time")
  5030. // timeLayout := "2006-01-02"
  5031. // loc, _ := time.LoadLocation("Local")
  5032. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5033. // if err != nil {
  5034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5035. // return
  5036. // }
  5037. // recordStartTime := theStartTime.Unix()
  5038. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5039. // if err != nil {
  5040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5041. // return
  5042. // }
  5043. // recordEndTime := theEndTime.Unix()
  5044. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5045. // data["pre"] = prescriptions
  5046. //
  5047. // }
  5048. //
  5049. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5050. //
  5051. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5052. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5053. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5054. // strconv.FormatInt(his.PatientId, 10)
  5055. //
  5056. // order_src, _ := service.GetHisOrderByID(order_id)
  5057. //
  5058. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5059. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5060. //
  5061. // var total float64
  5062. // for _, item := range prescriptions {
  5063. // if item.Type == 1 { //药品
  5064. // for _, subItem := range item.HisDoctorAdviceInfo {
  5065. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5066. // }
  5067. // }
  5068. // if item.Type == 2 { //项目
  5069. // for _, subItem := range item.HisPrescriptionProject {
  5070. // total = total + (subItem.Price * float64(subItem.Count))
  5071. // }
  5072. // }
  5073. // }
  5074. //
  5075. // for _, item := range prescriptions {
  5076. // for _, subItem := range item.HisAdditionalCharge {
  5077. // total = total + (subItem.Price * float64(subItem.Count))
  5078. // }
  5079. // }
  5080. //
  5081. // allTotal := fmt.Sprintf("%.2f", total)
  5082. // var rf []*ResultFive
  5083. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5084. // psn_no := order_src.PsnNo
  5085. // mdtrt_id := order_src.MdtrtId
  5086. // chrg_bchno := order_src.Number
  5087. // cert_no := order_src.Certno
  5088. // insutype := rf[0].Insutype
  5089. //
  5090. // if his.IdCardType == 1 {
  5091. // cert_no = his.MedicalInsuranceNumber
  5092. // } else {
  5093. // cert_no = his.Certno
  5094. // }
  5095. //
  5096. // 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)
  5097. // var dat map[string]interface{}
  5098. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5099. // fmt.Println(dat)
  5100. // } else {
  5101. // fmt.Println(err)
  5102. // }
  5103. //
  5104. // userJSONBytes, _ := json.Marshal(dat)
  5105. //
  5106. //
  5107. //
  5108. // var res ResultSeven
  5109. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5110. // utils.ErrorLog("解析失败:%v", err)
  5111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5112. // return
  5113. // }
  5114. // if res.Infcode == -1 {
  5115. // errlog := &models.HisOrderError{
  5116. // UserOrgId: adminUser.CurrentOrgId,
  5117. // Ctime: time.Now().Unix(),
  5118. // Mtime: time.Now().Unix(),
  5119. // Number: chrg_bchno,
  5120. // ErrMsg: res.ErrMsg,
  5121. // Status: 1,
  5122. // PatientId: id,
  5123. // RecordTime: recordDateTime,
  5124. // Stage: 6,
  5125. // }
  5126. // service.CreateErrMsgLog(errlog)
  5127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5128. // return
  5129. // } else {
  5130. // order_src.OrderStatus = 2
  5131. // order_src.PayWay = pay_way
  5132. // order_src.PayPrice = pay_price
  5133. // order_src.PayCardNo = pay_card_no
  5134. // order_src.DiscountPrice = discount_price
  5135. // order_src.PreferentialPrice = preferential_price
  5136. // order_src.RealityPrice = reality_price
  5137. // order_src.FoundPrice = found_price
  5138. // order_src.MedicalInsurancePrice = medical_insurance_price
  5139. // order_src.PrivatePrice = private_price
  5140. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5141. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5142. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5143. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5144. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5145. // order_src.Certno = res.Output.Setlinfo.Certno
  5146. // order_src.Gend = res.Output.Setlinfo.Gend
  5147. // order_src.Naty = res.Output.Setlinfo.Naty
  5148. // order_src.Age = res.Output.Setlinfo.Age
  5149. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5150. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5151. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5152. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5153. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5154. // order_src.MedType = res.Output.Setlinfo.MedType
  5155. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5156. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5157. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5158. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5159. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5160. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5161. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5162. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5163. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5164. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5165. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5166. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5167. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5168. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5169. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5170. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5171. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5172. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5173. // order_src.Balc = res.Output.Setlinfo.Balc
  5174. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5175. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5176. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5177. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5178. // order_src.Creator = order_src.Creator
  5179. // order_src.Modify = roles.ID
  5180. // order_src.RequestLog = src_resquest
  5181. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5182. // detailStr := string(setlDetail)
  5183. // order_src.SetlDetail = detailStr
  5184. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5185. // err = service.UpDateOrder(order_src)
  5186. //
  5187. // if err == nil {
  5188. // c.ServeSuccessJSON(map[string]interface{}{
  5189. // "msg": "结算成功",
  5190. // })
  5191. // } else {
  5192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5193. // return
  5194. // }
  5195. // }
  5196. // }
  5197. //}
  5198. //退款
  5199. func (c *HisApiController) Refund() {
  5200. order_id, _ := c.GetInt64("order_id")
  5201. admin_user_id, _ := c.GetInt64("admin_user_id")
  5202. //record_time := c.GetString("record_time")
  5203. //patient_id, _ := c.GetInt64("patient_id")
  5204. //timeLayout := "2006-01-02"
  5205. //loc, _ := time.LoadLocation("Local")
  5206. adminUser := c.GetAdminUserInfo()
  5207. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5208. //if err != nil {
  5209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5210. // return
  5211. //}
  5212. //recordDateTime := theTime.Unix()
  5213. var order models.HisOrder
  5214. order, _ = service.GetHisOrderByID(order_id)
  5215. //his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5216. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5217. if order.ID == 0 {
  5218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5219. return
  5220. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5221. }
  5222. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5223. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5224. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5225. if config.IsOpen == 1 { //对接了医保,走医保流程
  5226. var res ResultSixteen
  5227. var resSixteen10265 ResultSixteen10265
  5228. var src_resquest string
  5229. var result string
  5230. if miConfig.MdtrtareaAdmvs == "421300" {
  5231. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5232. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5233. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5234. resp3, requestErr3 := http.Get(api3)
  5235. if requestErr3 != nil {
  5236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5237. return
  5238. }
  5239. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5240. if ioErr3 != nil {
  5241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5243. return
  5244. }
  5245. var respJSON3 map[string]interface{}
  5246. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5249. return
  5250. }
  5251. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5252. userJSONBytes3, _ := json.Marshal(respJSON3)
  5253. fmt.Println("log")
  5254. fmt.Println(string(userJSONBytes3))
  5255. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5256. utils.ErrorLog("解析失败:%v", err)
  5257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5258. return
  5259. }
  5260. } else {
  5261. if miConfig.Code == "H15049901371" {
  5262. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5263. var dat map[string]interface{}
  5264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5265. fmt.Println(dat)
  5266. } else {
  5267. fmt.Println(err)
  5268. }
  5269. saveLog(result, src_resquest, "2208", "退费")
  5270. userJSONBytes, _ := json.Marshal(dat)
  5271. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5272. utils.ErrorLog("解析失败:%v", err)
  5273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5274. return
  5275. }
  5276. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5277. res.Output = resSixteen10265.Output
  5278. res.ErrMsg = resSixteen10265.ErrMsg
  5279. res.Cainfo = resSixteen10265.Cainfo
  5280. res.WarnMsg = resSixteen10265.WarnMsg
  5281. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5282. res.Infcode = infocode
  5283. } else {
  5284. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5285. var dat map[string]interface{}
  5286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5287. fmt.Println(dat)
  5288. } else {
  5289. fmt.Println(err)
  5290. }
  5291. saveLog(result, src_resquest, "2208", "退费")
  5292. userJSONBytes, _ := json.Marshal(dat)
  5293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5294. utils.ErrorLog("解析失败:%v", err)
  5295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5296. return
  5297. }
  5298. }
  5299. }
  5300. if res.Infcode == 0 {
  5301. var res2 ResultSix
  5302. var resSix10265 ResultSix10265
  5303. if miConfig.MdtrtareaAdmvs == "421300" {
  5304. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5305. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5306. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5307. resp3, requestErr3 := http.Get(api3)
  5308. if requestErr3 != nil {
  5309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5310. return
  5311. }
  5312. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5313. if ioErr3 != nil {
  5314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5316. return
  5317. }
  5318. var respJSON3 map[string]interface{}
  5319. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5322. return
  5323. }
  5324. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5325. userJSONBytes3, _ := json.Marshal(respJSON3)
  5326. fmt.Println("log")
  5327. fmt.Println(string(userJSONBytes3))
  5328. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5329. utils.ErrorLog("解析失败:%v", err)
  5330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5331. return
  5332. }
  5333. } else {
  5334. if miConfig.Code == "H15049901371" {
  5335. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5336. var dat map[string]interface{}
  5337. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5338. fmt.Println(dat)
  5339. } else {
  5340. fmt.Println(err)
  5341. }
  5342. saveLog(result2, src_request, "2205", "撤销明细")
  5343. userJSONBytes, _ := json.Marshal(dat)
  5344. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5345. utils.ErrorLog("解析失败:%v", err)
  5346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5347. return
  5348. }
  5349. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5350. res2.Output = resSix10265.Output
  5351. res2.ErrMsg = resSix10265.ErrMsg
  5352. res2.Cainfo = resSix10265.Cainfo
  5353. res2.WarnMsg = resSix10265.WarnMsg
  5354. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5355. res2.Infcode = infocode
  5356. } else {
  5357. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5358. var dat map[string]interface{}
  5359. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5360. fmt.Println(dat)
  5361. } else {
  5362. fmt.Println(err)
  5363. }
  5364. saveLog(result2, src_request, "2205", "撤销明细")
  5365. userJSONBytes, _ := json.Marshal(dat)
  5366. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5367. utils.ErrorLog("解析失败:%v", err)
  5368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5369. return
  5370. }
  5371. }
  5372. }
  5373. if res2.Infcode == 0 {
  5374. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5375. if err == nil {
  5376. c.ServeSuccessJSON(map[string]interface{}{
  5377. "msg": "退费成功",
  5378. })
  5379. } else {
  5380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5381. return
  5382. }
  5383. } else {
  5384. c.ServeSuccessJSON(map[string]interface{}{
  5385. "code": -10,
  5386. "msg": res2.ErrMsg,
  5387. })
  5388. }
  5389. } else {
  5390. c.ServeSuccessJSON(map[string]interface{}{
  5391. "code": -10,
  5392. "msg": res.ErrMsg,
  5393. })
  5394. }
  5395. }
  5396. }
  5397. func (c *HisApiController) RefundNumber() {
  5398. record_time := c.GetString("record_time")
  5399. //patient_id, _ := c.GetInt64("patient_id")
  5400. admin_user_id, _ := c.GetInt64("admin_user_id")
  5401. his_patient_id, _ := c.GetInt64("id")
  5402. timeLayout := "2006-01-02"
  5403. loc, _ := time.LoadLocation("Local")
  5404. adminUser := c.GetAdminUserInfo()
  5405. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5406. fmt.Println(err)
  5407. if err != nil {
  5408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5409. return
  5410. }
  5411. recordDateTime := theTime.Unix()
  5412. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5413. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5414. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5415. //order, _ := service.GetHisOrderByID(order_id)
  5416. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5417. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5418. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5419. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5420. if count > 0 {
  5421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5422. return
  5423. }
  5424. if config.IsOpen == 1 { //对接了医保,走医保流程
  5425. var res2 ResultSix
  5426. var resSix10265 ResultSix10265
  5427. if miConfig.MdtrtareaAdmvs == "421300" {
  5428. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5429. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5430. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5431. resp3, requestErr3 := http.Get(api3)
  5432. if requestErr3 != nil {
  5433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5434. return
  5435. }
  5436. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5437. if ioErr3 != nil {
  5438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5440. return
  5441. }
  5442. var respJSON3 map[string]interface{}
  5443. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5446. return
  5447. }
  5448. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5449. userJSONBytes3, _ := json.Marshal(respJSON3)
  5450. fmt.Println("log")
  5451. fmt.Println(string(userJSONBytes3))
  5452. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5453. utils.ErrorLog("解析失败:%v", err)
  5454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5455. return
  5456. }
  5457. } else {
  5458. var api3 string
  5459. if miConfig.Code == "H15049901371" {
  5460. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5461. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5462. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5463. } else {
  5464. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5465. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5466. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5467. }
  5468. resp3, requestErr3 := http.Get(api3)
  5469. if requestErr3 != nil {
  5470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5471. return
  5472. }
  5473. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5474. if ioErr3 != nil {
  5475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5477. return
  5478. }
  5479. var respJSON3 map[string]interface{}
  5480. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5483. return
  5484. }
  5485. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5486. userJSONBytes3, _ := json.Marshal(respJSON3)
  5487. if miConfig.Code == "H15049901371" {
  5488. if err := json.Unmarshal(userJSONBytes3, &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(userJSONBytes3, &res2); err != nil {
  5502. utils.ErrorLog("解析失败:%v", err)
  5503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5504. return
  5505. }
  5506. }
  5507. }
  5508. if res2.Infcode == 0 {
  5509. if err == nil {
  5510. c.ServeSuccessJSON(map[string]interface{}{
  5511. "msg": "退号成功",
  5512. })
  5513. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  5514. } else {
  5515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5516. return
  5517. }
  5518. } else {
  5519. c.ServeSuccessJSON(map[string]interface{}{
  5520. "code": -10,
  5521. "msg": res2.ErrMsg,
  5522. })
  5523. }
  5524. } else {
  5525. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  5526. //if err == nil {
  5527. // c.ServeSuccessJSON(map[string]interface{}{
  5528. // "msg": "退费成功",
  5529. // })
  5530. //} else {
  5531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5532. // return
  5533. //}
  5534. }
  5535. }
  5536. func (c *HisApiController) RefundDetail() {
  5537. order_id, _ := c.GetInt64("order_id")
  5538. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5539. number := c.GetString("number")
  5540. record_time := c.GetString("record_time")
  5541. patient_id, _ := c.GetInt64("patient_id")
  5542. timeLayout := "2006-01-02"
  5543. loc, _ := time.LoadLocation("Local")
  5544. adminUser := c.GetAdminUserInfo()
  5545. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5546. fmt.Println(err)
  5547. if err != nil {
  5548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5549. return
  5550. }
  5551. recordDateTime := theTime.Unix()
  5552. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5553. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5554. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5555. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5556. var order models.HisOrder
  5557. order, _ = service.GetHisOrderByID(order_id)
  5558. if order.ID == 0 {
  5559. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5560. }
  5561. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5562. if config.IsOpen == 1 { //对接了医保,走医保流程
  5563. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  5564. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5565. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5566. resp2, requestErr2 := http.Get(api2)
  5567. if requestErr2 != nil {
  5568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5569. return
  5570. }
  5571. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5572. if ioErr2 != nil {
  5573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5575. return
  5576. }
  5577. var respJSON2 map[string]interface{}
  5578. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  5579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5581. return
  5582. }
  5583. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5584. if err == nil {
  5585. c.ServeSuccessJSON(map[string]interface{}{
  5586. "msg": "退费成功",
  5587. })
  5588. } else {
  5589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5590. return
  5591. }
  5592. } else {
  5593. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5594. if err == nil {
  5595. c.ServeSuccessJSON(map[string]interface{}{
  5596. "msg": "退费成功",
  5597. })
  5598. } else {
  5599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5600. return
  5601. }
  5602. }
  5603. }
  5604. //对账
  5605. func (c *HisApiController) GetCheckAccount() {
  5606. start_time := c.GetString("start_time")
  5607. end_time := c.GetString("end_time")
  5608. insutype := c.GetString("insutype")
  5609. clr_type := c.GetString("clr_type")
  5610. admin_user_id, _ := c.GetInt64("admin_user_id")
  5611. adminUser := c.GetAdminUserInfo()
  5612. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5613. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5614. timeLayout := "2006-01-02"
  5615. loc, _ := time.LoadLocation("Local")
  5616. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5617. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5618. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5619. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5620. fixmedins_setl_cnt := int64(len(orders))
  5621. //
  5622. ////撤销的算2条数据为一笔
  5623. //for _, item := range orders_two {
  5624. // if item.OrderStatus == 3 {
  5625. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  5626. // }
  5627. //}
  5628. var medfee_sumamt float64
  5629. var acct_pay float64
  5630. var fund_pay_sumamt float64
  5631. for _, item := range orders {
  5632. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5633. acct_pay = acct_pay + item.AcctPay
  5634. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5635. }
  5636. var user_name string
  5637. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5638. if role.ID == 0 {
  5639. user_name = "xxx"
  5640. } else {
  5641. user_name = role.UserName
  5642. }
  5643. if config.IsOpen == 1 {
  5644. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5645. "insutype=" + insutype +
  5646. "&clr_type=" + clr_type +
  5647. "&setl_optins=" + "定点医保中心" +
  5648. "&stmt_begndate=" + start_time +
  5649. "&stm_enddate=" + end_time +
  5650. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5651. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5652. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  5653. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5654. "&fixmedins_code=" + miConfig.Code +
  5655. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5656. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5657. "&secret_key=" + miConfig.SecretKey +
  5658. "&org_name=" + miConfig.OrgName +
  5659. "&doctor=" + user_name
  5660. fmt.Println(api)
  5661. resp, requestErr := http.Get(api)
  5662. if requestErr != nil {
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5664. return
  5665. }
  5666. body, ioErr := ioutil.ReadAll(resp.Body)
  5667. fmt.Println(body)
  5668. if ioErr != nil {
  5669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5671. return
  5672. }
  5673. var respJSON map[string]interface{}
  5674. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. return
  5678. }
  5679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5680. userJSONBytes, _ := json.Marshal(respJSON)
  5681. var res ResultEight
  5682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5683. utils.ErrorLog("解析失败:%v", err)
  5684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5685. return
  5686. }
  5687. if res.Infcode == 0 {
  5688. if res.Output.Stmtinfo.StmtRslt == "0" {
  5689. micc := &models.MedicalInsuranceCostCompare{
  5690. StartTime: startime.Unix(),
  5691. EndTime: endtime.Unix(),
  5692. Insutype: insutype,
  5693. CheckType: 1,
  5694. Num: fixmedins_setl_cnt,
  5695. Mtime: time.Now().Unix(),
  5696. Status: 1,
  5697. UserOrgId: adminUser.CurrentOrgId,
  5698. CostTotal: medfee_sumamt,
  5699. FuncTotal: fund_pay_sumamt,
  5700. PsnPay: acct_pay,
  5701. Creator: admin_user_id,
  5702. Ctime: time.Now().Unix(),
  5703. }
  5704. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  5705. if err == nil {
  5706. c.ServeSuccessJSON(map[string]interface{}{
  5707. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5708. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5709. })
  5710. } else {
  5711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5712. }
  5713. } else {
  5714. c.ServeSuccessJSON(map[string]interface{}{
  5715. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5716. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5717. })
  5718. }
  5719. } else {
  5720. c.ServeSuccessJSON(map[string]interface{}{
  5721. "code": -10,
  5722. "msg": res.ErrMsg,
  5723. })
  5724. }
  5725. }
  5726. }
  5727. func (c *HisApiController) Check310() {
  5728. adminUser := c.GetAdminUserInfo()
  5729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5730. var user_name string
  5731. user_name = "xxx"
  5732. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5733. "insutype=" + "310" +
  5734. "&clr_type=" + "11" +
  5735. "&setl_optins=" + "定点医保中心" +
  5736. "&stmt_begndate=" + "2021-03-01" +
  5737. "&stm_enddate=" + "2021-03-31" +
  5738. "&medfee_sumamt=" + "11521" +
  5739. "&fund_pay_sumamt=" + "10166.66" +
  5740. "&acct_pay=" + "0" +
  5741. "&fixmedins_setl_cnt=" + "7" +
  5742. "&fixmedins_code=" + miConfig.Code +
  5743. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5744. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5745. "&secret_key=" + miConfig.SecretKey +
  5746. "&org_name=" + miConfig.OrgName +
  5747. "&doctor=" + user_name
  5748. fmt.Println(api)
  5749. resp, requestErr := http.Get(api)
  5750. if requestErr != nil {
  5751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5752. return
  5753. }
  5754. body, ioErr := ioutil.ReadAll(resp.Body)
  5755. fmt.Println(body)
  5756. if ioErr != nil {
  5757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5759. return
  5760. }
  5761. var respJSON map[string]interface{}
  5762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5765. return
  5766. }
  5767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5768. userJSONBytes, _ := json.Marshal(respJSON)
  5769. var res ResultEight
  5770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5771. utils.ErrorLog("解析失败:%v", err)
  5772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5773. return
  5774. }
  5775. }
  5776. func (c *HisApiController) Check390() {
  5777. adminUser := c.GetAdminUserInfo()
  5778. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5779. var user_name string
  5780. user_name = "张俊杰"
  5781. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5782. "insutype=" + "390" +
  5783. "&clr_type=" + "11" +
  5784. "&setl_optins=" + "定点医保中心" +
  5785. "&stmt_begndate=" + "2021-03-01" +
  5786. "&stm_enddate=" + "2021-03-31" +
  5787. "&medfee_sumamt=" + "209318.43" +
  5788. "&fund_pay_sumamt=" + "188029.12" +
  5789. "&acct_pay=" + "0" +
  5790. "&fixmedins_setl_cnt=" + "48" +
  5791. "&fixmedins_code=" + miConfig.Code +
  5792. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5793. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5794. "&secret_key=" + miConfig.SecretKey +
  5795. "&org_name=" + miConfig.OrgName +
  5796. "&doctor=" + user_name
  5797. fmt.Println(api)
  5798. resp, requestErr := http.Get(api)
  5799. if requestErr != nil {
  5800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5801. return
  5802. }
  5803. body, ioErr := ioutil.ReadAll(resp.Body)
  5804. fmt.Println(body)
  5805. if ioErr != nil {
  5806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5808. return
  5809. }
  5810. var respJSON map[string]interface{}
  5811. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5814. return
  5815. }
  5816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5817. userJSONBytes, _ := json.Marshal(respJSON)
  5818. var res ResultEight
  5819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5820. utils.ErrorLog("解析失败:%v", err)
  5821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5822. return
  5823. }
  5824. }
  5825. //对账明细
  5826. func (c *HisApiController) GetCheckDetailAccount() {
  5827. start_time := c.GetString("start_time")
  5828. end_time := c.GetString("end_time")
  5829. admin_user_id, _ := c.GetInt64("admin_user_id")
  5830. adminUser := c.GetAdminUserInfo()
  5831. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5832. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5833. timeLayout := "2006-01-02"
  5834. loc, _ := time.LoadLocation("Local")
  5835. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5836. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5837. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  5838. Mkdir(miConfig.OrgName)
  5839. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  5840. file_name := file + ".txt"
  5841. zip_name := file + ".zip"
  5842. zip_path := miConfig.OrgName + "/" + zip_name
  5843. file_path := miConfig.OrgName + "/" + file_name
  5844. decimal.DivisionPrecision = 2
  5845. var medfee_sumamt float64
  5846. var psn_cash_pay float64
  5847. var fund_pay_sumamt float64
  5848. fixmedins_setl_cnt := int64(len(orders))
  5849. for _, item := range orders {
  5850. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5851. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  5852. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5853. }
  5854. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  5855. defer f.Close()
  5856. if err != nil {
  5857. fmt.Println(err.Error())
  5858. } else {
  5859. for _, item := range orders {
  5860. var refd_setl_flag string
  5861. if item.OrderStatus == 2 {
  5862. refd_setl_flag = "0"
  5863. var str string
  5864. str = item.SetlId + " " +
  5865. item.MdtrtId + " " +
  5866. item.PsnNo + " " +
  5867. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5868. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5869. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  5870. _, err = f.Write([]byte(str))
  5871. }
  5872. if item.OrderStatus == 3 {
  5873. var str string
  5874. str = item.SetlId + " " +
  5875. item.MdtrtId + " " +
  5876. item.PsnNo + " " +
  5877. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5878. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5879. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  5880. _, err = f.Write([]byte(str))
  5881. var str2 string
  5882. str2 = item.SetlId + " " +
  5883. item.MdtrtId + " " +
  5884. item.PsnNo + " " +
  5885. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  5886. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  5887. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  5888. _, err = f.Write([]byte(str2))
  5889. }
  5890. }
  5891. }
  5892. Zip(file_path, zip_path)
  5893. fmt.Println(ReadFile(zip_path))
  5894. fmt.Println(string(ReadFile(zip_path)))
  5895. if config.IsOpen == 1 {
  5896. var user_name string
  5897. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5898. if role.ID == 0 {
  5899. user_name = "管理员"
  5900. } else {
  5901. user_name = role.UserName
  5902. }
  5903. baseParams := models.BaseParams{
  5904. SecretKey: miConfig.SecretKey,
  5905. FixmedinsCode: miConfig.Code,
  5906. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5907. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5908. OrgName: miConfig.OrgName,
  5909. Doctor: user_name,
  5910. }
  5911. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  5912. var dat map[string]interface{}
  5913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5914. fmt.Println(dat)
  5915. } else {
  5916. fmt.Println(err)
  5917. }
  5918. userJSONBytes, _ := json.Marshal(dat)
  5919. var res ResultNine
  5920. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5921. utils.ErrorLog("解析失败:%v", err)
  5922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5923. return
  5924. }
  5925. if res.Infcode == 0 {
  5926. fileNo := res.Output.FileQuryNo
  5927. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  5928. "file_qury_no=" + fileNo +
  5929. "&setl_optins=" + "定点医保中心" +
  5930. "&stmt_begndate=" + start_time +
  5931. "&stm_enddate=" + end_time +
  5932. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5933. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5934. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  5935. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5936. "&fixmedins_code=" + miConfig.Code +
  5937. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5938. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5939. "&secret_key=" + miConfig.SecretKey +
  5940. "&org_name=" + miConfig.OrgName +
  5941. "&doctor=" + user_name
  5942. resp, requestErr := http.Get(api)
  5943. if requestErr != nil {
  5944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5945. return
  5946. }
  5947. body, ioErr := ioutil.ReadAll(resp.Body)
  5948. if ioErr != nil {
  5949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5951. return
  5952. }
  5953. var respJSON map[string]interface{}
  5954. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5957. return
  5958. }
  5959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5960. userJSONBytes, _ := json.Marshal(respJSON)
  5961. var res ResultTen
  5962. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5963. utils.ErrorLog("解析失败:%v", err)
  5964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5965. return
  5966. }
  5967. if res.Infcode == 0 {
  5968. service.Gdyb9102(baseParams, zip_name, fileNo)
  5969. micc := &models.MedicalInsuranceCostCompare{
  5970. StartTime: startime.Unix(),
  5971. EndTime: endtime.Unix(),
  5972. Insutype: "0",
  5973. CheckType: 2,
  5974. Num: fixmedins_setl_cnt,
  5975. Mtime: time.Now().Unix(),
  5976. Status: 1,
  5977. UserOrgId: adminUser.CurrentOrgId,
  5978. CostTotal: medfee_sumamt,
  5979. FuncTotal: fund_pay_sumamt,
  5980. PsnPay: psn_cash_pay,
  5981. Creator: admin_user_id,
  5982. Ctime: time.Now().Unix(),
  5983. }
  5984. service.CreateMedicalInsuranceCostCompareRecord(micc)
  5985. c.ServeSuccessJSON(map[string]interface{}{
  5986. "msg": "明细对账成功",
  5987. })
  5988. }
  5989. } else {
  5990. }
  5991. }
  5992. }
  5993. type CustomOrderInfo struct {
  5994. Name string
  5995. Spec string
  5996. Unit string
  5997. Count float64
  5998. Price float64
  5999. Total float64
  6000. }
  6001. func (c *HisApiController) GetSettleAccounts() {
  6002. //id, _ := c.GetInt64("id")
  6003. //record_time := c.GetString("record_time")
  6004. order_id, _ := c.GetInt64("order_id")
  6005. admin_user_id, _ := c.GetInt64("admin_user_id")
  6006. //timeLayout := "2006-01-02"
  6007. //loc, _ := time.LoadLocation("Local")
  6008. //
  6009. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6010. //if err != nil {
  6011. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6012. // return
  6013. //}
  6014. //recordDateTime := theTime.Unix()
  6015. adminUser := c.GetAdminUserInfo()
  6016. order, _ := service.GetHisOrderByID(order_id)
  6017. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6018. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6019. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6020. orderInfos = append(orderInfos, orderInfos_two...)
  6021. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6022. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6023. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6024. //var config []*models.HisXtDiagnoseConfig
  6025. var name string
  6026. for _, item := range diagnosis_ids {
  6027. id, _ := strconv.ParseInt(item, 10, 64)
  6028. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6029. if len(name) == 0 {
  6030. name = diagnosisConfig.ClassName
  6031. } else {
  6032. name = name + "," + diagnosisConfig.ClassName
  6033. }
  6034. }
  6035. var bedCostTotal float64 = 0 //床位总费
  6036. var bedCostSelfTotal float64 = 0 //床位自费
  6037. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6038. var operationCostTotal float64 = 0 //手术费
  6039. var operationCostSelfTotal float64 = 0 //手术费
  6040. var operationCostPartSelfTotal float64 = 0 //手术费
  6041. var otherCostTotal float64 = 0 //其他费用
  6042. var otherCostSelfTotal float64 = 0 //其他费用
  6043. var otherCostPartSelfTotal float64 = 0 //其他费用
  6044. var materialCostTotal float64 = 0 //材料费
  6045. var materialCostSelfTotal float64 = 0 //材料费
  6046. var materialCostPartSelfTotal float64 = 0 //材料费
  6047. var westernMedicineCostTotal float64 = 0 //西药费
  6048. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6049. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6050. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6051. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6052. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6053. var checkCostTotal float64 = 0 //检查费
  6054. var checkCostSelfTotal float64 = 0 //检查费
  6055. var checkCostPartSelfTotal float64 = 0 //检查费
  6056. var laboratoryCostTotal float64 = 0 //化验费
  6057. var laboratoryCostSelfTotal float64 = 0 //化验费
  6058. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6059. var treatCostTotal float64 = 0 //治疗费用
  6060. var treatCostSelfTotal float64 = 0 //治疗费用
  6061. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6062. decimal.DivisionPrecision = 2
  6063. for _, item := range orderInfos {
  6064. if item.MedChrgitmType == "01" { //床位费
  6065. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6066. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6067. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6068. }
  6069. if item.MedChrgitmType == "03" { //检查费
  6070. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6071. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6072. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6073. }
  6074. if item.MedChrgitmType == "04" { //化验费
  6075. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6076. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6077. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6078. }
  6079. if item.MedChrgitmType == "05" { //治疗费
  6080. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6081. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6082. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6083. }
  6084. if item.MedChrgitmType == "06" { //手术费
  6085. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6086. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6087. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6088. }
  6089. if item.MedChrgitmType == "08" { //材料费
  6090. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6091. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6092. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6093. }
  6094. if item.MedChrgitmType == "09" { //西药费
  6095. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6096. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6097. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6098. }
  6099. if item.MedChrgitmType == "11" { //中成费
  6100. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6101. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6102. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6103. }
  6104. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6105. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6106. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6107. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6108. }
  6109. }
  6110. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6111. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6112. var user_name string
  6113. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6114. if role.ID == 0 {
  6115. user_name = "管理员"
  6116. } else {
  6117. user_name = role.UserName
  6118. }
  6119. baseParams := models.BaseParams{
  6120. SecretKey: miConfig.SecretKey,
  6121. FixmedinsCode: miConfig.Code,
  6122. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6123. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6124. OrgName: miConfig.OrgName,
  6125. Doctor: user_name,
  6126. }
  6127. businessParams := models.BusinessParams{
  6128. PsnNo: order.PsnNo,
  6129. MdtrtId: order.MdtrtId,
  6130. SetlId: order.SetlId,
  6131. }
  6132. var res ResultEleven
  6133. var resEleven10265 ResultEleven10265
  6134. if config.IsOpen == 1 {
  6135. if miConfig.MdtrtareaAdmvs == "421300" {
  6136. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6137. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6138. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6139. resp, requestErr := http.Get(api)
  6140. if requestErr != nil {
  6141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6142. return
  6143. }
  6144. body, ioErr := ioutil.ReadAll(resp.Body)
  6145. if ioErr != nil {
  6146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6148. return
  6149. }
  6150. var respJSON map[string]interface{}
  6151. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6154. return
  6155. }
  6156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6157. result, _ := json.Marshal(respJSON)
  6158. fmt.Println("log")
  6159. fmt.Println(string(result))
  6160. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6161. utils.ErrorLog("解析失败:%v", err)
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6163. return
  6164. }
  6165. } else {
  6166. result := service.Gdyb5203(baseParams, businessParams)
  6167. var dat map[string]interface{}
  6168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6169. fmt.Println(dat)
  6170. } else {
  6171. fmt.Println(err)
  6172. }
  6173. userJSONBytes, _ := json.Marshal(dat)
  6174. if miConfig.Code == "H15049901371" {
  6175. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6176. utils.ErrorLog("解析失败:%v", err)
  6177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6178. return
  6179. }
  6180. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6181. res.Output = resEleven10265.Output
  6182. res.ErrMsg = resEleven10265.ErrMsg
  6183. res.Cainfo = resEleven10265.Cainfo
  6184. res.WarnMsg = resEleven10265.WarnMsg
  6185. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6186. res.Infcode = infocode
  6187. } else {
  6188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6189. utils.ErrorLog("解析失败:%v", err)
  6190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6191. return
  6192. }
  6193. }
  6194. }
  6195. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6196. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6197. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6198. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6199. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6200. var doctor_name string
  6201. if roles.ID == 0 {
  6202. doctor_name = "管理员"
  6203. } else {
  6204. doctor_name = roles.UserName
  6205. }
  6206. yiliao_leibie := ""
  6207. switch order.MedType {
  6208. case "11":
  6209. yiliao_leibie = "普通门诊"
  6210. break
  6211. case "12":
  6212. yiliao_leibie = "门诊挂号"
  6213. break
  6214. case "13":
  6215. yiliao_leibie = "急诊"
  6216. break
  6217. case "14":
  6218. yiliao_leibie = "门诊特殊病"
  6219. break
  6220. case "15":
  6221. yiliao_leibie = "门诊统筹"
  6222. break
  6223. case "16":
  6224. yiliao_leibie = "门诊慢性病"
  6225. break
  6226. case "21":
  6227. yiliao_leibie = "普通住院"
  6228. break
  6229. }
  6230. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6231. if res.Infcode == 0 {
  6232. c.ServeSuccessJSON(map[string]interface{}{
  6233. "diagnosis": name,
  6234. "order_infos": orderInfos,
  6235. "number": order.MdtrtId,
  6236. "date": order.SettleAccountsDate,
  6237. "charge_admin": charge_admin,
  6238. "printor_admin": printor_admin,
  6239. "info": res.Output.Setlinfo,
  6240. "bedCostTotal": bedCostTotal,
  6241. "bedCostSelfTotal": bedCostSelfTotal,
  6242. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6243. "operationCostTotal": operationCostTotal,
  6244. "operationCostSelfTotal": operationCostSelfTotal,
  6245. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6246. "otherCostTotal": otherCostTotal,
  6247. "otherCostSelfTotal": otherCostSelfTotal,
  6248. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6249. "materialCostTotal": materialCostTotal,
  6250. "materialCostSelfTotal": materialCostSelfTotal,
  6251. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6252. "westernMedicineCostTotal": westernMedicineCostTotal,
  6253. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6254. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6255. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6256. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6257. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6258. "checkCostTotal": checkCostTotal,
  6259. "checkCostSelfTotal": checkCostSelfTotal,
  6260. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6261. "laboratoryCostTotal": laboratoryCostTotal,
  6262. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6263. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6264. "treatCostTotal": treatCostTotal,
  6265. "treatCostSelfTotal": treatCostSelfTotal,
  6266. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6267. "doctor_code": adminRole_two.DoctorCode,
  6268. "doctor_name": doctor_name,
  6269. "health_card_no": order.PsnNo,
  6270. "department": departments.Name,
  6271. "yiliao_leibie": yiliao_leibie,
  6272. "after_money": order.AccountPrice,
  6273. "patient": patient,
  6274. "org_name": miConfig.OrgName,
  6275. "org_code": miConfig.Code,
  6276. "order_number": order.Number,
  6277. //"check_order_info": cus_slice,
  6278. })
  6279. }
  6280. }
  6281. }
  6282. func (c *HisApiController) CheckTreatment() {
  6283. patient_id, _ := c.GetInt64("patient_id", 0)
  6284. record_time := c.GetString("record_time")
  6285. insutype := c.GetString("insutype")
  6286. timeLayout := "2006-01-02"
  6287. loc, _ := time.LoadLocation("Local")
  6288. adminUser := c.GetAdminUserInfo()
  6289. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6290. fmt.Println(err)
  6291. if err != nil {
  6292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6293. return
  6294. }
  6295. recordDateTime := theTime.Unix()
  6296. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6297. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6299. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6300. var user_name string
  6301. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  6302. if role.ID == 0 {
  6303. user_name = "xxx"
  6304. } else {
  6305. user_name = role.UserName
  6306. }
  6307. baseParams := models.BaseParams{
  6308. SecretKey: miConfig.SecretKey,
  6309. FixmedinsCode: miConfig.Code,
  6310. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6311. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6312. OrgName: miConfig.OrgName,
  6313. Doctor: user_name,
  6314. }
  6315. if config.IsOpen == 1 {
  6316. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  6317. var dat map[string]interface{}
  6318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6319. fmt.Println(dat)
  6320. } else {
  6321. fmt.Println(err)
  6322. }
  6323. }
  6324. }
  6325. func (c *HisApiController) PutRecord() {
  6326. id, _ := c.GetInt64("id")
  6327. record_time := c.GetString("record_time")
  6328. timeLayout := "2006-01-02"
  6329. loc, _ := time.LoadLocation("Local")
  6330. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6331. if err != nil {
  6332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6333. return
  6334. }
  6335. recordDateTime := theTime.Unix()
  6336. adminInfo := c.GetAdminUserInfo()
  6337. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  6338. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6339. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6340. fmt.Println(miConfig.SecretKey)
  6341. if patient == nil {
  6342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6343. return
  6344. }
  6345. if len(patient.IdCardNo) == 0 {
  6346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6347. return
  6348. }
  6349. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6350. if config.IsOpen == 1 {
  6351. 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
  6352. resp, requestErr := http.Get(api)
  6353. if requestErr != nil {
  6354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6355. return
  6356. }
  6357. defer resp.Body.Close()
  6358. body, ioErr := ioutil.ReadAll(resp.Body)
  6359. if ioErr != nil {
  6360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6362. return
  6363. }
  6364. var respJSON map[string]interface{}
  6365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6368. return
  6369. }
  6370. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6371. userJSONBytes, _ := json.Marshal(userJSON)
  6372. var res ResultTwo
  6373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6374. utils.ErrorLog("解析失败:%v", err)
  6375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6376. return
  6377. }
  6378. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6379. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6380. infoStr := string(Iinfos)
  6381. idetinfoStr := string(Idetinfos)
  6382. if res.Infcode == 0 {
  6383. his := models.VMHisPatient{
  6384. Status: 1,
  6385. Ctime: time.Now().Unix(),
  6386. Mtime: time.Now().Unix(),
  6387. PsnNo: res.Output.Baseinfo.PsnNo,
  6388. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6389. Certno: res.Output.Baseinfo.Certno,
  6390. PsnName: res.Output.Baseinfo.PsnName,
  6391. Gend: res.Output.Baseinfo.Gend,
  6392. Naty: res.Output.Baseinfo.Naty,
  6393. Brdy: res.Output.Baseinfo.Brdy,
  6394. Age: res.Output.Baseinfo.Age,
  6395. Iinfo: infoStr,
  6396. Idetinfo: idetinfoStr,
  6397. PatientId: patient.ID,
  6398. RecordDate: theTime.Unix(),
  6399. UserOrgId: adminInfo.CurrentOrgId,
  6400. AdminUserId: adminInfo.AdminUser.Id,
  6401. IsReturn: 1,
  6402. }
  6403. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  6404. //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")
  6405. 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")
  6406. //var dat map[string]interface{}
  6407. //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6408. // fmt.Println(dat)
  6409. //} else {
  6410. // fmt.Println(err)
  6411. //}
  6412. var dat2 map[string]interface{}
  6413. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  6414. fmt.Println(dat2)
  6415. } else {
  6416. fmt.Println(err)
  6417. }
  6418. } else {
  6419. adminUser := c.GetAdminUserInfo()
  6420. errlog := &models.HisOrderError{
  6421. UserOrgId: adminUser.CurrentOrgId,
  6422. Ctime: time.Now().Unix(),
  6423. Mtime: time.Now().Unix(),
  6424. ErrMsg: res.ErrMsg,
  6425. Status: 1,
  6426. PatientId: id,
  6427. RecordTime: recordDateTime,
  6428. Stage: 1,
  6429. }
  6430. service.CreateErrMsgLog(errlog)
  6431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  6432. return
  6433. }
  6434. }
  6435. }
  6436. func (c *HisApiController) GetUploadDiag() {
  6437. id, _ := c.GetInt64("id")
  6438. record_time := c.GetString("record_time")
  6439. diagnosis_id, _ := c.GetInt64("diagnosis")
  6440. sick_type, _ := c.GetInt64("sick_type")
  6441. reg_type, _ := c.GetInt64("reg_type")
  6442. timeLayout := "2006-01-02"
  6443. loc, _ := time.LoadLocation("Local")
  6444. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6445. if err != nil {
  6446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6447. return
  6448. }
  6449. var patientPrescription models.HisPrescriptionInfo
  6450. recordDateTime := theTime.Unix()
  6451. adminInfo := c.GetAdminUserInfo()
  6452. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6453. if patientPrescription.ID == 0 {
  6454. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6455. }
  6456. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6457. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6458. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6459. sickConfig, _ := service.FindSickById(sick_type)
  6460. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6461. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  6462. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  6463. "&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 +
  6464. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  6465. resp2, requestErr2 := http.Get(api2)
  6466. if requestErr2 != nil {
  6467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6468. return
  6469. }
  6470. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6471. if ioErr2 != nil {
  6472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6474. return
  6475. }
  6476. var respJSON2 map[string]interface{}
  6477. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6480. return
  6481. }
  6482. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6483. userJSONBytes2, _ := json.Marshal(respJSON2)
  6484. var res2 ResultSix
  6485. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6486. utils.ErrorLog("解析失败:%v", err)
  6487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6488. return
  6489. }
  6490. if res2.Infcode != 0 {
  6491. adminUser := c.GetAdminUserInfo()
  6492. errlog := &models.HisOrderError{
  6493. UserOrgId: adminUser.CurrentOrgId,
  6494. Ctime: time.Now().Unix(),
  6495. Mtime: time.Now().Unix(),
  6496. ErrMsg: res2.ErrMsg,
  6497. Status: 1,
  6498. PatientId: id,
  6499. RecordTime: recordDateTime,
  6500. Stage: 3,
  6501. }
  6502. service.CreateErrMsgLog(errlog)
  6503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  6504. return
  6505. }
  6506. c.ServeSuccessJSON(map[string]interface{}{
  6507. "msg": "上传成功",
  6508. })
  6509. }
  6510. type QueryResult struct {
  6511. ID int64
  6512. Name string
  6513. Code string
  6514. List_type_code string
  6515. }
  6516. func (c *HisApiController) GetCheckCode() {
  6517. ids_str := c.GetString("ids")
  6518. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6519. ids_arr := strings.Split(ids_str, ",")
  6520. var queryResult []QueryResult
  6521. ids := make([]int64, 0)
  6522. for _, item := range ids_arr {
  6523. id, _ := strconv.ParseInt(item, 10, 64)
  6524. ids = append(ids, id)
  6525. }
  6526. if record_type == 1 {
  6527. drugs, _ := service.GetBatchDrugList(ids)
  6528. for _, item := range drugs {
  6529. result := QueryResult{
  6530. ID: item.ID,
  6531. Name: item.DrugName,
  6532. Code: item.MedicalInsuranceNumber,
  6533. List_type_code: "101",
  6534. }
  6535. queryResult = append(queryResult, result)
  6536. }
  6537. } else if record_type == 2 {
  6538. goods, _ := service.GetBatchGoodInformationList(ids)
  6539. for _, item := range goods {
  6540. result := QueryResult{
  6541. ID: item.ID,
  6542. Name: item.GoodName,
  6543. Code: item.MedicalInsuranceNumber,
  6544. List_type_code: "301",
  6545. }
  6546. queryResult = append(queryResult, result)
  6547. }
  6548. } else if record_type == 3 {
  6549. projects, _ := service.GetBathchMyPorjecgList(ids)
  6550. for _, item := range projects {
  6551. result := QueryResult{
  6552. ID: item.ID,
  6553. Name: item.ProjectName,
  6554. Code: item.MedicalCode,
  6555. List_type_code: "201",
  6556. }
  6557. queryResult = append(queryResult, result)
  6558. }
  6559. }
  6560. admin_user_id, _ := c.GetInt64("admin_user_id")
  6561. adminUser := c.GetAdminUserInfo()
  6562. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6563. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6564. var user_name string
  6565. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6566. if role.ID == 0 {
  6567. user_name = "xxx"
  6568. } else {
  6569. user_name = role.UserName
  6570. }
  6571. baseParams := &models.BaseParams{
  6572. SecretKey: miConfig.SecretKey,
  6573. FixmedinsCode: miConfig.Code,
  6574. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6575. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6576. OrgName: miConfig.OrgName,
  6577. Doctor: user_name,
  6578. }
  6579. if config.IsOpen == 1 {
  6580. for _, item := range queryResult {
  6581. var result string
  6582. if record_type == 1 {
  6583. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6584. } else if record_type == 2 {
  6585. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6586. } else if record_type == 3 {
  6587. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6588. }
  6589. var dat map[string]interface{}
  6590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6591. fmt.Println(dat)
  6592. } else {
  6593. fmt.Println(err)
  6594. }
  6595. userJSONBytes, _ := json.Marshal(dat)
  6596. var res ResultSix
  6597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6598. utils.ErrorLog("解析失败:%v", err)
  6599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6600. return
  6601. }
  6602. if res.Infcode == 0 {
  6603. if record_type == 1 {
  6604. service.UpdateBaseDrugById(item.ID)
  6605. } else if record_type == 2 {
  6606. service.UpdateGoodInformaitonByDetail(item.ID)
  6607. } else if record_type == 3 {
  6608. service.UpdateProjectById(item.ID)
  6609. }
  6610. c.ServeSuccessJSON(map[string]interface{}{
  6611. "failed_code": 0,
  6612. "msg": "目录对照成功",
  6613. })
  6614. } else {
  6615. c.ServeSuccessJSON(map[string]interface{}{
  6616. "failed_code": -10,
  6617. "msg": res.ErrMsg,
  6618. })
  6619. }
  6620. }
  6621. }
  6622. }
  6623. func (c *HisApiController) UnCheckCode() {
  6624. ids_str := c.GetString("ids")
  6625. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6626. admin_user_id, _ := c.GetInt64("admin_user_id")
  6627. ids_arr := strings.Split(ids_str, ",")
  6628. var queryResult []QueryResult
  6629. ids := make([]int64, 0)
  6630. for _, item := range ids_arr {
  6631. id, _ := strconv.ParseInt(item, 10, 64)
  6632. ids = append(ids, id)
  6633. }
  6634. if record_type == 1 {
  6635. drugs, _ := service.GetBatchDrugList(ids)
  6636. for _, item := range drugs {
  6637. result := QueryResult{
  6638. ID: item.ID,
  6639. Name: item.DrugName,
  6640. Code: item.MedicalInsuranceNumber,
  6641. List_type_code: "101",
  6642. }
  6643. queryResult = append(queryResult, result)
  6644. }
  6645. } else if record_type == 2 {
  6646. goods, _ := service.GetBatchGoodInformationList(ids)
  6647. for _, item := range goods {
  6648. result := QueryResult{
  6649. ID: item.ID,
  6650. Name: item.GoodName,
  6651. Code: item.MedicalInsuranceNumber,
  6652. List_type_code: "301",
  6653. }
  6654. queryResult = append(queryResult, result)
  6655. }
  6656. } else if record_type == 3 {
  6657. projects, _ := service.GetBathchMyPorjecgList(ids)
  6658. for _, item := range projects {
  6659. result := QueryResult{
  6660. ID: item.ID,
  6661. Name: item.ProjectName,
  6662. Code: item.MedicalCode,
  6663. List_type_code: "201",
  6664. }
  6665. queryResult = append(queryResult, result)
  6666. }
  6667. }
  6668. adminUser := c.GetAdminUserInfo()
  6669. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6670. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6671. var user_name string
  6672. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6673. if role.ID == 0 {
  6674. user_name = "xxx"
  6675. } else {
  6676. user_name = role.UserName
  6677. }
  6678. baseParams := &models.BaseParams{
  6679. SecretKey: miConfig.SecretKey,
  6680. FixmedinsCode: miConfig.Code,
  6681. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6682. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6683. OrgName: miConfig.OrgName,
  6684. Doctor: user_name,
  6685. }
  6686. if config.IsOpen == 1 {
  6687. for _, item := range queryResult {
  6688. var result string
  6689. if record_type == 1 {
  6690. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6691. } else if record_type == 2 {
  6692. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6693. } else if record_type == 3 {
  6694. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6695. }
  6696. var dat2 map[string]interface{}
  6697. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  6698. fmt.Println(dat2)
  6699. } else {
  6700. fmt.Println(err)
  6701. }
  6702. userJSONBytes, _ := json.Marshal(dat2)
  6703. var res ResultSix
  6704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6705. utils.ErrorLog("解析失败:%v", err)
  6706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6707. return
  6708. }
  6709. if res.Infcode == 0 {
  6710. if record_type == 1 {
  6711. service.UpdateDrugByIdDetail(item.ID)
  6712. } else if record_type == 2 {
  6713. service.UpdateGoodInfoById(item.ID)
  6714. } else if record_type == 3 {
  6715. service.UpdateMyProjectById(item.ID)
  6716. }
  6717. c.ServeSuccessJSON(map[string]interface{}{
  6718. "failed_code": 0,
  6719. "msg": "撤销目录对照成功",
  6720. })
  6721. } else {
  6722. c.ServeSuccessJSON(map[string]interface{}{
  6723. "failed_code": -10,
  6724. "msg": res.ErrMsg,
  6725. })
  6726. }
  6727. }
  6728. }
  6729. }
  6730. func (c *HisApiController) GetPatientInfo() {
  6731. id_card_no := c.GetString("id_card_no")
  6732. admin_user_id, _ := c.GetInt64("admin_user_id")
  6733. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6734. if patient.ID == 0 {
  6735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6736. return
  6737. }
  6738. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6739. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6740. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  6741. if config.IsOpen == 1 {
  6742. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  6743. var dat map[string]interface{}
  6744. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6745. fmt.Println(dat)
  6746. } else {
  6747. fmt.Println(err)
  6748. }
  6749. userJSONBytes, _ := json.Marshal(dat)
  6750. var res ResultTwo
  6751. var res10265 ResultTwo10265
  6752. if miConfig.Code == "H15049901371" {
  6753. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6754. utils.ErrorLog("解析失败:%v", err)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. return
  6757. }
  6758. res.ErrMsg = res10265.ErrMsg
  6759. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6760. res.Infcode = infocode
  6761. res.Output = res10265.Output
  6762. res.InfRefmsgid = res10265.InfRefmsgid
  6763. } else {
  6764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6765. utils.ErrorLog("解析失败:%v", err)
  6766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6767. return
  6768. }
  6769. }
  6770. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6771. // utils.ErrorLog("解析失败:%v", err)
  6772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6773. // return
  6774. //}
  6775. if res.Infcode != 0 {
  6776. c.ServeSuccessJSON(map[string]interface{}{
  6777. "failed_code": -10,
  6778. "msg": res.ErrMsg,
  6779. })
  6780. } else {
  6781. c.ServeSuccessJSON(map[string]interface{}{
  6782. "failed_code": 0,
  6783. "info": res,
  6784. })
  6785. }
  6786. }
  6787. }
  6788. func (c *HisApiController) PsnPutOnRecord() {
  6789. record_type, _ := c.GetInt64("type")
  6790. patient_id, _ := c.GetInt64("patient_id")
  6791. admin_user_id, _ := c.GetInt64("admin_user_id")
  6792. start_time := c.GetString("start_time")
  6793. end_time := c.GetString("end_time")
  6794. adminUser := c.GetAdminUserInfo()
  6795. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6796. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6797. var patients []*models.Patients
  6798. if record_type == 1 { //全部备案
  6799. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  6800. patients = append(patients, patient...)
  6801. } else { //单个备案
  6802. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6803. patients = append(patients, patient)
  6804. }
  6805. var user_name string
  6806. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6807. if role.ID == 0 {
  6808. user_name = "xxx"
  6809. } else {
  6810. user_name = role.UserName
  6811. }
  6812. if config.IsOpen == 1 {
  6813. for _, item := range patients {
  6814. 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
  6815. resp, requestErr := http.Get(api)
  6816. if requestErr != nil {
  6817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6818. return
  6819. }
  6820. defer resp.Body.Close()
  6821. body, ioErr := ioutil.ReadAll(resp.Body)
  6822. if ioErr != nil {
  6823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6825. return
  6826. }
  6827. var respJSON map[string]interface{}
  6828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6831. return
  6832. }
  6833. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6834. userJSONBytes, _ := json.Marshal(userJSON)
  6835. var res ResultTwo
  6836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6837. utils.ErrorLog("解析失败:%v", err)
  6838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6839. return
  6840. }
  6841. if res.Infcode == 0 {
  6842. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  6843. var dat map[string]interface{}
  6844. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6845. fmt.Println(dat)
  6846. } else {
  6847. fmt.Println(err)
  6848. }
  6849. userJSONBytes, _ := json.Marshal(dat)
  6850. var res2 ResultThirteen
  6851. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6852. utils.ErrorLog("解析失败:%v", err)
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. return
  6855. }
  6856. if res2.Infcode == 0 {
  6857. psnResult := &models.GdybPsnRecord{
  6858. UserOrgId: adminUser.CurrentOrgId,
  6859. PatientId: item.ID,
  6860. PsnNo: res.Output.Baseinfo.PsnNo,
  6861. Ctime: time.Now().Unix(),
  6862. Mtime: time.Now().Unix(),
  6863. Status: 1,
  6864. IsCancel: 1,
  6865. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6866. }
  6867. service.CreatePsnRecord(psnResult)
  6868. } else {
  6869. c.ServeSuccessJSON(map[string]interface{}{
  6870. "failed_code": -10,
  6871. "msg": res2.ErrMsg,
  6872. })
  6873. return
  6874. }
  6875. }
  6876. }
  6877. }
  6878. }
  6879. func (c *HisApiController) PsnUnPutOnRecord() {
  6880. id, _ := c.GetInt64("id")
  6881. //record_type, _ := c.GetInt64("type")
  6882. admin_user_id, _ := c.GetInt64("admin_user_id")
  6883. adminUser := c.GetAdminUserInfo()
  6884. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6885. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6886. var user_name string
  6887. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6888. if role.ID == 0 {
  6889. user_name = "xxx"
  6890. } else {
  6891. user_name = role.UserName
  6892. }
  6893. psn_record, _ := service.GetPsnRecordById(id)
  6894. if psn_record.ID == 0 {
  6895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6896. return
  6897. }
  6898. if config.IsOpen == 1 {
  6899. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6900. var dat map[string]interface{}
  6901. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6902. fmt.Println(dat)
  6903. } else {
  6904. fmt.Println(err)
  6905. }
  6906. userJSONBytes, _ := json.Marshal(dat)
  6907. var res ResultFourteen
  6908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6909. utils.ErrorLog("解析失败:%v", err)
  6910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6911. return
  6912. }
  6913. if res.Infcode == 0 {
  6914. psn_record.IsCancel = 2
  6915. service.CreatePsnRecord(&psn_record)
  6916. } else {
  6917. c.ServeSuccessJSON(map[string]interface{}{
  6918. "failed_code": -10,
  6919. "msg": res.ErrMsg,
  6920. })
  6921. return
  6922. }
  6923. }
  6924. }
  6925. func (c *HisApiController) PsnPutNCDSOnRecord() {
  6926. patient_id, _ := c.GetInt64("patient_id")
  6927. insutype_two := c.GetString("insutype")
  6928. psn_no := c.GetString("psn_no")
  6929. doctor_id, _ := c.GetInt64("doctor_id")
  6930. sick_id, _ := c.GetInt64("sick_id")
  6931. department_id, _ := c.GetInt64("department_id")
  6932. start_time := c.GetString("start_time")
  6933. end_time := c.GetString("end_time")
  6934. check_time := c.GetString("check_time")
  6935. adminUser := c.GetAdminUserInfo()
  6936. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6937. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6938. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6939. sick, _ := service.FindSickById(sick_id)
  6940. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6941. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6942. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  6943. var res ResultTwo
  6944. var res10265 ResultTwo10265
  6945. if miConfig.Code == "H15049901371" {
  6946. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6947. utils.ErrorLog("解析失败:%v", err)
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. return
  6950. }
  6951. res.ErrMsg = res10265.ErrMsg
  6952. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6953. res.Infcode = infocode
  6954. res.Output = res10265.Output
  6955. res.InfRefmsgid = res10265.InfRefmsgid
  6956. } else {
  6957. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6958. utils.ErrorLog("解析失败:%v", err)
  6959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6960. return
  6961. }
  6962. }
  6963. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6964. infoStr := string(Iinfos)
  6965. var rf []*ResultFive
  6966. json.Unmarshal([]byte(infoStr), &rf)
  6967. var insuplc_admdvs string
  6968. var insutype string
  6969. var is390 int = 0
  6970. var is310 int = 0
  6971. var insutypes []*ResultFive
  6972. for _, item := range rf {
  6973. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6974. insutypes = append(insutypes, item)
  6975. }
  6976. }
  6977. if len(insutypes) == 1 {
  6978. insutype = insutypes[0].Insutype
  6979. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6980. } else {
  6981. for _, i := range insutypes {
  6982. if i.Insutype == "390" {
  6983. is390 = 1
  6984. }
  6985. if i.Insutype == "310" {
  6986. is310 = 1
  6987. }
  6988. }
  6989. }
  6990. if is390 == 1 {
  6991. insutype = "390"
  6992. }
  6993. if is310 == 1 {
  6994. insutype = "310"
  6995. }
  6996. if len(insutypes) == 2 {
  6997. insutype = insutype_two
  6998. }
  6999. if len(insutypes) == 0 {
  7000. insutype = "310"
  7001. }
  7002. insutype = insutype_two
  7003. fmt.Println(insutype)
  7004. for _, item := range rf {
  7005. fmt.Println(item.Insutype)
  7006. fmt.Println(insutype)
  7007. if item.Insutype == insutype {
  7008. fmt.Println(item.Insutype)
  7009. fmt.Println(insutype)
  7010. insuplc_admdvs = item.InsuplcAdmdvs
  7011. }
  7012. }
  7013. fmt.Println(insuplc_admdvs)
  7014. if config.IsOpen == 1 {
  7015. 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)
  7016. var dat map[string]interface{}
  7017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7018. fmt.Println(dat)
  7019. } else {
  7020. fmt.Println(err)
  7021. }
  7022. userJSONBytes, _ := json.Marshal(dat)
  7023. var res2 ResultThirteen
  7024. var res10265 ResultThirteen10265
  7025. if miConfig.Code == "H15049901371" {
  7026. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7027. utils.ErrorLog("解析失败:%v", err)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. return
  7030. }
  7031. res2.ErrMsg = res10265.ErrMsg
  7032. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7033. res2.Infcode = infocode
  7034. res2.Output = res10265.Output
  7035. res2.InfRefmsgid = res10265.InfRefmsgid
  7036. } else {
  7037. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7038. utils.ErrorLog("解析失败:%v", err)
  7039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7040. return
  7041. }
  7042. }
  7043. if res2.Infcode == 0 {
  7044. psnResult := &models.GdybPsnNcdsRecord{
  7045. UserOrgId: adminUser.CurrentOrgId,
  7046. PatientId: patient.ID,
  7047. PsnNo: psn_no,
  7048. DoctorId: doctor.AdminUserId,
  7049. DepartmentId: department_id,
  7050. SickType: sick_id,
  7051. Insutype: insutype,
  7052. Ctime: time.Now().Unix(),
  7053. Mtime: time.Now().Unix(),
  7054. Status: 1,
  7055. IsCancel: 1,
  7056. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7057. }
  7058. service.CreatePsnNCDSRecord(psnResult)
  7059. c.ServeSuccessJSON(map[string]interface{}{
  7060. "failed_code": 0,
  7061. "msg": "备案成功",
  7062. "result": psnResult,
  7063. })
  7064. } else {
  7065. c.ServeSuccessJSON(map[string]interface{}{
  7066. "failed_code": -10,
  7067. "msg": res2.ErrMsg,
  7068. })
  7069. return
  7070. }
  7071. }
  7072. }
  7073. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7074. id, _ := c.GetInt64("id")
  7075. admin_user_id, _ := c.GetInt64("admin_user_id")
  7076. adminUser := c.GetAdminUserInfo()
  7077. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7078. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7079. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7080. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7081. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7082. //var user_name string
  7083. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7084. //if role.ID == 0 {
  7085. // user_name = "xxx"
  7086. //} else {
  7087. // user_name = role.UserName
  7088. //}
  7089. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7090. var res ResultTwo
  7091. var res10265 ResultTwo10265
  7092. if miConfig.Code == "H15049901371" {
  7093. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7094. utils.ErrorLog("解析失败:%v", err)
  7095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7096. return
  7097. }
  7098. res.ErrMsg = res10265.ErrMsg
  7099. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7100. res.Infcode = infocode
  7101. res.Output = res10265.Output
  7102. res.InfRefmsgid = res10265.InfRefmsgid
  7103. } else {
  7104. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7105. utils.ErrorLog("解析失败:%v", err)
  7106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7107. return
  7108. }
  7109. }
  7110. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7111. infoStr := string(Iinfos)
  7112. var rf []*ResultFive
  7113. json.Unmarshal([]byte(infoStr), &rf)
  7114. var insuplc_admdvs string
  7115. var insutype string
  7116. var is390 int = 0
  7117. var is310 int = 0
  7118. var insutypes []*ResultFive
  7119. for _, item := range rf {
  7120. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7121. insutypes = append(insutypes, item)
  7122. }
  7123. }
  7124. if len(insutypes) == 1 {
  7125. insutype = insutypes[0].Insutype
  7126. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7127. } else {
  7128. for _, i := range insutypes {
  7129. if i.Insutype == "390" {
  7130. is390 = 1
  7131. }
  7132. if i.Insutype == "310" {
  7133. is310 = 1
  7134. }
  7135. }
  7136. }
  7137. if is390 == 1 {
  7138. insutype = "390"
  7139. }
  7140. if is310 == 1 {
  7141. insutype = "310"
  7142. }
  7143. if len(insutypes) == 0 {
  7144. insutype = "310"
  7145. }
  7146. for _, item := range rf {
  7147. if item.Insutype == insutype {
  7148. insuplc_admdvs = item.InsuplcAdmdvs
  7149. }
  7150. }
  7151. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7152. if psn_record.ID == 0 {
  7153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7154. return
  7155. }
  7156. if config.IsOpen == 1 {
  7157. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7158. var dat map[string]interface{}
  7159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7160. fmt.Println(dat)
  7161. } else {
  7162. fmt.Println(err)
  7163. }
  7164. userJSONBytes, _ := json.Marshal(dat)
  7165. var res ResultFourteen
  7166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7167. utils.ErrorLog("解析失败:%v", err)
  7168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7169. return
  7170. }
  7171. if res.Infcode == 0 {
  7172. psn_record.IsCancel = 2
  7173. service.CreatePsnNCDSRecord(&psn_record)
  7174. c.ServeSuccessJSON(map[string]interface{}{
  7175. "failed_code": 0,
  7176. "msg": "撤销备案成功",
  7177. })
  7178. } else {
  7179. c.ServeSuccessJSON(map[string]interface{}{
  7180. "failed_code": -10,
  7181. "msg": res.ErrMsg,
  7182. })
  7183. return
  7184. }
  7185. }
  7186. }
  7187. func (c *HisApiController) TestTest() {
  7188. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  7189. fmt.Println(patient.Iinfo)
  7190. }
  7191. type CustomData struct {
  7192. MsgId string
  7193. PsnNo string
  7194. Info string
  7195. }
  7196. func (c *HisApiController) ReversalData() {
  7197. var customData []*CustomData
  7198. custom := &CustomData{
  7199. MsgId: "H44022900158202103301714472004",
  7200. PsnNo: "44020000001101329945",
  7201. Info: "2207",
  7202. }
  7203. customData = append(customData, custom)
  7204. custom1 := &CustomData{
  7205. MsgId: "H4402290015820210330172057803",
  7206. PsnNo: "44020000001101161813",
  7207. Info: "2207",
  7208. }
  7209. customData = append(customData, custom1)
  7210. custom2 := &CustomData{
  7211. MsgId: "H44022900158202103301705198813",
  7212. PsnNo: "44190000133097375417",
  7213. Info: "2207",
  7214. }
  7215. customData = append(customData, custom2)
  7216. custom3 := &CustomData{
  7217. MsgId: "H44022900158202103301715524756",
  7218. PsnNo: "44020000001100187221",
  7219. Info: "2207",
  7220. }
  7221. customData = append(customData, custom3)
  7222. custom4 := &CustomData{
  7223. MsgId: "H44022900158202103301730376224",
  7224. PsnNo: "44020000001101959155",
  7225. Info: "2207",
  7226. }
  7227. customData = append(customData, custom4)
  7228. custom5 := &CustomData{
  7229. MsgId: "H44022900158202103301748008725",
  7230. PsnNo: "44020000001104246641",
  7231. Info: "2207",
  7232. }
  7233. customData = append(customData, custom5)
  7234. custom6 := &CustomData{
  7235. MsgId: "H44022900158202103301718096755",
  7236. PsnNo: "44020000001102211860",
  7237. Info: "2207",
  7238. }
  7239. customData = append(customData, custom6)
  7240. custom7 := &CustomData{
  7241. MsgId: "H44022900158202103301736551640",
  7242. PsnNo: "44020000001102687718",
  7243. Info: "2207",
  7244. }
  7245. customData = append(customData, custom7)
  7246. custom8 := &CustomData{
  7247. MsgId: "H44022900158202103301743097676",
  7248. PsnNo: "44020000001102127785",
  7249. Info: "2207",
  7250. }
  7251. customData = append(customData, custom8)
  7252. custom9 := &CustomData{
  7253. MsgId: "H44022900158202103301712304203",
  7254. PsnNo: "44020000001101518097",
  7255. Info: "2207",
  7256. }
  7257. customData = append(customData, custom9)
  7258. custom10 := &CustomData{
  7259. MsgId: "H44022900158202103301738448785",
  7260. PsnNo: "44020000001100500813",
  7261. Info: "2207",
  7262. }
  7263. customData = append(customData, custom10)
  7264. custom11 := &CustomData{
  7265. MsgId: "H44022900158202103301732455843",
  7266. PsnNo: "44020000001102690557",
  7267. Info: "2207",
  7268. }
  7269. customData = append(customData, custom11)
  7270. custom12 := &CustomData{
  7271. MsgId: "H44022900158202103301745421708",
  7272. PsnNo: "44020000001102211928",
  7273. Info: "2207",
  7274. }
  7275. customData = append(customData, custom12)
  7276. custom1212 := &CustomData{
  7277. MsgId: "H440229001582021033017351627",
  7278. PsnNo: "44020000001102481733",
  7279. Info: "2207",
  7280. }
  7281. customData = append(customData, custom1212)
  7282. custom13 := &CustomData{
  7283. MsgId: "H44022900158202103301740327951",
  7284. PsnNo: "44020000001103174866",
  7285. Info: "2207",
  7286. }
  7287. customData = append(customData, custom13)
  7288. custom14 := &CustomData{
  7289. MsgId: "H4402290015820210330174922668",
  7290. PsnNo: "44020000001102927272",
  7291. Info: "2207",
  7292. }
  7293. customData = append(customData, custom14)
  7294. custom15 := &CustomData{
  7295. MsgId: "H44022900158202103301752362273",
  7296. PsnNo: "44020000001102942890",
  7297. Info: "2207",
  7298. }
  7299. customData = append(customData, custom15)
  7300. custom16 := &CustomData{
  7301. MsgId: "H44022900158202103301751082917",
  7302. PsnNo: "44020000001101662162",
  7303. Info: "2207",
  7304. }
  7305. customData = append(customData, custom16)
  7306. custom17 := &CustomData{
  7307. MsgId: "H44022900158202103301754147728",
  7308. PsnNo: "44020000000229014511",
  7309. Info: "2207",
  7310. }
  7311. customData = append(customData, custom17)
  7312. adminUser := c.GetAdminUserInfo()
  7313. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7314. for _, item := range customData {
  7315. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7316. fmt.Println(result)
  7317. }
  7318. }
  7319. func (c *HisApiController) ReversalOtherData() {
  7320. var customData []*CustomData
  7321. custom := &CustomData{
  7322. MsgId: "H44022900158202103301714472004",
  7323. PsnNo: "44020000001101329945",
  7324. Info: "2208",
  7325. }
  7326. customData = append(customData, custom)
  7327. custom1 := &CustomData{
  7328. MsgId: "H4402290015820210330172057803",
  7329. PsnNo: "44020000001101161813",
  7330. Info: "2208",
  7331. }
  7332. customData = append(customData, custom1)
  7333. custom2 := &CustomData{
  7334. MsgId: "H44022900158202103301705198813",
  7335. PsnNo: "44190000133097375417",
  7336. Info: "2208",
  7337. }
  7338. customData = append(customData, custom2)
  7339. custom3 := &CustomData{
  7340. MsgId: "H44022900158202103301715524756",
  7341. PsnNo: "44020000001100187221",
  7342. Info: "2208",
  7343. }
  7344. customData = append(customData, custom3)
  7345. custom4 := &CustomData{
  7346. MsgId: "H44022900158202103301730376224",
  7347. PsnNo: "44020000001101959155",
  7348. Info: "2208",
  7349. }
  7350. customData = append(customData, custom4)
  7351. custom5 := &CustomData{
  7352. MsgId: "H44022900158202103301748008725",
  7353. PsnNo: "44020000001104246641",
  7354. Info: "2208",
  7355. }
  7356. customData = append(customData, custom5)
  7357. custom6 := &CustomData{
  7358. MsgId: "H44022900158202103301718096755",
  7359. PsnNo: "44020000001102211860",
  7360. Info: "2208",
  7361. }
  7362. customData = append(customData, custom6)
  7363. custom7 := &CustomData{
  7364. MsgId: "H44022900158202103301736551640",
  7365. PsnNo: "44020000001102687718",
  7366. Info: "2208",
  7367. }
  7368. customData = append(customData, custom7)
  7369. custom8 := &CustomData{
  7370. MsgId: "H44022900158202103301743097676",
  7371. PsnNo: "44020000001102127785",
  7372. Info: "2208",
  7373. }
  7374. customData = append(customData, custom8)
  7375. custom9 := &CustomData{
  7376. MsgId: "H44022900158202103301712304203",
  7377. PsnNo: "44020000001101518097",
  7378. Info: "2208",
  7379. }
  7380. customData = append(customData, custom9)
  7381. custom10 := &CustomData{
  7382. MsgId: "H44022900158202103301738448785",
  7383. PsnNo: "44020000001100500813",
  7384. Info: "2208",
  7385. }
  7386. customData = append(customData, custom10)
  7387. custom11 := &CustomData{
  7388. MsgId: "H44022900158202103301732455843",
  7389. PsnNo: "44020000001102690557",
  7390. Info: "2208",
  7391. }
  7392. customData = append(customData, custom11)
  7393. custom12 := &CustomData{
  7394. MsgId: "H44022900158202103301745421708",
  7395. PsnNo: "44020000001102211928",
  7396. Info: "2208",
  7397. }
  7398. customData = append(customData, custom12)
  7399. custom1212 := &CustomData{
  7400. MsgId: "H440229001582021033017351627",
  7401. PsnNo: "44020000001102481733",
  7402. Info: "2208",
  7403. }
  7404. customData = append(customData, custom1212)
  7405. custom13 := &CustomData{
  7406. MsgId: "H44022900158202103301740327951",
  7407. PsnNo: "44020000001103174866",
  7408. Info: "2208",
  7409. }
  7410. customData = append(customData, custom13)
  7411. custom14 := &CustomData{
  7412. MsgId: "H4402290015820210330174922668",
  7413. PsnNo: "44020000001102927272",
  7414. Info: "2208",
  7415. }
  7416. customData = append(customData, custom14)
  7417. custom15 := &CustomData{
  7418. MsgId: "H44022900158202103301752362273",
  7419. PsnNo: "44020000001102942890",
  7420. Info: "2208",
  7421. }
  7422. customData = append(customData, custom15)
  7423. custom16 := &CustomData{
  7424. MsgId: "H44022900158202103301751082917",
  7425. PsnNo: "44020000001101662162",
  7426. Info: "2208",
  7427. }
  7428. customData = append(customData, custom16)
  7429. custom17 := &CustomData{
  7430. MsgId: "H44022900158202103301754147728",
  7431. PsnNo: "44020000000229014511",
  7432. Info: "2208",
  7433. }
  7434. customData = append(customData, custom17)
  7435. adminUser := c.GetAdminUserInfo()
  7436. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7437. for _, item := range customData {
  7438. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7439. fmt.Println(result)
  7440. }
  7441. }
  7442. func PathExists(path string) (bool, error) {
  7443. _, err := os.Stat(path)
  7444. if err == nil {
  7445. return true, nil
  7446. }
  7447. if os.IsNotExist(err) {
  7448. return false, nil
  7449. }
  7450. return false, err
  7451. }
  7452. //创建文件夹
  7453. func Mkdir(dir string) {
  7454. // 创建文件夹
  7455. exist, err := PathExists(dir)
  7456. if err != nil {
  7457. fmt.Println(err.Error())
  7458. } else {
  7459. if exist {
  7460. fmt.Println(dir + "文件夹已存在!")
  7461. } else {
  7462. // 文件夹名称,权限
  7463. err := os.Mkdir(dir, os.ModePerm)
  7464. if err != nil {
  7465. fmt.Println(dir+"文件夹创建失败:", err.Error())
  7466. } else {
  7467. fmt.Println(dir + "文件夹创建成功!")
  7468. }
  7469. }
  7470. }
  7471. }
  7472. //压缩文件
  7473. func Zip(srcFile string, destZip string) error {
  7474. zipfile, err := os.Create(destZip)
  7475. if err != nil {
  7476. return err
  7477. }
  7478. defer zipfile.Close()
  7479. archive := zip.NewWriter(zipfile)
  7480. defer archive.Close()
  7481. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  7482. if err != nil {
  7483. return err
  7484. }
  7485. header, err := zip.FileInfoHeader(info)
  7486. if err != nil {
  7487. return err
  7488. }
  7489. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  7490. // header.Name = path
  7491. if info.IsDir() {
  7492. header.Name += "/"
  7493. } else {
  7494. header.Method = zip.Deflate
  7495. }
  7496. writer, err := archive.CreateHeader(header)
  7497. if err != nil {
  7498. return err
  7499. }
  7500. if !info.IsDir() {
  7501. file, err := os.Open(path)
  7502. if err != nil {
  7503. return err
  7504. }
  7505. defer file.Close()
  7506. _, err = io.Copy(writer, file)
  7507. }
  7508. return err
  7509. })
  7510. return err
  7511. }
  7512. func ReadFile(filePath string) []byte {
  7513. f, err := os.Open(filePath)
  7514. if err != nil {
  7515. fmt.Println("read file fail", err)
  7516. return nil
  7517. }
  7518. defer f.Close()
  7519. fd, err := ioutil.ReadAll(f)
  7520. if err != nil {
  7521. fmt.Println("read to fd fail", err)
  7522. return nil
  7523. }
  7524. return fd
  7525. }
  7526. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  7527. newArr = make([]*models.HisOrderInfo, 0)
  7528. for i := 0; i < len(arr); i++ {
  7529. repeat := false
  7530. for j := i + 1; j < len(arr); j++ {
  7531. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  7532. repeat = true
  7533. break
  7534. }
  7535. }
  7536. if !repeat {
  7537. newArr = append(newArr, arr[i])
  7538. }
  7539. }
  7540. return
  7541. }
  7542. func saveRegisterLog(result string) {
  7543. org_id, _ := beego.AppConfig.Int64("org_id")
  7544. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7545. dir := miConfig.OrgName + "日志"
  7546. utils.Mkdir(dir)
  7547. month := time.Unix(1557042972, 0).Format("1")
  7548. year := time.Now().Format("2006")
  7549. month = time.Now().Format("01")
  7550. day := time.Now().Format("02")
  7551. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7552. file_name := file + ".txt"
  7553. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7554. exist, _ := utils.PathExists(file_path)
  7555. if exist { //存在
  7556. fmt.Println("存在")
  7557. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7558. if err != nil {
  7559. fmt.Println("read fail")
  7560. }
  7561. content := "\r\n" + result
  7562. n, _ := f.Seek(0, 2)
  7563. _, err = f.WriteAt([]byte(content), n)
  7564. } else { //不存在
  7565. fmt.Println("文件不存在,创建文件")
  7566. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7567. defer f.Close()
  7568. if err != nil {
  7569. } else {
  7570. _, err = f.Write([]byte("记录日志"))
  7571. }
  7572. }
  7573. }
  7574. func saveLog(result string, request string, infno string, desc string) {
  7575. org_id, _ := beego.AppConfig.Int64("org_id")
  7576. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7577. dir := miConfig.OrgName + "日志"
  7578. utils.Mkdir(dir)
  7579. month := time.Unix(1557042972, 0).Format("1")
  7580. year := time.Now().Format("2006")
  7581. month = time.Now().Format("01")
  7582. day := time.Now().Format("02")
  7583. hour := time.Now().Format("15")
  7584. min := time.Now().Format("04")
  7585. sec := time.Now().Format("05")
  7586. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  7587. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7588. file_name := file + ".txt"
  7589. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7590. exist, _ := utils.PathExists(file_path)
  7591. if exist { //存在
  7592. fmt.Println("存在")
  7593. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7594. if err != nil {
  7595. fmt.Println("read fail")
  7596. }
  7597. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  7598. n, _ := f.Seek(0, 2)
  7599. _, err = f.WriteAt([]byte(content), n)
  7600. } else { //不存在
  7601. fmt.Println("文件不存在,创建文件")
  7602. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7603. defer f.Close()
  7604. if err != nil {
  7605. } else {
  7606. _, err = f.Write([]byte("记录日志"))
  7607. }
  7608. }
  7609. }
  7610. type Charset string
  7611. const (
  7612. UTF8 = Charset("UTF-8")
  7613. GB18030 = Charset("GB18030")
  7614. )
  7615. func ConvertToString(src string, srcCode string, tagCode string) string {
  7616. srcCoder := mahonia.NewDecoder(srcCode)
  7617. srcResult := srcCoder.ConvertString(src)
  7618. tagCoder := mahonia.NewDecoder(tagCode)
  7619. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  7620. result := string(cdata)
  7621. return result
  7622. }
  7623. //func (c *HisApiController)HandleCheckDetailAccount(){
  7624. // psn_no, _ := c.GetString("psn_no")
  7625. // psn_no, _ := c.GetString("psn_no")
  7626. // psn_no, _ := c.GetString("psn_no")
  7627. //
  7628. //
  7629. //
  7630. //}