his_api_controller.go 302KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515
  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. if reg_type == 1112 {
  3486. order.MedType = "1112"
  3487. }
  3488. if reg_type == 1111 {
  3489. order.MedType = "1111"
  3490. }
  3491. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3492. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3493. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3494. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3495. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3496. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3497. order.HifpPay = res.Output.Setlinfo.HifpPay
  3498. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3499. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3500. order.HifesPay = res.Output.Setlinfo.HifesPay
  3501. order.HifobPay = res.Output.Setlinfo.HifobPay
  3502. order.MafPay = res.Output.Setlinfo.MafPay
  3503. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3504. order.OthPay = res.Output.Setlinfo.OthPay
  3505. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3506. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3507. order.AcctPay = res.Output.Setlinfo.AcctPay
  3508. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3509. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3510. order.Balc = res.Output.Setlinfo.Balc
  3511. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3512. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3513. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3514. order.ClrWay = res.Output.Setlinfo.ClrWay
  3515. order.Creator = order.Creator
  3516. order.Modify = roles.AdminUserId
  3517. order.RequestLog = src_resquest
  3518. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3519. detailStr := string(setlDetail)
  3520. order.SetlDetail = detailStr
  3521. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3522. err = service.UpDateOrder(order)
  3523. if err == nil {
  3524. c.ServeSuccessJSON(map[string]interface{}{
  3525. "msg": "结算成功",
  3526. })
  3527. } else {
  3528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3529. return
  3530. }
  3531. }
  3532. } else {
  3533. adminUser := c.GetAdminUserInfo()
  3534. errlog := &models.HisOrderError{
  3535. UserOrgId: adminUser.CurrentOrgId,
  3536. Ctime: time.Now().Unix(),
  3537. Mtime: time.Now().Unix(),
  3538. ErrMsg: res.ErrMsg,
  3539. Status: 1,
  3540. PatientId: id,
  3541. RecordTime: recordDateTime,
  3542. Stage: 4,
  3543. }
  3544. service.CreateErrMsgLog(errlog)
  3545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3546. return
  3547. }
  3548. } else {
  3549. adminUser := c.GetAdminUserInfo()
  3550. errlog := &models.HisOrderError{
  3551. UserOrgId: adminUser.CurrentOrgId,
  3552. Ctime: time.Now().Unix(),
  3553. Mtime: time.Now().Unix(),
  3554. ErrMsg: res.ErrMsg,
  3555. Status: 1,
  3556. PatientId: id,
  3557. RecordTime: recordDateTime,
  3558. Stage: 4,
  3559. }
  3560. service.CreateErrMsgLog(errlog)
  3561. c.ServeSuccessJSON(map[string]interface{}{
  3562. "failed_code": -10,
  3563. "msg": res.ErrMsg,
  3564. })
  3565. return
  3566. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3567. //return
  3568. }
  3569. }
  3570. }
  3571. } else if tempOrder.ID > 0 {
  3572. if tempOrder.IsPre == 1 {
  3573. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3574. var rf []*ResultFive
  3575. json.Unmarshal([]byte(his.Iinfo), &rf)
  3576. chrg_bchno := tempOrder.Number
  3577. cert_no := his.Certno
  3578. var insutypes []string
  3579. var insutype string
  3580. var is390 int = 0
  3581. var is310 int = 0
  3582. for _, item := range rf {
  3583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3584. insutypes = append(insutypes, item.Insutype)
  3585. }
  3586. }
  3587. if len(insutypes) == 1 {
  3588. insutype = insutypes[0]
  3589. } else {
  3590. for _, i := range insutypes {
  3591. if i == "390" {
  3592. is390 = 1
  3593. }
  3594. if i == "310" {
  3595. is310 = 1
  3596. }
  3597. }
  3598. }
  3599. if is390 == 1 {
  3600. insutype = "390"
  3601. }
  3602. if is310 == 1 {
  3603. insutype = "310"
  3604. }
  3605. if len(insutypes) == 0 {
  3606. insutype = "310"
  3607. }
  3608. if len(insutypes) == 2 {
  3609. insutype = strconv.FormatInt(his.SocialType, 64)
  3610. }
  3611. //insutype = "390"
  3612. if his.IdCardType == 1 {
  3613. // cert_no = his.MedicalInsuranceNumber
  3614. cert_no = his.Certno
  3615. } else {
  3616. cert_no = his.Certno
  3617. }
  3618. var res ResultSeven
  3619. var resSeven10265 ResultSeven10265
  3620. var src_resquest string
  3621. var result2 string
  3622. var acct_used_flag string
  3623. fmt.Println("pay_way")
  3624. fmt.Println(pay_way)
  3625. fmt.Println("pay_way")
  3626. if pay_way == 4 {
  3627. acct_used_flag = "1"
  3628. } else {
  3629. acct_used_flag = "0"
  3630. }
  3631. if miConfig.MdtrtareaAdmvs == "421300" {
  3632. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3633. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3634. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3635. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3636. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3637. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3638. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3639. resp, requestErr := http.Get(api)
  3640. if requestErr != nil {
  3641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3642. return
  3643. }
  3644. body, ioErr := ioutil.ReadAll(resp.Body)
  3645. if ioErr != nil {
  3646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3648. return
  3649. }
  3650. var respJSON map[string]interface{}
  3651. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3654. return
  3655. }
  3656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3657. result, _ := json.Marshal(respJSON)
  3658. fmt.Println("log")
  3659. fmt.Println(string(result))
  3660. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3661. utils.ErrorLog("解析失败:%v", err)
  3662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3663. return
  3664. }
  3665. } else {
  3666. var src_resquest string
  3667. if miConfig.Code == "H15049901371" {
  3668. //赤峰地区国家医保医疗类别
  3669. //职工透析:医疗类别选特殊情况门诊990502
  3670. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3671. var med_type string
  3672. if his.Insutype == "390" {
  3673. if reg_type == 14 {
  3674. med_type = "9933"
  3675. } else if reg_type == 11 {
  3676. med_type = "11"
  3677. }
  3678. } else if his.Insutype == "310" {
  3679. if reg_type == 14 {
  3680. med_type = "990502"
  3681. } else if reg_type == 11 {
  3682. med_type = "11"
  3683. }
  3684. }
  3685. 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)
  3686. } else {
  3687. 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)
  3688. }
  3689. var dat map[string]interface{}
  3690. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3691. fmt.Println(dat)
  3692. } else {
  3693. fmt.Println(err)
  3694. }
  3695. saveLog(result2, src_resquest, "2207", "结算")
  3696. userJSONBytes, _ := json.Marshal(dat)
  3697. if miConfig.Code == "H15049901371" {
  3698. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3699. utils.ErrorLog("解析失败:%v", err)
  3700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3701. return
  3702. }
  3703. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3704. res.Output = resSeven10265.Output
  3705. res.ErrMsg = resSeven10265.ErrMsg
  3706. res.Cainfo = resSeven10265.Cainfo
  3707. res.WarnMsg = resSeven10265.WarnMsg
  3708. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3709. res.Infcode = infocode
  3710. } else {
  3711. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3712. utils.ErrorLog("解析失败:%v", err)
  3713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3714. return
  3715. }
  3716. }
  3717. }
  3718. if res.Infcode != 0 {
  3719. errlog := &models.HisOrderError{
  3720. UserOrgId: adminUser.CurrentOrgId,
  3721. Ctime: time.Now().Unix(),
  3722. Mtime: time.Now().Unix(),
  3723. Number: chrg_bchno,
  3724. ErrMsg: res.ErrMsg,
  3725. Status: 1,
  3726. PatientId: id,
  3727. RecordTime: recordDateTime,
  3728. Stage: 6,
  3729. }
  3730. service.CreateErrMsgLog(errlog)
  3731. c.ServeSuccessJSON(map[string]interface{}{
  3732. "failed_code": -10,
  3733. "msg": res.ErrMsg,
  3734. })
  3735. return
  3736. } else {
  3737. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3738. order.OrderStatus = 2
  3739. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3740. order.SetlId = res.Output.Setlinfo.SetlID
  3741. order.PsnNo = res.Output.Setlinfo.PsnNo
  3742. order.PsnName = res.Output.Setlinfo.PsnName
  3743. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3744. order.Certno = res.Output.Setlinfo.Certno
  3745. order.Gend = res.Output.Setlinfo.Gend
  3746. order.Naty = res.Output.Setlinfo.Naty
  3747. order.Age = res.Output.Setlinfo.Age
  3748. order.Insutype = res.Output.Setlinfo.Insutype
  3749. order.PsnType = res.Output.Setlinfo.PsnType
  3750. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3751. order.SetlTime = res.Output.Setlinfo.SetlTime
  3752. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3753. //order.MedType = res.Output.Setlinfo.MedType
  3754. if reg_type == 1112 {
  3755. order.MedType = "1112"
  3756. }
  3757. if reg_type == 1111 {
  3758. order.MedType = "1111"
  3759. }
  3760. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3761. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3762. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3763. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3764. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3765. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3766. order.HifpPay = res.Output.Setlinfo.HifpPay
  3767. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3768. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3769. order.HifesPay = res.Output.Setlinfo.HifesPay
  3770. order.HifobPay = res.Output.Setlinfo.HifobPay
  3771. order.MafPay = res.Output.Setlinfo.MafPay
  3772. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3773. order.OthPay = res.Output.Setlinfo.OthPay
  3774. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3775. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3776. order.AcctPay = res.Output.Setlinfo.AcctPay
  3777. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3778. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3779. order.Balc = res.Output.Setlinfo.Balc
  3780. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3781. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3782. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3783. order.ClrWay = res.Output.Setlinfo.ClrWay
  3784. order.Creator = order.Creator
  3785. order.Modify = roles.AdminUserId
  3786. order.RequestLog = src_resquest
  3787. order.Diagnosis = diagnosis_id
  3788. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3789. detailStr := string(setlDetail)
  3790. order.SetlDetail = detailStr
  3791. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3792. err = service.UpDateOrder(order)
  3793. if err == nil {
  3794. c.ServeSuccessJSON(map[string]interface{}{
  3795. "msg": "结算成功",
  3796. })
  3797. } else {
  3798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3799. return
  3800. }
  3801. }
  3802. }
  3803. }
  3804. }
  3805. //func (c *HisApiController) GetPreUploadInfo() {
  3806. // id, _ := c.GetInt64("id")
  3807. // record_time := c.GetString("record_time")
  3808. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3809. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3810. //
  3811. // timeLayout := "2006-01-02"
  3812. // loc, _ := time.LoadLocation("Local")
  3813. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3814. // if err != nil {
  3815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3816. // return
  3817. // }
  3818. // recordDateTime := theTime.Unix()
  3819. // adminUser := c.GetAdminUserInfo()
  3820. //
  3821. // var prescriptions []*models.HisPrescription
  3822. //
  3823. // var start_time int64
  3824. // var end_time int64
  3825. //
  3826. // data := make(map[string]interface{})
  3827. // if settle_accounts_type == 1 { //日结
  3828. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3829. // data["pre"] = prescriptions
  3830. //
  3831. // } else { //月结
  3832. // start_time_str := c.GetString("start_time")
  3833. // end_time_str := c.GetString("end_time")
  3834. // timeLayout := "2006-01-02"
  3835. // loc, _ := time.LoadLocation("Local")
  3836. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3837. // if err != nil {
  3838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3839. // return
  3840. // }
  3841. // recordStartTime := theStartTime.Unix()
  3842. // start_time = recordStartTime
  3843. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3844. // if err != nil {
  3845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3846. // return
  3847. // }
  3848. // recordEndTime := theEndTime.Unix()
  3849. // end_time = recordEndTime
  3850. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3851. // data["pre"] = prescriptions
  3852. //
  3853. // }
  3854. //
  3855. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3856. //
  3857. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3858. // timestamp := time.Now().Unix()
  3859. // tempTime := time.Unix(timestamp, 0)
  3860. // timeFormat := tempTime.Format("20060102150405")
  3861. // chrgBchno := rand.Intn(100000) + 10000
  3862. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3863. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3864. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3865. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3866. // strconv.FormatInt(his.PatientId, 10)
  3867. // client := &http.Client{}
  3868. // data["psn_no"] = his.PsnNo
  3869. // data["mdtrt_id"] = his.Number
  3870. // data["chrg_bchno"] = chrg_bchno
  3871. // data["org_name"] = miConfig.OrgName
  3872. // data["doctor"] = roles.UserName
  3873. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3874. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3875. // data["fixmedins_code"] = miConfig.Code
  3876. // data["dept_code"] = department.Number
  3877. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3878. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3879. // data["secret_key"] = miConfig.SecretKey
  3880. // var ids []int64
  3881. //
  3882. // for _, item := range prescriptions {
  3883. // ids = append(ids, item.ID)
  3884. // }
  3885. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3886. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3887. // bytesData, _ := json.Marshal(data)
  3888. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3889. // resp, _ := client.Do(req)
  3890. // defer resp.Body.Close()
  3891. // body, ioErr := ioutil.ReadAll(resp.Body)
  3892. // if ioErr != nil {
  3893. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3895. // return
  3896. // }
  3897. // var respJSON map[string]interface{}
  3898. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3899. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3901. // return
  3902. // }
  3903. //
  3904. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3905. // userJSONBytes, _ := json.Marshal(respJSON)
  3906. // var res ResultFour
  3907. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3908. // utils.ErrorLog("解析失败:%v", err)
  3909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3910. // return
  3911. // }
  3912. //
  3913. // if res.Infcode == 0 {
  3914. // order := &models.HisOrder{
  3915. // UserOrgId: adminUser.CurrentOrgId,
  3916. // HisPatientId: his.ID,
  3917. // PatientId: his.PatientId,
  3918. // SettleAccountsDate: recordDateTime,
  3919. // Ctime: time.Now().Unix(),
  3920. // Mtime: time.Now().Unix(),
  3921. // Status: 1,
  3922. // Number: chrg_bchno,
  3923. // Infcode: res.Infcode,
  3924. // WarnMsg: res.WarnMsg,
  3925. // Cainfo: res.Cainfo,
  3926. // ErrMsg: res.ErrMsg,
  3927. // RespondTime: res.RefmsgTime,
  3928. // InfRefmsgid: res.InfRefmsgid,
  3929. // OrderStatus: 1,
  3930. // IsMedicineInsurance: 1,
  3931. // SettleType: settle_accounts_type,
  3932. // SettleStartTime: start_time,
  3933. // SettleEndTime: end_time,
  3934. // Creator: roles.ID,
  3935. // Modify: roles.ID,
  3936. // PType: 2,
  3937. // }
  3938. // err = service.CreateOrder(order)
  3939. // if err != nil {
  3940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3941. // return
  3942. // }
  3943. //
  3944. // for _, item := range res.Output.Result {
  3945. // temp := strings.Split(item.FeedetlSn, "-")
  3946. // var advice_id int64 = 0
  3947. // var project_id int64 = 0
  3948. // var types int64 = 0
  3949. //
  3950. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  3951. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  3952. //
  3953. // if temp[1] == "1" {
  3954. // advice_id = id
  3955. // project_id = 0
  3956. // } else if temp[1] == "2" {
  3957. // advice_id = 0
  3958. // project_id = id
  3959. // }
  3960. //
  3961. // info := &models.HisOrderInfo{
  3962. // OrderNumber: order.Number,
  3963. // FeedetlSn: item.FeedetlSn,
  3964. // UploadDate: time.Now().Unix(),
  3965. // AdviceId: advice_id,
  3966. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  3967. // Cnt: item.Cnt,
  3968. // Pric: float64(item.Pric),
  3969. // PatientId: his.PatientId,
  3970. // PricUplmtAmt: item.PricUplmtAmt,
  3971. // SelfpayProp: item.SelfpayProp,
  3972. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3973. // OverlmtAmt: item.OverlmtAmt,
  3974. // PreselfpayAmt: item.PreselfpayAmt,
  3975. // BasMednFlag: item.BasMednFlag,
  3976. // MedChrgitmType: item.MedChrgitmType,
  3977. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  3978. // Status: 1,
  3979. // Memo: item.Memo,
  3980. // Mtime: time.Now().Unix(),
  3981. // InscpScpAmt: item.InscpScpAmt,
  3982. // DrtReimFlag: item.DrtReimFlag,
  3983. // Ctime: time.Now().Unix(),
  3984. // ListSpItemFlag: item.ListSpItemFlag,
  3985. // ChldMedcFlag: item.ChldMedcFlag,
  3986. // LmtUsedFlag: item.LmtUsedFlag,
  3987. // ChrgitmLv: item.ChrgitmLv,
  3988. // UserOrgId: adminUser.CurrentOrgId,
  3989. // HisPatientId: his.ID,
  3990. // OrderId: order.ID,
  3991. // ProjectId: project_id,
  3992. // Type: types,
  3993. // }
  3994. // service.CreateOrderInfo(info)
  3995. //
  3996. // }
  3997. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3998. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  3999. //
  4000. // var total float64
  4001. // for _, item := range prescriptions {
  4002. // if item.Type == 1 { //药品
  4003. // for _, subItem := range item.HisDoctorAdviceInfo {
  4004. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4005. // }
  4006. // }
  4007. // if item.Type == 2 { //项目
  4008. // for _, subItem := range item.HisPrescriptionProject {
  4009. // total = total + (subItem.Price * float64(subItem.Count))
  4010. // }
  4011. // }
  4012. // }
  4013. //
  4014. // for _, item := range prescriptions {
  4015. // for _, subItem := range item.HisAdditionalCharge {
  4016. // total = total + (subItem.Price * float64(subItem.Count))
  4017. // }
  4018. // }
  4019. //
  4020. // allTotal := fmt.Sprintf("%.2f", total)
  4021. // if res.Infcode == 0 {
  4022. // var rf []*ResultFive
  4023. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4024. // psn_no := his.PsnNo
  4025. // mdtrt_id := his.Number
  4026. // chrg_bchno := chrg_bchno
  4027. // cert_no := his.Certno
  4028. // insutype := rf[0].Insutype
  4029. //
  4030. // if his.IdCardType == 1 {
  4031. // cert_no = his.MedicalInsuranceNumber
  4032. //
  4033. // } else {
  4034. //
  4035. // cert_no = his.Certno
  4036. //
  4037. // }
  4038. //
  4039. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4040. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4041. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4042. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4043. // resp, requestErr := http.Get(api)
  4044. // if requestErr != nil {
  4045. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4046. // return
  4047. // }
  4048. // defer resp.Body.Close()
  4049. // body, ioErr := ioutil.ReadAll(resp.Body)
  4050. // if ioErr != nil {
  4051. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4053. // return
  4054. // }
  4055. // var respJSON map[string]interface{}
  4056. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4057. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4059. // return
  4060. // }
  4061. // fmt.Println(respJSON)
  4062. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4063. // userJSONBytes, _ := json.Marshal(respJSON)
  4064. // var res ResultSeven
  4065. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4066. // utils.ErrorLog("解析失败:%v", err)
  4067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4068. // return
  4069. // }
  4070. // if res.Infcode != 0 {
  4071. // errlog := &models.HisOrderError{
  4072. // UserOrgId: adminUser.CurrentOrgId,
  4073. // Ctime: time.Now().Unix(),
  4074. // Mtime: time.Now().Unix(),
  4075. // Number: chrg_bchno,
  4076. // ErrMsg: res.ErrMsg,
  4077. // Status: 1,
  4078. // PatientId: id,
  4079. // RecordTime: recordDateTime,
  4080. // Stage: 7,
  4081. // }
  4082. // service.CreateErrMsgLog(errlog)
  4083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4084. // return
  4085. // } else {
  4086. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4087. // order.OrderStatus = 1
  4088. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4089. // order.SetlId = res.Output.Setlinfo.SetlID
  4090. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4091. // order.PsnName = res.Output.Setlinfo.PsnName
  4092. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4093. // order.Certno = res.Output.Setlinfo.Certno
  4094. // order.Gend = res.Output.Setlinfo.Gend
  4095. // order.Naty = res.Output.Setlinfo.Naty
  4096. // order.Age = res.Output.Setlinfo.Age
  4097. // order.Insutype = res.Output.Setlinfo.Insutype
  4098. // order.PsnType = res.Output.Setlinfo.PsnType
  4099. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4100. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4101. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4102. // order.MedType = res.Output.Setlinfo.MedType
  4103. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4104. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4105. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4106. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4107. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4108. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4109. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4110. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4111. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4112. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4113. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4114. // order.MafPay = res.Output.Setlinfo.MafPay
  4115. // order.OthPay = res.Output.Setlinfo.OthPay
  4116. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4117. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4118. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4119. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4120. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4121. // order.Balc = res.Output.Setlinfo.Balc
  4122. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4123. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4124. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4125. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4126. // order.Creator = order.Creator
  4127. // order.Modify = roles.ID
  4128. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4129. // detailStr := string(setlDetail)
  4130. // order.SetlDetail = detailStr
  4131. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4132. // err = service.UpDateOrder(order)
  4133. // if err == nil {
  4134. // c.ServeSuccessJSON(map[string]interface{}{
  4135. // "msg": "预结算成功",
  4136. // })
  4137. // } else {
  4138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4139. // return
  4140. // }
  4141. // }
  4142. // } else {
  4143. // adminUser := c.GetAdminUserInfo()
  4144. // errlog := &models.HisOrderError{
  4145. // UserOrgId: adminUser.CurrentOrgId,
  4146. // Ctime: time.Now().Unix(),
  4147. // Mtime: time.Now().Unix(),
  4148. // ErrMsg: res.ErrMsg,
  4149. // Status: 1,
  4150. // PatientId: id,
  4151. // RecordTime: recordDateTime,
  4152. // Stage: 4,
  4153. // }
  4154. // service.CreateErrMsgLog(errlog)
  4155. //
  4156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4157. // return
  4158. // }
  4159. // } else {
  4160. // adminUser := c.GetAdminUserInfo()
  4161. // errlog := &models.HisOrderError{
  4162. // UserOrgId: adminUser.CurrentOrgId,
  4163. // Ctime: time.Now().Unix(),
  4164. // Mtime: time.Now().Unix(),
  4165. // ErrMsg: res.ErrMsg,
  4166. // Status: 1,
  4167. // PatientId: id,
  4168. // RecordTime: recordDateTime,
  4169. // Stage: 4,
  4170. // }
  4171. // service.CreateErrMsgLog(errlog)
  4172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4173. // return
  4174. // }
  4175. //
  4176. // } else {
  4177. // var total float64
  4178. // for _, item := range prescriptions {
  4179. // if item.Type == 1 { //药品
  4180. // for _, subItem := range item.HisDoctorAdviceInfo {
  4181. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4182. // }
  4183. // }
  4184. // if item.Type == 2 { //项目
  4185. // for _, subItem := range item.HisPrescriptionProject {
  4186. // total = total + (subItem.Price * float64(subItem.Count))
  4187. // }
  4188. // }
  4189. //
  4190. // for _, subItem := range item.HisAdditionalCharge {
  4191. // total = total + (subItem.Price * float64(subItem.Count))
  4192. // }
  4193. // }
  4194. //
  4195. // allTotal := fmt.Sprintf("%.2f", total)
  4196. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4197. // order := &models.HisOrder{
  4198. // UserOrgId: adminUser.CurrentOrgId,
  4199. // HisPatientId: his.ID,
  4200. // PatientId: id,
  4201. // SettleAccountsDate: recordDateTime,
  4202. // Ctime: time.Now().Unix(),
  4203. // Mtime: time.Now().Unix(),
  4204. // Status: 1,
  4205. // OrderStatus: 2,
  4206. // Number: chrg_bchno,
  4207. // MedfeeSumamt: totals,
  4208. // }
  4209. // err = service.CreateOrder(order)
  4210. // if err != nil {
  4211. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4212. // return
  4213. // }
  4214. //
  4215. // var customs []*Custom
  4216. // for _, item := range prescriptions {
  4217. //
  4218. // if item.Type == 1 { //药品
  4219. // for _, subItem := range item.HisDoctorAdviceInfo {
  4220. // cus := &Custom{
  4221. // AdviceId: subItem.ID,
  4222. // ProjectId: 0,
  4223. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4224. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4225. // FeedetlSn: subItem.FeedetlSn,
  4226. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4227. // MedListCodg: subItem.MedListCodg,
  4228. // Type: 1,
  4229. // }
  4230. // customs = append(customs, cus)
  4231. // }
  4232. // }
  4233. //
  4234. // if item.Type == 2 { //项目
  4235. // for _, subItem := range item.HisPrescriptionProject {
  4236. //
  4237. // cus := &Custom{
  4238. // AdviceId: 0,
  4239. // ProjectId: subItem.ID,
  4240. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4241. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4242. // FeedetlSn: subItem.FeedetlSn,
  4243. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4244. // MedListCodg: subItem.MedListCodg,
  4245. // Type: 2,
  4246. // }
  4247. //
  4248. // customs = append(customs, cus)
  4249. // }
  4250. // }
  4251. //
  4252. // for _, item := range item.HisAdditionalCharge {
  4253. // cus := &Custom{
  4254. // ItemId: item.ID,
  4255. // AdviceId: 0,
  4256. // ProjectId: 0,
  4257. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4258. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4259. // FeedetlSn: item.FeedetlSn,
  4260. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4261. // MedListCodg: item.XtHisAddtionConfig.Code,
  4262. // Type: 3,
  4263. // }
  4264. //
  4265. // customs = append(customs, cus)
  4266. // }
  4267. //
  4268. // }
  4269. //
  4270. // for _, item := range customs {
  4271. // var advice_id int64 = 0
  4272. // var project_id int64 = 0
  4273. // var item_id int64 = 0
  4274. //
  4275. // var types int64 = 0
  4276. //
  4277. // if item.Type == 1 {
  4278. // advice_id = item.AdviceId
  4279. // project_id = 0
  4280. // item_id = 0
  4281. // } else if item.Type == 2 {
  4282. // advice_id = 0
  4283. // item_id = 0
  4284. //
  4285. // project_id = item.ProjectId
  4286. // } else if item.Type == 3 {
  4287. // advice_id = 0
  4288. // item_id = item.ItemId
  4289. // project_id = 0
  4290. // }
  4291. //
  4292. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4293. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4294. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4295. //
  4296. // info := &models.HisOrderInfo{
  4297. // OrderNumber: order.Number,
  4298. // UploadDate: time.Now().Unix(),
  4299. // AdviceId: advice_id,
  4300. // DetItemFeeSumamt: detItemFeeSumamt,
  4301. // Cnt: cut,
  4302. // Pric: pric,
  4303. // PatientId: id,
  4304. // Status: 1,
  4305. // Mtime: time.Now().Unix(),
  4306. // Ctime: time.Now().Unix(),
  4307. // UserOrgId: adminUser.CurrentOrgId,
  4308. // HisPatientId: his.ID,
  4309. // OrderId: order.ID,
  4310. // ProjectId: project_id,
  4311. // Type: types,
  4312. // ItemId: item_id,
  4313. // }
  4314. // service.CreateOrderInfo(info)
  4315. // }
  4316. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4317. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4318. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4319. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4320. // if err == nil {
  4321. // c.ServeSuccessJSON(map[string]interface{}{
  4322. // "msg": "结算成功",
  4323. // })
  4324. // } else {
  4325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4326. // return
  4327. // }
  4328. // }
  4329. //}
  4330. //上传明细-预结算-
  4331. func (c *HisApiController) GetPreUploadInfo() {
  4332. id, _ := c.GetInt64("id")
  4333. record_time := c.GetString("record_time")
  4334. his_patient_id, _ := c.GetInt64("his_patient_id")
  4335. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4336. admin_user_id, _ := c.GetInt64("admin_user_id")
  4337. diagnosis_id := c.GetString("diagnosis")
  4338. sick_type, _ := c.GetInt64("sick_type")
  4339. reg_type, _ := c.GetInt64("p_type")
  4340. id_str := c.GetString("ids")
  4341. ids_arr := strings.Split(id_str, ",")
  4342. timeLayout := "2006-01-02"
  4343. loc, _ := time.LoadLocation("Local")
  4344. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4345. if err != nil {
  4346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4347. return
  4348. }
  4349. recordDateTime := theTime.Unix()
  4350. adminUser := c.GetAdminUserInfo()
  4351. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4352. var config []*models.HisXtDiagnoseConfig
  4353. for _, item := range diagnosis_ids {
  4354. id, _ := strconv.ParseInt(item, 10, 64)
  4355. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4356. config = append(config, &diagnosisConfig)
  4357. }
  4358. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4359. sickConfig, _ := service.FindSickById(sick_type)
  4360. var prescriptions []*models.HisPrescription
  4361. var start_time int64
  4362. var end_time int64
  4363. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4364. fmt.Println(his_patient_id)
  4365. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4366. timestamp := time.Now().Unix()
  4367. tempTime := time.Unix(timestamp, 0)
  4368. timeFormat := tempTime.Format("20060102150405")
  4369. chrgBchno := rand.Intn(100000) + 10000
  4370. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4371. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4372. var patientPrescription models.HisPrescriptionInfo
  4373. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4374. if patientPrescription.ID == 0 {
  4375. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4376. }
  4377. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4378. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4379. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4380. strconv.FormatInt(his.PatientId, 10)
  4381. var res2 ResultSix
  4382. var resSix10265 ResultSix10265
  4383. if miConfig.InsuplcAdmdvs == "421300" {
  4384. data := make(map[string]interface{})
  4385. client := &http.Client{}
  4386. data["psn_no"] = his.PsnNo
  4387. data["mdtrt_id"] = his.Number
  4388. data["doctor"] = roles.UserName
  4389. data["department"] = department.Name
  4390. data["org_name"] = miConfig.OrgName
  4391. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4392. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4393. data["fixmedins_code"] = miConfig.Code
  4394. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4395. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4396. data["secret_key"] = miConfig.SecretKey
  4397. data["sick_code"] = sickConfig.CountryCode
  4398. data["sick_name"] = sickConfig.ClassName
  4399. data["dept"] = strconv.FormatInt(department.ID, 10)
  4400. data["config"] = config
  4401. fmt.Println(data)
  4402. bytesData, _ := json.Marshal(data)
  4403. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4404. resp, _ := client.Do(req)
  4405. defer resp.Body.Close()
  4406. body, ioErr := ioutil.ReadAll(resp.Body)
  4407. if ioErr != nil {
  4408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4410. return
  4411. }
  4412. var respJSON map[string]interface{}
  4413. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4416. return
  4417. }
  4418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4419. userJSONBytes, _ := json.Marshal(respJSON)
  4420. fmt.Println("log")
  4421. fmt.Println(string(userJSONBytes))
  4422. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4423. utils.ErrorLog("解析失败:%v", err)
  4424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4425. return
  4426. }
  4427. } else {
  4428. var result string
  4429. var requestLog string
  4430. if miConfig.InsuplcAdmdvs == "440781" { //
  4431. 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)
  4432. } else {
  4433. if miConfig.Code == "H15049901371" {
  4434. //赤峰地区国家医保医疗类别
  4435. //职工透析:医疗类别选特殊情况门诊990502
  4436. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4437. var med_type string
  4438. if his.Insutype == "390" {
  4439. if reg_type == 14 {
  4440. med_type = "9933"
  4441. } else if reg_type == 11 {
  4442. med_type = "11"
  4443. }
  4444. } else if his.Insutype == "310" {
  4445. if reg_type == 14 {
  4446. med_type = "990502"
  4447. } else if reg_type == 11 {
  4448. med_type = "11"
  4449. }
  4450. }
  4451. 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)
  4452. } else {
  4453. 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)
  4454. }
  4455. saveLog(result, requestLog, "2203", "上传就诊信息")
  4456. var respJSON2 map[string]interface{}
  4457. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4460. return
  4461. }
  4462. //userJSONBytes2, _ := json.Marshal(respJSON2)
  4463. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4464. // utils.ErrorLog("解析失败:%v", err)
  4465. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4466. // return
  4467. //}
  4468. userJSONBytes2, _ := json.Marshal(respJSON2)
  4469. if miConfig.Code == "H15049901371" {
  4470. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4471. utils.ErrorLog("解析失败:%v", err)
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4473. return
  4474. }
  4475. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4476. res2.Output = resSix10265.Output
  4477. res2.ErrMsg = resSix10265.ErrMsg
  4478. res2.Cainfo = resSix10265.Cainfo
  4479. res2.WarnMsg = resSix10265.WarnMsg
  4480. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4481. res2.Infcode = infocode
  4482. } else {
  4483. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4484. utils.ErrorLog("解析失败:%v", err)
  4485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. return
  4487. }
  4488. }
  4489. }
  4490. }
  4491. if res2.Infcode != 0 {
  4492. adminUser := c.GetAdminUserInfo()
  4493. errlog := &models.HisOrderError{
  4494. UserOrgId: adminUser.CurrentOrgId,
  4495. Ctime: time.Now().Unix(),
  4496. Mtime: time.Now().Unix(),
  4497. ErrMsg: res2.ErrMsg,
  4498. Status: 1,
  4499. PatientId: id,
  4500. RecordTime: recordDateTime,
  4501. Stage: 3,
  4502. }
  4503. service.CreateErrMsgLog(errlog)
  4504. c.ServeSuccessJSON(map[string]interface{}{
  4505. "failed_code": -10,
  4506. "msg": res2.ErrMsg,
  4507. })
  4508. return
  4509. } else {
  4510. his.Diagnosis = diagnosis_id
  4511. his.SickType = sickConfig.ID
  4512. his.PType = fmt.Sprintf("%d", reg_type)
  4513. service.UpdateHisPatientThree(&his)
  4514. data := make(map[string]interface{})
  4515. if settle_accounts_type == 1 { //日结
  4516. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4517. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4518. } else {
  4519. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4520. }
  4521. data["pre"] = prescriptions
  4522. } else { //月结
  4523. start_time_str := c.GetString("start_time")
  4524. end_time_str := c.GetString("end_time")
  4525. timeLayout := "2006-01-02"
  4526. loc, _ := time.LoadLocation("Local")
  4527. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4528. if err != nil {
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4530. return
  4531. }
  4532. recordStartTime := theStartTime.Unix()
  4533. start_time = recordStartTime
  4534. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4535. if err != nil {
  4536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4537. return
  4538. }
  4539. recordEndTime := theEndTime.Unix()
  4540. end_time = recordEndTime
  4541. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4542. data["pre"] = prescriptions
  4543. }
  4544. client := &http.Client{}
  4545. data["psn_no"] = his.PsnNo
  4546. data["mdtrt_id"] = his.Number
  4547. data["chrg_bchno"] = chrg_bchno
  4548. data["org_name"] = miConfig.OrgName
  4549. data["doctor"] = roles.UserName
  4550. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4551. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4552. data["fixmedins_code"] = miConfig.Code
  4553. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4554. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4555. data["dept_code"] = "15"
  4556. } else {
  4557. data["dept_code"] = department.Number
  4558. }
  4559. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4560. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4561. data["secret_key"] = miConfig.SecretKey
  4562. var ids []int64
  4563. for _, item := range prescriptions {
  4564. ids = append(ids, item.ID)
  4565. }
  4566. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4567. if config.IsOpen == 1 { //对接了医保,走医保流程
  4568. var res ResultFour
  4569. var resFour10265 ResultFour10265
  4570. if miConfig.MdtrtareaAdmvs == "421300" {
  4571. bytesData, _ := json.Marshal(data)
  4572. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4573. resp, _ := client.Do(req)
  4574. defer resp.Body.Close()
  4575. body, ioErr := ioutil.ReadAll(resp.Body)
  4576. if ioErr != nil {
  4577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4579. return
  4580. }
  4581. var respJSON map[string]interface{}
  4582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4585. return
  4586. }
  4587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4588. userJSONBytes, _ := json.Marshal(respJSON)
  4589. fmt.Println("log")
  4590. fmt.Println(string(userJSONBytes))
  4591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4592. utils.ErrorLog("解析失败:%v", err)
  4593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4594. return
  4595. }
  4596. } else {
  4597. if miConfig.Code == "H15049901371" {
  4598. 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)
  4599. var dat map[string]interface{}
  4600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4601. fmt.Println(dat)
  4602. } else {
  4603. fmt.Println(err)
  4604. }
  4605. saveLog(result, request_log, "2204", "上传费用明细")
  4606. userJSONBytes, _ := json.Marshal(dat)
  4607. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4608. utils.ErrorLog("解析失败:%v", err)
  4609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4610. return
  4611. }
  4612. res.InfRefmsgid = resFour10265.InfRefmsgid
  4613. res.Output = resFour10265.Output
  4614. res.ErrMsg = resFour10265.ErrMsg
  4615. res.Cainfo = resFour10265.Cainfo
  4616. res.WarnMsg = resFour10265.WarnMsg
  4617. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4618. res.Infcode = infocode
  4619. } else {
  4620. 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)
  4621. var dat map[string]interface{}
  4622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4623. fmt.Println(dat)
  4624. } else {
  4625. fmt.Println(err)
  4626. }
  4627. saveLog(result, request_log, "2204", "上传费用明细")
  4628. userJSONBytes, _ := json.Marshal(dat)
  4629. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4630. utils.ErrorLog("解析失败:%v", err)
  4631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4632. return
  4633. }
  4634. }
  4635. }
  4636. if res.Infcode == 0 {
  4637. order := &models.HisOrder{
  4638. UserOrgId: adminUser.CurrentOrgId,
  4639. HisPatientId: his.ID,
  4640. PatientId: his.PatientId,
  4641. SettleAccountsDate: recordDateTime,
  4642. Ctime: time.Now().Unix(),
  4643. Mtime: time.Now().Unix(),
  4644. Status: 1,
  4645. Number: chrg_bchno,
  4646. Infcode: res.Infcode,
  4647. WarnMsg: res.WarnMsg,
  4648. Cainfo: res.Cainfo,
  4649. ErrMsg: res.ErrMsg,
  4650. RespondTime: res.RefmsgTime,
  4651. InfRefmsgid: res.InfRefmsgid,
  4652. OrderStatus: 1,
  4653. IsMedicineInsurance: 1,
  4654. SettleType: settle_accounts_type,
  4655. SettleStartTime: start_time,
  4656. SettleEndTime: end_time,
  4657. Creator: roles.AdminUserId,
  4658. Modify: roles.AdminUserId,
  4659. PType: 2,
  4660. Diagnosis: diagnosis_id,
  4661. }
  4662. err = service.CreateOrder(order)
  4663. if err != nil {
  4664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4665. return
  4666. }
  4667. for _, item := range res.Output.Result {
  4668. temp := strings.Split(item.FeedetlSn, "-")
  4669. var advice_id int64 = 0
  4670. var project_id int64 = 0
  4671. var types int64 = 0
  4672. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4673. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4674. if temp[1] == "1" {
  4675. advice_id = id
  4676. project_id = 0
  4677. } else if temp[1] == "2" {
  4678. advice_id = 0
  4679. project_id = id
  4680. }
  4681. info := &models.HisOrderInfo{
  4682. OrderNumber: order.Number,
  4683. FeedetlSn: item.FeedetlSn,
  4684. UploadDate: time.Now().Unix(),
  4685. AdviceId: advice_id,
  4686. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4687. Cnt: item.Cnt,
  4688. Pric: float64(item.Pric),
  4689. PatientId: his.PatientId,
  4690. PricUplmtAmt: item.PricUplmtAmt,
  4691. SelfpayProp: item.SelfpayProp,
  4692. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4693. OverlmtAmt: item.OverlmtAmt,
  4694. PreselfpayAmt: item.PreselfpayAmt,
  4695. BasMednFlag: item.BasMednFlag,
  4696. MedChrgitmType: item.MedChrgitmType,
  4697. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4698. Status: 1,
  4699. Memo: item.Memo,
  4700. Mtime: time.Now().Unix(),
  4701. InscpScpAmt: item.InscpScpAmt,
  4702. DrtReimFlag: item.DrtReimFlag,
  4703. Ctime: time.Now().Unix(),
  4704. ListSpItemFlag: item.ListSpItemFlag,
  4705. ChldMedcFlag: item.ChldMedcFlag,
  4706. LmtUsedFlag: item.LmtUsedFlag,
  4707. ChrgitmLv: item.ChrgitmLv,
  4708. UserOrgId: adminUser.CurrentOrgId,
  4709. HisPatientId: his.ID,
  4710. OrderId: order.ID,
  4711. ProjectId: project_id,
  4712. Type: types,
  4713. }
  4714. service.CreateOrderInfo(info)
  4715. }
  4716. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4717. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4718. var total float64
  4719. for _, item := range prescriptions {
  4720. if item.Type == 1 { //药品
  4721. for _, subItem := range item.HisDoctorAdviceInfo {
  4722. total = total + (subItem.Price * subItem.PrescribingNumber)
  4723. }
  4724. }
  4725. if item.Type == 2 { //项目
  4726. for _, subItem := range item.HisPrescriptionProject {
  4727. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4728. total = total + (subItem.Price * cnt)
  4729. }
  4730. }
  4731. }
  4732. for _, item := range prescriptions {
  4733. for _, subItem := range item.HisAdditionalCharge {
  4734. total = total + (subItem.Price * float64(subItem.Count))
  4735. }
  4736. }
  4737. allTotal := fmt.Sprintf("%.4f", total)
  4738. if res.Infcode == 0 {
  4739. var rf []*ResultFive
  4740. json.Unmarshal([]byte(his.Iinfo), &rf)
  4741. chrg_bchno := chrg_bchno
  4742. cert_no := his.Certno
  4743. var insutypes []string
  4744. var insutype string
  4745. var is390 int = 0
  4746. var is310 int = 0
  4747. for _, item := range rf {
  4748. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4749. insutypes = append(insutypes, item.Insutype)
  4750. }
  4751. }
  4752. if len(insutypes) == 1 {
  4753. insutype = insutypes[0]
  4754. } else {
  4755. for _, i := range insutypes {
  4756. if i == "390" {
  4757. is390 = 1
  4758. }
  4759. if i == "310" {
  4760. is310 = 1
  4761. }
  4762. }
  4763. }
  4764. if is390 == 1 {
  4765. insutype = "390"
  4766. }
  4767. if is310 == 1 {
  4768. insutype = "310"
  4769. }
  4770. if len(insutypes) == 0 {
  4771. insutype = "310"
  4772. }
  4773. if len(insutypes) == 2 {
  4774. insutype = strconv.FormatInt(his.SocialType, 64)
  4775. }
  4776. //insutype = "390"
  4777. if his.IdCardType == 1 {
  4778. cert_no = his.MedicalInsuranceNumber
  4779. } else {
  4780. cert_no = his.Certno
  4781. }
  4782. var res ResultSeven
  4783. var resSeven10265 ResultSeven10265
  4784. if miConfig.MdtrtareaAdmvs == "421300" {
  4785. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4786. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4787. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4788. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4789. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4790. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4791. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  4792. resp, requestErr := http.Get(api)
  4793. if requestErr != nil {
  4794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4795. return
  4796. }
  4797. body, ioErr := ioutil.ReadAll(resp.Body)
  4798. if ioErr != nil {
  4799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4801. return
  4802. }
  4803. var respJSON map[string]interface{}
  4804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4807. return
  4808. }
  4809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4810. result, _ := json.Marshal(respJSON)
  4811. fmt.Println("log")
  4812. fmt.Println(string(result))
  4813. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4814. utils.ErrorLog("解析失败:%v", err)
  4815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4816. return
  4817. }
  4818. } else {
  4819. var result string
  4820. var request_log string
  4821. if miConfig.Code == "H15049901371" {
  4822. //赤峰地区国家医保医疗类别
  4823. //职工透析:医疗类别选特殊情况门诊990502
  4824. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4825. var med_type string
  4826. if his.Insutype == "390" {
  4827. if reg_type == 14 {
  4828. med_type = "9933"
  4829. } else if reg_type == 11 {
  4830. med_type = "11"
  4831. }
  4832. } else if his.Insutype == "310" {
  4833. if reg_type == 14 {
  4834. med_type = "990502"
  4835. } else if reg_type == 11 {
  4836. med_type = "11"
  4837. }
  4838. }
  4839. 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)
  4840. } else {
  4841. 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)
  4842. }
  4843. var dat map[string]interface{}
  4844. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4845. fmt.Println(dat)
  4846. } else {
  4847. fmt.Println(err)
  4848. }
  4849. saveLog(result, request_log, "2206", "预结算")
  4850. //userJSONBytes, _ := json.Marshal(dat)
  4851. //
  4852. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4853. // utils.ErrorLog("解析失败:%v", err)
  4854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4855. // return
  4856. //}
  4857. userJSONBytes, _ := json.Marshal(dat)
  4858. if miConfig.Code == "H15049901371" {
  4859. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4860. utils.ErrorLog("解析失败:%v", err)
  4861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4862. return
  4863. }
  4864. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4865. res.Output = resSeven10265.Output
  4866. res.ErrMsg = resSeven10265.ErrMsg
  4867. res.Cainfo = resSeven10265.Cainfo
  4868. res.WarnMsg = resSeven10265.WarnMsg
  4869. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4870. res.Infcode = infocode
  4871. } else {
  4872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4873. utils.ErrorLog("解析失败:%v", err)
  4874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4875. return
  4876. }
  4877. }
  4878. }
  4879. if res.Infcode != 0 {
  4880. errlog := &models.HisOrderError{
  4881. UserOrgId: adminUser.CurrentOrgId,
  4882. Ctime: time.Now().Unix(),
  4883. Mtime: time.Now().Unix(),
  4884. Number: chrg_bchno,
  4885. ErrMsg: res.ErrMsg,
  4886. Status: 1,
  4887. PatientId: id,
  4888. RecordTime: recordDateTime,
  4889. Stage: 20,
  4890. }
  4891. service.CreateErrMsgLog(errlog)
  4892. c.ServeSuccessJSON(map[string]interface{}{
  4893. "failed_code": -10,
  4894. "msg": res.ErrMsg,
  4895. })
  4896. return
  4897. } else {
  4898. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4899. order.OrderStatus = 1
  4900. order.IsPre = 1
  4901. order.Status = 1
  4902. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4903. order.SetlId = res.Output.Setlinfo.SetlID
  4904. order.PsnNo = res.Output.Setlinfo.PsnNo
  4905. order.PsnName = res.Output.Setlinfo.PsnName
  4906. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4907. order.Certno = res.Output.Setlinfo.Certno
  4908. order.Gend = res.Output.Setlinfo.Gend
  4909. order.Naty = res.Output.Setlinfo.Naty
  4910. order.Age = res.Output.Setlinfo.Age
  4911. order.Insutype = res.Output.Setlinfo.Insutype
  4912. order.PsnType = res.Output.Setlinfo.PsnType
  4913. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4914. order.SetlTime = res.Output.Setlinfo.SetlTime
  4915. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4916. if res.Output.Setlinfo.MedType == "140101" {
  4917. order.MedType = "14"
  4918. } else {
  4919. order.MedType = res.Output.Setlinfo.MedType
  4920. }
  4921. if reg_type == 1112 {
  4922. order.MedType = "1112"
  4923. }
  4924. if reg_type == 1111 {
  4925. order.MedType = "1111"
  4926. }
  4927. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4928. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4929. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4930. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4931. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4932. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4933. order.HifpPay = res.Output.Setlinfo.HifpPay
  4934. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4935. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4936. order.HifesPay = res.Output.Setlinfo.HifesPay
  4937. order.HifobPay = res.Output.Setlinfo.HifobPay
  4938. order.MafPay = res.Output.Setlinfo.MafPay
  4939. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4940. order.OthPay = res.Output.Setlinfo.OthPay
  4941. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4942. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4943. order.AcctPay = res.Output.Setlinfo.AcctPay
  4944. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4945. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4946. order.Balc = res.Output.Setlinfo.Balc
  4947. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4948. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4949. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4950. order.ClrWay = res.Output.Setlinfo.ClrWay
  4951. order.Creator = order.Creator
  4952. order.Modify = roles.AdminUserId
  4953. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4954. detailStr := string(setlDetail)
  4955. order.SetlDetail = detailStr
  4956. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4957. err = service.UpDateOrder(order)
  4958. if err == nil {
  4959. c.ServeSuccessJSON(map[string]interface{}{
  4960. "msg": "预结算成功",
  4961. })
  4962. } else {
  4963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4964. return
  4965. }
  4966. }
  4967. } else {
  4968. adminUser := c.GetAdminUserInfo()
  4969. errlog := &models.HisOrderError{
  4970. UserOrgId: adminUser.CurrentOrgId,
  4971. Ctime: time.Now().Unix(),
  4972. Mtime: time.Now().Unix(),
  4973. ErrMsg: res.ErrMsg,
  4974. Status: 1,
  4975. PatientId: id,
  4976. RecordTime: recordDateTime,
  4977. Stage: 4,
  4978. }
  4979. service.CreateErrMsgLog(errlog)
  4980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4981. return
  4982. }
  4983. } else {
  4984. adminUser := c.GetAdminUserInfo()
  4985. errlog := &models.HisOrderError{
  4986. UserOrgId: adminUser.CurrentOrgId,
  4987. Ctime: time.Now().Unix(),
  4988. Mtime: time.Now().Unix(),
  4989. ErrMsg: res.ErrMsg,
  4990. Status: 1,
  4991. PatientId: id,
  4992. RecordTime: recordDateTime,
  4993. Stage: 4,
  4994. }
  4995. service.CreateErrMsgLog(errlog)
  4996. c.ServeSuccessJSON(map[string]interface{}{
  4997. "failed_code": -10,
  4998. "msg": res.ErrMsg,
  4999. })
  5000. return
  5001. }
  5002. }
  5003. }
  5004. }
  5005. //func (c *HisApiController) GetSettleInfo() {
  5006. // id, _ := c.GetInt64("id")
  5007. // order_id, _ := c.GetInt64("order_id")
  5008. //
  5009. // record_time := c.GetString("record_time")
  5010. // pay_way, _ := c.GetInt64("pay_way")
  5011. // pay_price, _ := c.GetFloat("pay_price")
  5012. // pay_card_no := c.GetString("pay_card_no")
  5013. // discount_price, _ := c.GetFloat("discount_price")
  5014. // preferential_price, _ := c.GetFloat("preferential_price")
  5015. // reality_price, _ := c.GetFloat("reality_price")
  5016. // found_price, _ := c.GetFloat("found_price")
  5017. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5018. // private_price, _ := c.GetFloat("private_price")
  5019. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5020. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5021. //
  5022. // timeLayout := "2006-01-02"
  5023. // loc, _ := time.LoadLocation("Local")
  5024. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5025. // if err != nil {
  5026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5027. // return
  5028. // }
  5029. // recordDateTime := theTime.Unix()
  5030. // adminUser := c.GetAdminUserInfo()
  5031. //
  5032. // var prescriptions []*models.HisPrescription
  5033. //
  5034. // data := make(map[string]interface{})
  5035. // if settle_accounts_type == 1 { //日结
  5036. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5037. // data["pre"] = prescriptions
  5038. //
  5039. // } else { //月结
  5040. // start_time_str := c.GetString("start_time")
  5041. // end_time_str := c.GetString("end_time")
  5042. // timeLayout := "2006-01-02"
  5043. // loc, _ := time.LoadLocation("Local")
  5044. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5045. // if err != nil {
  5046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5047. // return
  5048. // }
  5049. // recordStartTime := theStartTime.Unix()
  5050. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5051. // if err != nil {
  5052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5053. // return
  5054. // }
  5055. // recordEndTime := theEndTime.Unix()
  5056. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5057. // data["pre"] = prescriptions
  5058. //
  5059. // }
  5060. //
  5061. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5062. //
  5063. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5064. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5065. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5066. // strconv.FormatInt(his.PatientId, 10)
  5067. //
  5068. // order_src, _ := service.GetHisOrderByID(order_id)
  5069. //
  5070. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5071. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5072. //
  5073. // var total float64
  5074. // for _, item := range prescriptions {
  5075. // if item.Type == 1 { //药品
  5076. // for _, subItem := range item.HisDoctorAdviceInfo {
  5077. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5078. // }
  5079. // }
  5080. // if item.Type == 2 { //项目
  5081. // for _, subItem := range item.HisPrescriptionProject {
  5082. // total = total + (subItem.Price * float64(subItem.Count))
  5083. // }
  5084. // }
  5085. // }
  5086. //
  5087. // for _, item := range prescriptions {
  5088. // for _, subItem := range item.HisAdditionalCharge {
  5089. // total = total + (subItem.Price * float64(subItem.Count))
  5090. // }
  5091. // }
  5092. //
  5093. // allTotal := fmt.Sprintf("%.2f", total)
  5094. // var rf []*ResultFive
  5095. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5096. // psn_no := order_src.PsnNo
  5097. // mdtrt_id := order_src.MdtrtId
  5098. // chrg_bchno := order_src.Number
  5099. // cert_no := order_src.Certno
  5100. // insutype := rf[0].Insutype
  5101. //
  5102. // if his.IdCardType == 1 {
  5103. // cert_no = his.MedicalInsuranceNumber
  5104. // } else {
  5105. // cert_no = his.Certno
  5106. // }
  5107. //
  5108. // 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)
  5109. // var dat map[string]interface{}
  5110. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5111. // fmt.Println(dat)
  5112. // } else {
  5113. // fmt.Println(err)
  5114. // }
  5115. //
  5116. // userJSONBytes, _ := json.Marshal(dat)
  5117. //
  5118. //
  5119. //
  5120. // var res ResultSeven
  5121. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5122. // utils.ErrorLog("解析失败:%v", err)
  5123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5124. // return
  5125. // }
  5126. // if res.Infcode == -1 {
  5127. // errlog := &models.HisOrderError{
  5128. // UserOrgId: adminUser.CurrentOrgId,
  5129. // Ctime: time.Now().Unix(),
  5130. // Mtime: time.Now().Unix(),
  5131. // Number: chrg_bchno,
  5132. // ErrMsg: res.ErrMsg,
  5133. // Status: 1,
  5134. // PatientId: id,
  5135. // RecordTime: recordDateTime,
  5136. // Stage: 6,
  5137. // }
  5138. // service.CreateErrMsgLog(errlog)
  5139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5140. // return
  5141. // } else {
  5142. // order_src.OrderStatus = 2
  5143. // order_src.PayWay = pay_way
  5144. // order_src.PayPrice = pay_price
  5145. // order_src.PayCardNo = pay_card_no
  5146. // order_src.DiscountPrice = discount_price
  5147. // order_src.PreferentialPrice = preferential_price
  5148. // order_src.RealityPrice = reality_price
  5149. // order_src.FoundPrice = found_price
  5150. // order_src.MedicalInsurancePrice = medical_insurance_price
  5151. // order_src.PrivatePrice = private_price
  5152. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5153. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5154. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5155. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5156. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5157. // order_src.Certno = res.Output.Setlinfo.Certno
  5158. // order_src.Gend = res.Output.Setlinfo.Gend
  5159. // order_src.Naty = res.Output.Setlinfo.Naty
  5160. // order_src.Age = res.Output.Setlinfo.Age
  5161. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5162. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5163. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5164. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5165. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5166. // order_src.MedType = res.Output.Setlinfo.MedType
  5167. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5168. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5169. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5170. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5171. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5172. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5173. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5174. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5175. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5176. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5177. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5178. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5179. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5180. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5181. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5182. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5183. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5184. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5185. // order_src.Balc = res.Output.Setlinfo.Balc
  5186. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5187. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5188. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5189. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5190. // order_src.Creator = order_src.Creator
  5191. // order_src.Modify = roles.ID
  5192. // order_src.RequestLog = src_resquest
  5193. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5194. // detailStr := string(setlDetail)
  5195. // order_src.SetlDetail = detailStr
  5196. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5197. // err = service.UpDateOrder(order_src)
  5198. //
  5199. // if err == nil {
  5200. // c.ServeSuccessJSON(map[string]interface{}{
  5201. // "msg": "结算成功",
  5202. // })
  5203. // } else {
  5204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5205. // return
  5206. // }
  5207. // }
  5208. // }
  5209. //}
  5210. //退款
  5211. func (c *HisApiController) Refund() {
  5212. order_id, _ := c.GetInt64("order_id")
  5213. admin_user_id, _ := c.GetInt64("admin_user_id")
  5214. //record_time := c.GetString("record_time")
  5215. //patient_id, _ := c.GetInt64("patient_id")
  5216. //timeLayout := "2006-01-02"
  5217. //loc, _ := time.LoadLocation("Local")
  5218. adminUser := c.GetAdminUserInfo()
  5219. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5220. //if err != nil {
  5221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5222. // return
  5223. //}
  5224. //recordDateTime := theTime.Unix()
  5225. var order models.HisOrder
  5226. order, _ = service.GetHisOrderByID(order_id)
  5227. //his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5228. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5229. if order.ID == 0 {
  5230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5231. return
  5232. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5233. }
  5234. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5235. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5236. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5237. if config.IsOpen == 1 { //对接了医保,走医保流程
  5238. var res ResultSixteen
  5239. var resSixteen10265 ResultSixteen10265
  5240. var src_resquest string
  5241. var result string
  5242. if miConfig.MdtrtareaAdmvs == "421300" {
  5243. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5244. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5245. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5246. resp3, requestErr3 := http.Get(api3)
  5247. if requestErr3 != nil {
  5248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5249. return
  5250. }
  5251. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5252. if ioErr3 != nil {
  5253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5255. return
  5256. }
  5257. var respJSON3 map[string]interface{}
  5258. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5264. userJSONBytes3, _ := json.Marshal(respJSON3)
  5265. fmt.Println("log")
  5266. fmt.Println(string(userJSONBytes3))
  5267. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5268. utils.ErrorLog("解析失败:%v", err)
  5269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. return
  5271. }
  5272. } else {
  5273. if miConfig.Code == "H15049901371" {
  5274. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5275. var dat map[string]interface{}
  5276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5277. fmt.Println(dat)
  5278. } else {
  5279. fmt.Println(err)
  5280. }
  5281. saveLog(result, src_resquest, "2208", "退费")
  5282. userJSONBytes, _ := json.Marshal(dat)
  5283. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5284. utils.ErrorLog("解析失败:%v", err)
  5285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5286. return
  5287. }
  5288. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5289. res.Output = resSixteen10265.Output
  5290. res.ErrMsg = resSixteen10265.ErrMsg
  5291. res.Cainfo = resSixteen10265.Cainfo
  5292. res.WarnMsg = resSixteen10265.WarnMsg
  5293. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5294. res.Infcode = infocode
  5295. } else {
  5296. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5297. var dat map[string]interface{}
  5298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5299. fmt.Println(dat)
  5300. } else {
  5301. fmt.Println(err)
  5302. }
  5303. saveLog(result, src_resquest, "2208", "退费")
  5304. userJSONBytes, _ := json.Marshal(dat)
  5305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5306. utils.ErrorLog("解析失败:%v", err)
  5307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5308. return
  5309. }
  5310. }
  5311. }
  5312. if res.Infcode == 0 {
  5313. var res2 ResultSix
  5314. var resSix10265 ResultSix10265
  5315. if miConfig.MdtrtareaAdmvs == "421300" {
  5316. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5317. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5318. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5319. resp3, requestErr3 := http.Get(api3)
  5320. if requestErr3 != nil {
  5321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5322. return
  5323. }
  5324. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5325. if ioErr3 != nil {
  5326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5328. return
  5329. }
  5330. var respJSON3 map[string]interface{}
  5331. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. return
  5335. }
  5336. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5337. userJSONBytes3, _ := json.Marshal(respJSON3)
  5338. fmt.Println("log")
  5339. fmt.Println(string(userJSONBytes3))
  5340. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5341. utils.ErrorLog("解析失败:%v", err)
  5342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5343. return
  5344. }
  5345. } else {
  5346. if miConfig.Code == "H15049901371" {
  5347. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5348. var dat map[string]interface{}
  5349. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5350. fmt.Println(dat)
  5351. } else {
  5352. fmt.Println(err)
  5353. }
  5354. saveLog(result2, src_request, "2205", "撤销明细")
  5355. userJSONBytes, _ := json.Marshal(dat)
  5356. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5357. utils.ErrorLog("解析失败:%v", err)
  5358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5359. return
  5360. }
  5361. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5362. res2.Output = resSix10265.Output
  5363. res2.ErrMsg = resSix10265.ErrMsg
  5364. res2.Cainfo = resSix10265.Cainfo
  5365. res2.WarnMsg = resSix10265.WarnMsg
  5366. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5367. res2.Infcode = infocode
  5368. } else {
  5369. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5370. var dat map[string]interface{}
  5371. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5372. fmt.Println(dat)
  5373. } else {
  5374. fmt.Println(err)
  5375. }
  5376. saveLog(result2, src_request, "2205", "撤销明细")
  5377. userJSONBytes, _ := json.Marshal(dat)
  5378. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5379. utils.ErrorLog("解析失败:%v", err)
  5380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5381. return
  5382. }
  5383. }
  5384. }
  5385. if res2.Infcode == 0 {
  5386. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5387. if err == nil {
  5388. c.ServeSuccessJSON(map[string]interface{}{
  5389. "msg": "退费成功",
  5390. })
  5391. } else {
  5392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5393. return
  5394. }
  5395. } else {
  5396. c.ServeSuccessJSON(map[string]interface{}{
  5397. "code": -10,
  5398. "msg": res2.ErrMsg,
  5399. })
  5400. }
  5401. } else {
  5402. c.ServeSuccessJSON(map[string]interface{}{
  5403. "code": -10,
  5404. "msg": res.ErrMsg,
  5405. })
  5406. }
  5407. }
  5408. }
  5409. func (c *HisApiController) RefundNumber() {
  5410. record_time := c.GetString("record_time")
  5411. //patient_id, _ := c.GetInt64("patient_id")
  5412. admin_user_id, _ := c.GetInt64("admin_user_id")
  5413. his_patient_id, _ := c.GetInt64("id")
  5414. timeLayout := "2006-01-02"
  5415. loc, _ := time.LoadLocation("Local")
  5416. adminUser := c.GetAdminUserInfo()
  5417. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5418. fmt.Println(err)
  5419. if err != nil {
  5420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5421. return
  5422. }
  5423. recordDateTime := theTime.Unix()
  5424. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5425. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5426. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5427. //order, _ := service.GetHisOrderByID(order_id)
  5428. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5429. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5430. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5431. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5432. if count > 0 {
  5433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5434. return
  5435. }
  5436. if config.IsOpen == 1 { //对接了医保,走医保流程
  5437. var res2 ResultSix
  5438. var resSix10265 ResultSix10265
  5439. if miConfig.MdtrtareaAdmvs == "421300" {
  5440. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5441. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5442. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5443. resp3, requestErr3 := http.Get(api3)
  5444. if requestErr3 != nil {
  5445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5446. return
  5447. }
  5448. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5449. if ioErr3 != nil {
  5450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5452. return
  5453. }
  5454. var respJSON3 map[string]interface{}
  5455. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5458. return
  5459. }
  5460. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5461. userJSONBytes3, _ := json.Marshal(respJSON3)
  5462. fmt.Println("log")
  5463. fmt.Println(string(userJSONBytes3))
  5464. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5465. utils.ErrorLog("解析失败:%v", err)
  5466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5467. return
  5468. }
  5469. } else {
  5470. var api3 string
  5471. if miConfig.Code == "H15049901371" {
  5472. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5473. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5475. } else {
  5476. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5477. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5478. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5479. }
  5480. resp3, requestErr3 := http.Get(api3)
  5481. if requestErr3 != nil {
  5482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5483. return
  5484. }
  5485. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5486. if ioErr3 != nil {
  5487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5489. return
  5490. }
  5491. var respJSON3 map[string]interface{}
  5492. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5495. return
  5496. }
  5497. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5498. userJSONBytes3, _ := json.Marshal(respJSON3)
  5499. if miConfig.Code == "H15049901371" {
  5500. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5501. utils.ErrorLog("解析失败:%v", err)
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5503. return
  5504. }
  5505. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5506. res2.Output = resSix10265.Output
  5507. res2.ErrMsg = resSix10265.ErrMsg
  5508. res2.Cainfo = resSix10265.Cainfo
  5509. res2.WarnMsg = resSix10265.WarnMsg
  5510. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5511. res2.Infcode = infocode
  5512. } else {
  5513. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5514. utils.ErrorLog("解析失败:%v", err)
  5515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5516. return
  5517. }
  5518. }
  5519. }
  5520. if res2.Infcode == 0 {
  5521. if err == nil {
  5522. c.ServeSuccessJSON(map[string]interface{}{
  5523. "msg": "退号成功",
  5524. })
  5525. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  5526. } else {
  5527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5528. return
  5529. }
  5530. } else {
  5531. c.ServeSuccessJSON(map[string]interface{}{
  5532. "code": -10,
  5533. "msg": res2.ErrMsg,
  5534. })
  5535. }
  5536. } else {
  5537. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  5538. //if err == nil {
  5539. // c.ServeSuccessJSON(map[string]interface{}{
  5540. // "msg": "退费成功",
  5541. // })
  5542. //} else {
  5543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5544. // return
  5545. //}
  5546. }
  5547. }
  5548. func (c *HisApiController) RefundDetail() {
  5549. order_id, _ := c.GetInt64("order_id")
  5550. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5551. number := c.GetString("number")
  5552. record_time := c.GetString("record_time")
  5553. patient_id, _ := c.GetInt64("patient_id")
  5554. timeLayout := "2006-01-02"
  5555. loc, _ := time.LoadLocation("Local")
  5556. adminUser := c.GetAdminUserInfo()
  5557. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5558. fmt.Println(err)
  5559. if err != nil {
  5560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5561. return
  5562. }
  5563. recordDateTime := theTime.Unix()
  5564. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5565. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5566. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5567. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5568. var order models.HisOrder
  5569. order, _ = service.GetHisOrderByID(order_id)
  5570. if order.ID == 0 {
  5571. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5572. }
  5573. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5574. if config.IsOpen == 1 { //对接了医保,走医保流程
  5575. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  5576. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5577. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5578. resp2, requestErr2 := http.Get(api2)
  5579. if requestErr2 != nil {
  5580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5581. return
  5582. }
  5583. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5584. if ioErr2 != nil {
  5585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5587. return
  5588. }
  5589. var respJSON2 map[string]interface{}
  5590. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  5591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5593. return
  5594. }
  5595. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5596. if err == nil {
  5597. c.ServeSuccessJSON(map[string]interface{}{
  5598. "msg": "退费成功",
  5599. })
  5600. } else {
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5602. return
  5603. }
  5604. } else {
  5605. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5606. if err == nil {
  5607. c.ServeSuccessJSON(map[string]interface{}{
  5608. "msg": "退费成功",
  5609. })
  5610. } else {
  5611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5612. return
  5613. }
  5614. }
  5615. }
  5616. //对账
  5617. func (c *HisApiController) GetCheckAccount() {
  5618. start_time := c.GetString("start_time")
  5619. end_time := c.GetString("end_time")
  5620. insutype := c.GetString("insutype")
  5621. clr_type := c.GetString("clr_type")
  5622. admin_user_id, _ := c.GetInt64("admin_user_id")
  5623. adminUser := c.GetAdminUserInfo()
  5624. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5625. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5626. timeLayout := "2006-01-02"
  5627. loc, _ := time.LoadLocation("Local")
  5628. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5629. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5630. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5631. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5632. fixmedins_setl_cnt := int64(len(orders))
  5633. //
  5634. ////撤销的算2条数据为一笔
  5635. //for _, item := range orders_two {
  5636. // if item.OrderStatus == 3 {
  5637. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  5638. // }
  5639. //}
  5640. var medfee_sumamt float64
  5641. var acct_pay float64
  5642. var fund_pay_sumamt float64
  5643. for _, item := range orders {
  5644. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5645. acct_pay = acct_pay + item.AcctPay
  5646. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5647. }
  5648. var user_name string
  5649. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5650. if role.ID == 0 {
  5651. user_name = "xxx"
  5652. } else {
  5653. user_name = role.UserName
  5654. }
  5655. if config.IsOpen == 1 {
  5656. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5657. "insutype=" + insutype +
  5658. "&clr_type=" + clr_type +
  5659. "&setl_optins=" + "定点医保中心" +
  5660. "&stmt_begndate=" + start_time +
  5661. "&stm_enddate=" + end_time +
  5662. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5663. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5664. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  5665. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5666. "&fixmedins_code=" + miConfig.Code +
  5667. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5668. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5669. "&secret_key=" + miConfig.SecretKey +
  5670. "&org_name=" + miConfig.OrgName +
  5671. "&doctor=" + user_name
  5672. fmt.Println(api)
  5673. resp, requestErr := http.Get(api)
  5674. if requestErr != nil {
  5675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5676. return
  5677. }
  5678. body, ioErr := ioutil.ReadAll(resp.Body)
  5679. fmt.Println(body)
  5680. if ioErr != nil {
  5681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return
  5684. }
  5685. var respJSON map[string]interface{}
  5686. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5689. return
  5690. }
  5691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5692. userJSONBytes, _ := json.Marshal(respJSON)
  5693. var res ResultEight
  5694. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5695. utils.ErrorLog("解析失败:%v", err)
  5696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5697. return
  5698. }
  5699. if res.Infcode == 0 {
  5700. if res.Output.Stmtinfo.StmtRslt == "0" {
  5701. micc := &models.MedicalInsuranceCostCompare{
  5702. StartTime: startime.Unix(),
  5703. EndTime: endtime.Unix(),
  5704. Insutype: insutype,
  5705. CheckType: 1,
  5706. Num: fixmedins_setl_cnt,
  5707. Mtime: time.Now().Unix(),
  5708. Status: 1,
  5709. UserOrgId: adminUser.CurrentOrgId,
  5710. CostTotal: medfee_sumamt,
  5711. FuncTotal: fund_pay_sumamt,
  5712. PsnPay: acct_pay,
  5713. Creator: admin_user_id,
  5714. Ctime: time.Now().Unix(),
  5715. }
  5716. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  5717. if err == nil {
  5718. c.ServeSuccessJSON(map[string]interface{}{
  5719. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5720. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5721. })
  5722. } else {
  5723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5724. }
  5725. } else {
  5726. c.ServeSuccessJSON(map[string]interface{}{
  5727. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5728. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5729. })
  5730. }
  5731. } else {
  5732. c.ServeSuccessJSON(map[string]interface{}{
  5733. "code": -10,
  5734. "msg": res.ErrMsg,
  5735. })
  5736. }
  5737. }
  5738. }
  5739. func (c *HisApiController) Check310() {
  5740. adminUser := c.GetAdminUserInfo()
  5741. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5742. var user_name string
  5743. user_name = "xxx"
  5744. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5745. "insutype=" + "310" +
  5746. "&clr_type=" + "11" +
  5747. "&setl_optins=" + "定点医保中心" +
  5748. "&stmt_begndate=" + "2021-03-01" +
  5749. "&stm_enddate=" + "2021-03-31" +
  5750. "&medfee_sumamt=" + "11521" +
  5751. "&fund_pay_sumamt=" + "10166.66" +
  5752. "&acct_pay=" + "0" +
  5753. "&fixmedins_setl_cnt=" + "7" +
  5754. "&fixmedins_code=" + miConfig.Code +
  5755. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5756. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5757. "&secret_key=" + miConfig.SecretKey +
  5758. "&org_name=" + miConfig.OrgName +
  5759. "&doctor=" + user_name
  5760. fmt.Println(api)
  5761. resp, requestErr := http.Get(api)
  5762. if requestErr != nil {
  5763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5764. return
  5765. }
  5766. body, ioErr := ioutil.ReadAll(resp.Body)
  5767. fmt.Println(body)
  5768. if ioErr != nil {
  5769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5771. return
  5772. }
  5773. var respJSON map[string]interface{}
  5774. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5777. return
  5778. }
  5779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5780. userJSONBytes, _ := json.Marshal(respJSON)
  5781. var res ResultEight
  5782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5783. utils.ErrorLog("解析失败:%v", err)
  5784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5785. return
  5786. }
  5787. }
  5788. func (c *HisApiController) Check390() {
  5789. adminUser := c.GetAdminUserInfo()
  5790. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5791. var user_name string
  5792. user_name = "张俊杰"
  5793. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5794. "insutype=" + "390" +
  5795. "&clr_type=" + "11" +
  5796. "&setl_optins=" + "定点医保中心" +
  5797. "&stmt_begndate=" + "2021-03-01" +
  5798. "&stm_enddate=" + "2021-03-31" +
  5799. "&medfee_sumamt=" + "209318.43" +
  5800. "&fund_pay_sumamt=" + "188029.12" +
  5801. "&acct_pay=" + "0" +
  5802. "&fixmedins_setl_cnt=" + "48" +
  5803. "&fixmedins_code=" + miConfig.Code +
  5804. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5805. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5806. "&secret_key=" + miConfig.SecretKey +
  5807. "&org_name=" + miConfig.OrgName +
  5808. "&doctor=" + user_name
  5809. fmt.Println(api)
  5810. resp, requestErr := http.Get(api)
  5811. if requestErr != nil {
  5812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5813. return
  5814. }
  5815. body, ioErr := ioutil.ReadAll(resp.Body)
  5816. fmt.Println(body)
  5817. if ioErr != nil {
  5818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5820. return
  5821. }
  5822. var respJSON map[string]interface{}
  5823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5826. return
  5827. }
  5828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5829. userJSONBytes, _ := json.Marshal(respJSON)
  5830. var res ResultEight
  5831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5832. utils.ErrorLog("解析失败:%v", err)
  5833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5834. return
  5835. }
  5836. }
  5837. //对账明细
  5838. func (c *HisApiController) GetCheckDetailAccount() {
  5839. start_time := c.GetString("start_time")
  5840. end_time := c.GetString("end_time")
  5841. admin_user_id, _ := c.GetInt64("admin_user_id")
  5842. adminUser := c.GetAdminUserInfo()
  5843. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5844. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5845. timeLayout := "2006-01-02"
  5846. loc, _ := time.LoadLocation("Local")
  5847. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5848. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5849. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  5850. Mkdir(miConfig.OrgName)
  5851. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  5852. file_name := file + ".txt"
  5853. zip_name := file + ".zip"
  5854. zip_path := miConfig.OrgName + "/" + zip_name
  5855. file_path := miConfig.OrgName + "/" + file_name
  5856. decimal.DivisionPrecision = 2
  5857. var medfee_sumamt float64
  5858. var psn_cash_pay float64
  5859. var fund_pay_sumamt float64
  5860. fixmedins_setl_cnt := int64(len(orders))
  5861. for _, item := range orders {
  5862. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5863. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  5864. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5865. }
  5866. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  5867. defer f.Close()
  5868. if err != nil {
  5869. fmt.Println(err.Error())
  5870. } else {
  5871. for _, item := range orders {
  5872. var refd_setl_flag string
  5873. if item.OrderStatus == 2 {
  5874. refd_setl_flag = "0"
  5875. var str string
  5876. str = item.SetlId + " " +
  5877. item.MdtrtId + " " +
  5878. item.PsnNo + " " +
  5879. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5880. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5881. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  5882. _, err = f.Write([]byte(str))
  5883. }
  5884. if item.OrderStatus == 3 {
  5885. var str string
  5886. str = item.SetlId + " " +
  5887. item.MdtrtId + " " +
  5888. item.PsnNo + " " +
  5889. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5890. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5891. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  5892. _, err = f.Write([]byte(str))
  5893. var str2 string
  5894. str2 = item.SetlId + " " +
  5895. item.MdtrtId + " " +
  5896. item.PsnNo + " " +
  5897. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  5898. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  5899. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  5900. _, err = f.Write([]byte(str2))
  5901. }
  5902. }
  5903. }
  5904. Zip(file_path, zip_path)
  5905. fmt.Println(ReadFile(zip_path))
  5906. fmt.Println(string(ReadFile(zip_path)))
  5907. if config.IsOpen == 1 {
  5908. var user_name string
  5909. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5910. if role.ID == 0 {
  5911. user_name = "管理员"
  5912. } else {
  5913. user_name = role.UserName
  5914. }
  5915. baseParams := models.BaseParams{
  5916. SecretKey: miConfig.SecretKey,
  5917. FixmedinsCode: miConfig.Code,
  5918. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5919. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5920. OrgName: miConfig.OrgName,
  5921. Doctor: user_name,
  5922. }
  5923. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  5924. var dat map[string]interface{}
  5925. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5926. fmt.Println(dat)
  5927. } else {
  5928. fmt.Println(err)
  5929. }
  5930. userJSONBytes, _ := json.Marshal(dat)
  5931. var res ResultNine
  5932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5933. utils.ErrorLog("解析失败:%v", err)
  5934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5935. return
  5936. }
  5937. if res.Infcode == 0 {
  5938. fileNo := res.Output.FileQuryNo
  5939. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  5940. "file_qury_no=" + fileNo +
  5941. "&setl_optins=" + "定点医保中心" +
  5942. "&stmt_begndate=" + start_time +
  5943. "&stm_enddate=" + end_time +
  5944. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5945. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5946. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  5947. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5948. "&fixmedins_code=" + miConfig.Code +
  5949. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5950. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5951. "&secret_key=" + miConfig.SecretKey +
  5952. "&org_name=" + miConfig.OrgName +
  5953. "&doctor=" + user_name
  5954. resp, requestErr := http.Get(api)
  5955. if requestErr != nil {
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5957. return
  5958. }
  5959. body, ioErr := ioutil.ReadAll(resp.Body)
  5960. if ioErr != nil {
  5961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5963. return
  5964. }
  5965. var respJSON map[string]interface{}
  5966. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5969. return
  5970. }
  5971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5972. userJSONBytes, _ := json.Marshal(respJSON)
  5973. var res ResultTen
  5974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5975. utils.ErrorLog("解析失败:%v", err)
  5976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5977. return
  5978. }
  5979. if res.Infcode == 0 {
  5980. service.Gdyb9102(baseParams, zip_name, fileNo)
  5981. micc := &models.MedicalInsuranceCostCompare{
  5982. StartTime: startime.Unix(),
  5983. EndTime: endtime.Unix(),
  5984. Insutype: "0",
  5985. CheckType: 2,
  5986. Num: fixmedins_setl_cnt,
  5987. Mtime: time.Now().Unix(),
  5988. Status: 1,
  5989. UserOrgId: adminUser.CurrentOrgId,
  5990. CostTotal: medfee_sumamt,
  5991. FuncTotal: fund_pay_sumamt,
  5992. PsnPay: psn_cash_pay,
  5993. Creator: admin_user_id,
  5994. Ctime: time.Now().Unix(),
  5995. }
  5996. service.CreateMedicalInsuranceCostCompareRecord(micc)
  5997. c.ServeSuccessJSON(map[string]interface{}{
  5998. "msg": "明细对账成功",
  5999. })
  6000. }
  6001. } else {
  6002. }
  6003. }
  6004. }
  6005. type CustomOrderInfo struct {
  6006. Name string
  6007. Spec string
  6008. Unit string
  6009. Count float64
  6010. Price float64
  6011. Total float64
  6012. }
  6013. func (c *HisApiController) GetSettleAccounts() {
  6014. //id, _ := c.GetInt64("id")
  6015. //record_time := c.GetString("record_time")
  6016. order_id, _ := c.GetInt64("order_id")
  6017. admin_user_id, _ := c.GetInt64("admin_user_id")
  6018. //timeLayout := "2006-01-02"
  6019. //loc, _ := time.LoadLocation("Local")
  6020. //
  6021. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6022. //if err != nil {
  6023. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6024. // return
  6025. //}
  6026. //recordDateTime := theTime.Unix()
  6027. adminUser := c.GetAdminUserInfo()
  6028. order, _ := service.GetHisOrderByID(order_id)
  6029. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6030. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6031. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6032. orderInfos = append(orderInfos, orderInfos_two...)
  6033. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6034. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6035. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6036. //var config []*models.HisXtDiagnoseConfig
  6037. var name string
  6038. for _, item := range diagnosis_ids {
  6039. id, _ := strconv.ParseInt(item, 10, 64)
  6040. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6041. if len(name) == 0 {
  6042. name = diagnosisConfig.ClassName
  6043. } else {
  6044. name = name + "," + diagnosisConfig.ClassName
  6045. }
  6046. }
  6047. var bedCostTotal float64 = 0 //床位总费
  6048. var bedCostSelfTotal float64 = 0 //床位自费
  6049. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6050. var operationCostTotal float64 = 0 //手术费
  6051. var operationCostSelfTotal float64 = 0 //手术费
  6052. var operationCostPartSelfTotal float64 = 0 //手术费
  6053. var otherCostTotal float64 = 0 //其他费用
  6054. var otherCostSelfTotal float64 = 0 //其他费用
  6055. var otherCostPartSelfTotal float64 = 0 //其他费用
  6056. var materialCostTotal float64 = 0 //材料费
  6057. var materialCostSelfTotal float64 = 0 //材料费
  6058. var materialCostPartSelfTotal float64 = 0 //材料费
  6059. var westernMedicineCostTotal float64 = 0 //西药费
  6060. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6061. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6062. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6063. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6064. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6065. var checkCostTotal float64 = 0 //检查费
  6066. var checkCostSelfTotal float64 = 0 //检查费
  6067. var checkCostPartSelfTotal float64 = 0 //检查费
  6068. var laboratoryCostTotal float64 = 0 //化验费
  6069. var laboratoryCostSelfTotal float64 = 0 //化验费
  6070. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6071. var treatCostTotal float64 = 0 //治疗费用
  6072. var treatCostSelfTotal float64 = 0 //治疗费用
  6073. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6074. decimal.DivisionPrecision = 2
  6075. for _, item := range orderInfos {
  6076. if item.MedChrgitmType == "01" { //床位费
  6077. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6078. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6079. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6080. }
  6081. if item.MedChrgitmType == "03" { //检查费
  6082. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6083. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6084. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6085. }
  6086. if item.MedChrgitmType == "04" { //化验费
  6087. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6088. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6089. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6090. }
  6091. if item.MedChrgitmType == "05" { //治疗费
  6092. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6093. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6094. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6095. }
  6096. if item.MedChrgitmType == "06" { //手术费
  6097. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6098. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6099. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6100. }
  6101. if item.MedChrgitmType == "08" { //材料费
  6102. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6103. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6104. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6105. }
  6106. if item.MedChrgitmType == "09" { //西药费
  6107. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6108. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6109. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6110. }
  6111. if item.MedChrgitmType == "11" { //中成费
  6112. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6113. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6114. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6115. }
  6116. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6117. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6118. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6119. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6120. }
  6121. }
  6122. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6123. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6124. var user_name string
  6125. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6126. if role.ID == 0 {
  6127. user_name = "管理员"
  6128. } else {
  6129. user_name = role.UserName
  6130. }
  6131. baseParams := models.BaseParams{
  6132. SecretKey: miConfig.SecretKey,
  6133. FixmedinsCode: miConfig.Code,
  6134. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6135. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6136. OrgName: miConfig.OrgName,
  6137. Doctor: user_name,
  6138. }
  6139. businessParams := models.BusinessParams{
  6140. PsnNo: order.PsnNo,
  6141. MdtrtId: order.MdtrtId,
  6142. SetlId: order.SetlId,
  6143. }
  6144. var res ResultEleven
  6145. var resEleven10265 ResultEleven10265
  6146. if config.IsOpen == 1 {
  6147. if miConfig.MdtrtareaAdmvs == "421300" {
  6148. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6149. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6150. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6151. resp, requestErr := http.Get(api)
  6152. if requestErr != nil {
  6153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6154. return
  6155. }
  6156. body, ioErr := ioutil.ReadAll(resp.Body)
  6157. if ioErr != nil {
  6158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6160. return
  6161. }
  6162. var respJSON map[string]interface{}
  6163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6166. return
  6167. }
  6168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6169. result, _ := json.Marshal(respJSON)
  6170. fmt.Println("log")
  6171. fmt.Println(string(result))
  6172. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6173. utils.ErrorLog("解析失败:%v", err)
  6174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6175. return
  6176. }
  6177. } else {
  6178. result := service.Gdyb5203(baseParams, businessParams)
  6179. var dat map[string]interface{}
  6180. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6181. fmt.Println(dat)
  6182. } else {
  6183. fmt.Println(err)
  6184. }
  6185. userJSONBytes, _ := json.Marshal(dat)
  6186. if miConfig.Code == "H15049901371" {
  6187. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6188. utils.ErrorLog("解析失败:%v", err)
  6189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6190. return
  6191. }
  6192. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6193. res.Output = resEleven10265.Output
  6194. res.ErrMsg = resEleven10265.ErrMsg
  6195. res.Cainfo = resEleven10265.Cainfo
  6196. res.WarnMsg = resEleven10265.WarnMsg
  6197. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6198. res.Infcode = infocode
  6199. } else {
  6200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6201. utils.ErrorLog("解析失败:%v", err)
  6202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6203. return
  6204. }
  6205. }
  6206. }
  6207. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6208. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6209. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6210. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6211. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6212. var doctor_name string
  6213. if roles.ID == 0 {
  6214. doctor_name = "管理员"
  6215. } else {
  6216. doctor_name = roles.UserName
  6217. }
  6218. yiliao_leibie := ""
  6219. switch order.MedType {
  6220. case "11":
  6221. yiliao_leibie = "普通门诊"
  6222. break
  6223. case "12":
  6224. yiliao_leibie = "门诊挂号"
  6225. break
  6226. case "13":
  6227. yiliao_leibie = "急诊"
  6228. break
  6229. case "14":
  6230. yiliao_leibie = "门诊特殊病"
  6231. break
  6232. case "15":
  6233. yiliao_leibie = "门诊统筹"
  6234. break
  6235. case "16":
  6236. yiliao_leibie = "门诊慢性病"
  6237. break
  6238. case "21":
  6239. yiliao_leibie = "普通住院"
  6240. break
  6241. }
  6242. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6243. if res.Infcode == 0 {
  6244. c.ServeSuccessJSON(map[string]interface{}{
  6245. "diagnosis": name,
  6246. "order_infos": orderInfos,
  6247. "number": order.MdtrtId,
  6248. "date": order.SettleAccountsDate,
  6249. "charge_admin": charge_admin,
  6250. "printor_admin": printor_admin,
  6251. "info": res.Output.Setlinfo,
  6252. "bedCostTotal": bedCostTotal,
  6253. "bedCostSelfTotal": bedCostSelfTotal,
  6254. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6255. "operationCostTotal": operationCostTotal,
  6256. "operationCostSelfTotal": operationCostSelfTotal,
  6257. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6258. "otherCostTotal": otherCostTotal,
  6259. "otherCostSelfTotal": otherCostSelfTotal,
  6260. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6261. "materialCostTotal": materialCostTotal,
  6262. "materialCostSelfTotal": materialCostSelfTotal,
  6263. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6264. "westernMedicineCostTotal": westernMedicineCostTotal,
  6265. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6266. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6267. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6268. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6269. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6270. "checkCostTotal": checkCostTotal,
  6271. "checkCostSelfTotal": checkCostSelfTotal,
  6272. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6273. "laboratoryCostTotal": laboratoryCostTotal,
  6274. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6275. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6276. "treatCostTotal": treatCostTotal,
  6277. "treatCostSelfTotal": treatCostSelfTotal,
  6278. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6279. "doctor_code": adminRole_two.DoctorCode,
  6280. "doctor_name": doctor_name,
  6281. "health_card_no": order.PsnNo,
  6282. "department": departments.Name,
  6283. "yiliao_leibie": yiliao_leibie,
  6284. "after_money": order.AccountPrice,
  6285. "patient": patient,
  6286. "org_name": miConfig.OrgName,
  6287. "org_code": miConfig.Code,
  6288. "order_number": order.Number,
  6289. //"check_order_info": cus_slice,
  6290. })
  6291. }
  6292. }
  6293. }
  6294. func (c *HisApiController) CheckTreatment() {
  6295. patient_id, _ := c.GetInt64("patient_id", 0)
  6296. record_time := c.GetString("record_time")
  6297. insutype := c.GetString("insutype")
  6298. timeLayout := "2006-01-02"
  6299. loc, _ := time.LoadLocation("Local")
  6300. adminUser := c.GetAdminUserInfo()
  6301. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6302. fmt.Println(err)
  6303. if err != nil {
  6304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6305. return
  6306. }
  6307. recordDateTime := theTime.Unix()
  6308. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6309. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6310. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6311. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6312. var user_name string
  6313. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  6314. if role.ID == 0 {
  6315. user_name = "xxx"
  6316. } else {
  6317. user_name = role.UserName
  6318. }
  6319. baseParams := models.BaseParams{
  6320. SecretKey: miConfig.SecretKey,
  6321. FixmedinsCode: miConfig.Code,
  6322. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6323. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6324. OrgName: miConfig.OrgName,
  6325. Doctor: user_name,
  6326. }
  6327. if config.IsOpen == 1 {
  6328. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  6329. var dat map[string]interface{}
  6330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6331. fmt.Println(dat)
  6332. } else {
  6333. fmt.Println(err)
  6334. }
  6335. }
  6336. }
  6337. func (c *HisApiController) PutRecord() {
  6338. id, _ := c.GetInt64("id")
  6339. record_time := c.GetString("record_time")
  6340. timeLayout := "2006-01-02"
  6341. loc, _ := time.LoadLocation("Local")
  6342. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6343. if err != nil {
  6344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6345. return
  6346. }
  6347. recordDateTime := theTime.Unix()
  6348. adminInfo := c.GetAdminUserInfo()
  6349. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  6350. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6351. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6352. fmt.Println(miConfig.SecretKey)
  6353. if patient == nil {
  6354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6355. return
  6356. }
  6357. if len(patient.IdCardNo) == 0 {
  6358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6359. return
  6360. }
  6361. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6362. if config.IsOpen == 1 {
  6363. 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
  6364. resp, requestErr := http.Get(api)
  6365. if requestErr != nil {
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. return
  6368. }
  6369. defer resp.Body.Close()
  6370. body, ioErr := ioutil.ReadAll(resp.Body)
  6371. if ioErr != nil {
  6372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. return
  6375. }
  6376. var respJSON map[string]interface{}
  6377. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6380. return
  6381. }
  6382. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6383. userJSONBytes, _ := json.Marshal(userJSON)
  6384. var res ResultTwo
  6385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6386. utils.ErrorLog("解析失败:%v", err)
  6387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6388. return
  6389. }
  6390. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6391. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6392. infoStr := string(Iinfos)
  6393. idetinfoStr := string(Idetinfos)
  6394. if res.Infcode == 0 {
  6395. his := models.VMHisPatient{
  6396. Status: 1,
  6397. Ctime: time.Now().Unix(),
  6398. Mtime: time.Now().Unix(),
  6399. PsnNo: res.Output.Baseinfo.PsnNo,
  6400. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6401. Certno: res.Output.Baseinfo.Certno,
  6402. PsnName: res.Output.Baseinfo.PsnName,
  6403. Gend: res.Output.Baseinfo.Gend,
  6404. Naty: res.Output.Baseinfo.Naty,
  6405. Brdy: res.Output.Baseinfo.Brdy,
  6406. Age: res.Output.Baseinfo.Age,
  6407. Iinfo: infoStr,
  6408. Idetinfo: idetinfoStr,
  6409. PatientId: patient.ID,
  6410. RecordDate: theTime.Unix(),
  6411. UserOrgId: adminInfo.CurrentOrgId,
  6412. AdminUserId: adminInfo.AdminUser.Id,
  6413. IsReturn: 1,
  6414. }
  6415. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  6416. //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")
  6417. 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")
  6418. //var dat map[string]interface{}
  6419. //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6420. // fmt.Println(dat)
  6421. //} else {
  6422. // fmt.Println(err)
  6423. //}
  6424. var dat2 map[string]interface{}
  6425. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  6426. fmt.Println(dat2)
  6427. } else {
  6428. fmt.Println(err)
  6429. }
  6430. } else {
  6431. adminUser := c.GetAdminUserInfo()
  6432. errlog := &models.HisOrderError{
  6433. UserOrgId: adminUser.CurrentOrgId,
  6434. Ctime: time.Now().Unix(),
  6435. Mtime: time.Now().Unix(),
  6436. ErrMsg: res.ErrMsg,
  6437. Status: 1,
  6438. PatientId: id,
  6439. RecordTime: recordDateTime,
  6440. Stage: 1,
  6441. }
  6442. service.CreateErrMsgLog(errlog)
  6443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  6444. return
  6445. }
  6446. }
  6447. }
  6448. func (c *HisApiController) GetUploadDiag() {
  6449. id, _ := c.GetInt64("id")
  6450. record_time := c.GetString("record_time")
  6451. diagnosis_id, _ := c.GetInt64("diagnosis")
  6452. sick_type, _ := c.GetInt64("sick_type")
  6453. reg_type, _ := c.GetInt64("reg_type")
  6454. timeLayout := "2006-01-02"
  6455. loc, _ := time.LoadLocation("Local")
  6456. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6457. if err != nil {
  6458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6459. return
  6460. }
  6461. var patientPrescription models.HisPrescriptionInfo
  6462. recordDateTime := theTime.Unix()
  6463. adminInfo := c.GetAdminUserInfo()
  6464. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6465. if patientPrescription.ID == 0 {
  6466. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6467. }
  6468. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6469. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6470. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6471. sickConfig, _ := service.FindSickById(sick_type)
  6472. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6473. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  6474. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  6475. "&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 +
  6476. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  6477. resp2, requestErr2 := http.Get(api2)
  6478. if requestErr2 != nil {
  6479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6480. return
  6481. }
  6482. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6483. if ioErr2 != nil {
  6484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. return
  6487. }
  6488. var respJSON2 map[string]interface{}
  6489. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6492. return
  6493. }
  6494. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6495. userJSONBytes2, _ := json.Marshal(respJSON2)
  6496. var res2 ResultSix
  6497. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6498. utils.ErrorLog("解析失败:%v", err)
  6499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6500. return
  6501. }
  6502. if res2.Infcode != 0 {
  6503. adminUser := c.GetAdminUserInfo()
  6504. errlog := &models.HisOrderError{
  6505. UserOrgId: adminUser.CurrentOrgId,
  6506. Ctime: time.Now().Unix(),
  6507. Mtime: time.Now().Unix(),
  6508. ErrMsg: res2.ErrMsg,
  6509. Status: 1,
  6510. PatientId: id,
  6511. RecordTime: recordDateTime,
  6512. Stage: 3,
  6513. }
  6514. service.CreateErrMsgLog(errlog)
  6515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  6516. return
  6517. }
  6518. c.ServeSuccessJSON(map[string]interface{}{
  6519. "msg": "上传成功",
  6520. })
  6521. }
  6522. type QueryResult struct {
  6523. ID int64
  6524. Name string
  6525. Code string
  6526. List_type_code string
  6527. }
  6528. func (c *HisApiController) GetCheckCode() {
  6529. ids_str := c.GetString("ids")
  6530. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6531. ids_arr := strings.Split(ids_str, ",")
  6532. var queryResult []QueryResult
  6533. ids := make([]int64, 0)
  6534. for _, item := range ids_arr {
  6535. id, _ := strconv.ParseInt(item, 10, 64)
  6536. ids = append(ids, id)
  6537. }
  6538. if record_type == 1 {
  6539. drugs, _ := service.GetBatchDrugList(ids)
  6540. for _, item := range drugs {
  6541. result := QueryResult{
  6542. ID: item.ID,
  6543. Name: item.DrugName,
  6544. Code: item.MedicalInsuranceNumber,
  6545. List_type_code: "101",
  6546. }
  6547. queryResult = append(queryResult, result)
  6548. }
  6549. } else if record_type == 2 {
  6550. goods, _ := service.GetBatchGoodInformationList(ids)
  6551. for _, item := range goods {
  6552. result := QueryResult{
  6553. ID: item.ID,
  6554. Name: item.GoodName,
  6555. Code: item.MedicalInsuranceNumber,
  6556. List_type_code: "301",
  6557. }
  6558. queryResult = append(queryResult, result)
  6559. }
  6560. } else if record_type == 3 {
  6561. projects, _ := service.GetBathchMyPorjecgList(ids)
  6562. for _, item := range projects {
  6563. result := QueryResult{
  6564. ID: item.ID,
  6565. Name: item.ProjectName,
  6566. Code: item.MedicalCode,
  6567. List_type_code: "201",
  6568. }
  6569. queryResult = append(queryResult, result)
  6570. }
  6571. }
  6572. admin_user_id, _ := c.GetInt64("admin_user_id")
  6573. adminUser := c.GetAdminUserInfo()
  6574. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6575. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6576. var user_name string
  6577. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6578. if role.ID == 0 {
  6579. user_name = "xxx"
  6580. } else {
  6581. user_name = role.UserName
  6582. }
  6583. baseParams := &models.BaseParams{
  6584. SecretKey: miConfig.SecretKey,
  6585. FixmedinsCode: miConfig.Code,
  6586. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6587. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6588. OrgName: miConfig.OrgName,
  6589. Doctor: user_name,
  6590. }
  6591. if config.IsOpen == 1 {
  6592. for _, item := range queryResult {
  6593. var result string
  6594. if record_type == 1 {
  6595. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6596. } else if record_type == 2 {
  6597. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6598. } else if record_type == 3 {
  6599. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6600. }
  6601. var dat map[string]interface{}
  6602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6603. fmt.Println(dat)
  6604. } else {
  6605. fmt.Println(err)
  6606. }
  6607. userJSONBytes, _ := json.Marshal(dat)
  6608. var res ResultSix
  6609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6610. utils.ErrorLog("解析失败:%v", err)
  6611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6612. return
  6613. }
  6614. if res.Infcode == 0 {
  6615. if record_type == 1 {
  6616. service.UpdateBaseDrugById(item.ID)
  6617. } else if record_type == 2 {
  6618. service.UpdateGoodInformaitonByDetail(item.ID)
  6619. } else if record_type == 3 {
  6620. service.UpdateProjectById(item.ID)
  6621. }
  6622. c.ServeSuccessJSON(map[string]interface{}{
  6623. "failed_code": 0,
  6624. "msg": "目录对照成功",
  6625. })
  6626. } else {
  6627. c.ServeSuccessJSON(map[string]interface{}{
  6628. "failed_code": -10,
  6629. "msg": res.ErrMsg,
  6630. })
  6631. }
  6632. }
  6633. }
  6634. }
  6635. func (c *HisApiController) UnCheckCode() {
  6636. ids_str := c.GetString("ids")
  6637. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6638. admin_user_id, _ := c.GetInt64("admin_user_id")
  6639. ids_arr := strings.Split(ids_str, ",")
  6640. var queryResult []QueryResult
  6641. ids := make([]int64, 0)
  6642. for _, item := range ids_arr {
  6643. id, _ := strconv.ParseInt(item, 10, 64)
  6644. ids = append(ids, id)
  6645. }
  6646. if record_type == 1 {
  6647. drugs, _ := service.GetBatchDrugList(ids)
  6648. for _, item := range drugs {
  6649. result := QueryResult{
  6650. ID: item.ID,
  6651. Name: item.DrugName,
  6652. Code: item.MedicalInsuranceNumber,
  6653. List_type_code: "101",
  6654. }
  6655. queryResult = append(queryResult, result)
  6656. }
  6657. } else if record_type == 2 {
  6658. goods, _ := service.GetBatchGoodInformationList(ids)
  6659. for _, item := range goods {
  6660. result := QueryResult{
  6661. ID: item.ID,
  6662. Name: item.GoodName,
  6663. Code: item.MedicalInsuranceNumber,
  6664. List_type_code: "301",
  6665. }
  6666. queryResult = append(queryResult, result)
  6667. }
  6668. } else if record_type == 3 {
  6669. projects, _ := service.GetBathchMyPorjecgList(ids)
  6670. for _, item := range projects {
  6671. result := QueryResult{
  6672. ID: item.ID,
  6673. Name: item.ProjectName,
  6674. Code: item.MedicalCode,
  6675. List_type_code: "201",
  6676. }
  6677. queryResult = append(queryResult, result)
  6678. }
  6679. }
  6680. adminUser := c.GetAdminUserInfo()
  6681. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6682. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6683. var user_name string
  6684. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6685. if role.ID == 0 {
  6686. user_name = "xxx"
  6687. } else {
  6688. user_name = role.UserName
  6689. }
  6690. baseParams := &models.BaseParams{
  6691. SecretKey: miConfig.SecretKey,
  6692. FixmedinsCode: miConfig.Code,
  6693. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6694. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6695. OrgName: miConfig.OrgName,
  6696. Doctor: user_name,
  6697. }
  6698. if config.IsOpen == 1 {
  6699. for _, item := range queryResult {
  6700. var result string
  6701. if record_type == 1 {
  6702. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6703. } else if record_type == 2 {
  6704. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6705. } else if record_type == 3 {
  6706. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6707. }
  6708. var dat2 map[string]interface{}
  6709. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  6710. fmt.Println(dat2)
  6711. } else {
  6712. fmt.Println(err)
  6713. }
  6714. userJSONBytes, _ := json.Marshal(dat2)
  6715. var res ResultSix
  6716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6717. utils.ErrorLog("解析失败:%v", err)
  6718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6719. return
  6720. }
  6721. if res.Infcode == 0 {
  6722. if record_type == 1 {
  6723. service.UpdateDrugByIdDetail(item.ID)
  6724. } else if record_type == 2 {
  6725. service.UpdateGoodInfoById(item.ID)
  6726. } else if record_type == 3 {
  6727. service.UpdateMyProjectById(item.ID)
  6728. }
  6729. c.ServeSuccessJSON(map[string]interface{}{
  6730. "failed_code": 0,
  6731. "msg": "撤销目录对照成功",
  6732. })
  6733. } else {
  6734. c.ServeSuccessJSON(map[string]interface{}{
  6735. "failed_code": -10,
  6736. "msg": res.ErrMsg,
  6737. })
  6738. }
  6739. }
  6740. }
  6741. }
  6742. func (c *HisApiController) GetPatientInfo() {
  6743. id_card_no := c.GetString("id_card_no")
  6744. admin_user_id, _ := c.GetInt64("admin_user_id")
  6745. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6746. if patient.ID == 0 {
  6747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6748. return
  6749. }
  6750. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6751. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6752. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  6753. if config.IsOpen == 1 {
  6754. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  6755. var dat map[string]interface{}
  6756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6757. fmt.Println(dat)
  6758. } else {
  6759. fmt.Println(err)
  6760. }
  6761. userJSONBytes, _ := json.Marshal(dat)
  6762. var res ResultTwo
  6763. var res10265 ResultTwo10265
  6764. if miConfig.Code == "H15049901371" {
  6765. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6766. utils.ErrorLog("解析失败:%v", err)
  6767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6768. return
  6769. }
  6770. res.ErrMsg = res10265.ErrMsg
  6771. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6772. res.Infcode = infocode
  6773. res.Output = res10265.Output
  6774. res.InfRefmsgid = res10265.InfRefmsgid
  6775. } else {
  6776. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6777. utils.ErrorLog("解析失败:%v", err)
  6778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6779. return
  6780. }
  6781. }
  6782. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6783. // utils.ErrorLog("解析失败:%v", err)
  6784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6785. // return
  6786. //}
  6787. if res.Infcode != 0 {
  6788. c.ServeSuccessJSON(map[string]interface{}{
  6789. "failed_code": -10,
  6790. "msg": res.ErrMsg,
  6791. })
  6792. } else {
  6793. c.ServeSuccessJSON(map[string]interface{}{
  6794. "failed_code": 0,
  6795. "info": res,
  6796. })
  6797. }
  6798. }
  6799. }
  6800. func (c *HisApiController) PsnPutOnRecord() {
  6801. record_type, _ := c.GetInt64("type")
  6802. patient_id, _ := c.GetInt64("patient_id")
  6803. admin_user_id, _ := c.GetInt64("admin_user_id")
  6804. start_time := c.GetString("start_time")
  6805. end_time := c.GetString("end_time")
  6806. adminUser := c.GetAdminUserInfo()
  6807. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6808. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6809. var patients []*models.Patients
  6810. if record_type == 1 { //全部备案
  6811. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  6812. patients = append(patients, patient...)
  6813. } else { //单个备案
  6814. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6815. patients = append(patients, patient)
  6816. }
  6817. var user_name string
  6818. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6819. if role.ID == 0 {
  6820. user_name = "xxx"
  6821. } else {
  6822. user_name = role.UserName
  6823. }
  6824. if config.IsOpen == 1 {
  6825. for _, item := range patients {
  6826. 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
  6827. resp, requestErr := http.Get(api)
  6828. if requestErr != nil {
  6829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. return
  6831. }
  6832. defer resp.Body.Close()
  6833. body, ioErr := ioutil.ReadAll(resp.Body)
  6834. if ioErr != nil {
  6835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6837. return
  6838. }
  6839. var respJSON map[string]interface{}
  6840. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. return
  6844. }
  6845. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6846. userJSONBytes, _ := json.Marshal(userJSON)
  6847. var res ResultTwo
  6848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6849. utils.ErrorLog("解析失败:%v", err)
  6850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6851. return
  6852. }
  6853. if res.Infcode == 0 {
  6854. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  6855. var dat map[string]interface{}
  6856. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6857. fmt.Println(dat)
  6858. } else {
  6859. fmt.Println(err)
  6860. }
  6861. userJSONBytes, _ := json.Marshal(dat)
  6862. var res2 ResultThirteen
  6863. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6864. utils.ErrorLog("解析失败:%v", err)
  6865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6866. return
  6867. }
  6868. if res2.Infcode == 0 {
  6869. psnResult := &models.GdybPsnRecord{
  6870. UserOrgId: adminUser.CurrentOrgId,
  6871. PatientId: item.ID,
  6872. PsnNo: res.Output.Baseinfo.PsnNo,
  6873. Ctime: time.Now().Unix(),
  6874. Mtime: time.Now().Unix(),
  6875. Status: 1,
  6876. IsCancel: 1,
  6877. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6878. }
  6879. service.CreatePsnRecord(psnResult)
  6880. } else {
  6881. c.ServeSuccessJSON(map[string]interface{}{
  6882. "failed_code": -10,
  6883. "msg": res2.ErrMsg,
  6884. })
  6885. return
  6886. }
  6887. }
  6888. }
  6889. }
  6890. }
  6891. func (c *HisApiController) PsnUnPutOnRecord() {
  6892. id, _ := c.GetInt64("id")
  6893. //record_type, _ := c.GetInt64("type")
  6894. admin_user_id, _ := c.GetInt64("admin_user_id")
  6895. adminUser := c.GetAdminUserInfo()
  6896. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6897. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6898. var user_name string
  6899. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6900. if role.ID == 0 {
  6901. user_name = "xxx"
  6902. } else {
  6903. user_name = role.UserName
  6904. }
  6905. psn_record, _ := service.GetPsnRecordById(id)
  6906. if psn_record.ID == 0 {
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6908. return
  6909. }
  6910. if config.IsOpen == 1 {
  6911. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6912. var dat map[string]interface{}
  6913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6914. fmt.Println(dat)
  6915. } else {
  6916. fmt.Println(err)
  6917. }
  6918. userJSONBytes, _ := json.Marshal(dat)
  6919. var res ResultFourteen
  6920. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6921. utils.ErrorLog("解析失败:%v", err)
  6922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6923. return
  6924. }
  6925. if res.Infcode == 0 {
  6926. psn_record.IsCancel = 2
  6927. service.CreatePsnRecord(&psn_record)
  6928. } else {
  6929. c.ServeSuccessJSON(map[string]interface{}{
  6930. "failed_code": -10,
  6931. "msg": res.ErrMsg,
  6932. })
  6933. return
  6934. }
  6935. }
  6936. }
  6937. func (c *HisApiController) PsnPutNCDSOnRecord() {
  6938. patient_id, _ := c.GetInt64("patient_id")
  6939. insutype_two := c.GetString("insutype")
  6940. psn_no := c.GetString("psn_no")
  6941. doctor_id, _ := c.GetInt64("doctor_id")
  6942. sick_id, _ := c.GetInt64("sick_id")
  6943. department_id, _ := c.GetInt64("department_id")
  6944. start_time := c.GetString("start_time")
  6945. end_time := c.GetString("end_time")
  6946. check_time := c.GetString("check_time")
  6947. adminUser := c.GetAdminUserInfo()
  6948. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6949. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6950. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6951. sick, _ := service.FindSickById(sick_id)
  6952. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6953. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6954. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  6955. var res ResultTwo
  6956. var res10265 ResultTwo10265
  6957. if miConfig.Code == "H15049901371" {
  6958. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6959. utils.ErrorLog("解析失败:%v", err)
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. return
  6962. }
  6963. res.ErrMsg = res10265.ErrMsg
  6964. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6965. res.Infcode = infocode
  6966. res.Output = res10265.Output
  6967. res.InfRefmsgid = res10265.InfRefmsgid
  6968. } else {
  6969. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6970. utils.ErrorLog("解析失败:%v", err)
  6971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6972. return
  6973. }
  6974. }
  6975. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6976. infoStr := string(Iinfos)
  6977. var rf []*ResultFive
  6978. json.Unmarshal([]byte(infoStr), &rf)
  6979. var insuplc_admdvs string
  6980. var insutype string
  6981. var is390 int = 0
  6982. var is310 int = 0
  6983. var insutypes []*ResultFive
  6984. for _, item := range rf {
  6985. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6986. insutypes = append(insutypes, item)
  6987. }
  6988. }
  6989. if len(insutypes) == 1 {
  6990. insutype = insutypes[0].Insutype
  6991. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6992. } else {
  6993. for _, i := range insutypes {
  6994. if i.Insutype == "390" {
  6995. is390 = 1
  6996. }
  6997. if i.Insutype == "310" {
  6998. is310 = 1
  6999. }
  7000. }
  7001. }
  7002. if is390 == 1 {
  7003. insutype = "390"
  7004. }
  7005. if is310 == 1 {
  7006. insutype = "310"
  7007. }
  7008. if len(insutypes) == 2 {
  7009. insutype = insutype_two
  7010. }
  7011. if len(insutypes) == 0 {
  7012. insutype = "310"
  7013. }
  7014. insutype = insutype_two
  7015. fmt.Println(insutype)
  7016. for _, item := range rf {
  7017. fmt.Println(item.Insutype)
  7018. fmt.Println(insutype)
  7019. if item.Insutype == insutype {
  7020. fmt.Println(item.Insutype)
  7021. fmt.Println(insutype)
  7022. insuplc_admdvs = item.InsuplcAdmdvs
  7023. }
  7024. }
  7025. fmt.Println(insuplc_admdvs)
  7026. if config.IsOpen == 1 {
  7027. 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)
  7028. var dat map[string]interface{}
  7029. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7030. fmt.Println(dat)
  7031. } else {
  7032. fmt.Println(err)
  7033. }
  7034. userJSONBytes, _ := json.Marshal(dat)
  7035. var res2 ResultThirteen
  7036. var res10265 ResultThirteen10265
  7037. if miConfig.Code == "H15049901371" {
  7038. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7039. utils.ErrorLog("解析失败:%v", err)
  7040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7041. return
  7042. }
  7043. res2.ErrMsg = res10265.ErrMsg
  7044. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7045. res2.Infcode = infocode
  7046. res2.Output = res10265.Output
  7047. res2.InfRefmsgid = res10265.InfRefmsgid
  7048. } else {
  7049. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7050. utils.ErrorLog("解析失败:%v", err)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. }
  7055. if res2.Infcode == 0 {
  7056. psnResult := &models.GdybPsnNcdsRecord{
  7057. UserOrgId: adminUser.CurrentOrgId,
  7058. PatientId: patient.ID,
  7059. PsnNo: psn_no,
  7060. DoctorId: doctor.AdminUserId,
  7061. DepartmentId: department_id,
  7062. SickType: sick_id,
  7063. Insutype: insutype,
  7064. Ctime: time.Now().Unix(),
  7065. Mtime: time.Now().Unix(),
  7066. Status: 1,
  7067. IsCancel: 1,
  7068. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7069. }
  7070. service.CreatePsnNCDSRecord(psnResult)
  7071. c.ServeSuccessJSON(map[string]interface{}{
  7072. "failed_code": 0,
  7073. "msg": "备案成功",
  7074. "result": psnResult,
  7075. })
  7076. } else {
  7077. c.ServeSuccessJSON(map[string]interface{}{
  7078. "failed_code": -10,
  7079. "msg": res2.ErrMsg,
  7080. })
  7081. return
  7082. }
  7083. }
  7084. }
  7085. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7086. id, _ := c.GetInt64("id")
  7087. admin_user_id, _ := c.GetInt64("admin_user_id")
  7088. adminUser := c.GetAdminUserInfo()
  7089. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7090. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7091. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7092. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7093. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7094. //var user_name string
  7095. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7096. //if role.ID == 0 {
  7097. // user_name = "xxx"
  7098. //} else {
  7099. // user_name = role.UserName
  7100. //}
  7101. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7102. var res ResultTwo
  7103. var res10265 ResultTwo10265
  7104. if miConfig.Code == "H15049901371" {
  7105. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7106. utils.ErrorLog("解析失败:%v", err)
  7107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7108. return
  7109. }
  7110. res.ErrMsg = res10265.ErrMsg
  7111. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7112. res.Infcode = infocode
  7113. res.Output = res10265.Output
  7114. res.InfRefmsgid = res10265.InfRefmsgid
  7115. } else {
  7116. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7117. utils.ErrorLog("解析失败:%v", err)
  7118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7119. return
  7120. }
  7121. }
  7122. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7123. infoStr := string(Iinfos)
  7124. var rf []*ResultFive
  7125. json.Unmarshal([]byte(infoStr), &rf)
  7126. var insuplc_admdvs string
  7127. var insutype string
  7128. var is390 int = 0
  7129. var is310 int = 0
  7130. var insutypes []*ResultFive
  7131. for _, item := range rf {
  7132. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7133. insutypes = append(insutypes, item)
  7134. }
  7135. }
  7136. if len(insutypes) == 1 {
  7137. insutype = insutypes[0].Insutype
  7138. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7139. } else {
  7140. for _, i := range insutypes {
  7141. if i.Insutype == "390" {
  7142. is390 = 1
  7143. }
  7144. if i.Insutype == "310" {
  7145. is310 = 1
  7146. }
  7147. }
  7148. }
  7149. if is390 == 1 {
  7150. insutype = "390"
  7151. }
  7152. if is310 == 1 {
  7153. insutype = "310"
  7154. }
  7155. if len(insutypes) == 0 {
  7156. insutype = "310"
  7157. }
  7158. for _, item := range rf {
  7159. if item.Insutype == insutype {
  7160. insuplc_admdvs = item.InsuplcAdmdvs
  7161. }
  7162. }
  7163. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7164. if psn_record.ID == 0 {
  7165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7166. return
  7167. }
  7168. if config.IsOpen == 1 {
  7169. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7170. var dat map[string]interface{}
  7171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7172. fmt.Println(dat)
  7173. } else {
  7174. fmt.Println(err)
  7175. }
  7176. userJSONBytes, _ := json.Marshal(dat)
  7177. var res ResultFourteen
  7178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7179. utils.ErrorLog("解析失败:%v", err)
  7180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7181. return
  7182. }
  7183. if res.Infcode == 0 {
  7184. psn_record.IsCancel = 2
  7185. service.CreatePsnNCDSRecord(&psn_record)
  7186. c.ServeSuccessJSON(map[string]interface{}{
  7187. "failed_code": 0,
  7188. "msg": "撤销备案成功",
  7189. })
  7190. } else {
  7191. c.ServeSuccessJSON(map[string]interface{}{
  7192. "failed_code": -10,
  7193. "msg": res.ErrMsg,
  7194. })
  7195. return
  7196. }
  7197. }
  7198. }
  7199. func (c *HisApiController) TestTest() {
  7200. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  7201. fmt.Println(patient.Iinfo)
  7202. }
  7203. type CustomData struct {
  7204. MsgId string
  7205. PsnNo string
  7206. Info string
  7207. }
  7208. func (c *HisApiController) ReversalData() {
  7209. var customData []*CustomData
  7210. custom := &CustomData{
  7211. MsgId: "H44022900158202103301714472004",
  7212. PsnNo: "44020000001101329945",
  7213. Info: "2207",
  7214. }
  7215. customData = append(customData, custom)
  7216. custom1 := &CustomData{
  7217. MsgId: "H4402290015820210330172057803",
  7218. PsnNo: "44020000001101161813",
  7219. Info: "2207",
  7220. }
  7221. customData = append(customData, custom1)
  7222. custom2 := &CustomData{
  7223. MsgId: "H44022900158202103301705198813",
  7224. PsnNo: "44190000133097375417",
  7225. Info: "2207",
  7226. }
  7227. customData = append(customData, custom2)
  7228. custom3 := &CustomData{
  7229. MsgId: "H44022900158202103301715524756",
  7230. PsnNo: "44020000001100187221",
  7231. Info: "2207",
  7232. }
  7233. customData = append(customData, custom3)
  7234. custom4 := &CustomData{
  7235. MsgId: "H44022900158202103301730376224",
  7236. PsnNo: "44020000001101959155",
  7237. Info: "2207",
  7238. }
  7239. customData = append(customData, custom4)
  7240. custom5 := &CustomData{
  7241. MsgId: "H44022900158202103301748008725",
  7242. PsnNo: "44020000001104246641",
  7243. Info: "2207",
  7244. }
  7245. customData = append(customData, custom5)
  7246. custom6 := &CustomData{
  7247. MsgId: "H44022900158202103301718096755",
  7248. PsnNo: "44020000001102211860",
  7249. Info: "2207",
  7250. }
  7251. customData = append(customData, custom6)
  7252. custom7 := &CustomData{
  7253. MsgId: "H44022900158202103301736551640",
  7254. PsnNo: "44020000001102687718",
  7255. Info: "2207",
  7256. }
  7257. customData = append(customData, custom7)
  7258. custom8 := &CustomData{
  7259. MsgId: "H44022900158202103301743097676",
  7260. PsnNo: "44020000001102127785",
  7261. Info: "2207",
  7262. }
  7263. customData = append(customData, custom8)
  7264. custom9 := &CustomData{
  7265. MsgId: "H44022900158202103301712304203",
  7266. PsnNo: "44020000001101518097",
  7267. Info: "2207",
  7268. }
  7269. customData = append(customData, custom9)
  7270. custom10 := &CustomData{
  7271. MsgId: "H44022900158202103301738448785",
  7272. PsnNo: "44020000001100500813",
  7273. Info: "2207",
  7274. }
  7275. customData = append(customData, custom10)
  7276. custom11 := &CustomData{
  7277. MsgId: "H44022900158202103301732455843",
  7278. PsnNo: "44020000001102690557",
  7279. Info: "2207",
  7280. }
  7281. customData = append(customData, custom11)
  7282. custom12 := &CustomData{
  7283. MsgId: "H44022900158202103301745421708",
  7284. PsnNo: "44020000001102211928",
  7285. Info: "2207",
  7286. }
  7287. customData = append(customData, custom12)
  7288. custom1212 := &CustomData{
  7289. MsgId: "H440229001582021033017351627",
  7290. PsnNo: "44020000001102481733",
  7291. Info: "2207",
  7292. }
  7293. customData = append(customData, custom1212)
  7294. custom13 := &CustomData{
  7295. MsgId: "H44022900158202103301740327951",
  7296. PsnNo: "44020000001103174866",
  7297. Info: "2207",
  7298. }
  7299. customData = append(customData, custom13)
  7300. custom14 := &CustomData{
  7301. MsgId: "H4402290015820210330174922668",
  7302. PsnNo: "44020000001102927272",
  7303. Info: "2207",
  7304. }
  7305. customData = append(customData, custom14)
  7306. custom15 := &CustomData{
  7307. MsgId: "H44022900158202103301752362273",
  7308. PsnNo: "44020000001102942890",
  7309. Info: "2207",
  7310. }
  7311. customData = append(customData, custom15)
  7312. custom16 := &CustomData{
  7313. MsgId: "H44022900158202103301751082917",
  7314. PsnNo: "44020000001101662162",
  7315. Info: "2207",
  7316. }
  7317. customData = append(customData, custom16)
  7318. custom17 := &CustomData{
  7319. MsgId: "H44022900158202103301754147728",
  7320. PsnNo: "44020000000229014511",
  7321. Info: "2207",
  7322. }
  7323. customData = append(customData, custom17)
  7324. adminUser := c.GetAdminUserInfo()
  7325. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7326. for _, item := range customData {
  7327. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7328. fmt.Println(result)
  7329. }
  7330. }
  7331. func (c *HisApiController) ReversalOtherData() {
  7332. var customData []*CustomData
  7333. custom := &CustomData{
  7334. MsgId: "H44022900158202103301714472004",
  7335. PsnNo: "44020000001101329945",
  7336. Info: "2208",
  7337. }
  7338. customData = append(customData, custom)
  7339. custom1 := &CustomData{
  7340. MsgId: "H4402290015820210330172057803",
  7341. PsnNo: "44020000001101161813",
  7342. Info: "2208",
  7343. }
  7344. customData = append(customData, custom1)
  7345. custom2 := &CustomData{
  7346. MsgId: "H44022900158202103301705198813",
  7347. PsnNo: "44190000133097375417",
  7348. Info: "2208",
  7349. }
  7350. customData = append(customData, custom2)
  7351. custom3 := &CustomData{
  7352. MsgId: "H44022900158202103301715524756",
  7353. PsnNo: "44020000001100187221",
  7354. Info: "2208",
  7355. }
  7356. customData = append(customData, custom3)
  7357. custom4 := &CustomData{
  7358. MsgId: "H44022900158202103301730376224",
  7359. PsnNo: "44020000001101959155",
  7360. Info: "2208",
  7361. }
  7362. customData = append(customData, custom4)
  7363. custom5 := &CustomData{
  7364. MsgId: "H44022900158202103301748008725",
  7365. PsnNo: "44020000001104246641",
  7366. Info: "2208",
  7367. }
  7368. customData = append(customData, custom5)
  7369. custom6 := &CustomData{
  7370. MsgId: "H44022900158202103301718096755",
  7371. PsnNo: "44020000001102211860",
  7372. Info: "2208",
  7373. }
  7374. customData = append(customData, custom6)
  7375. custom7 := &CustomData{
  7376. MsgId: "H44022900158202103301736551640",
  7377. PsnNo: "44020000001102687718",
  7378. Info: "2208",
  7379. }
  7380. customData = append(customData, custom7)
  7381. custom8 := &CustomData{
  7382. MsgId: "H44022900158202103301743097676",
  7383. PsnNo: "44020000001102127785",
  7384. Info: "2208",
  7385. }
  7386. customData = append(customData, custom8)
  7387. custom9 := &CustomData{
  7388. MsgId: "H44022900158202103301712304203",
  7389. PsnNo: "44020000001101518097",
  7390. Info: "2208",
  7391. }
  7392. customData = append(customData, custom9)
  7393. custom10 := &CustomData{
  7394. MsgId: "H44022900158202103301738448785",
  7395. PsnNo: "44020000001100500813",
  7396. Info: "2208",
  7397. }
  7398. customData = append(customData, custom10)
  7399. custom11 := &CustomData{
  7400. MsgId: "H44022900158202103301732455843",
  7401. PsnNo: "44020000001102690557",
  7402. Info: "2208",
  7403. }
  7404. customData = append(customData, custom11)
  7405. custom12 := &CustomData{
  7406. MsgId: "H44022900158202103301745421708",
  7407. PsnNo: "44020000001102211928",
  7408. Info: "2208",
  7409. }
  7410. customData = append(customData, custom12)
  7411. custom1212 := &CustomData{
  7412. MsgId: "H440229001582021033017351627",
  7413. PsnNo: "44020000001102481733",
  7414. Info: "2208",
  7415. }
  7416. customData = append(customData, custom1212)
  7417. custom13 := &CustomData{
  7418. MsgId: "H44022900158202103301740327951",
  7419. PsnNo: "44020000001103174866",
  7420. Info: "2208",
  7421. }
  7422. customData = append(customData, custom13)
  7423. custom14 := &CustomData{
  7424. MsgId: "H4402290015820210330174922668",
  7425. PsnNo: "44020000001102927272",
  7426. Info: "2208",
  7427. }
  7428. customData = append(customData, custom14)
  7429. custom15 := &CustomData{
  7430. MsgId: "H44022900158202103301752362273",
  7431. PsnNo: "44020000001102942890",
  7432. Info: "2208",
  7433. }
  7434. customData = append(customData, custom15)
  7435. custom16 := &CustomData{
  7436. MsgId: "H44022900158202103301751082917",
  7437. PsnNo: "44020000001101662162",
  7438. Info: "2208",
  7439. }
  7440. customData = append(customData, custom16)
  7441. custom17 := &CustomData{
  7442. MsgId: "H44022900158202103301754147728",
  7443. PsnNo: "44020000000229014511",
  7444. Info: "2208",
  7445. }
  7446. customData = append(customData, custom17)
  7447. adminUser := c.GetAdminUserInfo()
  7448. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7449. for _, item := range customData {
  7450. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7451. fmt.Println(result)
  7452. }
  7453. }
  7454. func PathExists(path string) (bool, error) {
  7455. _, err := os.Stat(path)
  7456. if err == nil {
  7457. return true, nil
  7458. }
  7459. if os.IsNotExist(err) {
  7460. return false, nil
  7461. }
  7462. return false, err
  7463. }
  7464. //创建文件夹
  7465. func Mkdir(dir string) {
  7466. // 创建文件夹
  7467. exist, err := PathExists(dir)
  7468. if err != nil {
  7469. fmt.Println(err.Error())
  7470. } else {
  7471. if exist {
  7472. fmt.Println(dir + "文件夹已存在!")
  7473. } else {
  7474. // 文件夹名称,权限
  7475. err := os.Mkdir(dir, os.ModePerm)
  7476. if err != nil {
  7477. fmt.Println(dir+"文件夹创建失败:", err.Error())
  7478. } else {
  7479. fmt.Println(dir + "文件夹创建成功!")
  7480. }
  7481. }
  7482. }
  7483. }
  7484. //压缩文件
  7485. func Zip(srcFile string, destZip string) error {
  7486. zipfile, err := os.Create(destZip)
  7487. if err != nil {
  7488. return err
  7489. }
  7490. defer zipfile.Close()
  7491. archive := zip.NewWriter(zipfile)
  7492. defer archive.Close()
  7493. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  7494. if err != nil {
  7495. return err
  7496. }
  7497. header, err := zip.FileInfoHeader(info)
  7498. if err != nil {
  7499. return err
  7500. }
  7501. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  7502. // header.Name = path
  7503. if info.IsDir() {
  7504. header.Name += "/"
  7505. } else {
  7506. header.Method = zip.Deflate
  7507. }
  7508. writer, err := archive.CreateHeader(header)
  7509. if err != nil {
  7510. return err
  7511. }
  7512. if !info.IsDir() {
  7513. file, err := os.Open(path)
  7514. if err != nil {
  7515. return err
  7516. }
  7517. defer file.Close()
  7518. _, err = io.Copy(writer, file)
  7519. }
  7520. return err
  7521. })
  7522. return err
  7523. }
  7524. func ReadFile(filePath string) []byte {
  7525. f, err := os.Open(filePath)
  7526. if err != nil {
  7527. fmt.Println("read file fail", err)
  7528. return nil
  7529. }
  7530. defer f.Close()
  7531. fd, err := ioutil.ReadAll(f)
  7532. if err != nil {
  7533. fmt.Println("read to fd fail", err)
  7534. return nil
  7535. }
  7536. return fd
  7537. }
  7538. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  7539. newArr = make([]*models.HisOrderInfo, 0)
  7540. for i := 0; i < len(arr); i++ {
  7541. repeat := false
  7542. for j := i + 1; j < len(arr); j++ {
  7543. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  7544. repeat = true
  7545. break
  7546. }
  7547. }
  7548. if !repeat {
  7549. newArr = append(newArr, arr[i])
  7550. }
  7551. }
  7552. return
  7553. }
  7554. func saveRegisterLog(result string) {
  7555. org_id, _ := beego.AppConfig.Int64("org_id")
  7556. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7557. dir := miConfig.OrgName + "日志"
  7558. utils.Mkdir(dir)
  7559. month := time.Unix(1557042972, 0).Format("1")
  7560. year := time.Now().Format("2006")
  7561. month = time.Now().Format("01")
  7562. day := time.Now().Format("02")
  7563. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7564. file_name := file + ".txt"
  7565. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7566. exist, _ := utils.PathExists(file_path)
  7567. if exist { //存在
  7568. fmt.Println("存在")
  7569. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7570. if err != nil {
  7571. fmt.Println("read fail")
  7572. }
  7573. content := "\r\n" + result
  7574. n, _ := f.Seek(0, 2)
  7575. _, err = f.WriteAt([]byte(content), n)
  7576. } else { //不存在
  7577. fmt.Println("文件不存在,创建文件")
  7578. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7579. defer f.Close()
  7580. if err != nil {
  7581. } else {
  7582. _, err = f.Write([]byte("记录日志"))
  7583. }
  7584. }
  7585. }
  7586. func saveLog(result string, request string, infno string, desc string) {
  7587. org_id, _ := beego.AppConfig.Int64("org_id")
  7588. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7589. dir := miConfig.OrgName + "日志"
  7590. utils.Mkdir(dir)
  7591. month := time.Unix(1557042972, 0).Format("1")
  7592. year := time.Now().Format("2006")
  7593. month = time.Now().Format("01")
  7594. day := time.Now().Format("02")
  7595. hour := time.Now().Format("15")
  7596. min := time.Now().Format("04")
  7597. sec := time.Now().Format("05")
  7598. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  7599. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7600. file_name := file + ".txt"
  7601. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7602. exist, _ := utils.PathExists(file_path)
  7603. if exist { //存在
  7604. fmt.Println("存在")
  7605. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7606. if err != nil {
  7607. fmt.Println("read fail")
  7608. }
  7609. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  7610. n, _ := f.Seek(0, 2)
  7611. _, err = f.WriteAt([]byte(content), n)
  7612. } else { //不存在
  7613. fmt.Println("文件不存在,创建文件")
  7614. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7615. defer f.Close()
  7616. if err != nil {
  7617. } else {
  7618. _, err = f.Write([]byte("记录日志"))
  7619. }
  7620. }
  7621. }
  7622. type Charset string
  7623. const (
  7624. UTF8 = Charset("UTF-8")
  7625. GB18030 = Charset("GB18030")
  7626. )
  7627. func ConvertToString(src string, srcCode string, tagCode string) string {
  7628. srcCoder := mahonia.NewDecoder(srcCode)
  7629. srcResult := srcCoder.ConvertString(src)
  7630. tagCoder := mahonia.NewDecoder(tagCode)
  7631. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  7632. result := string(cdata)
  7633. return result
  7634. }
  7635. //func (c *HisApiController)HandleCheckDetailAccount(){
  7636. // psn_no, _ := c.GetString("psn_no")
  7637. // psn_no, _ := c.GetString("psn_no")
  7638. // psn_no, _ := c.GetString("psn_no")
  7639. //
  7640. //
  7641. //
  7642. //}