his_api_controller.go 293KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224
  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 ResultFourteen struct {
  2310. ErrMsg string `json:"err_msg"`
  2311. InfRefmsgid string `json:"inf_refmsgid"`
  2312. Infcode int64 `json:"infcode"`
  2313. Output struct {
  2314. } `json:"output"`
  2315. RefmsgTime string `json:"refmsg_time"`
  2316. RespondTime string `json:"respond_time"`
  2317. Signtype interface{} `json:"signtype"`
  2318. WarnInfo interface{} `json:"warn_info"`
  2319. }
  2320. type ResultSixteen struct {
  2321. Cainfo string `json:"cainfo"`
  2322. ErrMsg string `json:"err_msg"`
  2323. InfRefmsgid string `json:"inf_refmsgid"`
  2324. Infcode int64 `json:"infcode"`
  2325. Output struct {
  2326. Setldetail []interface{} `json:"setldetail"`
  2327. Setlinfo struct {
  2328. MdtrtID string `json:"mdtrt_id"`
  2329. SetlID string `json:"setl_id"`
  2330. ClrOptins string `json:"clr_optins"`
  2331. SetlTime string `json:"setl_time"`
  2332. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2333. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2334. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2335. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2336. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2337. ActPayDedc float64 `json:"act_pay_dedc"`
  2338. HifpPay float64 `json:"hifp_pay"`
  2339. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2340. Lfpay float64 `json:"selfpay"`
  2341. CvlservPay float64 `json:"cvlserv_pay"`
  2342. HifesPay float64 `json:"hifes_pay"`
  2343. HifmiPay float64 `json:"hifmi_pay"`
  2344. HifobPay float64 `json:"hifob_pay"`
  2345. MafPay float64 `json:"maf_pay"`
  2346. OthPay float64 `json:"oth_pay"`
  2347. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2348. PsnPartAmt float64 `json:"psn_part_amt"`
  2349. AcctPay float64 `json:"acct_pay"`
  2350. Balc float64 `json:"balc"`
  2351. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2352. HospPartAmt float64 `json:"hosp_part_amt"`
  2353. MedinsSetlID string `json:"medins_setl_id"`
  2354. PdnCashPay string `json:"pdn_cash_pay"`
  2355. } `json:"setlinfo"`
  2356. } `json:"output"`
  2357. RefmsgTime string `json:"refmsg_time"`
  2358. RespondTime string `json:"respond_time"`
  2359. Signtype interface{} `json:"signtype"`
  2360. WarnMsg interface{} `json:"warn_msg"`
  2361. }
  2362. type ResultSixteen10265 struct {
  2363. Cainfo string `json:"cainfo"`
  2364. ErrMsg string `json:"err_msg"`
  2365. InfRefmsgid string `json:"inf_refmsgid"`
  2366. Infcode string `json:"infcode"`
  2367. Output struct {
  2368. Setldetail []interface{} `json:"setldetail"`
  2369. Setlinfo struct {
  2370. MdtrtID string `json:"mdtrt_id"`
  2371. SetlID string `json:"setl_id"`
  2372. ClrOptins string `json:"clr_optins"`
  2373. SetlTime string `json:"setl_time"`
  2374. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2375. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2376. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2377. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2378. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2379. ActPayDedc float64 `json:"act_pay_dedc"`
  2380. HifpPay float64 `json:"hifp_pay"`
  2381. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2382. Lfpay float64 `json:"selfpay"`
  2383. CvlservPay float64 `json:"cvlserv_pay"`
  2384. HifesPay float64 `json:"hifes_pay"`
  2385. HifmiPay float64 `json:"hifmi_pay"`
  2386. HifobPay float64 `json:"hifob_pay"`
  2387. MafPay float64 `json:"maf_pay"`
  2388. OthPay float64 `json:"oth_pay"`
  2389. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2390. PsnPartAmt float64 `json:"psn_part_amt"`
  2391. AcctPay float64 `json:"acct_pay"`
  2392. Balc float64 `json:"balc"`
  2393. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2394. HospPartAmt float64 `json:"hosp_part_amt"`
  2395. MedinsSetlID string `json:"medins_setl_id"`
  2396. PdnCashPay string `json:"pdn_cash_pay"`
  2397. } `json:"setlinfo"`
  2398. } `json:"output"`
  2399. RefmsgTime string `json:"refmsg_time"`
  2400. RespondTime string `json:"respond_time"`
  2401. Signtype interface{} `json:"signtype"`
  2402. WarnMsg interface{} `json:"warn_msg"`
  2403. }
  2404. type ResultSeventeen struct {
  2405. ErrMsg string `json:"err_msg"`
  2406. InfRefmsgid string `json:"inf_refmsgid"`
  2407. Infcode int64 `json:"infcode"`
  2408. Output struct {
  2409. SetlListId string `json:"setl_list_id"`
  2410. } `json:"output"`
  2411. RefmsgTime string `json:"refmsg_time"`
  2412. RespondTime string `json:"respond_time"`
  2413. Signtype string `json:"signtype"`
  2414. WarnInfo string `json:"warn_info"`
  2415. }
  2416. type Result90991 struct {
  2417. ErrMsg string `json:"err_msg"`
  2418. InfRefmsgid string `json:"inf_refmsgid"`
  2419. Infcode int64 `json:"infcode"`
  2420. Output struct {
  2421. Result struct {
  2422. PsnNo string `json:"psn_no"`
  2423. CardStat string `json:"card_stat"`
  2424. Certno string `json:"certno"`
  2425. PsnName string `json:"psn_name"`
  2426. CheckStat string `json:"check_stat"`
  2427. } `json:"result"`
  2428. } `json:"output"`
  2429. RefmsgTime string `json:"refmsg_time"`
  2430. RespondTime string `json:"respond_time"`
  2431. Signtype interface{} `json:"signtype"`
  2432. WarnInfo interface{} `json:"warn_info"`
  2433. }
  2434. type Result90100 struct {
  2435. ErrMsg string `json:"err_msg"`
  2436. InfRefmsgid string `json:"inf_refmsgid"`
  2437. Infcode int64 `json:"infcode"`
  2438. Output struct {
  2439. PoolareaNo string `json:"poolarea_no"`
  2440. PoolareaNoName string `json:"poolarea_no_name"`
  2441. Insutype string `json:"insutype"`
  2442. InsutypeName string `json:"insutype_name"`
  2443. ClctType string `json:"clct_type"`
  2444. ClctTypeName string `json:"clct_type_name"`
  2445. ClctFlag string `json:"clct_flag"`
  2446. ClctFlagName string `json:"clct_flag_name"`
  2447. AccrymBegn string `json:"accrym_begn"`
  2448. AccrymEnd string `json:"accrym_end"`
  2449. ClctTime string `json:"clct_time"`
  2450. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  2451. } `json:"output"`
  2452. RefmsgTime string `json:"refmsg_time"`
  2453. RespondTime string `json:"respond_time"`
  2454. Signtype interface{} `json:"signtype"`
  2455. WarnInfo interface{} `json:"warn_info"`
  2456. }
  2457. type Custom struct {
  2458. DetItemFeeSumamt string
  2459. Cut string
  2460. FeedetlSn string
  2461. Price string
  2462. MedListCodg string
  2463. Type int64
  2464. AdviceId int64
  2465. ProjectId int64
  2466. ItemId int64
  2467. }
  2468. //获取个人信息----挂号-----上传就诊信息
  2469. func (c *HisApiController) GetRegisterInfo() {
  2470. fmt.Println("~~~~~~~~")
  2471. id, _ := c.GetInt64("id")
  2472. record_time := c.GetString("record_time")
  2473. settlementValue, _ := c.GetInt64("settlement_value")
  2474. medical_insurance_card := c.GetString("medical_insurance_card")
  2475. name := c.GetString("name")
  2476. id_card_type, _ := c.GetInt64("id_card_type")
  2477. certificates, _ := c.GetInt64("certificates")
  2478. medical_care, _ := c.GetInt64("medical_care")
  2479. birthday := c.GetString("birthday")
  2480. //age, _ := c.GetInt64("age")
  2481. id_card := c.GetString("id_card")
  2482. register_type, _ := c.GetInt64("register")
  2483. doctor, _ := c.GetInt64("doctor")
  2484. department, _ := c.GetInt64("department")
  2485. gender, _ := c.GetInt64("sex")
  2486. //phone := c.GetString("phone")
  2487. registration_fee, _ := c.GetFloat("registration_fee")
  2488. medical_expenses, _ := c.GetFloat("medical_expenses")
  2489. social_type, _ := c.GetInt64("social_type")
  2490. med_type := c.GetString("social_type")
  2491. admin_user_id, _ := c.GetInt64("admin_user_id")
  2492. timeLayout := "2006-01-02"
  2493. loc, _ := time.LoadLocation("Local")
  2494. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2495. birthUnix := birthdays.Unix()
  2496. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2497. if err != nil {
  2498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2499. return
  2500. }
  2501. recordDateTime := theTime.Unix()
  2502. adminInfo := c.GetAdminUserInfo()
  2503. var patient service.Patients
  2504. if id == 0 {
  2505. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2506. } else {
  2507. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2508. }
  2509. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2510. if patientPrescription.ID == 0 {
  2511. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2512. }
  2513. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  2514. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2515. //sickConfig, _ := service.FindSickById(sick_type)
  2516. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2517. if patient.ID == 0 {
  2518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2519. return
  2520. }
  2521. if len(patient.IdCardNo) == 0 {
  2522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2523. return
  2524. }
  2525. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2526. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2527. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2528. //就诊结算未完成,不能进行二次挂号
  2529. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2530. if len(his) >= 1 {
  2531. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2532. if len(his) >= 1 && order.ID == 0 {
  2533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2534. return
  2535. }
  2536. }
  2537. //var register_log string
  2538. if config.IsOpen == 1 {
  2539. var res ResultTwo
  2540. var res10265 ResultTwo10265
  2541. var PsnNo string
  2542. var PsnCertType string
  2543. var Certno string
  2544. var PsnName string
  2545. var Gend string
  2546. var Naty string
  2547. var Brdy string
  2548. var Age float64
  2549. var infoStr string
  2550. var idetinfoStr string
  2551. var infocode int64
  2552. if miConfig.MdtrtareaAdmvs == "421300" {
  2553. psn_info, _ := service.GetPsnByPatientId(id)
  2554. PsnNo = psn_info.PsnNo
  2555. PsnCertType = psn_info.PsnCertType
  2556. Certno = psn_info.Certno
  2557. PsnName = psn_info.PsnName
  2558. Gend = psn_info.Gend
  2559. Naty = psn_info.Naty
  2560. Brdy = psn_info.Brdy
  2561. Age = psn_info.Age
  2562. infoStr = psn_info.Insuinfo
  2563. idetinfoStr = psn_info.Idetinfo
  2564. } else {
  2565. 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)
  2566. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2567. if miConfig.Code == "H15049901371" {
  2568. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2569. utils.ErrorLog("解析失败:%v", err)
  2570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2571. return
  2572. }
  2573. res.ErrMsg = res10265.ErrMsg
  2574. res.Output = res10265.Output
  2575. res.InfRefmsgid = res10265.InfRefmsgid
  2576. } else {
  2577. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2578. utils.ErrorLog("解析失败:%v", err)
  2579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2580. return
  2581. }
  2582. }
  2583. PsnNo = res.Output.Baseinfo.PsnNo
  2584. PsnCertType = res.Output.Baseinfo.PsnCertType
  2585. Certno = res.Output.Baseinfo.Certno
  2586. PsnName = res.Output.Baseinfo.PsnName
  2587. Gend = res.Output.Baseinfo.Gend
  2588. Naty = res.Output.Baseinfo.Naty
  2589. Brdy = res.Output.Baseinfo.Brdy
  2590. Age = res.Output.Baseinfo.Age
  2591. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2592. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2593. infoStr = string(Iinfos)
  2594. idetinfoStr = string(Idetinfos)
  2595. if miConfig.Code == "H15049901371" {
  2596. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  2597. } else {
  2598. infocode = res.Infcode
  2599. }
  2600. }
  2601. if infocode == 0 {
  2602. his := models.VMHisPatient{
  2603. Name: name,
  2604. Gender: gender,
  2605. Birthday: birthUnix,
  2606. MedicalTreatmentType: medical_care,
  2607. IdType: certificates,
  2608. IdCardNo: id_card,
  2609. BalanceAccountsType: settlementValue,
  2610. SocialType: social_type,
  2611. MedicalInsuranceNumber: medical_insurance_card,
  2612. RegisterType: register_type,
  2613. RegisterCost: registration_fee,
  2614. TreatmentCost: medical_expenses,
  2615. Status: 1,
  2616. Ctime: time.Now().Unix(),
  2617. Mtime: time.Now().Unix(),
  2618. PsnNo: PsnNo,
  2619. PsnCertType: PsnCertType,
  2620. Certno: Certno,
  2621. PsnName: PsnName,
  2622. Gend: Gend,
  2623. Naty: Naty,
  2624. Brdy: Brdy,
  2625. Age: Age,
  2626. Iinfo: infoStr,
  2627. Idetinfo: idetinfoStr,
  2628. PatientId: patient.ID,
  2629. RecordDate: theTime.Unix(),
  2630. UserOrgId: adminInfo.CurrentOrgId,
  2631. AdminUserId: admin_user_id,
  2632. IsReturn: 1,
  2633. IdCardType: id_card_type,
  2634. Doctor: doctor,
  2635. Departments: department,
  2636. }
  2637. timestamp := time.Now().Unix()
  2638. tempTime := time.Unix(timestamp, 0)
  2639. timeFormat := tempTime.Format("20060102150405")
  2640. chrgBchno := rand.Intn(100000) + 10000
  2641. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2642. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2643. department, _ := service.GetDepartMentDetail(department)
  2644. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2645. IdCardNo := ""
  2646. if id_card_type == 1 {
  2647. // IdCardNo = medical_insurance_card
  2648. IdCardNo = patient.IdCardNo
  2649. } else {
  2650. IdCardNo = patient.IdCardNo
  2651. }
  2652. var rf []*ResultFive
  2653. json.Unmarshal([]byte(his.Iinfo), &rf)
  2654. var insutypes []*ResultFive
  2655. var insutype string
  2656. var insuplc_admdvs string
  2657. var is390 int = 0
  2658. var is310 int = 0
  2659. for _, item := range rf {
  2660. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2661. insutypes = append(insutypes, item)
  2662. }
  2663. }
  2664. if len(insutypes) == 1 {
  2665. insutype = insutypes[0].Insutype
  2666. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2667. } else {
  2668. for _, i := range insutypes {
  2669. if i.Insutype == "390" {
  2670. is390 = 1
  2671. }
  2672. if i.Insutype == "310" {
  2673. is310 = 1
  2674. }
  2675. }
  2676. }
  2677. if is390 == 1 {
  2678. insutype = "390"
  2679. }
  2680. if is310 == 1 {
  2681. insutype = "310"
  2682. }
  2683. if len(insutypes) == 0 {
  2684. insutype = "310"
  2685. }
  2686. if len(insutypes) == 2 {
  2687. insutype = med_type
  2688. }
  2689. for _, item := range rf {
  2690. if item.Insutype == insutype {
  2691. insuplc_admdvs = item.InsuplcAdmdvs
  2692. }
  2693. }
  2694. var infocode int64
  2695. var resThree ResultThree
  2696. var resThree10265 ResultThree10265
  2697. if miConfig.MdtrtareaAdmvs == "421300" {
  2698. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2699. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2700. "&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
  2701. resp, requestErr := http.Get(api)
  2702. if requestErr != nil {
  2703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2704. return
  2705. }
  2706. body, ioErr := ioutil.ReadAll(resp.Body)
  2707. if ioErr != nil {
  2708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2710. return
  2711. }
  2712. var respJSON map[string]interface{}
  2713. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2716. return
  2717. }
  2718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2719. result, _ := json.Marshal(respJSON)
  2720. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2721. utils.ErrorLog("解析失败:%v", err)
  2722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2723. return
  2724. }
  2725. infocode = resThree.Infcode
  2726. } else {
  2727. 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)
  2728. saveLog(result, requestLog, "2201", "挂号")
  2729. if miConfig.Code == "H15049901371" {
  2730. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2731. utils.ErrorLog("解析失败:%v", err)
  2732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2733. return
  2734. }
  2735. resThree.ErrMsg = resThree10265.ErrMsg
  2736. resThree.Output = resThree10265.Output
  2737. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2738. } else {
  2739. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2740. utils.ErrorLog("解析失败:%v", err)
  2741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2742. return
  2743. }
  2744. }
  2745. if miConfig.Code == "H15049901371" {
  2746. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2747. } else {
  2748. infocode = resThree.Infcode
  2749. }
  2750. }
  2751. if infocode != 0 {
  2752. adminUser := c.GetAdminUserInfo()
  2753. errlog := &models.HisOrderError{
  2754. UserOrgId: adminUser.CurrentOrgId,
  2755. Ctime: time.Now().Unix(),
  2756. Mtime: time.Now().Unix(),
  2757. ErrMsg: resThree.ErrMsg,
  2758. Status: 1,
  2759. PatientId: id,
  2760. RecordTime: recordDateTime,
  2761. Stage: 2,
  2762. }
  2763. service.CreateErrMsgLog(errlog)
  2764. c.ServeSuccessJSON(map[string]interface{}{
  2765. "failed_code": -10,
  2766. "msg": resThree.ErrMsg,
  2767. })
  2768. return
  2769. }
  2770. his.Number = resThree.Output.Data.MdtrtID
  2771. his.PsnNo = resThree.Output.Data.PsnNo
  2772. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  2773. his.IdCardNo = patient.IdCardNo
  2774. his.PhoneNumber = patient.Phone
  2775. his.UserOrgId = adminInfo.CurrentOrgId
  2776. his.Insutype = insutype
  2777. his.Ctime = time.Now().Unix()
  2778. his.Mtime = time.Now().Unix()
  2779. his.InsuplcAdmdvs = insuplc_admdvs
  2780. his.Status = 1
  2781. service.UpdateHisPatientStatus(&his)
  2782. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  2783. c.ServeSuccessJSON(map[string]interface{}{
  2784. "his_info": his,
  2785. })
  2786. } else {
  2787. adminUser := c.GetAdminUserInfo()
  2788. errlog := &models.HisOrderError{
  2789. UserOrgId: adminUser.CurrentOrgId,
  2790. Ctime: time.Now().Unix(),
  2791. Mtime: time.Now().Unix(),
  2792. ErrMsg: res.ErrMsg,
  2793. Status: 1,
  2794. PatientId: id,
  2795. RecordTime: recordDateTime,
  2796. Stage: 1,
  2797. }
  2798. service.CreateErrMsgLog(errlog)
  2799. c.ServeSuccessJSON(map[string]interface{}{
  2800. "failed_code": -10,
  2801. "msg": res.ErrMsg,
  2802. })
  2803. return
  2804. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  2805. }
  2806. }
  2807. }
  2808. //上传明细----预结算----确认订单
  2809. func (c *HisApiController) GetUploadInfo() {
  2810. id, _ := c.GetInt64("id")
  2811. record_time := c.GetString("record_time")
  2812. his_patient_id, _ := c.GetInt64("his_patient_id")
  2813. order_id, _ := c.GetInt64("order_id")
  2814. pay_way, _ := c.GetInt64("pay_way")
  2815. pay_price, _ := c.GetFloat("pay_price")
  2816. pay_card_no := c.GetString("pay_card_no")
  2817. discount_price, _ := c.GetFloat("discount_price")
  2818. preferential_price, _ := c.GetFloat("preferential_price")
  2819. reality_price, _ := c.GetFloat("reality_price")
  2820. found_price, _ := c.GetFloat("found_price")
  2821. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2822. private_price, _ := c.GetFloat("private_price")
  2823. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2824. admin_user_id, _ := c.GetInt64("admin_user_id")
  2825. fapiao_code := c.GetString("fapiao_code")
  2826. fapiao_number := c.GetString("fapiao_number")
  2827. diagnosis_id := c.GetString("diagnosis")
  2828. sick_type, _ := c.GetInt64("sick_type")
  2829. reg_type, _ := c.GetInt64("p_type")
  2830. id_str := c.GetString("ids")
  2831. ids_arr := strings.Split(id_str, ",")
  2832. timeLayout := "2006-01-02"
  2833. loc, _ := time.LoadLocation("Local")
  2834. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2835. if err != nil {
  2836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2837. return
  2838. }
  2839. recordDateTime := theTime.Unix()
  2840. adminUser := c.GetAdminUserInfo()
  2841. var tempOrder models.HisOrder
  2842. tempOrder, _ = service.GetHisOrderByID(order_id)
  2843. var prescriptions []*models.HisPrescription
  2844. var start_time int64
  2845. var end_time int64
  2846. //if adminUser.CurrentOrgId == 10106{
  2847. // if len(fapiao_code) == 0{
  2848. // fapiao_code = "144072080589"
  2849. // }
  2850. // if len(fapiao_number) == 0{
  2851. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  2852. // if order.ID == 0{
  2853. // fapiao_number = "00001520"
  2854. // }else{
  2855. // //fapiao_code = "00001520"
  2856. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  2857. // var zero string
  2858. // if fpNumber >= 1000{
  2859. // zero = "0000" + strconv.Itoa(fpNumber)
  2860. // }else if fpNumber >= 10000{
  2861. // zero = "000" + strconv.Itoa(fpNumber)
  2862. // } else if fpNumber >= 100000{
  2863. // zero = "00" + strconv.Itoa(fpNumber)
  2864. // } else if fpNumber >= 1000000{
  2865. // zero = "0" + strconv.Itoa(fpNumber)
  2866. // }else {
  2867. // zero = strconv.Itoa(fpNumber)
  2868. // }
  2869. // fapiao_number = zero
  2870. // }
  2871. // }
  2872. //}
  2873. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2874. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2875. var patientPrescription models.HisPrescriptionInfo
  2876. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2877. if patientPrescription.ID == 0 {
  2878. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2879. }
  2880. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2881. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2882. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2883. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2884. var config []*models.HisXtDiagnoseConfig
  2885. for _, item := range diagnosis_ids {
  2886. id, _ := strconv.ParseInt(item, 10, 64)
  2887. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2888. config = append(config, &diagnosisConfig)
  2889. }
  2890. sickConfig, _ := service.FindSickById(sick_type)
  2891. if tempOrder.ID == 0 {
  2892. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  2893. }
  2894. if tempOrder.ID == 0 {
  2895. var result string
  2896. var requestLog string
  2897. var res2 ResultSix
  2898. var ressix10265 ResultSix10265
  2899. if miConfig.InsuplcAdmdvs == "421300" {
  2900. data := make(map[string]interface{})
  2901. client := &http.Client{}
  2902. data["psn_no"] = his.PsnNo
  2903. data["mdtrt_id"] = his.Number
  2904. data["doctor"] = roles.UserName
  2905. data["department"] = department.Name
  2906. data["org_name"] = miConfig.OrgName
  2907. data["med_type"] = strconv.FormatInt(reg_type, 10)
  2908. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  2909. data["fixmedins_code"] = miConfig.Code
  2910. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2911. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2912. data["secret_key"] = miConfig.SecretKey
  2913. data["sick_code"] = sickConfig.CountryCode
  2914. data["sick_name"] = sickConfig.ClassName
  2915. data["dept"] = strconv.FormatInt(department.ID, 10)
  2916. data["config"] = config
  2917. bytesData, _ := json.Marshal(data)
  2918. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  2919. resp, _ := client.Do(req)
  2920. defer resp.Body.Close()
  2921. body, ioErr := ioutil.ReadAll(resp.Body)
  2922. if ioErr != nil {
  2923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2925. return
  2926. }
  2927. var respJSON map[string]interface{}
  2928. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2931. return
  2932. }
  2933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2934. userJSONBytes, _ := json.Marshal(respJSON)
  2935. fmt.Println("log")
  2936. fmt.Println(string(userJSONBytes))
  2937. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2938. utils.ErrorLog("解析失败:%v", err)
  2939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2940. return
  2941. }
  2942. } else {
  2943. if miConfig.InsuplcAdmdvs == "440781" { //
  2944. 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)
  2945. } else {
  2946. if miConfig.Code == "H15049901371" {
  2947. //赤峰地区国家医保医疗类别
  2948. //职工透析:医疗类别选特殊情况门诊990502
  2949. //居民定额血透门慢: 医疗类别选门诊慢病140104
  2950. var med_type string
  2951. if his.Insutype == "390" {
  2952. if reg_type == 14 {
  2953. med_type = "140104"
  2954. } else if reg_type == 11 {
  2955. med_type = "11"
  2956. }
  2957. } else if his.Insutype == "310" {
  2958. if reg_type == 14 {
  2959. med_type = "990502"
  2960. } else if reg_type == 11 {
  2961. med_type = "11"
  2962. }
  2963. }
  2964. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  2965. } else {
  2966. 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, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  2967. }
  2968. }
  2969. saveLog(result, requestLog, "2203", "上传就诊信息")
  2970. var respJSON2 map[string]interface{}
  2971. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2974. return
  2975. }
  2976. userJSONBytes2, _ := json.Marshal(respJSON2)
  2977. if miConfig.Code == "H15049901371" {
  2978. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  2979. utils.ErrorLog("解析失败:%v", err)
  2980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2981. return
  2982. }
  2983. res2.InfRefmsgid = ressix10265.InfRefmsgid
  2984. res2.Output = ressix10265.Output
  2985. res2.ErrMsg = ressix10265.ErrMsg
  2986. res2.Cainfo = ressix10265.Cainfo
  2987. res2.WarnMsg = ressix10265.WarnMsg
  2988. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  2989. res2.Infcode = infocode
  2990. } else {
  2991. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2992. utils.ErrorLog("解析失败:%v", err)
  2993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2994. return
  2995. }
  2996. }
  2997. }
  2998. if res2.Infcode != 0 {
  2999. adminUser := c.GetAdminUserInfo()
  3000. errlog := &models.HisOrderError{
  3001. UserOrgId: adminUser.CurrentOrgId,
  3002. Ctime: time.Now().Unix(),
  3003. Mtime: time.Now().Unix(),
  3004. ErrMsg: res2.ErrMsg,
  3005. Status: 1,
  3006. PatientId: id,
  3007. RecordTime: recordDateTime,
  3008. Stage: 3,
  3009. }
  3010. service.CreateErrMsgLog(errlog)
  3011. c.ServeSuccessJSON(map[string]interface{}{
  3012. "failed_code": -10,
  3013. "msg": res2.ErrMsg,
  3014. })
  3015. return
  3016. } else {
  3017. his.Diagnosis = diagnosis_id
  3018. his.SickType = sickConfig.ID
  3019. var p_type int64
  3020. if reg_type == 1111 || reg_type == 1112 {
  3021. p_type = 11
  3022. }
  3023. his.PType = fmt.Sprintf("%d", p_type)
  3024. service.UpdateHisPatientThree(&his)
  3025. data := make(map[string]interface{})
  3026. if settle_accounts_type == 1 { //日结
  3027. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3028. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3029. } else {
  3030. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3031. }
  3032. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3033. data["pre"] = prescriptions
  3034. } else { //月结
  3035. start_time_str := c.GetString("start_time")
  3036. end_time_str := c.GetString("end_time")
  3037. timeLayout := "2006-01-02"
  3038. loc, _ := time.LoadLocation("Local")
  3039. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3040. if err != nil {
  3041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3042. return
  3043. }
  3044. recordStartTime := theStartTime.Unix()
  3045. start_time = recordStartTime
  3046. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3047. if err != nil {
  3048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3049. return
  3050. }
  3051. recordEndTime := theEndTime.Unix()
  3052. end_time = recordEndTime
  3053. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3054. data["pre"] = prescriptions
  3055. }
  3056. timestamp := time.Now().Unix()
  3057. tempTime := time.Unix(timestamp, 0)
  3058. timeFormat := tempTime.Format("20060102150405")
  3059. chrgBchno := rand.Intn(100000) + 10000
  3060. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3061. strconv.FormatInt(his.PatientId, 10)
  3062. client := &http.Client{}
  3063. data["psn_no"] = his.PsnNo
  3064. data["mdtrt_id"] = his.Number
  3065. data["chrg_bchno"] = chrg_bchno
  3066. data["org_name"] = miConfig.OrgName
  3067. data["doctor"] = roles.UserName
  3068. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3069. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3070. data["fixmedins_code"] = miConfig.Code
  3071. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3072. data["dept_code"] = "15"
  3073. } else {
  3074. data["dept_code"] = department.Number
  3075. }
  3076. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3077. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3078. data["secret_key"] = miConfig.SecretKey
  3079. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3080. var ids []int64
  3081. for _, item := range prescriptions {
  3082. ids = append(ids, item.ID)
  3083. }
  3084. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3085. if config.IsOpen == 1 { //对接了医保,走医保流程
  3086. var res ResultFour
  3087. var resFour10265 ResultFour10265
  3088. if miConfig.MdtrtareaAdmvs == "421300" {
  3089. bytesData, _ := json.Marshal(data)
  3090. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3091. resp, _ := client.Do(req)
  3092. defer resp.Body.Close()
  3093. body, ioErr := ioutil.ReadAll(resp.Body)
  3094. if ioErr != nil {
  3095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3097. return
  3098. }
  3099. var respJSON map[string]interface{}
  3100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3103. return
  3104. }
  3105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3106. userJSONBytes, _ := json.Marshal(respJSON)
  3107. fmt.Println("log")
  3108. fmt.Println(string(userJSONBytes))
  3109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3110. utils.ErrorLog("解析失败:%v", err)
  3111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3112. return
  3113. }
  3114. } else {
  3115. 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), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10))
  3116. var dat map[string]interface{}
  3117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3118. fmt.Println(dat)
  3119. } else {
  3120. fmt.Println(err)
  3121. }
  3122. saveLog(result, request_log, "2204", "上传费用明细")
  3123. userJSONBytes, _ := json.Marshal(dat)
  3124. if miConfig.Code == "H15049901371" {
  3125. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3126. utils.ErrorLog("解析失败:%v", err)
  3127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3128. return
  3129. }
  3130. res.InfRefmsgid = resFour10265.InfRefmsgid
  3131. res.Output = resFour10265.Output
  3132. res.ErrMsg = resFour10265.ErrMsg
  3133. res.Cainfo = resFour10265.Cainfo
  3134. res.WarnMsg = resFour10265.WarnMsg
  3135. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3136. res.Infcode = infocode
  3137. } else {
  3138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3139. utils.ErrorLog("解析失败:%v", err)
  3140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3141. return
  3142. }
  3143. }
  3144. }
  3145. if res.Infcode == 0 {
  3146. order := &models.HisOrder{
  3147. UserOrgId: adminUser.CurrentOrgId,
  3148. HisPatientId: his.ID,
  3149. PatientId: his.PatientId,
  3150. SettleAccountsDate: recordDateTime,
  3151. Ctime: time.Now().Unix(),
  3152. Mtime: time.Now().Unix(),
  3153. Status: 1,
  3154. Number: chrg_bchno,
  3155. Infcode: res.Infcode,
  3156. WarnMsg: res.WarnMsg,
  3157. Cainfo: res.Cainfo,
  3158. ErrMsg: res.ErrMsg,
  3159. RespondTime: res.RefmsgTime,
  3160. InfRefmsgid: res.InfRefmsgid,
  3161. OrderStatus: 1,
  3162. PayWay: pay_way,
  3163. PayPrice: pay_price,
  3164. PayCardNo: pay_card_no,
  3165. DiscountPrice: discount_price,
  3166. PreferentialPrice: preferential_price,
  3167. RealityPrice: reality_price,
  3168. FoundPrice: found_price,
  3169. MedicalInsurancePrice: medical_insurance_price,
  3170. PrivatePrice: private_price,
  3171. IsMedicineInsurance: 1,
  3172. SettleType: settle_accounts_type,
  3173. SettleStartTime: start_time,
  3174. SettleEndTime: end_time,
  3175. Creator: roles.AdminUserId,
  3176. Modify: roles.AdminUserId,
  3177. FaPiaoNumber: fapiao_number,
  3178. FaPiaoCode: fapiao_code,
  3179. PType: 2,
  3180. Diagnosis: diagnosis_id,
  3181. }
  3182. err = service.CreateOrder(order)
  3183. if err != nil {
  3184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3185. return
  3186. }
  3187. for _, item := range res.Output.Result {
  3188. temp := strings.Split(item.FeedetlSn, "-")
  3189. var advice_id int64 = 0
  3190. var project_id int64 = 0
  3191. var types int64 = 0
  3192. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3193. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3194. if temp[1] == "1" {
  3195. advice_id = id
  3196. project_id = 0
  3197. } else if temp[1] == "2" {
  3198. advice_id = 0
  3199. project_id = id
  3200. }
  3201. info := &models.HisOrderInfo{
  3202. OrderNumber: order.Number,
  3203. FeedetlSn: item.FeedetlSn,
  3204. UploadDate: time.Now().Unix(),
  3205. AdviceId: advice_id,
  3206. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3207. Cnt: item.Cnt,
  3208. Pric: float64(item.Pric),
  3209. PatientId: his.PatientId,
  3210. PricUplmtAmt: item.PricUplmtAmt,
  3211. SelfpayProp: item.SelfpayProp,
  3212. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3213. OverlmtAmt: item.OverlmtAmt,
  3214. PreselfpayAmt: item.PreselfpayAmt,
  3215. BasMednFlag: item.BasMednFlag,
  3216. MedChrgitmType: item.MedChrgitmType,
  3217. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3218. Status: 1,
  3219. Memo: item.Memo,
  3220. Mtime: time.Now().Unix(),
  3221. InscpScpAmt: item.InscpScpAmt,
  3222. DrtReimFlag: item.DrtReimFlag,
  3223. Ctime: time.Now().Unix(),
  3224. ListSpItemFlag: item.ListSpItemFlag,
  3225. ChldMedcFlag: item.ChldMedcFlag,
  3226. LmtUsedFlag: item.LmtUsedFlag,
  3227. ChrgitmLv: item.ChrgitmLv,
  3228. UserOrgId: adminUser.CurrentOrgId,
  3229. HisPatientId: his.ID,
  3230. OrderId: order.ID,
  3231. ProjectId: project_id,
  3232. Type: types,
  3233. }
  3234. service.CreateOrderInfo(info)
  3235. }
  3236. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3237. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3238. var total float64
  3239. for _, item := range prescriptions {
  3240. if item.Type == 1 { //药品
  3241. for _, subItem := range item.HisDoctorAdviceInfo {
  3242. total = total + (subItem.Price * subItem.PrescribingNumber)
  3243. }
  3244. }
  3245. if item.Type == 2 { //项目
  3246. for _, subItem := range item.HisPrescriptionProject {
  3247. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3248. total = total + (subItem.Price * cnt)
  3249. }
  3250. }
  3251. }
  3252. for _, item := range prescriptions {
  3253. for _, subItem := range item.HisAdditionalCharge {
  3254. total = total + (subItem.Price * float64(subItem.Count))
  3255. }
  3256. }
  3257. var allTotal string
  3258. if adminUser.CurrentOrgId == 9919 {
  3259. allTotal = fmt.Sprintf("%.2f", total)
  3260. } else {
  3261. allTotal = fmt.Sprintf("%.4f", total)
  3262. }
  3263. if res.Infcode == 0 {
  3264. var rf []*ResultFive
  3265. json.Unmarshal([]byte(his.Iinfo), &rf)
  3266. chrg_bchno := chrg_bchno
  3267. cert_no := his.Certno
  3268. var insutypes []string
  3269. var insutype string
  3270. var is390 int = 0
  3271. var is310 int = 0
  3272. for _, item := range rf {
  3273. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3274. insutypes = append(insutypes, item.Insutype)
  3275. }
  3276. }
  3277. if len(insutypes) == 1 {
  3278. insutype = insutypes[0]
  3279. } else {
  3280. for _, i := range insutypes {
  3281. if i == "390" {
  3282. is390 = 1
  3283. }
  3284. if i == "310" {
  3285. is310 = 1
  3286. }
  3287. }
  3288. }
  3289. if is390 == 1 {
  3290. insutype = "390"
  3291. }
  3292. if is310 == 1 {
  3293. insutype = "310"
  3294. }
  3295. if len(insutypes) == 0 {
  3296. insutype = "310"
  3297. }
  3298. if len(insutypes) == 2 {
  3299. insutype = strconv.FormatInt(his.SocialType, 10)
  3300. }
  3301. //insutype = "390"
  3302. if his.IdCardType == 1 {
  3303. // cert_no = his.MedicalInsuranceNumber
  3304. cert_no = his.Certno
  3305. } else {
  3306. cert_no = his.Certno
  3307. }
  3308. var res ResultSeven
  3309. var resSeven10265 ResultSeven10265
  3310. var src_resquest string
  3311. var result2 string
  3312. var acct_used_flag string
  3313. fmt.Println("pay_way")
  3314. fmt.Println(pay_way)
  3315. fmt.Println("pay_way")
  3316. if pay_way == 4 {
  3317. acct_used_flag = "1"
  3318. } else {
  3319. acct_used_flag = "0"
  3320. }
  3321. if miConfig.MdtrtareaAdmvs == "421300" {
  3322. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3323. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3324. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3325. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3326. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3327. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3328. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3329. resp, requestErr := http.Get(api)
  3330. if requestErr != nil {
  3331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3332. return
  3333. }
  3334. body, ioErr := ioutil.ReadAll(resp.Body)
  3335. if ioErr != nil {
  3336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3338. return
  3339. }
  3340. var respJSON map[string]interface{}
  3341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3347. result, _ := json.Marshal(respJSON)
  3348. if miConfig.Code == "H15049901371" {
  3349. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3350. utils.ErrorLog("解析失败:%v", err)
  3351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3352. return
  3353. }
  3354. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3355. res.Output = resSeven10265.Output
  3356. res.ErrMsg = resSeven10265.ErrMsg
  3357. res.Cainfo = resSeven10265.Cainfo
  3358. res.WarnMsg = resSeven10265.WarnMsg
  3359. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3360. res.Infcode = infocode
  3361. } else {
  3362. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3363. utils.ErrorLog("解析失败:%v", err)
  3364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3365. return
  3366. }
  3367. }
  3368. } else {
  3369. if miConfig.Code == "H15049901371" {
  3370. //赤峰地区国家医保医疗类别
  3371. //职工透析:医疗类别选特殊情况门诊990502
  3372. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3373. var med_type string
  3374. if his.Insutype == "390" {
  3375. if reg_type == 14 {
  3376. med_type = "140104"
  3377. } else if reg_type == 11 {
  3378. med_type = "11"
  3379. }
  3380. } else if his.Insutype == "310" {
  3381. if reg_type == 14 {
  3382. med_type = "990502"
  3383. } else if reg_type == 11 {
  3384. med_type = "11"
  3385. }
  3386. }
  3387. 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, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3388. } else {
  3389. 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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3390. }
  3391. //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)
  3392. var dat map[string]interface{}
  3393. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3394. fmt.Println(dat)
  3395. } else {
  3396. fmt.Println(err)
  3397. }
  3398. saveLog(result2, src_resquest, "2207", "结算")
  3399. userJSONBytes, _ := json.Marshal(dat)
  3400. if miConfig.Code == "H15049901371" {
  3401. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3402. utils.ErrorLog("解析失败:%v", err)
  3403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3404. return
  3405. }
  3406. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3407. res.Output = resSeven10265.Output
  3408. res.ErrMsg = resSeven10265.ErrMsg
  3409. res.Cainfo = resSeven10265.Cainfo
  3410. res.WarnMsg = resSeven10265.WarnMsg
  3411. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3412. res.Infcode = infocode
  3413. } else {
  3414. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3415. utils.ErrorLog("解析失败:%v", err)
  3416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3417. return
  3418. }
  3419. }
  3420. }
  3421. if res.Infcode != 0 {
  3422. errlog := &models.HisOrderError{
  3423. UserOrgId: adminUser.CurrentOrgId,
  3424. Ctime: time.Now().Unix(),
  3425. Mtime: time.Now().Unix(),
  3426. Number: chrg_bchno,
  3427. ErrMsg: res.ErrMsg,
  3428. Status: 1,
  3429. PatientId: id,
  3430. RecordTime: recordDateTime,
  3431. Stage: 6,
  3432. }
  3433. service.CreateErrMsgLog(errlog)
  3434. c.ServeSuccessJSON(map[string]interface{}{
  3435. "failed_code": -10,
  3436. "msg": res.ErrMsg,
  3437. })
  3438. return
  3439. } else {
  3440. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3441. order.OrderStatus = 2
  3442. order.Status = 1
  3443. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3444. order.SetlId = res.Output.Setlinfo.SetlID
  3445. order.PsnNo = res.Output.Setlinfo.PsnNo
  3446. order.PsnName = res.Output.Setlinfo.PsnName
  3447. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3448. order.Certno = res.Output.Setlinfo.Certno
  3449. order.Gend = res.Output.Setlinfo.Gend
  3450. order.Naty = res.Output.Setlinfo.Naty
  3451. order.Age = res.Output.Setlinfo.Age
  3452. order.Insutype = res.Output.Setlinfo.Insutype
  3453. order.PsnType = res.Output.Setlinfo.PsnType
  3454. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3455. order.SetlTime = res.Output.Setlinfo.SetlTime
  3456. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3457. if res.Output.Setlinfo.MedType == "140101" {
  3458. order.MedType = "14"
  3459. } else {
  3460. order.MedType = res.Output.Setlinfo.MedType
  3461. }
  3462. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3463. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3464. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3465. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3466. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3467. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3468. order.HifpPay = res.Output.Setlinfo.HifpPay
  3469. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3470. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3471. order.HifesPay = res.Output.Setlinfo.HifesPay
  3472. order.HifobPay = res.Output.Setlinfo.HifobPay
  3473. order.MafPay = res.Output.Setlinfo.MafPay
  3474. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3475. order.OthPay = res.Output.Setlinfo.OthPay
  3476. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3477. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3478. order.AcctPay = res.Output.Setlinfo.AcctPay
  3479. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3480. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3481. order.Balc = res.Output.Setlinfo.Balc
  3482. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3483. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3484. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3485. order.ClrWay = res.Output.Setlinfo.ClrWay
  3486. order.Creator = order.Creator
  3487. order.Modify = roles.AdminUserId
  3488. order.RequestLog = src_resquest
  3489. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3490. detailStr := string(setlDetail)
  3491. order.SetlDetail = detailStr
  3492. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3493. err = service.UpDateOrder(order)
  3494. if err == nil {
  3495. c.ServeSuccessJSON(map[string]interface{}{
  3496. "msg": "结算成功",
  3497. })
  3498. } else {
  3499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3500. return
  3501. }
  3502. }
  3503. } else {
  3504. adminUser := c.GetAdminUserInfo()
  3505. errlog := &models.HisOrderError{
  3506. UserOrgId: adminUser.CurrentOrgId,
  3507. Ctime: time.Now().Unix(),
  3508. Mtime: time.Now().Unix(),
  3509. ErrMsg: res.ErrMsg,
  3510. Status: 1,
  3511. PatientId: id,
  3512. RecordTime: recordDateTime,
  3513. Stage: 4,
  3514. }
  3515. service.CreateErrMsgLog(errlog)
  3516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3517. return
  3518. }
  3519. } else {
  3520. adminUser := c.GetAdminUserInfo()
  3521. errlog := &models.HisOrderError{
  3522. UserOrgId: adminUser.CurrentOrgId,
  3523. Ctime: time.Now().Unix(),
  3524. Mtime: time.Now().Unix(),
  3525. ErrMsg: res.ErrMsg,
  3526. Status: 1,
  3527. PatientId: id,
  3528. RecordTime: recordDateTime,
  3529. Stage: 4,
  3530. }
  3531. service.CreateErrMsgLog(errlog)
  3532. c.ServeSuccessJSON(map[string]interface{}{
  3533. "failed_code": -10,
  3534. "msg": res.ErrMsg,
  3535. })
  3536. return
  3537. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3538. //return
  3539. }
  3540. }
  3541. }
  3542. } else if tempOrder.ID > 0 {
  3543. if tempOrder.IsPre == 1 {
  3544. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3545. var rf []*ResultFive
  3546. json.Unmarshal([]byte(his.Iinfo), &rf)
  3547. chrg_bchno := tempOrder.Number
  3548. cert_no := his.Certno
  3549. var insutypes []string
  3550. var insutype string
  3551. var is390 int = 0
  3552. var is310 int = 0
  3553. for _, item := range rf {
  3554. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3555. insutypes = append(insutypes, item.Insutype)
  3556. }
  3557. }
  3558. if len(insutypes) == 1 {
  3559. insutype = insutypes[0]
  3560. } else {
  3561. for _, i := range insutypes {
  3562. if i == "390" {
  3563. is390 = 1
  3564. }
  3565. if i == "310" {
  3566. is310 = 1
  3567. }
  3568. }
  3569. }
  3570. if is390 == 1 {
  3571. insutype = "390"
  3572. }
  3573. if is310 == 1 {
  3574. insutype = "310"
  3575. }
  3576. if len(insutypes) == 0 {
  3577. insutype = "310"
  3578. }
  3579. if len(insutypes) == 2 {
  3580. insutype = strconv.FormatInt(his.SocialType, 64)
  3581. }
  3582. //insutype = "390"
  3583. if his.IdCardType == 1 {
  3584. // cert_no = his.MedicalInsuranceNumber
  3585. cert_no = his.Certno
  3586. } else {
  3587. cert_no = his.Certno
  3588. }
  3589. var res ResultSeven
  3590. var resSeven10265 ResultSeven10265
  3591. var src_resquest string
  3592. var result2 string
  3593. var acct_used_flag string
  3594. fmt.Println("pay_way")
  3595. fmt.Println(pay_way)
  3596. fmt.Println("pay_way")
  3597. if pay_way == 4 {
  3598. acct_used_flag = "1"
  3599. } else {
  3600. acct_used_flag = "0"
  3601. }
  3602. if miConfig.MdtrtareaAdmvs == "421300" {
  3603. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3604. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3605. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3606. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3607. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3608. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3609. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3610. resp, requestErr := http.Get(api)
  3611. if requestErr != nil {
  3612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3613. return
  3614. }
  3615. body, ioErr := ioutil.ReadAll(resp.Body)
  3616. if ioErr != nil {
  3617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. var respJSON map[string]interface{}
  3622. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3625. return
  3626. }
  3627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3628. result, _ := json.Marshal(respJSON)
  3629. fmt.Println("log")
  3630. fmt.Println(string(result))
  3631. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3632. utils.ErrorLog("解析失败:%v", err)
  3633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3634. return
  3635. }
  3636. } else {
  3637. var src_resquest string
  3638. if miConfig.Code == "H15049901371" {
  3639. //赤峰地区国家医保医疗类别
  3640. //职工透析:医疗类别选特殊情况门诊990502
  3641. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3642. var med_type string
  3643. if his.Insutype == "390" {
  3644. if reg_type == 14 {
  3645. med_type = "140104"
  3646. } else if reg_type == 11 {
  3647. med_type = "11"
  3648. }
  3649. } else if his.Insutype == "310" {
  3650. if reg_type == 14 {
  3651. med_type = "990502"
  3652. } else if reg_type == 11 {
  3653. med_type = "11"
  3654. }
  3655. }
  3656. 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, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3657. } else {
  3658. 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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3659. }
  3660. var dat map[string]interface{}
  3661. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3662. fmt.Println(dat)
  3663. } else {
  3664. fmt.Println(err)
  3665. }
  3666. saveLog(result2, src_resquest, "2207", "结算")
  3667. userJSONBytes, _ := json.Marshal(dat)
  3668. if miConfig.Code == "H15049901371" {
  3669. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3670. utils.ErrorLog("解析失败:%v", err)
  3671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3672. return
  3673. }
  3674. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3675. res.Output = resSeven10265.Output
  3676. res.ErrMsg = resSeven10265.ErrMsg
  3677. res.Cainfo = resSeven10265.Cainfo
  3678. res.WarnMsg = resSeven10265.WarnMsg
  3679. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3680. res.Infcode = infocode
  3681. } else {
  3682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3683. utils.ErrorLog("解析失败:%v", err)
  3684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3685. return
  3686. }
  3687. }
  3688. }
  3689. if res.Infcode != 0 {
  3690. errlog := &models.HisOrderError{
  3691. UserOrgId: adminUser.CurrentOrgId,
  3692. Ctime: time.Now().Unix(),
  3693. Mtime: time.Now().Unix(),
  3694. Number: chrg_bchno,
  3695. ErrMsg: res.ErrMsg,
  3696. Status: 1,
  3697. PatientId: id,
  3698. RecordTime: recordDateTime,
  3699. Stage: 6,
  3700. }
  3701. service.CreateErrMsgLog(errlog)
  3702. c.ServeSuccessJSON(map[string]interface{}{
  3703. "failed_code": -10,
  3704. "msg": res.ErrMsg,
  3705. })
  3706. return
  3707. } else {
  3708. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3709. order.OrderStatus = 2
  3710. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3711. order.SetlId = res.Output.Setlinfo.SetlID
  3712. order.PsnNo = res.Output.Setlinfo.PsnNo
  3713. order.PsnName = res.Output.Setlinfo.PsnName
  3714. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3715. order.Certno = res.Output.Setlinfo.Certno
  3716. order.Gend = res.Output.Setlinfo.Gend
  3717. order.Naty = res.Output.Setlinfo.Naty
  3718. order.Age = res.Output.Setlinfo.Age
  3719. order.Insutype = res.Output.Setlinfo.Insutype
  3720. order.PsnType = res.Output.Setlinfo.PsnType
  3721. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3722. order.SetlTime = res.Output.Setlinfo.SetlTime
  3723. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3724. order.MedType = res.Output.Setlinfo.MedType
  3725. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3726. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3727. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3728. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3729. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3730. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3731. order.HifpPay = res.Output.Setlinfo.HifpPay
  3732. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3733. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3734. order.HifesPay = res.Output.Setlinfo.HifesPay
  3735. order.HifobPay = res.Output.Setlinfo.HifobPay
  3736. order.MafPay = res.Output.Setlinfo.MafPay
  3737. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3738. order.OthPay = res.Output.Setlinfo.OthPay
  3739. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3740. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3741. order.AcctPay = res.Output.Setlinfo.AcctPay
  3742. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3743. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3744. order.Balc = res.Output.Setlinfo.Balc
  3745. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3746. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3747. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3748. order.ClrWay = res.Output.Setlinfo.ClrWay
  3749. order.Creator = order.Creator
  3750. order.Modify = roles.AdminUserId
  3751. order.RequestLog = src_resquest
  3752. order.Diagnosis = diagnosis_id
  3753. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3754. detailStr := string(setlDetail)
  3755. order.SetlDetail = detailStr
  3756. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3757. err = service.UpDateOrder(order)
  3758. if err == nil {
  3759. c.ServeSuccessJSON(map[string]interface{}{
  3760. "msg": "结算成功",
  3761. })
  3762. } else {
  3763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3764. return
  3765. }
  3766. }
  3767. }
  3768. }
  3769. }
  3770. //func (c *HisApiController) GetPreUploadInfo() {
  3771. // id, _ := c.GetInt64("id")
  3772. // record_time := c.GetString("record_time")
  3773. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3774. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3775. //
  3776. // timeLayout := "2006-01-02"
  3777. // loc, _ := time.LoadLocation("Local")
  3778. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3779. // if err != nil {
  3780. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3781. // return
  3782. // }
  3783. // recordDateTime := theTime.Unix()
  3784. // adminUser := c.GetAdminUserInfo()
  3785. //
  3786. // var prescriptions []*models.HisPrescription
  3787. //
  3788. // var start_time int64
  3789. // var end_time int64
  3790. //
  3791. // data := make(map[string]interface{})
  3792. // if settle_accounts_type == 1 { //日结
  3793. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3794. // data["pre"] = prescriptions
  3795. //
  3796. // } else { //月结
  3797. // start_time_str := c.GetString("start_time")
  3798. // end_time_str := c.GetString("end_time")
  3799. // timeLayout := "2006-01-02"
  3800. // loc, _ := time.LoadLocation("Local")
  3801. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3802. // if err != nil {
  3803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3804. // return
  3805. // }
  3806. // recordStartTime := theStartTime.Unix()
  3807. // start_time = recordStartTime
  3808. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3809. // if err != nil {
  3810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3811. // return
  3812. // }
  3813. // recordEndTime := theEndTime.Unix()
  3814. // end_time = recordEndTime
  3815. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3816. // data["pre"] = prescriptions
  3817. //
  3818. // }
  3819. //
  3820. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3821. //
  3822. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3823. // timestamp := time.Now().Unix()
  3824. // tempTime := time.Unix(timestamp, 0)
  3825. // timeFormat := tempTime.Format("20060102150405")
  3826. // chrgBchno := rand.Intn(100000) + 10000
  3827. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3828. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3829. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3830. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3831. // strconv.FormatInt(his.PatientId, 10)
  3832. // client := &http.Client{}
  3833. // data["psn_no"] = his.PsnNo
  3834. // data["mdtrt_id"] = his.Number
  3835. // data["chrg_bchno"] = chrg_bchno
  3836. // data["org_name"] = miConfig.OrgName
  3837. // data["doctor"] = roles.UserName
  3838. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3839. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3840. // data["fixmedins_code"] = miConfig.Code
  3841. // data["dept_code"] = department.Number
  3842. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3843. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3844. // data["secret_key"] = miConfig.SecretKey
  3845. // var ids []int64
  3846. //
  3847. // for _, item := range prescriptions {
  3848. // ids = append(ids, item.ID)
  3849. // }
  3850. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3851. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3852. // bytesData, _ := json.Marshal(data)
  3853. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3854. // resp, _ := client.Do(req)
  3855. // defer resp.Body.Close()
  3856. // body, ioErr := ioutil.ReadAll(resp.Body)
  3857. // if ioErr != nil {
  3858. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3860. // return
  3861. // }
  3862. // var respJSON map[string]interface{}
  3863. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3864. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. // return
  3867. // }
  3868. //
  3869. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3870. // userJSONBytes, _ := json.Marshal(respJSON)
  3871. // var res ResultFour
  3872. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3873. // utils.ErrorLog("解析失败:%v", err)
  3874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3875. // return
  3876. // }
  3877. //
  3878. // if res.Infcode == 0 {
  3879. // order := &models.HisOrder{
  3880. // UserOrgId: adminUser.CurrentOrgId,
  3881. // HisPatientId: his.ID,
  3882. // PatientId: his.PatientId,
  3883. // SettleAccountsDate: recordDateTime,
  3884. // Ctime: time.Now().Unix(),
  3885. // Mtime: time.Now().Unix(),
  3886. // Status: 1,
  3887. // Number: chrg_bchno,
  3888. // Infcode: res.Infcode,
  3889. // WarnMsg: res.WarnMsg,
  3890. // Cainfo: res.Cainfo,
  3891. // ErrMsg: res.ErrMsg,
  3892. // RespondTime: res.RefmsgTime,
  3893. // InfRefmsgid: res.InfRefmsgid,
  3894. // OrderStatus: 1,
  3895. // IsMedicineInsurance: 1,
  3896. // SettleType: settle_accounts_type,
  3897. // SettleStartTime: start_time,
  3898. // SettleEndTime: end_time,
  3899. // Creator: roles.ID,
  3900. // Modify: roles.ID,
  3901. // PType: 2,
  3902. // }
  3903. // err = service.CreateOrder(order)
  3904. // if err != nil {
  3905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3906. // return
  3907. // }
  3908. //
  3909. // for _, item := range res.Output.Result {
  3910. // temp := strings.Split(item.FeedetlSn, "-")
  3911. // var advice_id int64 = 0
  3912. // var project_id int64 = 0
  3913. // var types int64 = 0
  3914. //
  3915. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  3916. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  3917. //
  3918. // if temp[1] == "1" {
  3919. // advice_id = id
  3920. // project_id = 0
  3921. // } else if temp[1] == "2" {
  3922. // advice_id = 0
  3923. // project_id = id
  3924. // }
  3925. //
  3926. // info := &models.HisOrderInfo{
  3927. // OrderNumber: order.Number,
  3928. // FeedetlSn: item.FeedetlSn,
  3929. // UploadDate: time.Now().Unix(),
  3930. // AdviceId: advice_id,
  3931. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  3932. // Cnt: item.Cnt,
  3933. // Pric: float64(item.Pric),
  3934. // PatientId: his.PatientId,
  3935. // PricUplmtAmt: item.PricUplmtAmt,
  3936. // SelfpayProp: item.SelfpayProp,
  3937. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3938. // OverlmtAmt: item.OverlmtAmt,
  3939. // PreselfpayAmt: item.PreselfpayAmt,
  3940. // BasMednFlag: item.BasMednFlag,
  3941. // MedChrgitmType: item.MedChrgitmType,
  3942. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  3943. // Status: 1,
  3944. // Memo: item.Memo,
  3945. // Mtime: time.Now().Unix(),
  3946. // InscpScpAmt: item.InscpScpAmt,
  3947. // DrtReimFlag: item.DrtReimFlag,
  3948. // Ctime: time.Now().Unix(),
  3949. // ListSpItemFlag: item.ListSpItemFlag,
  3950. // ChldMedcFlag: item.ChldMedcFlag,
  3951. // LmtUsedFlag: item.LmtUsedFlag,
  3952. // ChrgitmLv: item.ChrgitmLv,
  3953. // UserOrgId: adminUser.CurrentOrgId,
  3954. // HisPatientId: his.ID,
  3955. // OrderId: order.ID,
  3956. // ProjectId: project_id,
  3957. // Type: types,
  3958. // }
  3959. // service.CreateOrderInfo(info)
  3960. //
  3961. // }
  3962. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3963. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  3964. //
  3965. // var total float64
  3966. // for _, item := range prescriptions {
  3967. // if item.Type == 1 { //药品
  3968. // for _, subItem := range item.HisDoctorAdviceInfo {
  3969. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3970. // }
  3971. // }
  3972. // if item.Type == 2 { //项目
  3973. // for _, subItem := range item.HisPrescriptionProject {
  3974. // total = total + (subItem.Price * float64(subItem.Count))
  3975. // }
  3976. // }
  3977. // }
  3978. //
  3979. // for _, item := range prescriptions {
  3980. // for _, subItem := range item.HisAdditionalCharge {
  3981. // total = total + (subItem.Price * float64(subItem.Count))
  3982. // }
  3983. // }
  3984. //
  3985. // allTotal := fmt.Sprintf("%.2f", total)
  3986. // if res.Infcode == 0 {
  3987. // var rf []*ResultFive
  3988. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3989. // psn_no := his.PsnNo
  3990. // mdtrt_id := his.Number
  3991. // chrg_bchno := chrg_bchno
  3992. // cert_no := his.Certno
  3993. // insutype := rf[0].Insutype
  3994. //
  3995. // if his.IdCardType == 1 {
  3996. // cert_no = his.MedicalInsuranceNumber
  3997. //
  3998. // } else {
  3999. //
  4000. // cert_no = his.Certno
  4001. //
  4002. // }
  4003. //
  4004. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4005. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4006. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4007. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4008. // resp, requestErr := http.Get(api)
  4009. // if requestErr != nil {
  4010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4011. // return
  4012. // }
  4013. // defer resp.Body.Close()
  4014. // body, ioErr := ioutil.ReadAll(resp.Body)
  4015. // if ioErr != nil {
  4016. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4018. // return
  4019. // }
  4020. // var respJSON map[string]interface{}
  4021. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4022. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4023. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4024. // return
  4025. // }
  4026. // fmt.Println(respJSON)
  4027. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4028. // userJSONBytes, _ := json.Marshal(respJSON)
  4029. // var res ResultSeven
  4030. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4031. // utils.ErrorLog("解析失败:%v", err)
  4032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4033. // return
  4034. // }
  4035. // if res.Infcode != 0 {
  4036. // errlog := &models.HisOrderError{
  4037. // UserOrgId: adminUser.CurrentOrgId,
  4038. // Ctime: time.Now().Unix(),
  4039. // Mtime: time.Now().Unix(),
  4040. // Number: chrg_bchno,
  4041. // ErrMsg: res.ErrMsg,
  4042. // Status: 1,
  4043. // PatientId: id,
  4044. // RecordTime: recordDateTime,
  4045. // Stage: 7,
  4046. // }
  4047. // service.CreateErrMsgLog(errlog)
  4048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4049. // return
  4050. // } else {
  4051. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4052. // order.OrderStatus = 1
  4053. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4054. // order.SetlId = res.Output.Setlinfo.SetlID
  4055. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4056. // order.PsnName = res.Output.Setlinfo.PsnName
  4057. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4058. // order.Certno = res.Output.Setlinfo.Certno
  4059. // order.Gend = res.Output.Setlinfo.Gend
  4060. // order.Naty = res.Output.Setlinfo.Naty
  4061. // order.Age = res.Output.Setlinfo.Age
  4062. // order.Insutype = res.Output.Setlinfo.Insutype
  4063. // order.PsnType = res.Output.Setlinfo.PsnType
  4064. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4065. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4066. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4067. // order.MedType = res.Output.Setlinfo.MedType
  4068. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4069. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4070. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4071. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4072. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4073. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4074. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4075. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4076. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4077. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4078. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4079. // order.MafPay = res.Output.Setlinfo.MafPay
  4080. // order.OthPay = res.Output.Setlinfo.OthPay
  4081. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4082. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4083. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4084. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4085. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4086. // order.Balc = res.Output.Setlinfo.Balc
  4087. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4088. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4089. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4090. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4091. // order.Creator = order.Creator
  4092. // order.Modify = roles.ID
  4093. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4094. // detailStr := string(setlDetail)
  4095. // order.SetlDetail = detailStr
  4096. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4097. // err = service.UpDateOrder(order)
  4098. // if err == nil {
  4099. // c.ServeSuccessJSON(map[string]interface{}{
  4100. // "msg": "预结算成功",
  4101. // })
  4102. // } else {
  4103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4104. // return
  4105. // }
  4106. // }
  4107. // } else {
  4108. // adminUser := c.GetAdminUserInfo()
  4109. // errlog := &models.HisOrderError{
  4110. // UserOrgId: adminUser.CurrentOrgId,
  4111. // Ctime: time.Now().Unix(),
  4112. // Mtime: time.Now().Unix(),
  4113. // ErrMsg: res.ErrMsg,
  4114. // Status: 1,
  4115. // PatientId: id,
  4116. // RecordTime: recordDateTime,
  4117. // Stage: 4,
  4118. // }
  4119. // service.CreateErrMsgLog(errlog)
  4120. //
  4121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4122. // return
  4123. // }
  4124. // } else {
  4125. // adminUser := c.GetAdminUserInfo()
  4126. // errlog := &models.HisOrderError{
  4127. // UserOrgId: adminUser.CurrentOrgId,
  4128. // Ctime: time.Now().Unix(),
  4129. // Mtime: time.Now().Unix(),
  4130. // ErrMsg: res.ErrMsg,
  4131. // Status: 1,
  4132. // PatientId: id,
  4133. // RecordTime: recordDateTime,
  4134. // Stage: 4,
  4135. // }
  4136. // service.CreateErrMsgLog(errlog)
  4137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4138. // return
  4139. // }
  4140. //
  4141. // } else {
  4142. // var total float64
  4143. // for _, item := range prescriptions {
  4144. // if item.Type == 1 { //药品
  4145. // for _, subItem := range item.HisDoctorAdviceInfo {
  4146. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4147. // }
  4148. // }
  4149. // if item.Type == 2 { //项目
  4150. // for _, subItem := range item.HisPrescriptionProject {
  4151. // total = total + (subItem.Price * float64(subItem.Count))
  4152. // }
  4153. // }
  4154. //
  4155. // for _, subItem := range item.HisAdditionalCharge {
  4156. // total = total + (subItem.Price * float64(subItem.Count))
  4157. // }
  4158. // }
  4159. //
  4160. // allTotal := fmt.Sprintf("%.2f", total)
  4161. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4162. // order := &models.HisOrder{
  4163. // UserOrgId: adminUser.CurrentOrgId,
  4164. // HisPatientId: his.ID,
  4165. // PatientId: id,
  4166. // SettleAccountsDate: recordDateTime,
  4167. // Ctime: time.Now().Unix(),
  4168. // Mtime: time.Now().Unix(),
  4169. // Status: 1,
  4170. // OrderStatus: 2,
  4171. // Number: chrg_bchno,
  4172. // MedfeeSumamt: totals,
  4173. // }
  4174. // err = service.CreateOrder(order)
  4175. // if err != nil {
  4176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4177. // return
  4178. // }
  4179. //
  4180. // var customs []*Custom
  4181. // for _, item := range prescriptions {
  4182. //
  4183. // if item.Type == 1 { //药品
  4184. // for _, subItem := range item.HisDoctorAdviceInfo {
  4185. // cus := &Custom{
  4186. // AdviceId: subItem.ID,
  4187. // ProjectId: 0,
  4188. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4189. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4190. // FeedetlSn: subItem.FeedetlSn,
  4191. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4192. // MedListCodg: subItem.MedListCodg,
  4193. // Type: 1,
  4194. // }
  4195. // customs = append(customs, cus)
  4196. // }
  4197. // }
  4198. //
  4199. // if item.Type == 2 { //项目
  4200. // for _, subItem := range item.HisPrescriptionProject {
  4201. //
  4202. // cus := &Custom{
  4203. // AdviceId: 0,
  4204. // ProjectId: subItem.ID,
  4205. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4206. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4207. // FeedetlSn: subItem.FeedetlSn,
  4208. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4209. // MedListCodg: subItem.MedListCodg,
  4210. // Type: 2,
  4211. // }
  4212. //
  4213. // customs = append(customs, cus)
  4214. // }
  4215. // }
  4216. //
  4217. // for _, item := range item.HisAdditionalCharge {
  4218. // cus := &Custom{
  4219. // ItemId: item.ID,
  4220. // AdviceId: 0,
  4221. // ProjectId: 0,
  4222. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4223. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4224. // FeedetlSn: item.FeedetlSn,
  4225. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4226. // MedListCodg: item.XtHisAddtionConfig.Code,
  4227. // Type: 3,
  4228. // }
  4229. //
  4230. // customs = append(customs, cus)
  4231. // }
  4232. //
  4233. // }
  4234. //
  4235. // for _, item := range customs {
  4236. // var advice_id int64 = 0
  4237. // var project_id int64 = 0
  4238. // var item_id int64 = 0
  4239. //
  4240. // var types int64 = 0
  4241. //
  4242. // if item.Type == 1 {
  4243. // advice_id = item.AdviceId
  4244. // project_id = 0
  4245. // item_id = 0
  4246. // } else if item.Type == 2 {
  4247. // advice_id = 0
  4248. // item_id = 0
  4249. //
  4250. // project_id = item.ProjectId
  4251. // } else if item.Type == 3 {
  4252. // advice_id = 0
  4253. // item_id = item.ItemId
  4254. // project_id = 0
  4255. // }
  4256. //
  4257. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4258. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4259. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4260. //
  4261. // info := &models.HisOrderInfo{
  4262. // OrderNumber: order.Number,
  4263. // UploadDate: time.Now().Unix(),
  4264. // AdviceId: advice_id,
  4265. // DetItemFeeSumamt: detItemFeeSumamt,
  4266. // Cnt: cut,
  4267. // Pric: pric,
  4268. // PatientId: id,
  4269. // Status: 1,
  4270. // Mtime: time.Now().Unix(),
  4271. // Ctime: time.Now().Unix(),
  4272. // UserOrgId: adminUser.CurrentOrgId,
  4273. // HisPatientId: his.ID,
  4274. // OrderId: order.ID,
  4275. // ProjectId: project_id,
  4276. // Type: types,
  4277. // ItemId: item_id,
  4278. // }
  4279. // service.CreateOrderInfo(info)
  4280. // }
  4281. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4282. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4283. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4284. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4285. // if err == nil {
  4286. // c.ServeSuccessJSON(map[string]interface{}{
  4287. // "msg": "结算成功",
  4288. // })
  4289. // } else {
  4290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4291. // return
  4292. // }
  4293. // }
  4294. //}
  4295. //上传明细-预结算-
  4296. func (c *HisApiController) GetPreUploadInfo() {
  4297. id, _ := c.GetInt64("id")
  4298. record_time := c.GetString("record_time")
  4299. his_patient_id, _ := c.GetInt64("his_patient_id")
  4300. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4301. admin_user_id, _ := c.GetInt64("admin_user_id")
  4302. diagnosis_id := c.GetString("diagnosis")
  4303. sick_type, _ := c.GetInt64("sick_type")
  4304. reg_type, _ := c.GetInt64("p_type")
  4305. id_str := c.GetString("ids")
  4306. ids_arr := strings.Split(id_str, ",")
  4307. timeLayout := "2006-01-02"
  4308. loc, _ := time.LoadLocation("Local")
  4309. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4310. if err != nil {
  4311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4312. return
  4313. }
  4314. recordDateTime := theTime.Unix()
  4315. adminUser := c.GetAdminUserInfo()
  4316. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4317. var config []*models.HisXtDiagnoseConfig
  4318. for _, item := range diagnosis_ids {
  4319. id, _ := strconv.ParseInt(item, 10, 64)
  4320. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4321. config = append(config, &diagnosisConfig)
  4322. }
  4323. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4324. sickConfig, _ := service.FindSickById(sick_type)
  4325. var prescriptions []*models.HisPrescription
  4326. var start_time int64
  4327. var end_time int64
  4328. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4329. fmt.Println(his_patient_id)
  4330. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4331. timestamp := time.Now().Unix()
  4332. tempTime := time.Unix(timestamp, 0)
  4333. timeFormat := tempTime.Format("20060102150405")
  4334. chrgBchno := rand.Intn(100000) + 10000
  4335. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4336. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4337. var patientPrescription models.HisPrescriptionInfo
  4338. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4339. if patientPrescription.ID == 0 {
  4340. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4341. }
  4342. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4343. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4344. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4345. strconv.FormatInt(his.PatientId, 10)
  4346. var res2 ResultSix
  4347. var resSix10265 ResultSix10265
  4348. if miConfig.InsuplcAdmdvs == "421300" {
  4349. data := make(map[string]interface{})
  4350. client := &http.Client{}
  4351. data["psn_no"] = his.PsnNo
  4352. data["mdtrt_id"] = his.Number
  4353. data["doctor"] = roles.UserName
  4354. data["department"] = department.Name
  4355. data["org_name"] = miConfig.OrgName
  4356. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4357. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4358. data["fixmedins_code"] = miConfig.Code
  4359. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4360. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4361. data["secret_key"] = miConfig.SecretKey
  4362. data["sick_code"] = sickConfig.CountryCode
  4363. data["sick_name"] = sickConfig.ClassName
  4364. data["dept"] = strconv.FormatInt(department.ID, 10)
  4365. data["config"] = config
  4366. fmt.Println(data)
  4367. bytesData, _ := json.Marshal(data)
  4368. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4369. resp, _ := client.Do(req)
  4370. defer resp.Body.Close()
  4371. body, ioErr := ioutil.ReadAll(resp.Body)
  4372. if ioErr != nil {
  4373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4375. return
  4376. }
  4377. var respJSON map[string]interface{}
  4378. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4381. return
  4382. }
  4383. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4384. userJSONBytes, _ := json.Marshal(respJSON)
  4385. fmt.Println("log")
  4386. fmt.Println(string(userJSONBytes))
  4387. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4388. utils.ErrorLog("解析失败:%v", err)
  4389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4390. return
  4391. }
  4392. } else {
  4393. var result string
  4394. var requestLog string
  4395. if miConfig.InsuplcAdmdvs == "440781" { //
  4396. 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)
  4397. } else {
  4398. if miConfig.Code == "H15049901371" {
  4399. //赤峰地区国家医保医疗类别
  4400. //职工透析:医疗类别选特殊情况门诊990502
  4401. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4402. var med_type string
  4403. if his.Insutype == "390" {
  4404. if reg_type == 14 {
  4405. med_type = "140104"
  4406. } else if reg_type == 11 {
  4407. med_type = "11"
  4408. }
  4409. } else if his.Insutype == "310" {
  4410. if reg_type == 14 {
  4411. med_type = "990502"
  4412. } else if reg_type == 11 {
  4413. med_type = "11"
  4414. }
  4415. }
  4416. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  4417. } else {
  4418. 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, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  4419. }
  4420. saveLog(result, requestLog, "2203", "上传就诊信息")
  4421. var respJSON2 map[string]interface{}
  4422. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4425. return
  4426. }
  4427. //userJSONBytes2, _ := json.Marshal(respJSON2)
  4428. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4429. // utils.ErrorLog("解析失败:%v", err)
  4430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4431. // return
  4432. //}
  4433. userJSONBytes2, _ := json.Marshal(respJSON2)
  4434. if miConfig.Code == "H15049901371" {
  4435. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4436. utils.ErrorLog("解析失败:%v", err)
  4437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4438. return
  4439. }
  4440. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4441. res2.Output = resSix10265.Output
  4442. res2.ErrMsg = resSix10265.ErrMsg
  4443. res2.Cainfo = resSix10265.Cainfo
  4444. res2.WarnMsg = resSix10265.WarnMsg
  4445. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4446. res2.Infcode = infocode
  4447. } else {
  4448. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4449. utils.ErrorLog("解析失败:%v", err)
  4450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4451. return
  4452. }
  4453. }
  4454. }
  4455. }
  4456. if res2.Infcode != 0 {
  4457. adminUser := c.GetAdminUserInfo()
  4458. errlog := &models.HisOrderError{
  4459. UserOrgId: adminUser.CurrentOrgId,
  4460. Ctime: time.Now().Unix(),
  4461. Mtime: time.Now().Unix(),
  4462. ErrMsg: res2.ErrMsg,
  4463. Status: 1,
  4464. PatientId: id,
  4465. RecordTime: recordDateTime,
  4466. Stage: 3,
  4467. }
  4468. service.CreateErrMsgLog(errlog)
  4469. c.ServeSuccessJSON(map[string]interface{}{
  4470. "failed_code": -10,
  4471. "msg": res2.ErrMsg,
  4472. })
  4473. return
  4474. } else {
  4475. his.Diagnosis = diagnosis_id
  4476. his.SickType = sickConfig.ID
  4477. his.PType = fmt.Sprintf("%d", reg_type)
  4478. service.UpdateHisPatientThree(&his)
  4479. data := make(map[string]interface{})
  4480. if settle_accounts_type == 1 { //日结
  4481. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4482. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4483. } else {
  4484. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4485. }
  4486. data["pre"] = prescriptions
  4487. } else { //月结
  4488. start_time_str := c.GetString("start_time")
  4489. end_time_str := c.GetString("end_time")
  4490. timeLayout := "2006-01-02"
  4491. loc, _ := time.LoadLocation("Local")
  4492. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4493. if err != nil {
  4494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4495. return
  4496. }
  4497. recordStartTime := theStartTime.Unix()
  4498. start_time = recordStartTime
  4499. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4500. if err != nil {
  4501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4502. return
  4503. }
  4504. recordEndTime := theEndTime.Unix()
  4505. end_time = recordEndTime
  4506. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4507. data["pre"] = prescriptions
  4508. }
  4509. client := &http.Client{}
  4510. data["psn_no"] = his.PsnNo
  4511. data["mdtrt_id"] = his.Number
  4512. data["chrg_bchno"] = chrg_bchno
  4513. data["org_name"] = miConfig.OrgName
  4514. data["doctor"] = roles.UserName
  4515. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4516. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4517. data["fixmedins_code"] = miConfig.Code
  4518. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4519. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4520. data["dept_code"] = "15"
  4521. } else {
  4522. data["dept_code"] = department.Number
  4523. }
  4524. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4525. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4526. data["secret_key"] = miConfig.SecretKey
  4527. var ids []int64
  4528. for _, item := range prescriptions {
  4529. ids = append(ids, item.ID)
  4530. }
  4531. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4532. if config.IsOpen == 1 { //对接了医保,走医保流程
  4533. var res ResultFour
  4534. var resFour10265 ResultFour10265
  4535. if miConfig.MdtrtareaAdmvs == "421300" {
  4536. bytesData, _ := json.Marshal(data)
  4537. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4538. resp, _ := client.Do(req)
  4539. defer resp.Body.Close()
  4540. body, ioErr := ioutil.ReadAll(resp.Body)
  4541. if ioErr != nil {
  4542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4544. return
  4545. }
  4546. var respJSON map[string]interface{}
  4547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. return
  4551. }
  4552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4553. userJSONBytes, _ := json.Marshal(respJSON)
  4554. fmt.Println("log")
  4555. fmt.Println(string(userJSONBytes))
  4556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4557. utils.ErrorLog("解析失败:%v", err)
  4558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4559. return
  4560. }
  4561. } else {
  4562. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string))
  4563. var dat map[string]interface{}
  4564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4565. fmt.Println(dat)
  4566. } else {
  4567. fmt.Println(err)
  4568. }
  4569. saveLog(result, request_log, "2204", "上传费用明细")
  4570. userJSONBytes, _ := json.Marshal(dat)
  4571. if miConfig.Code == "H15049901371" {
  4572. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4573. utils.ErrorLog("解析失败:%v", err)
  4574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4575. return
  4576. }
  4577. res.InfRefmsgid = resFour10265.InfRefmsgid
  4578. res.Output = resFour10265.Output
  4579. res.ErrMsg = resFour10265.ErrMsg
  4580. res.Cainfo = resFour10265.Cainfo
  4581. res.WarnMsg = resFour10265.WarnMsg
  4582. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4583. res.Infcode = infocode
  4584. } else {
  4585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4586. utils.ErrorLog("解析失败:%v", err)
  4587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. return
  4589. }
  4590. }
  4591. }
  4592. if res.Infcode == 0 {
  4593. order := &models.HisOrder{
  4594. UserOrgId: adminUser.CurrentOrgId,
  4595. HisPatientId: his.ID,
  4596. PatientId: his.PatientId,
  4597. SettleAccountsDate: recordDateTime,
  4598. Ctime: time.Now().Unix(),
  4599. Mtime: time.Now().Unix(),
  4600. Status: 1,
  4601. Number: chrg_bchno,
  4602. Infcode: res.Infcode,
  4603. WarnMsg: res.WarnMsg,
  4604. Cainfo: res.Cainfo,
  4605. ErrMsg: res.ErrMsg,
  4606. RespondTime: res.RefmsgTime,
  4607. InfRefmsgid: res.InfRefmsgid,
  4608. OrderStatus: 1,
  4609. IsMedicineInsurance: 1,
  4610. SettleType: settle_accounts_type,
  4611. SettleStartTime: start_time,
  4612. SettleEndTime: end_time,
  4613. Creator: roles.AdminUserId,
  4614. Modify: roles.AdminUserId,
  4615. PType: 2,
  4616. Diagnosis: diagnosis_id,
  4617. }
  4618. err = service.CreateOrder(order)
  4619. if err != nil {
  4620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4621. return
  4622. }
  4623. for _, item := range res.Output.Result {
  4624. temp := strings.Split(item.FeedetlSn, "-")
  4625. var advice_id int64 = 0
  4626. var project_id int64 = 0
  4627. var types int64 = 0
  4628. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4629. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4630. if temp[1] == "1" {
  4631. advice_id = id
  4632. project_id = 0
  4633. } else if temp[1] == "2" {
  4634. advice_id = 0
  4635. project_id = id
  4636. }
  4637. info := &models.HisOrderInfo{
  4638. OrderNumber: order.Number,
  4639. FeedetlSn: item.FeedetlSn,
  4640. UploadDate: time.Now().Unix(),
  4641. AdviceId: advice_id,
  4642. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4643. Cnt: item.Cnt,
  4644. Pric: float64(item.Pric),
  4645. PatientId: his.PatientId,
  4646. PricUplmtAmt: item.PricUplmtAmt,
  4647. SelfpayProp: item.SelfpayProp,
  4648. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4649. OverlmtAmt: item.OverlmtAmt,
  4650. PreselfpayAmt: item.PreselfpayAmt,
  4651. BasMednFlag: item.BasMednFlag,
  4652. MedChrgitmType: item.MedChrgitmType,
  4653. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4654. Status: 1,
  4655. Memo: item.Memo,
  4656. Mtime: time.Now().Unix(),
  4657. InscpScpAmt: item.InscpScpAmt,
  4658. DrtReimFlag: item.DrtReimFlag,
  4659. Ctime: time.Now().Unix(),
  4660. ListSpItemFlag: item.ListSpItemFlag,
  4661. ChldMedcFlag: item.ChldMedcFlag,
  4662. LmtUsedFlag: item.LmtUsedFlag,
  4663. ChrgitmLv: item.ChrgitmLv,
  4664. UserOrgId: adminUser.CurrentOrgId,
  4665. HisPatientId: his.ID,
  4666. OrderId: order.ID,
  4667. ProjectId: project_id,
  4668. Type: types,
  4669. }
  4670. service.CreateOrderInfo(info)
  4671. }
  4672. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4673. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4674. var total float64
  4675. for _, item := range prescriptions {
  4676. if item.Type == 1 { //药品
  4677. for _, subItem := range item.HisDoctorAdviceInfo {
  4678. total = total + (subItem.Price * subItem.PrescribingNumber)
  4679. }
  4680. }
  4681. if item.Type == 2 { //项目
  4682. for _, subItem := range item.HisPrescriptionProject {
  4683. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4684. total = total + (subItem.Price * cnt)
  4685. }
  4686. }
  4687. }
  4688. for _, item := range prescriptions {
  4689. for _, subItem := range item.HisAdditionalCharge {
  4690. total = total + (subItem.Price * float64(subItem.Count))
  4691. }
  4692. }
  4693. allTotal := fmt.Sprintf("%.4f", total)
  4694. if res.Infcode == 0 {
  4695. var rf []*ResultFive
  4696. json.Unmarshal([]byte(his.Iinfo), &rf)
  4697. chrg_bchno := chrg_bchno
  4698. cert_no := his.Certno
  4699. var insutypes []string
  4700. var insutype string
  4701. var is390 int = 0
  4702. var is310 int = 0
  4703. for _, item := range rf {
  4704. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4705. insutypes = append(insutypes, item.Insutype)
  4706. }
  4707. }
  4708. if len(insutypes) == 1 {
  4709. insutype = insutypes[0]
  4710. } else {
  4711. for _, i := range insutypes {
  4712. if i == "390" {
  4713. is390 = 1
  4714. }
  4715. if i == "310" {
  4716. is310 = 1
  4717. }
  4718. }
  4719. }
  4720. if is390 == 1 {
  4721. insutype = "390"
  4722. }
  4723. if is310 == 1 {
  4724. insutype = "310"
  4725. }
  4726. if len(insutypes) == 0 {
  4727. insutype = "310"
  4728. }
  4729. if len(insutypes) == 2 {
  4730. insutype = strconv.FormatInt(his.SocialType, 64)
  4731. }
  4732. //insutype = "390"
  4733. if his.IdCardType == 1 {
  4734. cert_no = his.MedicalInsuranceNumber
  4735. } else {
  4736. cert_no = his.Certno
  4737. }
  4738. var res ResultSeven
  4739. var resSeven10265 ResultSeven10265
  4740. if miConfig.MdtrtareaAdmvs == "421300" {
  4741. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4742. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4743. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4744. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4745. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4746. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4747. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  4748. resp, requestErr := http.Get(api)
  4749. if requestErr != nil {
  4750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4751. return
  4752. }
  4753. body, ioErr := ioutil.ReadAll(resp.Body)
  4754. if ioErr != nil {
  4755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4757. return
  4758. }
  4759. var respJSON map[string]interface{}
  4760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4763. return
  4764. }
  4765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4766. result, _ := json.Marshal(respJSON)
  4767. fmt.Println("log")
  4768. fmt.Println(string(result))
  4769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4770. utils.ErrorLog("解析失败:%v", err)
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4772. return
  4773. }
  4774. } else {
  4775. var result string
  4776. var request_log string
  4777. if miConfig.Code == "H15049901371" {
  4778. //赤峰地区国家医保医疗类别
  4779. //职工透析:医疗类别选特殊情况门诊990502
  4780. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4781. var med_type string
  4782. if his.Insutype == "390" {
  4783. if reg_type == 14 {
  4784. med_type = "140104"
  4785. } else if reg_type == 11 {
  4786. med_type = "11"
  4787. }
  4788. } else if his.Insutype == "310" {
  4789. if reg_type == 14 {
  4790. med_type = "990502"
  4791. } else if reg_type == 11 {
  4792. med_type = "11"
  4793. }
  4794. }
  4795. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  4796. } else {
  4797. result, request_log = service.Gdyb2206(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)
  4798. }
  4799. var dat map[string]interface{}
  4800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4801. fmt.Println(dat)
  4802. } else {
  4803. fmt.Println(err)
  4804. }
  4805. saveLog(result, request_log, "2206", "预结算")
  4806. //userJSONBytes, _ := json.Marshal(dat)
  4807. //
  4808. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4809. // utils.ErrorLog("解析失败:%v", err)
  4810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4811. // return
  4812. //}
  4813. userJSONBytes, _ := json.Marshal(dat)
  4814. if miConfig.Code == "H15049901371" {
  4815. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4816. utils.ErrorLog("解析失败:%v", err)
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4818. return
  4819. }
  4820. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4821. res.Output = resSeven10265.Output
  4822. res.ErrMsg = resSeven10265.ErrMsg
  4823. res.Cainfo = resSeven10265.Cainfo
  4824. res.WarnMsg = resSeven10265.WarnMsg
  4825. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4826. res.Infcode = infocode
  4827. } else {
  4828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4829. utils.ErrorLog("解析失败:%v", err)
  4830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4831. return
  4832. }
  4833. }
  4834. }
  4835. if res.Infcode != 0 {
  4836. errlog := &models.HisOrderError{
  4837. UserOrgId: adminUser.CurrentOrgId,
  4838. Ctime: time.Now().Unix(),
  4839. Mtime: time.Now().Unix(),
  4840. Number: chrg_bchno,
  4841. ErrMsg: res.ErrMsg,
  4842. Status: 1,
  4843. PatientId: id,
  4844. RecordTime: recordDateTime,
  4845. Stage: 20,
  4846. }
  4847. service.CreateErrMsgLog(errlog)
  4848. c.ServeSuccessJSON(map[string]interface{}{
  4849. "failed_code": -10,
  4850. "msg": res.ErrMsg,
  4851. })
  4852. return
  4853. } else {
  4854. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4855. order.OrderStatus = 1
  4856. order.IsPre = 1
  4857. order.Status = 1
  4858. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4859. order.SetlId = res.Output.Setlinfo.SetlID
  4860. order.PsnNo = res.Output.Setlinfo.PsnNo
  4861. order.PsnName = res.Output.Setlinfo.PsnName
  4862. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4863. order.Certno = res.Output.Setlinfo.Certno
  4864. order.Gend = res.Output.Setlinfo.Gend
  4865. order.Naty = res.Output.Setlinfo.Naty
  4866. order.Age = res.Output.Setlinfo.Age
  4867. order.Insutype = res.Output.Setlinfo.Insutype
  4868. order.PsnType = res.Output.Setlinfo.PsnType
  4869. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4870. order.SetlTime = res.Output.Setlinfo.SetlTime
  4871. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4872. if res.Output.Setlinfo.MedType == "140101" {
  4873. order.MedType = "14"
  4874. } else {
  4875. order.MedType = res.Output.Setlinfo.MedType
  4876. }
  4877. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4878. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4879. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4880. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4881. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4882. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4883. order.HifpPay = res.Output.Setlinfo.HifpPay
  4884. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4885. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4886. order.HifesPay = res.Output.Setlinfo.HifesPay
  4887. order.HifobPay = res.Output.Setlinfo.HifobPay
  4888. order.MafPay = res.Output.Setlinfo.MafPay
  4889. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4890. order.OthPay = res.Output.Setlinfo.OthPay
  4891. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4892. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4893. order.AcctPay = res.Output.Setlinfo.AcctPay
  4894. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4895. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4896. order.Balc = res.Output.Setlinfo.Balc
  4897. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4898. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4899. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4900. order.ClrWay = res.Output.Setlinfo.ClrWay
  4901. order.Creator = order.Creator
  4902. order.Modify = roles.AdminUserId
  4903. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4904. detailStr := string(setlDetail)
  4905. order.SetlDetail = detailStr
  4906. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4907. err = service.UpDateOrder(order)
  4908. if err == nil {
  4909. c.ServeSuccessJSON(map[string]interface{}{
  4910. "msg": "预结算成功",
  4911. })
  4912. } else {
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4914. return
  4915. }
  4916. }
  4917. } else {
  4918. adminUser := c.GetAdminUserInfo()
  4919. errlog := &models.HisOrderError{
  4920. UserOrgId: adminUser.CurrentOrgId,
  4921. Ctime: time.Now().Unix(),
  4922. Mtime: time.Now().Unix(),
  4923. ErrMsg: res.ErrMsg,
  4924. Status: 1,
  4925. PatientId: id,
  4926. RecordTime: recordDateTime,
  4927. Stage: 4,
  4928. }
  4929. service.CreateErrMsgLog(errlog)
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4931. return
  4932. }
  4933. } else {
  4934. adminUser := c.GetAdminUserInfo()
  4935. errlog := &models.HisOrderError{
  4936. UserOrgId: adminUser.CurrentOrgId,
  4937. Ctime: time.Now().Unix(),
  4938. Mtime: time.Now().Unix(),
  4939. ErrMsg: res.ErrMsg,
  4940. Status: 1,
  4941. PatientId: id,
  4942. RecordTime: recordDateTime,
  4943. Stage: 4,
  4944. }
  4945. service.CreateErrMsgLog(errlog)
  4946. c.ServeSuccessJSON(map[string]interface{}{
  4947. "failed_code": -10,
  4948. "msg": res.ErrMsg,
  4949. })
  4950. return
  4951. }
  4952. }
  4953. }
  4954. }
  4955. //func (c *HisApiController) GetSettleInfo() {
  4956. // id, _ := c.GetInt64("id")
  4957. // order_id, _ := c.GetInt64("order_id")
  4958. //
  4959. // record_time := c.GetString("record_time")
  4960. // pay_way, _ := c.GetInt64("pay_way")
  4961. // pay_price, _ := c.GetFloat("pay_price")
  4962. // pay_card_no := c.GetString("pay_card_no")
  4963. // discount_price, _ := c.GetFloat("discount_price")
  4964. // preferential_price, _ := c.GetFloat("preferential_price")
  4965. // reality_price, _ := c.GetFloat("reality_price")
  4966. // found_price, _ := c.GetFloat("found_price")
  4967. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4968. // private_price, _ := c.GetFloat("private_price")
  4969. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4970. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4971. //
  4972. // timeLayout := "2006-01-02"
  4973. // loc, _ := time.LoadLocation("Local")
  4974. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4975. // if err != nil {
  4976. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4977. // return
  4978. // }
  4979. // recordDateTime := theTime.Unix()
  4980. // adminUser := c.GetAdminUserInfo()
  4981. //
  4982. // var prescriptions []*models.HisPrescription
  4983. //
  4984. // data := make(map[string]interface{})
  4985. // if settle_accounts_type == 1 { //日结
  4986. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4987. // data["pre"] = prescriptions
  4988. //
  4989. // } else { //月结
  4990. // start_time_str := c.GetString("start_time")
  4991. // end_time_str := c.GetString("end_time")
  4992. // timeLayout := "2006-01-02"
  4993. // loc, _ := time.LoadLocation("Local")
  4994. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4995. // if err != nil {
  4996. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4997. // return
  4998. // }
  4999. // recordStartTime := theStartTime.Unix()
  5000. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5001. // if err != nil {
  5002. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5003. // return
  5004. // }
  5005. // recordEndTime := theEndTime.Unix()
  5006. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5007. // data["pre"] = prescriptions
  5008. //
  5009. // }
  5010. //
  5011. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5012. //
  5013. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5014. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5015. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5016. // strconv.FormatInt(his.PatientId, 10)
  5017. //
  5018. // order_src, _ := service.GetHisOrderByID(order_id)
  5019. //
  5020. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5021. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5022. //
  5023. // var total float64
  5024. // for _, item := range prescriptions {
  5025. // if item.Type == 1 { //药品
  5026. // for _, subItem := range item.HisDoctorAdviceInfo {
  5027. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5028. // }
  5029. // }
  5030. // if item.Type == 2 { //项目
  5031. // for _, subItem := range item.HisPrescriptionProject {
  5032. // total = total + (subItem.Price * float64(subItem.Count))
  5033. // }
  5034. // }
  5035. // }
  5036. //
  5037. // for _, item := range prescriptions {
  5038. // for _, subItem := range item.HisAdditionalCharge {
  5039. // total = total + (subItem.Price * float64(subItem.Count))
  5040. // }
  5041. // }
  5042. //
  5043. // allTotal := fmt.Sprintf("%.2f", total)
  5044. // var rf []*ResultFive
  5045. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5046. // psn_no := order_src.PsnNo
  5047. // mdtrt_id := order_src.MdtrtId
  5048. // chrg_bchno := order_src.Number
  5049. // cert_no := order_src.Certno
  5050. // insutype := rf[0].Insutype
  5051. //
  5052. // if his.IdCardType == 1 {
  5053. // cert_no = his.MedicalInsuranceNumber
  5054. // } else {
  5055. // cert_no = his.Certno
  5056. // }
  5057. //
  5058. // 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)
  5059. // var dat map[string]interface{}
  5060. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5061. // fmt.Println(dat)
  5062. // } else {
  5063. // fmt.Println(err)
  5064. // }
  5065. //
  5066. // userJSONBytes, _ := json.Marshal(dat)
  5067. //
  5068. //
  5069. //
  5070. // var res ResultSeven
  5071. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5072. // utils.ErrorLog("解析失败:%v", err)
  5073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5074. // return
  5075. // }
  5076. // if res.Infcode == -1 {
  5077. // errlog := &models.HisOrderError{
  5078. // UserOrgId: adminUser.CurrentOrgId,
  5079. // Ctime: time.Now().Unix(),
  5080. // Mtime: time.Now().Unix(),
  5081. // Number: chrg_bchno,
  5082. // ErrMsg: res.ErrMsg,
  5083. // Status: 1,
  5084. // PatientId: id,
  5085. // RecordTime: recordDateTime,
  5086. // Stage: 6,
  5087. // }
  5088. // service.CreateErrMsgLog(errlog)
  5089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5090. // return
  5091. // } else {
  5092. // order_src.OrderStatus = 2
  5093. // order_src.PayWay = pay_way
  5094. // order_src.PayPrice = pay_price
  5095. // order_src.PayCardNo = pay_card_no
  5096. // order_src.DiscountPrice = discount_price
  5097. // order_src.PreferentialPrice = preferential_price
  5098. // order_src.RealityPrice = reality_price
  5099. // order_src.FoundPrice = found_price
  5100. // order_src.MedicalInsurancePrice = medical_insurance_price
  5101. // order_src.PrivatePrice = private_price
  5102. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5103. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5104. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5105. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5106. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5107. // order_src.Certno = res.Output.Setlinfo.Certno
  5108. // order_src.Gend = res.Output.Setlinfo.Gend
  5109. // order_src.Naty = res.Output.Setlinfo.Naty
  5110. // order_src.Age = res.Output.Setlinfo.Age
  5111. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5112. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5113. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5114. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5115. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5116. // order_src.MedType = res.Output.Setlinfo.MedType
  5117. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5118. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5119. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5120. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5121. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5122. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5123. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5124. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5125. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5126. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5127. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5128. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5129. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5130. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5131. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5132. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5133. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5134. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5135. // order_src.Balc = res.Output.Setlinfo.Balc
  5136. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5137. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5138. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5139. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5140. // order_src.Creator = order_src.Creator
  5141. // order_src.Modify = roles.ID
  5142. // order_src.RequestLog = src_resquest
  5143. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5144. // detailStr := string(setlDetail)
  5145. // order_src.SetlDetail = detailStr
  5146. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5147. // err = service.UpDateOrder(order_src)
  5148. //
  5149. // if err == nil {
  5150. // c.ServeSuccessJSON(map[string]interface{}{
  5151. // "msg": "结算成功",
  5152. // })
  5153. // } else {
  5154. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5155. // return
  5156. // }
  5157. // }
  5158. // }
  5159. //}
  5160. //退款
  5161. func (c *HisApiController) Refund() {
  5162. order_id, _ := c.GetInt64("order_id")
  5163. admin_user_id, _ := c.GetInt64("admin_user_id")
  5164. //record_time := c.GetString("record_time")
  5165. //patient_id, _ := c.GetInt64("patient_id")
  5166. //timeLayout := "2006-01-02"
  5167. //loc, _ := time.LoadLocation("Local")
  5168. adminUser := c.GetAdminUserInfo()
  5169. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5170. //if err != nil {
  5171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5172. // return
  5173. //}
  5174. //recordDateTime := theTime.Unix()
  5175. var order models.HisOrder
  5176. order, _ = service.GetHisOrderByID(order_id)
  5177. //his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5178. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5179. if order.ID == 0 {
  5180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5181. return
  5182. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5183. }
  5184. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5185. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5186. if config.IsOpen == 1 { //对接了医保,走医保流程
  5187. var res ResultSixteen
  5188. var resSixteen10265 ResultSixteen10265
  5189. var src_resquest string
  5190. var result string
  5191. if miConfig.MdtrtareaAdmvs == "421300" {
  5192. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5193. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5194. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5195. resp3, requestErr3 := http.Get(api3)
  5196. if requestErr3 != nil {
  5197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5198. return
  5199. }
  5200. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5201. if ioErr3 != nil {
  5202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5204. return
  5205. }
  5206. var respJSON3 map[string]interface{}
  5207. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5210. return
  5211. }
  5212. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5213. userJSONBytes3, _ := json.Marshal(respJSON3)
  5214. fmt.Println("log")
  5215. fmt.Println(string(userJSONBytes3))
  5216. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5217. utils.ErrorLog("解析失败:%v", err)
  5218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5219. return
  5220. }
  5221. } else {
  5222. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5223. var dat map[string]interface{}
  5224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5225. fmt.Println(dat)
  5226. } else {
  5227. fmt.Println(err)
  5228. }
  5229. saveLog(result, src_resquest, "2208", "退费")
  5230. userJSONBytes, _ := json.Marshal(dat)
  5231. if miConfig.Code == "H15049901371" {
  5232. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5233. utils.ErrorLog("解析失败:%v", err)
  5234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5235. return
  5236. }
  5237. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5238. res.Output = resSixteen10265.Output
  5239. res.ErrMsg = resSixteen10265.ErrMsg
  5240. res.Cainfo = resSixteen10265.Cainfo
  5241. res.WarnMsg = resSixteen10265.WarnMsg
  5242. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5243. res.Infcode = infocode
  5244. } else {
  5245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5246. utils.ErrorLog("解析失败:%v", err)
  5247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5248. return
  5249. }
  5250. }
  5251. }
  5252. if res.Infcode == 0 {
  5253. var res2 ResultSix
  5254. var resSix10265 ResultSix10265
  5255. if miConfig.MdtrtareaAdmvs == "421300" {
  5256. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5257. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5258. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5259. resp3, requestErr3 := http.Get(api3)
  5260. if requestErr3 != nil {
  5261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5262. return
  5263. }
  5264. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5265. if ioErr3 != nil {
  5266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5268. return
  5269. }
  5270. var respJSON3 map[string]interface{}
  5271. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5274. return
  5275. }
  5276. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5277. userJSONBytes3, _ := json.Marshal(respJSON3)
  5278. fmt.Println("log")
  5279. fmt.Println(string(userJSONBytes3))
  5280. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5281. utils.ErrorLog("解析失败:%v", err)
  5282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5283. return
  5284. }
  5285. } else {
  5286. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5287. var dat map[string]interface{}
  5288. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5289. fmt.Println(dat)
  5290. } else {
  5291. fmt.Println(err)
  5292. }
  5293. saveLog(result2, src_request, "2205", "撤销明细")
  5294. userJSONBytes, _ := json.Marshal(dat)
  5295. if miConfig.Code == "H15049901371" {
  5296. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5297. utils.ErrorLog("解析失败:%v", err)
  5298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5299. return
  5300. }
  5301. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5302. res2.Output = resSix10265.Output
  5303. res2.ErrMsg = resSix10265.ErrMsg
  5304. res2.Cainfo = resSix10265.Cainfo
  5305. res2.WarnMsg = resSix10265.WarnMsg
  5306. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5307. res2.Infcode = infocode
  5308. } else {
  5309. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5310. utils.ErrorLog("解析失败:%v", err)
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. }
  5315. }
  5316. if res2.Infcode == 0 {
  5317. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5318. if err == nil {
  5319. c.ServeSuccessJSON(map[string]interface{}{
  5320. "msg": "退费成功",
  5321. })
  5322. } else {
  5323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5324. return
  5325. }
  5326. } else {
  5327. c.ServeSuccessJSON(map[string]interface{}{
  5328. "code": -10,
  5329. "msg": res2.ErrMsg,
  5330. })
  5331. }
  5332. } else {
  5333. c.ServeSuccessJSON(map[string]interface{}{
  5334. "code": -10,
  5335. "msg": res.ErrMsg,
  5336. })
  5337. }
  5338. }
  5339. }
  5340. func (c *HisApiController) RefundNumber() {
  5341. record_time := c.GetString("record_time")
  5342. //patient_id, _ := c.GetInt64("patient_id")
  5343. admin_user_id, _ := c.GetInt64("admin_user_id")
  5344. his_patient_id, _ := c.GetInt64("id")
  5345. timeLayout := "2006-01-02"
  5346. loc, _ := time.LoadLocation("Local")
  5347. adminUser := c.GetAdminUserInfo()
  5348. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5349. fmt.Println(err)
  5350. if err != nil {
  5351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5352. return
  5353. }
  5354. recordDateTime := theTime.Unix()
  5355. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5356. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5357. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5358. //order, _ := service.GetHisOrderByID(order_id)
  5359. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5360. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5361. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5362. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5363. if count > 0 {
  5364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5365. return
  5366. }
  5367. if config.IsOpen == 1 { //对接了医保,走医保流程
  5368. var res2 ResultSix
  5369. var resSix10265 ResultSix10265
  5370. if miConfig.MdtrtareaAdmvs == "421300" {
  5371. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5372. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5373. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5374. resp3, requestErr3 := http.Get(api3)
  5375. if requestErr3 != nil {
  5376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5377. return
  5378. }
  5379. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5380. if ioErr3 != nil {
  5381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5383. return
  5384. }
  5385. var respJSON3 map[string]interface{}
  5386. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5389. return
  5390. }
  5391. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5392. userJSONBytes3, _ := json.Marshal(respJSON3)
  5393. fmt.Println("log")
  5394. fmt.Println(string(userJSONBytes3))
  5395. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5396. utils.ErrorLog("解析失败:%v", err)
  5397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5398. return
  5399. }
  5400. } else {
  5401. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5402. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5403. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5404. resp3, requestErr3 := http.Get(api3)
  5405. if requestErr3 != nil {
  5406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5407. return
  5408. }
  5409. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5410. if ioErr3 != nil {
  5411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5413. return
  5414. }
  5415. var respJSON3 map[string]interface{}
  5416. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5419. return
  5420. }
  5421. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5422. userJSONBytes3, _ := json.Marshal(respJSON3)
  5423. if miConfig.Code == "H15049901371" {
  5424. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5425. utils.ErrorLog("解析失败:%v", err)
  5426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5427. return
  5428. }
  5429. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5430. res2.Output = resSix10265.Output
  5431. res2.ErrMsg = resSix10265.ErrMsg
  5432. res2.Cainfo = resSix10265.Cainfo
  5433. res2.WarnMsg = resSix10265.WarnMsg
  5434. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5435. res2.Infcode = infocode
  5436. } else {
  5437. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5438. utils.ErrorLog("解析失败:%v", err)
  5439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5440. return
  5441. }
  5442. }
  5443. }
  5444. if res2.Infcode == 0 {
  5445. if err == nil {
  5446. c.ServeSuccessJSON(map[string]interface{}{
  5447. "msg": "退号成功",
  5448. })
  5449. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  5450. } else {
  5451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5452. return
  5453. }
  5454. } else {
  5455. c.ServeSuccessJSON(map[string]interface{}{
  5456. "code": -10,
  5457. "msg": res2.ErrMsg,
  5458. })
  5459. }
  5460. } else {
  5461. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  5462. //if err == nil {
  5463. // c.ServeSuccessJSON(map[string]interface{}{
  5464. // "msg": "退费成功",
  5465. // })
  5466. //} else {
  5467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5468. // return
  5469. //}
  5470. }
  5471. }
  5472. func (c *HisApiController) RefundDetail() {
  5473. order_id, _ := c.GetInt64("order_id")
  5474. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5475. number := c.GetString("number")
  5476. record_time := c.GetString("record_time")
  5477. patient_id, _ := c.GetInt64("patient_id")
  5478. timeLayout := "2006-01-02"
  5479. loc, _ := time.LoadLocation("Local")
  5480. adminUser := c.GetAdminUserInfo()
  5481. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5482. fmt.Println(err)
  5483. if err != nil {
  5484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5485. return
  5486. }
  5487. recordDateTime := theTime.Unix()
  5488. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5489. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5490. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5491. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5492. var order models.HisOrder
  5493. order, _ = service.GetHisOrderByID(order_id)
  5494. if order.ID == 0 {
  5495. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5496. }
  5497. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5498. if config.IsOpen == 1 { //对接了医保,走医保流程
  5499. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  5500. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5501. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5502. resp2, requestErr2 := http.Get(api2)
  5503. if requestErr2 != nil {
  5504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5505. return
  5506. }
  5507. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5508. if ioErr2 != nil {
  5509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5511. return
  5512. }
  5513. var respJSON2 map[string]interface{}
  5514. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  5515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5517. return
  5518. }
  5519. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5520. if err == nil {
  5521. c.ServeSuccessJSON(map[string]interface{}{
  5522. "msg": "退费成功",
  5523. })
  5524. } else {
  5525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5526. return
  5527. }
  5528. } else {
  5529. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5530. if err == nil {
  5531. c.ServeSuccessJSON(map[string]interface{}{
  5532. "msg": "退费成功",
  5533. })
  5534. } else {
  5535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5536. return
  5537. }
  5538. }
  5539. }
  5540. //对账
  5541. func (c *HisApiController) GetCheckAccount() {
  5542. start_time := c.GetString("start_time")
  5543. end_time := c.GetString("end_time")
  5544. insutype := c.GetString("insutype")
  5545. clr_type := c.GetString("clr_type")
  5546. admin_user_id, _ := c.GetInt64("admin_user_id")
  5547. adminUser := c.GetAdminUserInfo()
  5548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5549. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5550. timeLayout := "2006-01-02"
  5551. loc, _ := time.LoadLocation("Local")
  5552. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5553. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5554. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5555. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5556. fixmedins_setl_cnt := int64(len(orders))
  5557. //
  5558. ////撤销的算2条数据为一笔
  5559. //for _, item := range orders_two {
  5560. // if item.OrderStatus == 3 {
  5561. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  5562. // }
  5563. //}
  5564. var medfee_sumamt float64
  5565. var acct_pay float64
  5566. var fund_pay_sumamt float64
  5567. for _, item := range orders {
  5568. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5569. acct_pay = acct_pay + item.AcctPay
  5570. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5571. }
  5572. var user_name string
  5573. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5574. if role.ID == 0 {
  5575. user_name = "xxx"
  5576. } else {
  5577. user_name = role.UserName
  5578. }
  5579. if config.IsOpen == 1 {
  5580. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5581. "insutype=" + insutype +
  5582. "&clr_type=" + clr_type +
  5583. "&setl_optins=" + "定点医保中心" +
  5584. "&stmt_begndate=" + start_time +
  5585. "&stm_enddate=" + end_time +
  5586. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5587. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5588. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  5589. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5590. "&fixmedins_code=" + miConfig.Code +
  5591. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5592. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5593. "&secret_key=" + miConfig.SecretKey +
  5594. "&org_name=" + miConfig.OrgName +
  5595. "&doctor=" + user_name
  5596. fmt.Println(api)
  5597. resp, requestErr := http.Get(api)
  5598. if requestErr != nil {
  5599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5600. return
  5601. }
  5602. body, ioErr := ioutil.ReadAll(resp.Body)
  5603. fmt.Println(body)
  5604. if ioErr != nil {
  5605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5607. return
  5608. }
  5609. var respJSON map[string]interface{}
  5610. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5613. return
  5614. }
  5615. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5616. userJSONBytes, _ := json.Marshal(respJSON)
  5617. var res ResultEight
  5618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5619. utils.ErrorLog("解析失败:%v", err)
  5620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5621. return
  5622. }
  5623. if res.Infcode == 0 {
  5624. if res.Output.Stmtinfo.StmtRslt == "0" {
  5625. micc := &models.MedicalInsuranceCostCompare{
  5626. StartTime: startime.Unix(),
  5627. EndTime: endtime.Unix(),
  5628. Insutype: insutype,
  5629. CheckType: 1,
  5630. Num: fixmedins_setl_cnt,
  5631. Mtime: time.Now().Unix(),
  5632. Status: 1,
  5633. UserOrgId: adminUser.CurrentOrgId,
  5634. CostTotal: medfee_sumamt,
  5635. FuncTotal: fund_pay_sumamt,
  5636. PsnPay: acct_pay,
  5637. Creator: admin_user_id,
  5638. Ctime: time.Now().Unix(),
  5639. }
  5640. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  5641. if err == nil {
  5642. c.ServeSuccessJSON(map[string]interface{}{
  5643. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5644. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5645. })
  5646. } else {
  5647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5648. }
  5649. } else {
  5650. c.ServeSuccessJSON(map[string]interface{}{
  5651. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5652. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5653. })
  5654. }
  5655. } else {
  5656. c.ServeSuccessJSON(map[string]interface{}{
  5657. "code": -10,
  5658. "msg": res.ErrMsg,
  5659. })
  5660. }
  5661. }
  5662. }
  5663. func (c *HisApiController) Check310() {
  5664. adminUser := c.GetAdminUserInfo()
  5665. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5666. var user_name string
  5667. user_name = "xxx"
  5668. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5669. "insutype=" + "310" +
  5670. "&clr_type=" + "11" +
  5671. "&setl_optins=" + "定点医保中心" +
  5672. "&stmt_begndate=" + "2021-03-01" +
  5673. "&stm_enddate=" + "2021-03-31" +
  5674. "&medfee_sumamt=" + "11521" +
  5675. "&fund_pay_sumamt=" + "10166.66" +
  5676. "&acct_pay=" + "0" +
  5677. "&fixmedins_setl_cnt=" + "7" +
  5678. "&fixmedins_code=" + miConfig.Code +
  5679. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5680. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5681. "&secret_key=" + miConfig.SecretKey +
  5682. "&org_name=" + miConfig.OrgName +
  5683. "&doctor=" + user_name
  5684. fmt.Println(api)
  5685. resp, requestErr := http.Get(api)
  5686. if requestErr != nil {
  5687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5688. return
  5689. }
  5690. body, ioErr := ioutil.ReadAll(resp.Body)
  5691. fmt.Println(body)
  5692. if ioErr != nil {
  5693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5695. return
  5696. }
  5697. var respJSON map[string]interface{}
  5698. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5701. return
  5702. }
  5703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5704. userJSONBytes, _ := json.Marshal(respJSON)
  5705. var res ResultEight
  5706. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5707. utils.ErrorLog("解析失败:%v", err)
  5708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5709. return
  5710. }
  5711. }
  5712. func (c *HisApiController) Check390() {
  5713. adminUser := c.GetAdminUserInfo()
  5714. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5715. var user_name string
  5716. user_name = "张俊杰"
  5717. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5718. "insutype=" + "390" +
  5719. "&clr_type=" + "11" +
  5720. "&setl_optins=" + "定点医保中心" +
  5721. "&stmt_begndate=" + "2021-03-01" +
  5722. "&stm_enddate=" + "2021-03-31" +
  5723. "&medfee_sumamt=" + "209318.43" +
  5724. "&fund_pay_sumamt=" + "188029.12" +
  5725. "&acct_pay=" + "0" +
  5726. "&fixmedins_setl_cnt=" + "48" +
  5727. "&fixmedins_code=" + miConfig.Code +
  5728. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5729. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5730. "&secret_key=" + miConfig.SecretKey +
  5731. "&org_name=" + miConfig.OrgName +
  5732. "&doctor=" + user_name
  5733. fmt.Println(api)
  5734. resp, requestErr := http.Get(api)
  5735. if requestErr != nil {
  5736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5737. return
  5738. }
  5739. body, ioErr := ioutil.ReadAll(resp.Body)
  5740. fmt.Println(body)
  5741. if ioErr != nil {
  5742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5744. return
  5745. }
  5746. var respJSON map[string]interface{}
  5747. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5750. return
  5751. }
  5752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5753. userJSONBytes, _ := json.Marshal(respJSON)
  5754. var res ResultEight
  5755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5756. utils.ErrorLog("解析失败:%v", err)
  5757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5758. return
  5759. }
  5760. }
  5761. //对账明细
  5762. func (c *HisApiController) GetCheckDetailAccount() {
  5763. start_time := c.GetString("start_time")
  5764. end_time := c.GetString("end_time")
  5765. admin_user_id, _ := c.GetInt64("admin_user_id")
  5766. adminUser := c.GetAdminUserInfo()
  5767. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5768. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5769. timeLayout := "2006-01-02"
  5770. loc, _ := time.LoadLocation("Local")
  5771. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5772. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5773. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  5774. Mkdir(miConfig.OrgName)
  5775. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  5776. file_name := file + ".txt"
  5777. zip_name := file + ".zip"
  5778. zip_path := miConfig.OrgName + "/" + zip_name
  5779. file_path := miConfig.OrgName + "/" + file_name
  5780. decimal.DivisionPrecision = 2
  5781. var medfee_sumamt float64
  5782. var psn_cash_pay float64
  5783. var fund_pay_sumamt float64
  5784. fixmedins_setl_cnt := int64(len(orders))
  5785. for _, item := range orders {
  5786. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5787. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  5788. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5789. }
  5790. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  5791. defer f.Close()
  5792. if err != nil {
  5793. fmt.Println(err.Error())
  5794. } else {
  5795. for _, item := range orders {
  5796. var refd_setl_flag string
  5797. if item.OrderStatus == 2 {
  5798. refd_setl_flag = "0"
  5799. var str string
  5800. str = item.SetlId + " " +
  5801. item.MdtrtId + " " +
  5802. item.PsnNo + " " +
  5803. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5804. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5805. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  5806. _, err = f.Write([]byte(str))
  5807. }
  5808. if item.OrderStatus == 3 {
  5809. var str string
  5810. str = item.SetlId + " " +
  5811. item.MdtrtId + " " +
  5812. item.PsnNo + " " +
  5813. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5814. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5815. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  5816. _, err = f.Write([]byte(str))
  5817. var str2 string
  5818. str2 = item.SetlId + " " +
  5819. item.MdtrtId + " " +
  5820. item.PsnNo + " " +
  5821. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  5822. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  5823. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  5824. _, err = f.Write([]byte(str2))
  5825. }
  5826. }
  5827. }
  5828. Zip(file_path, zip_path)
  5829. fmt.Println(ReadFile(zip_path))
  5830. fmt.Println(string(ReadFile(zip_path)))
  5831. if config.IsOpen == 1 {
  5832. var user_name string
  5833. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5834. if role.ID == 0 {
  5835. user_name = "管理员"
  5836. } else {
  5837. user_name = role.UserName
  5838. }
  5839. baseParams := models.BaseParams{
  5840. SecretKey: miConfig.SecretKey,
  5841. FixmedinsCode: miConfig.Code,
  5842. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5843. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5844. OrgName: miConfig.OrgName,
  5845. Doctor: user_name,
  5846. }
  5847. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  5848. var dat map[string]interface{}
  5849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5850. fmt.Println(dat)
  5851. } else {
  5852. fmt.Println(err)
  5853. }
  5854. userJSONBytes, _ := json.Marshal(dat)
  5855. var res ResultNine
  5856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5857. utils.ErrorLog("解析失败:%v", err)
  5858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5859. return
  5860. }
  5861. if res.Infcode == 0 {
  5862. fileNo := res.Output.FileQuryNo
  5863. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  5864. "file_qury_no=" + fileNo +
  5865. "&setl_optins=" + "定点医保中心" +
  5866. "&stmt_begndate=" + start_time +
  5867. "&stm_enddate=" + end_time +
  5868. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5869. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5870. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  5871. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5872. "&fixmedins_code=" + miConfig.Code +
  5873. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5874. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5875. "&secret_key=" + miConfig.SecretKey +
  5876. "&org_name=" + miConfig.OrgName +
  5877. "&doctor=" + user_name
  5878. resp, requestErr := http.Get(api)
  5879. if requestErr != nil {
  5880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5881. return
  5882. }
  5883. body, ioErr := ioutil.ReadAll(resp.Body)
  5884. if ioErr != nil {
  5885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5887. return
  5888. }
  5889. var respJSON map[string]interface{}
  5890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5893. return
  5894. }
  5895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5896. userJSONBytes, _ := json.Marshal(respJSON)
  5897. var res ResultTen
  5898. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5899. utils.ErrorLog("解析失败:%v", err)
  5900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5901. return
  5902. }
  5903. if res.Infcode == 0 {
  5904. service.Gdyb9102(baseParams, zip_name, fileNo)
  5905. micc := &models.MedicalInsuranceCostCompare{
  5906. StartTime: startime.Unix(),
  5907. EndTime: endtime.Unix(),
  5908. Insutype: "0",
  5909. CheckType: 2,
  5910. Num: fixmedins_setl_cnt,
  5911. Mtime: time.Now().Unix(),
  5912. Status: 1,
  5913. UserOrgId: adminUser.CurrentOrgId,
  5914. CostTotal: medfee_sumamt,
  5915. FuncTotal: fund_pay_sumamt,
  5916. PsnPay: psn_cash_pay,
  5917. Creator: admin_user_id,
  5918. Ctime: time.Now().Unix(),
  5919. }
  5920. service.CreateMedicalInsuranceCostCompareRecord(micc)
  5921. c.ServeSuccessJSON(map[string]interface{}{
  5922. "msg": "明细对账成功",
  5923. })
  5924. }
  5925. } else {
  5926. }
  5927. }
  5928. }
  5929. type CustomOrderInfo struct {
  5930. Name string
  5931. Spec string
  5932. Unit string
  5933. Count float64
  5934. Price float64
  5935. Total float64
  5936. }
  5937. func (c *HisApiController) GetSettleAccounts() {
  5938. //id, _ := c.GetInt64("id")
  5939. //record_time := c.GetString("record_time")
  5940. order_id, _ := c.GetInt64("order_id")
  5941. admin_user_id, _ := c.GetInt64("admin_user_id")
  5942. //timeLayout := "2006-01-02"
  5943. //loc, _ := time.LoadLocation("Local")
  5944. //
  5945. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5946. //if err != nil {
  5947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5948. // return
  5949. //}
  5950. //recordDateTime := theTime.Unix()
  5951. adminUser := c.GetAdminUserInfo()
  5952. order, _ := service.GetHisOrderByID(order_id)
  5953. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5954. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  5955. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  5956. orderInfos = append(orderInfos, orderInfos_two...)
  5957. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  5958. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5959. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  5960. //var config []*models.HisXtDiagnoseConfig
  5961. var name string
  5962. for _, item := range diagnosis_ids {
  5963. id, _ := strconv.ParseInt(item, 10, 64)
  5964. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5965. if len(name) == 0 {
  5966. name = diagnosisConfig.ClassName
  5967. } else {
  5968. name = name + "," + diagnosisConfig.ClassName
  5969. }
  5970. }
  5971. var bedCostTotal float64 = 0 //床位总费
  5972. var bedCostSelfTotal float64 = 0 //床位自费
  5973. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5974. var operationCostTotal float64 = 0 //手术费
  5975. var operationCostSelfTotal float64 = 0 //手术费
  5976. var operationCostPartSelfTotal float64 = 0 //手术费
  5977. var otherCostTotal float64 = 0 //其他费用
  5978. var otherCostSelfTotal float64 = 0 //其他费用
  5979. var otherCostPartSelfTotal float64 = 0 //其他费用
  5980. var materialCostTotal float64 = 0 //材料费
  5981. var materialCostSelfTotal float64 = 0 //材料费
  5982. var materialCostPartSelfTotal float64 = 0 //材料费
  5983. var westernMedicineCostTotal float64 = 0 //西药费
  5984. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5985. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5986. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5987. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5988. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5989. var checkCostTotal float64 = 0 //检查费
  5990. var checkCostSelfTotal float64 = 0 //检查费
  5991. var checkCostPartSelfTotal float64 = 0 //检查费
  5992. var laboratoryCostTotal float64 = 0 //化验费
  5993. var laboratoryCostSelfTotal float64 = 0 //化验费
  5994. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5995. var treatCostTotal float64 = 0 //治疗费用
  5996. var treatCostSelfTotal float64 = 0 //治疗费用
  5997. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5998. decimal.DivisionPrecision = 2
  5999. for _, item := range orderInfos {
  6000. if item.MedChrgitmType == "01" { //床位费
  6001. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6002. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6003. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6004. }
  6005. if item.MedChrgitmType == "03" { //检查费
  6006. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6007. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6008. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6009. }
  6010. if item.MedChrgitmType == "04" { //化验费
  6011. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6012. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6013. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6014. }
  6015. if item.MedChrgitmType == "05" { //治疗费
  6016. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6017. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6018. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6019. }
  6020. if item.MedChrgitmType == "06" { //手术费
  6021. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6022. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6023. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6024. }
  6025. if item.MedChrgitmType == "08" { //材料费
  6026. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6027. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6028. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6029. }
  6030. if item.MedChrgitmType == "09" { //西药费
  6031. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6032. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6033. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6034. }
  6035. if item.MedChrgitmType == "11" { //中成费
  6036. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6037. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6038. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6039. }
  6040. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6041. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6042. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6043. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6044. }
  6045. }
  6046. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6047. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6048. var user_name string
  6049. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6050. if role.ID == 0 {
  6051. user_name = "管理员"
  6052. } else {
  6053. user_name = role.UserName
  6054. }
  6055. baseParams := models.BaseParams{
  6056. SecretKey: miConfig.SecretKey,
  6057. FixmedinsCode: miConfig.Code,
  6058. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6059. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6060. OrgName: miConfig.OrgName,
  6061. Doctor: user_name,
  6062. }
  6063. businessParams := models.BusinessParams{
  6064. PsnNo: order.PsnNo,
  6065. MdtrtId: order.MdtrtId,
  6066. SetlId: order.SetlId,
  6067. }
  6068. var res ResultEleven
  6069. var resEleven10265 ResultEleven10265
  6070. if config.IsOpen == 1 {
  6071. if miConfig.MdtrtareaAdmvs == "421300" {
  6072. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6073. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6074. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6075. resp, requestErr := http.Get(api)
  6076. if requestErr != nil {
  6077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6078. return
  6079. }
  6080. body, ioErr := ioutil.ReadAll(resp.Body)
  6081. if ioErr != nil {
  6082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6084. return
  6085. }
  6086. var respJSON map[string]interface{}
  6087. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6090. return
  6091. }
  6092. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6093. result, _ := json.Marshal(respJSON)
  6094. fmt.Println("log")
  6095. fmt.Println(string(result))
  6096. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6097. utils.ErrorLog("解析失败:%v", err)
  6098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6099. return
  6100. }
  6101. } else {
  6102. result := service.Gdyb5203(baseParams, businessParams)
  6103. var dat map[string]interface{}
  6104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6105. fmt.Println(dat)
  6106. } else {
  6107. fmt.Println(err)
  6108. }
  6109. userJSONBytes, _ := json.Marshal(dat)
  6110. if miConfig.Code == "H15049901371" {
  6111. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6112. utils.ErrorLog("解析失败:%v", err)
  6113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6114. return
  6115. }
  6116. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6117. res.Output = resEleven10265.Output
  6118. res.ErrMsg = resEleven10265.ErrMsg
  6119. res.Cainfo = resEleven10265.Cainfo
  6120. res.WarnMsg = resEleven10265.WarnMsg
  6121. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6122. res.Infcode = infocode
  6123. } else {
  6124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6125. utils.ErrorLog("解析失败:%v", err)
  6126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6127. return
  6128. }
  6129. }
  6130. }
  6131. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6132. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6133. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6134. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6135. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6136. var doctor_name string
  6137. if roles.ID == 0 {
  6138. doctor_name = "管理员"
  6139. } else {
  6140. doctor_name = roles.UserName
  6141. }
  6142. yiliao_leibie := ""
  6143. switch order.MedType {
  6144. case "11":
  6145. yiliao_leibie = "普通门诊"
  6146. break
  6147. case "12":
  6148. yiliao_leibie = "门诊挂号"
  6149. break
  6150. case "13":
  6151. yiliao_leibie = "急诊"
  6152. break
  6153. case "14":
  6154. yiliao_leibie = "门诊特殊病"
  6155. break
  6156. case "15":
  6157. yiliao_leibie = "门诊统筹"
  6158. break
  6159. case "16":
  6160. yiliao_leibie = "门诊慢性病"
  6161. break
  6162. case "21":
  6163. yiliao_leibie = "普通住院"
  6164. break
  6165. }
  6166. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6167. if res.Infcode == 0 {
  6168. c.ServeSuccessJSON(map[string]interface{}{
  6169. "diagnosis": name,
  6170. "order_infos": orderInfos,
  6171. "number": order.MdtrtId,
  6172. "date": order.SettleAccountsDate,
  6173. "charge_admin": charge_admin,
  6174. "printor_admin": printor_admin,
  6175. "info": res.Output.Setlinfo,
  6176. "bedCostTotal": bedCostTotal,
  6177. "bedCostSelfTotal": bedCostSelfTotal,
  6178. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6179. "operationCostTotal": operationCostTotal,
  6180. "operationCostSelfTotal": operationCostSelfTotal,
  6181. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6182. "otherCostTotal": otherCostTotal,
  6183. "otherCostSelfTotal": otherCostSelfTotal,
  6184. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6185. "materialCostTotal": materialCostTotal,
  6186. "materialCostSelfTotal": materialCostSelfTotal,
  6187. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6188. "westernMedicineCostTotal": westernMedicineCostTotal,
  6189. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6190. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6191. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6192. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6193. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6194. "checkCostTotal": checkCostTotal,
  6195. "checkCostSelfTotal": checkCostSelfTotal,
  6196. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6197. "laboratoryCostTotal": laboratoryCostTotal,
  6198. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6199. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6200. "treatCostTotal": treatCostTotal,
  6201. "treatCostSelfTotal": treatCostSelfTotal,
  6202. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6203. "doctor_code": adminRole_two.DoctorCode,
  6204. "doctor_name": doctor_name,
  6205. "health_card_no": order.PsnNo,
  6206. "department": departments.Name,
  6207. "yiliao_leibie": yiliao_leibie,
  6208. "after_money": order.AccountPrice,
  6209. "patient": patient,
  6210. "org_name": miConfig.OrgName,
  6211. "org_code": miConfig.Code,
  6212. "order_number": order.Number,
  6213. //"check_order_info": cus_slice,
  6214. })
  6215. }
  6216. }
  6217. }
  6218. func (c *HisApiController) CheckTreatment() {
  6219. patient_id, _ := c.GetInt64("patient_id", 0)
  6220. record_time := c.GetString("record_time")
  6221. insutype := c.GetString("insutype")
  6222. timeLayout := "2006-01-02"
  6223. loc, _ := time.LoadLocation("Local")
  6224. adminUser := c.GetAdminUserInfo()
  6225. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6226. fmt.Println(err)
  6227. if err != nil {
  6228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6229. return
  6230. }
  6231. recordDateTime := theTime.Unix()
  6232. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6233. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6234. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6235. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6236. var user_name string
  6237. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  6238. if role.ID == 0 {
  6239. user_name = "xxx"
  6240. } else {
  6241. user_name = role.UserName
  6242. }
  6243. baseParams := models.BaseParams{
  6244. SecretKey: miConfig.SecretKey,
  6245. FixmedinsCode: miConfig.Code,
  6246. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6247. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6248. OrgName: miConfig.OrgName,
  6249. Doctor: user_name,
  6250. }
  6251. if config.IsOpen == 1 {
  6252. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  6253. var dat map[string]interface{}
  6254. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6255. fmt.Println(dat)
  6256. } else {
  6257. fmt.Println(err)
  6258. }
  6259. }
  6260. }
  6261. func (c *HisApiController) PutRecord() {
  6262. id, _ := c.GetInt64("id")
  6263. record_time := c.GetString("record_time")
  6264. timeLayout := "2006-01-02"
  6265. loc, _ := time.LoadLocation("Local")
  6266. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6267. if err != nil {
  6268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6269. return
  6270. }
  6271. recordDateTime := theTime.Unix()
  6272. adminInfo := c.GetAdminUserInfo()
  6273. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  6274. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6275. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6276. fmt.Println(miConfig.SecretKey)
  6277. if patient == nil {
  6278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6279. return
  6280. }
  6281. if len(patient.IdCardNo) == 0 {
  6282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6283. return
  6284. }
  6285. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6286. if config.IsOpen == 1 {
  6287. 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
  6288. resp, requestErr := http.Get(api)
  6289. if requestErr != nil {
  6290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6291. return
  6292. }
  6293. defer resp.Body.Close()
  6294. body, ioErr := ioutil.ReadAll(resp.Body)
  6295. if ioErr != nil {
  6296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6298. return
  6299. }
  6300. var respJSON map[string]interface{}
  6301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6304. return
  6305. }
  6306. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6307. userJSONBytes, _ := json.Marshal(userJSON)
  6308. var res ResultTwo
  6309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6310. utils.ErrorLog("解析失败:%v", err)
  6311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6312. return
  6313. }
  6314. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6315. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6316. infoStr := string(Iinfos)
  6317. idetinfoStr := string(Idetinfos)
  6318. if res.Infcode == 0 {
  6319. his := models.VMHisPatient{
  6320. Status: 1,
  6321. Ctime: time.Now().Unix(),
  6322. Mtime: time.Now().Unix(),
  6323. PsnNo: res.Output.Baseinfo.PsnNo,
  6324. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6325. Certno: res.Output.Baseinfo.Certno,
  6326. PsnName: res.Output.Baseinfo.PsnName,
  6327. Gend: res.Output.Baseinfo.Gend,
  6328. Naty: res.Output.Baseinfo.Naty,
  6329. Brdy: res.Output.Baseinfo.Brdy,
  6330. Age: res.Output.Baseinfo.Age,
  6331. Iinfo: infoStr,
  6332. Idetinfo: idetinfoStr,
  6333. PatientId: patient.ID,
  6334. RecordDate: theTime.Unix(),
  6335. UserOrgId: adminInfo.CurrentOrgId,
  6336. AdminUserId: adminInfo.AdminUser.Id,
  6337. IsReturn: 1,
  6338. }
  6339. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  6340. 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")
  6341. 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")
  6342. var dat map[string]interface{}
  6343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6344. fmt.Println(dat)
  6345. } else {
  6346. fmt.Println(err)
  6347. }
  6348. var dat2 map[string]interface{}
  6349. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  6350. fmt.Println(dat2)
  6351. } else {
  6352. fmt.Println(err)
  6353. }
  6354. } else {
  6355. adminUser := c.GetAdminUserInfo()
  6356. errlog := &models.HisOrderError{
  6357. UserOrgId: adminUser.CurrentOrgId,
  6358. Ctime: time.Now().Unix(),
  6359. Mtime: time.Now().Unix(),
  6360. ErrMsg: res.ErrMsg,
  6361. Status: 1,
  6362. PatientId: id,
  6363. RecordTime: recordDateTime,
  6364. Stage: 1,
  6365. }
  6366. service.CreateErrMsgLog(errlog)
  6367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  6368. return
  6369. }
  6370. }
  6371. }
  6372. func (c *HisApiController) GetUploadDiag() {
  6373. id, _ := c.GetInt64("id")
  6374. record_time := c.GetString("record_time")
  6375. diagnosis_id, _ := c.GetInt64("diagnosis")
  6376. sick_type, _ := c.GetInt64("sick_type")
  6377. reg_type, _ := c.GetInt64("reg_type")
  6378. timeLayout := "2006-01-02"
  6379. loc, _ := time.LoadLocation("Local")
  6380. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6381. if err != nil {
  6382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6383. return
  6384. }
  6385. var patientPrescription models.HisPrescriptionInfo
  6386. recordDateTime := theTime.Unix()
  6387. adminInfo := c.GetAdminUserInfo()
  6388. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6389. if patientPrescription.ID == 0 {
  6390. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6391. }
  6392. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6393. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6394. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6395. sickConfig, _ := service.FindSickById(sick_type)
  6396. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6397. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  6398. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  6399. "&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 +
  6400. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  6401. resp2, requestErr2 := http.Get(api2)
  6402. if requestErr2 != nil {
  6403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6404. return
  6405. }
  6406. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6407. if ioErr2 != nil {
  6408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. return
  6411. }
  6412. var respJSON2 map[string]interface{}
  6413. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6416. return
  6417. }
  6418. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6419. userJSONBytes2, _ := json.Marshal(respJSON2)
  6420. var res2 ResultSix
  6421. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6422. utils.ErrorLog("解析失败:%v", err)
  6423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6424. return
  6425. }
  6426. if res2.Infcode != 0 {
  6427. adminUser := c.GetAdminUserInfo()
  6428. errlog := &models.HisOrderError{
  6429. UserOrgId: adminUser.CurrentOrgId,
  6430. Ctime: time.Now().Unix(),
  6431. Mtime: time.Now().Unix(),
  6432. ErrMsg: res2.ErrMsg,
  6433. Status: 1,
  6434. PatientId: id,
  6435. RecordTime: recordDateTime,
  6436. Stage: 3,
  6437. }
  6438. service.CreateErrMsgLog(errlog)
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  6440. return
  6441. }
  6442. c.ServeSuccessJSON(map[string]interface{}{
  6443. "msg": "上传成功",
  6444. })
  6445. }
  6446. type QueryResult struct {
  6447. ID int64
  6448. Name string
  6449. Code string
  6450. List_type_code string
  6451. }
  6452. func (c *HisApiController) GetCheckCode() {
  6453. ids_str := c.GetString("ids")
  6454. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6455. ids_arr := strings.Split(ids_str, ",")
  6456. var queryResult []QueryResult
  6457. ids := make([]int64, 0)
  6458. for _, item := range ids_arr {
  6459. id, _ := strconv.ParseInt(item, 10, 64)
  6460. ids = append(ids, id)
  6461. }
  6462. if record_type == 1 {
  6463. drugs, _ := service.GetBatchDrugList(ids)
  6464. for _, item := range drugs {
  6465. result := QueryResult{
  6466. ID: item.ID,
  6467. Name: item.DrugName,
  6468. Code: item.MedicalInsuranceNumber,
  6469. List_type_code: "101",
  6470. }
  6471. queryResult = append(queryResult, result)
  6472. }
  6473. } else if record_type == 2 {
  6474. goods, _ := service.GetBatchGoodInformationList(ids)
  6475. for _, item := range goods {
  6476. result := QueryResult{
  6477. ID: item.ID,
  6478. Name: item.GoodName,
  6479. Code: item.MedicalInsuranceNumber,
  6480. List_type_code: "301",
  6481. }
  6482. queryResult = append(queryResult, result)
  6483. }
  6484. } else if record_type == 3 {
  6485. projects, _ := service.GetBathchMyPorjecgList(ids)
  6486. for _, item := range projects {
  6487. result := QueryResult{
  6488. ID: item.ID,
  6489. Name: item.ProjectName,
  6490. Code: item.MedicalCode,
  6491. List_type_code: "201",
  6492. }
  6493. queryResult = append(queryResult, result)
  6494. }
  6495. }
  6496. admin_user_id, _ := c.GetInt64("admin_user_id")
  6497. adminUser := c.GetAdminUserInfo()
  6498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6499. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6500. var user_name string
  6501. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6502. if role.ID == 0 {
  6503. user_name = "xxx"
  6504. } else {
  6505. user_name = role.UserName
  6506. }
  6507. baseParams := &models.BaseParams{
  6508. SecretKey: miConfig.SecretKey,
  6509. FixmedinsCode: miConfig.Code,
  6510. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6511. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6512. OrgName: miConfig.OrgName,
  6513. Doctor: user_name,
  6514. }
  6515. if config.IsOpen == 1 {
  6516. for _, item := range queryResult {
  6517. var result string
  6518. if record_type == 1 {
  6519. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6520. } else if record_type == 2 {
  6521. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6522. } else if record_type == 3 {
  6523. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6524. }
  6525. var dat map[string]interface{}
  6526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6527. fmt.Println(dat)
  6528. } else {
  6529. fmt.Println(err)
  6530. }
  6531. userJSONBytes, _ := json.Marshal(dat)
  6532. var res ResultSix
  6533. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6534. utils.ErrorLog("解析失败:%v", err)
  6535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6536. return
  6537. }
  6538. if res.Infcode == 0 {
  6539. if record_type == 1 {
  6540. service.UpdateBaseDrugById(item.ID)
  6541. } else if record_type == 2 {
  6542. service.UpdateGoodInformaitonByDetail(item.ID)
  6543. } else if record_type == 3 {
  6544. service.UpdateProjectById(item.ID)
  6545. }
  6546. c.ServeSuccessJSON(map[string]interface{}{
  6547. "failed_code": 0,
  6548. "msg": "目录对照成功",
  6549. })
  6550. } else {
  6551. c.ServeSuccessJSON(map[string]interface{}{
  6552. "failed_code": -10,
  6553. "msg": res.ErrMsg,
  6554. })
  6555. }
  6556. }
  6557. }
  6558. }
  6559. func (c *HisApiController) UnCheckCode() {
  6560. ids_str := c.GetString("ids")
  6561. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6562. admin_user_id, _ := c.GetInt64("admin_user_id")
  6563. ids_arr := strings.Split(ids_str, ",")
  6564. var queryResult []QueryResult
  6565. ids := make([]int64, 0)
  6566. for _, item := range ids_arr {
  6567. id, _ := strconv.ParseInt(item, 10, 64)
  6568. ids = append(ids, id)
  6569. }
  6570. if record_type == 1 {
  6571. drugs, _ := service.GetBatchDrugList(ids)
  6572. for _, item := range drugs {
  6573. result := QueryResult{
  6574. ID: item.ID,
  6575. Name: item.DrugName,
  6576. Code: item.MedicalInsuranceNumber,
  6577. List_type_code: "101",
  6578. }
  6579. queryResult = append(queryResult, result)
  6580. }
  6581. } else if record_type == 2 {
  6582. goods, _ := service.GetBatchGoodInformationList(ids)
  6583. for _, item := range goods {
  6584. result := QueryResult{
  6585. ID: item.ID,
  6586. Name: item.GoodName,
  6587. Code: item.MedicalInsuranceNumber,
  6588. List_type_code: "301",
  6589. }
  6590. queryResult = append(queryResult, result)
  6591. }
  6592. } else if record_type == 3 {
  6593. projects, _ := service.GetBathchMyPorjecgList(ids)
  6594. for _, item := range projects {
  6595. result := QueryResult{
  6596. ID: item.ID,
  6597. Name: item.ProjectName,
  6598. Code: item.MedicalCode,
  6599. List_type_code: "201",
  6600. }
  6601. queryResult = append(queryResult, result)
  6602. }
  6603. }
  6604. adminUser := c.GetAdminUserInfo()
  6605. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6606. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6607. var user_name string
  6608. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6609. if role.ID == 0 {
  6610. user_name = "xxx"
  6611. } else {
  6612. user_name = role.UserName
  6613. }
  6614. baseParams := &models.BaseParams{
  6615. SecretKey: miConfig.SecretKey,
  6616. FixmedinsCode: miConfig.Code,
  6617. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6618. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6619. OrgName: miConfig.OrgName,
  6620. Doctor: user_name,
  6621. }
  6622. if config.IsOpen == 1 {
  6623. for _, item := range queryResult {
  6624. var result string
  6625. if record_type == 1 {
  6626. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6627. } else if record_type == 2 {
  6628. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6629. } else if record_type == 3 {
  6630. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6631. }
  6632. var dat2 map[string]interface{}
  6633. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  6634. fmt.Println(dat2)
  6635. } else {
  6636. fmt.Println(err)
  6637. }
  6638. userJSONBytes, _ := json.Marshal(dat2)
  6639. var res ResultSix
  6640. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6641. utils.ErrorLog("解析失败:%v", err)
  6642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6643. return
  6644. }
  6645. if res.Infcode == 0 {
  6646. if record_type == 1 {
  6647. service.UpdateDrugByIdDetail(item.ID)
  6648. } else if record_type == 2 {
  6649. service.UpdateGoodInfoById(item.ID)
  6650. } else if record_type == 3 {
  6651. service.UpdateMyProjectById(item.ID)
  6652. }
  6653. c.ServeSuccessJSON(map[string]interface{}{
  6654. "failed_code": 0,
  6655. "msg": "撤销目录对照成功",
  6656. })
  6657. } else {
  6658. c.ServeSuccessJSON(map[string]interface{}{
  6659. "failed_code": -10,
  6660. "msg": res.ErrMsg,
  6661. })
  6662. }
  6663. }
  6664. }
  6665. }
  6666. func (c *HisApiController) GetPatientInfo() {
  6667. id_card_no := c.GetString("id_card_no")
  6668. admin_user_id, _ := c.GetInt64("admin_user_id")
  6669. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6670. if patient.ID == 0 {
  6671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6672. return
  6673. }
  6674. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6675. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6676. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  6677. if config.IsOpen == 1 {
  6678. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6679. var dat map[string]interface{}
  6680. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6681. fmt.Println(dat)
  6682. } else {
  6683. fmt.Println(err)
  6684. }
  6685. userJSONBytes, _ := json.Marshal(dat)
  6686. var res ResultTwo
  6687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6688. utils.ErrorLog("解析失败:%v", err)
  6689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6690. return
  6691. }
  6692. if res.Infcode != 0 {
  6693. c.ServeSuccessJSON(map[string]interface{}{
  6694. "failed_code": -10,
  6695. "msg": res.ErrMsg,
  6696. })
  6697. } else {
  6698. c.ServeSuccessJSON(map[string]interface{}{
  6699. "failed_code": 0,
  6700. "info": res,
  6701. })
  6702. }
  6703. }
  6704. }
  6705. func (c *HisApiController) PsnPutOnRecord() {
  6706. record_type, _ := c.GetInt64("type")
  6707. patient_id, _ := c.GetInt64("patient_id")
  6708. admin_user_id, _ := c.GetInt64("admin_user_id")
  6709. start_time := c.GetString("start_time")
  6710. end_time := c.GetString("end_time")
  6711. adminUser := c.GetAdminUserInfo()
  6712. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6713. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6714. var patients []*models.Patients
  6715. if record_type == 1 { //全部备案
  6716. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  6717. patients = append(patients, patient...)
  6718. } else { //单个备案
  6719. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6720. patients = append(patients, patient)
  6721. }
  6722. var user_name string
  6723. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6724. if role.ID == 0 {
  6725. user_name = "xxx"
  6726. } else {
  6727. user_name = role.UserName
  6728. }
  6729. if config.IsOpen == 1 {
  6730. for _, item := range patients {
  6731. 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
  6732. resp, requestErr := http.Get(api)
  6733. if requestErr != nil {
  6734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6735. return
  6736. }
  6737. defer resp.Body.Close()
  6738. body, ioErr := ioutil.ReadAll(resp.Body)
  6739. if ioErr != nil {
  6740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6742. return
  6743. }
  6744. var respJSON map[string]interface{}
  6745. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6748. return
  6749. }
  6750. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6751. userJSONBytes, _ := json.Marshal(userJSON)
  6752. var res ResultTwo
  6753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6754. utils.ErrorLog("解析失败:%v", err)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. return
  6757. }
  6758. if res.Infcode == 0 {
  6759. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  6760. var dat map[string]interface{}
  6761. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6762. fmt.Println(dat)
  6763. } else {
  6764. fmt.Println(err)
  6765. }
  6766. userJSONBytes, _ := json.Marshal(dat)
  6767. var res2 ResultThirteen
  6768. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6769. utils.ErrorLog("解析失败:%v", err)
  6770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6771. return
  6772. }
  6773. if res2.Infcode == 0 {
  6774. psnResult := &models.GdybPsnRecord{
  6775. UserOrgId: adminUser.CurrentOrgId,
  6776. PatientId: item.ID,
  6777. PsnNo: res.Output.Baseinfo.PsnNo,
  6778. Ctime: time.Now().Unix(),
  6779. Mtime: time.Now().Unix(),
  6780. Status: 1,
  6781. IsCancel: 1,
  6782. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6783. }
  6784. service.CreatePsnRecord(psnResult)
  6785. } else {
  6786. c.ServeSuccessJSON(map[string]interface{}{
  6787. "failed_code": -10,
  6788. "msg": res2.ErrMsg,
  6789. })
  6790. return
  6791. }
  6792. }
  6793. }
  6794. }
  6795. }
  6796. func (c *HisApiController) PsnUnPutOnRecord() {
  6797. id, _ := c.GetInt64("id")
  6798. //record_type, _ := c.GetInt64("type")
  6799. admin_user_id, _ := c.GetInt64("admin_user_id")
  6800. adminUser := c.GetAdminUserInfo()
  6801. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6802. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6803. var user_name string
  6804. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6805. if role.ID == 0 {
  6806. user_name = "xxx"
  6807. } else {
  6808. user_name = role.UserName
  6809. }
  6810. psn_record, _ := service.GetPsnRecordById(id)
  6811. if psn_record.ID == 0 {
  6812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6813. return
  6814. }
  6815. if config.IsOpen == 1 {
  6816. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6817. var dat map[string]interface{}
  6818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6819. fmt.Println(dat)
  6820. } else {
  6821. fmt.Println(err)
  6822. }
  6823. userJSONBytes, _ := json.Marshal(dat)
  6824. var res ResultFourteen
  6825. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6826. utils.ErrorLog("解析失败:%v", err)
  6827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6828. return
  6829. }
  6830. if res.Infcode == 0 {
  6831. psn_record.IsCancel = 2
  6832. service.CreatePsnRecord(&psn_record)
  6833. } else {
  6834. c.ServeSuccessJSON(map[string]interface{}{
  6835. "failed_code": -10,
  6836. "msg": res.ErrMsg,
  6837. })
  6838. return
  6839. }
  6840. }
  6841. }
  6842. func (c *HisApiController) PsnPutNCDSOnRecord() {
  6843. patient_id, _ := c.GetInt64("patient_id")
  6844. insutype := c.GetString("insutype")
  6845. psn_no := c.GetString("psn_no")
  6846. doctor_id, _ := c.GetInt64("doctor_id")
  6847. sick_id, _ := c.GetInt64("sick_id")
  6848. department_id, _ := c.GetInt64("department_id")
  6849. adminUser := c.GetAdminUserInfo()
  6850. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6851. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6852. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6853. sick, _ := service.FindSickById(sick_id)
  6854. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6855. if config.IsOpen == 1 {
  6856. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode)
  6857. var dat map[string]interface{}
  6858. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6859. fmt.Println(dat)
  6860. } else {
  6861. fmt.Println(err)
  6862. }
  6863. userJSONBytes, _ := json.Marshal(dat)
  6864. var res2 ResultThirteen
  6865. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6866. utils.ErrorLog("解析失败:%v", err)
  6867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6868. return
  6869. }
  6870. if res2.Infcode == 0 {
  6871. psnResult := &models.GdybPsnNcdsRecord{
  6872. UserOrgId: adminUser.CurrentOrgId,
  6873. PatientId: patient.ID,
  6874. PsnNo: psn_no,
  6875. DoctorId: doctor.AdminUserId,
  6876. DepartmentId: department_id,
  6877. SickType: sick_id,
  6878. Insutype: insutype,
  6879. Ctime: time.Now().Unix(),
  6880. Mtime: time.Now().Unix(),
  6881. Status: 1,
  6882. IsCancel: 1,
  6883. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6884. }
  6885. service.CreatePsnNCDSRecord(psnResult)
  6886. c.ServeSuccessJSON(map[string]interface{}{
  6887. "failed_code": 0,
  6888. "msg": "备案成功",
  6889. "result": psnResult,
  6890. })
  6891. } else {
  6892. c.ServeSuccessJSON(map[string]interface{}{
  6893. "failed_code": -10,
  6894. "msg": res2.ErrMsg,
  6895. })
  6896. return
  6897. }
  6898. }
  6899. }
  6900. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  6901. id, _ := c.GetInt64("id")
  6902. admin_user_id, _ := c.GetInt64("admin_user_id")
  6903. adminUser := c.GetAdminUserInfo()
  6904. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6905. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6906. var user_name string
  6907. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6908. if role.ID == 0 {
  6909. user_name = "xxx"
  6910. } else {
  6911. user_name = role.UserName
  6912. }
  6913. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6914. if psn_record.ID == 0 {
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6916. return
  6917. }
  6918. if config.IsOpen == 1 {
  6919. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6920. var dat map[string]interface{}
  6921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6922. fmt.Println(dat)
  6923. } else {
  6924. fmt.Println(err)
  6925. }
  6926. userJSONBytes, _ := json.Marshal(dat)
  6927. var res ResultFourteen
  6928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6929. utils.ErrorLog("解析失败:%v", err)
  6930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6931. return
  6932. }
  6933. if res.Infcode == 0 {
  6934. psn_record.IsCancel = 2
  6935. service.CreatePsnNCDSRecord(&psn_record)
  6936. c.ServeSuccessJSON(map[string]interface{}{
  6937. "failed_code": 0,
  6938. "msg": "撤销备案成功",
  6939. })
  6940. } else {
  6941. c.ServeSuccessJSON(map[string]interface{}{
  6942. "failed_code": -10,
  6943. "msg": res.ErrMsg,
  6944. })
  6945. return
  6946. }
  6947. }
  6948. }
  6949. func (c *HisApiController) TestTest() {
  6950. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  6951. fmt.Println(patient.Iinfo)
  6952. }
  6953. type CustomData struct {
  6954. MsgId string
  6955. PsnNo string
  6956. Info string
  6957. }
  6958. func (c *HisApiController) ReversalData() {
  6959. var customData []*CustomData
  6960. custom := &CustomData{
  6961. MsgId: "H44022900158202103301714472004",
  6962. PsnNo: "44020000001101329945",
  6963. Info: "2207",
  6964. }
  6965. customData = append(customData, custom)
  6966. custom1 := &CustomData{
  6967. MsgId: "H4402290015820210330172057803",
  6968. PsnNo: "44020000001101161813",
  6969. Info: "2207",
  6970. }
  6971. customData = append(customData, custom1)
  6972. custom2 := &CustomData{
  6973. MsgId: "H44022900158202103301705198813",
  6974. PsnNo: "44190000133097375417",
  6975. Info: "2207",
  6976. }
  6977. customData = append(customData, custom2)
  6978. custom3 := &CustomData{
  6979. MsgId: "H44022900158202103301715524756",
  6980. PsnNo: "44020000001100187221",
  6981. Info: "2207",
  6982. }
  6983. customData = append(customData, custom3)
  6984. custom4 := &CustomData{
  6985. MsgId: "H44022900158202103301730376224",
  6986. PsnNo: "44020000001101959155",
  6987. Info: "2207",
  6988. }
  6989. customData = append(customData, custom4)
  6990. custom5 := &CustomData{
  6991. MsgId: "H44022900158202103301748008725",
  6992. PsnNo: "44020000001104246641",
  6993. Info: "2207",
  6994. }
  6995. customData = append(customData, custom5)
  6996. custom6 := &CustomData{
  6997. MsgId: "H44022900158202103301718096755",
  6998. PsnNo: "44020000001102211860",
  6999. Info: "2207",
  7000. }
  7001. customData = append(customData, custom6)
  7002. custom7 := &CustomData{
  7003. MsgId: "H44022900158202103301736551640",
  7004. PsnNo: "44020000001102687718",
  7005. Info: "2207",
  7006. }
  7007. customData = append(customData, custom7)
  7008. custom8 := &CustomData{
  7009. MsgId: "H44022900158202103301743097676",
  7010. PsnNo: "44020000001102127785",
  7011. Info: "2207",
  7012. }
  7013. customData = append(customData, custom8)
  7014. custom9 := &CustomData{
  7015. MsgId: "H44022900158202103301712304203",
  7016. PsnNo: "44020000001101518097",
  7017. Info: "2207",
  7018. }
  7019. customData = append(customData, custom9)
  7020. custom10 := &CustomData{
  7021. MsgId: "H44022900158202103301738448785",
  7022. PsnNo: "44020000001100500813",
  7023. Info: "2207",
  7024. }
  7025. customData = append(customData, custom10)
  7026. custom11 := &CustomData{
  7027. MsgId: "H44022900158202103301732455843",
  7028. PsnNo: "44020000001102690557",
  7029. Info: "2207",
  7030. }
  7031. customData = append(customData, custom11)
  7032. custom12 := &CustomData{
  7033. MsgId: "H44022900158202103301745421708",
  7034. PsnNo: "44020000001102211928",
  7035. Info: "2207",
  7036. }
  7037. customData = append(customData, custom12)
  7038. custom1212 := &CustomData{
  7039. MsgId: "H440229001582021033017351627",
  7040. PsnNo: "44020000001102481733",
  7041. Info: "2207",
  7042. }
  7043. customData = append(customData, custom1212)
  7044. custom13 := &CustomData{
  7045. MsgId: "H44022900158202103301740327951",
  7046. PsnNo: "44020000001103174866",
  7047. Info: "2207",
  7048. }
  7049. customData = append(customData, custom13)
  7050. custom14 := &CustomData{
  7051. MsgId: "H4402290015820210330174922668",
  7052. PsnNo: "44020000001102927272",
  7053. Info: "2207",
  7054. }
  7055. customData = append(customData, custom14)
  7056. custom15 := &CustomData{
  7057. MsgId: "H44022900158202103301752362273",
  7058. PsnNo: "44020000001102942890",
  7059. Info: "2207",
  7060. }
  7061. customData = append(customData, custom15)
  7062. custom16 := &CustomData{
  7063. MsgId: "H44022900158202103301751082917",
  7064. PsnNo: "44020000001101662162",
  7065. Info: "2207",
  7066. }
  7067. customData = append(customData, custom16)
  7068. custom17 := &CustomData{
  7069. MsgId: "H44022900158202103301754147728",
  7070. PsnNo: "44020000000229014511",
  7071. Info: "2207",
  7072. }
  7073. customData = append(customData, custom17)
  7074. adminUser := c.GetAdminUserInfo()
  7075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7076. for _, item := range customData {
  7077. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7078. fmt.Println(result)
  7079. }
  7080. }
  7081. func (c *HisApiController) ReversalOtherData() {
  7082. var customData []*CustomData
  7083. custom := &CustomData{
  7084. MsgId: "H44022900158202103301714472004",
  7085. PsnNo: "44020000001101329945",
  7086. Info: "2208",
  7087. }
  7088. customData = append(customData, custom)
  7089. custom1 := &CustomData{
  7090. MsgId: "H4402290015820210330172057803",
  7091. PsnNo: "44020000001101161813",
  7092. Info: "2208",
  7093. }
  7094. customData = append(customData, custom1)
  7095. custom2 := &CustomData{
  7096. MsgId: "H44022900158202103301705198813",
  7097. PsnNo: "44190000133097375417",
  7098. Info: "2208",
  7099. }
  7100. customData = append(customData, custom2)
  7101. custom3 := &CustomData{
  7102. MsgId: "H44022900158202103301715524756",
  7103. PsnNo: "44020000001100187221",
  7104. Info: "2208",
  7105. }
  7106. customData = append(customData, custom3)
  7107. custom4 := &CustomData{
  7108. MsgId: "H44022900158202103301730376224",
  7109. PsnNo: "44020000001101959155",
  7110. Info: "2208",
  7111. }
  7112. customData = append(customData, custom4)
  7113. custom5 := &CustomData{
  7114. MsgId: "H44022900158202103301748008725",
  7115. PsnNo: "44020000001104246641",
  7116. Info: "2208",
  7117. }
  7118. customData = append(customData, custom5)
  7119. custom6 := &CustomData{
  7120. MsgId: "H44022900158202103301718096755",
  7121. PsnNo: "44020000001102211860",
  7122. Info: "2208",
  7123. }
  7124. customData = append(customData, custom6)
  7125. custom7 := &CustomData{
  7126. MsgId: "H44022900158202103301736551640",
  7127. PsnNo: "44020000001102687718",
  7128. Info: "2208",
  7129. }
  7130. customData = append(customData, custom7)
  7131. custom8 := &CustomData{
  7132. MsgId: "H44022900158202103301743097676",
  7133. PsnNo: "44020000001102127785",
  7134. Info: "2208",
  7135. }
  7136. customData = append(customData, custom8)
  7137. custom9 := &CustomData{
  7138. MsgId: "H44022900158202103301712304203",
  7139. PsnNo: "44020000001101518097",
  7140. Info: "2208",
  7141. }
  7142. customData = append(customData, custom9)
  7143. custom10 := &CustomData{
  7144. MsgId: "H44022900158202103301738448785",
  7145. PsnNo: "44020000001100500813",
  7146. Info: "2208",
  7147. }
  7148. customData = append(customData, custom10)
  7149. custom11 := &CustomData{
  7150. MsgId: "H44022900158202103301732455843",
  7151. PsnNo: "44020000001102690557",
  7152. Info: "2208",
  7153. }
  7154. customData = append(customData, custom11)
  7155. custom12 := &CustomData{
  7156. MsgId: "H44022900158202103301745421708",
  7157. PsnNo: "44020000001102211928",
  7158. Info: "2208",
  7159. }
  7160. customData = append(customData, custom12)
  7161. custom1212 := &CustomData{
  7162. MsgId: "H440229001582021033017351627",
  7163. PsnNo: "44020000001102481733",
  7164. Info: "2208",
  7165. }
  7166. customData = append(customData, custom1212)
  7167. custom13 := &CustomData{
  7168. MsgId: "H44022900158202103301740327951",
  7169. PsnNo: "44020000001103174866",
  7170. Info: "2208",
  7171. }
  7172. customData = append(customData, custom13)
  7173. custom14 := &CustomData{
  7174. MsgId: "H4402290015820210330174922668",
  7175. PsnNo: "44020000001102927272",
  7176. Info: "2208",
  7177. }
  7178. customData = append(customData, custom14)
  7179. custom15 := &CustomData{
  7180. MsgId: "H44022900158202103301752362273",
  7181. PsnNo: "44020000001102942890",
  7182. Info: "2208",
  7183. }
  7184. customData = append(customData, custom15)
  7185. custom16 := &CustomData{
  7186. MsgId: "H44022900158202103301751082917",
  7187. PsnNo: "44020000001101662162",
  7188. Info: "2208",
  7189. }
  7190. customData = append(customData, custom16)
  7191. custom17 := &CustomData{
  7192. MsgId: "H44022900158202103301754147728",
  7193. PsnNo: "44020000000229014511",
  7194. Info: "2208",
  7195. }
  7196. customData = append(customData, custom17)
  7197. adminUser := c.GetAdminUserInfo()
  7198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7199. for _, item := range customData {
  7200. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7201. fmt.Println(result)
  7202. }
  7203. }
  7204. func PathExists(path string) (bool, error) {
  7205. _, err := os.Stat(path)
  7206. if err == nil {
  7207. return true, nil
  7208. }
  7209. if os.IsNotExist(err) {
  7210. return false, nil
  7211. }
  7212. return false, err
  7213. }
  7214. //创建文件夹
  7215. func Mkdir(dir string) {
  7216. // 创建文件夹
  7217. exist, err := PathExists(dir)
  7218. if err != nil {
  7219. fmt.Println(err.Error())
  7220. } else {
  7221. if exist {
  7222. fmt.Println(dir + "文件夹已存在!")
  7223. } else {
  7224. // 文件夹名称,权限
  7225. err := os.Mkdir(dir, os.ModePerm)
  7226. if err != nil {
  7227. fmt.Println(dir+"文件夹创建失败:", err.Error())
  7228. } else {
  7229. fmt.Println(dir + "文件夹创建成功!")
  7230. }
  7231. }
  7232. }
  7233. }
  7234. //压缩文件
  7235. func Zip(srcFile string, destZip string) error {
  7236. zipfile, err := os.Create(destZip)
  7237. if err != nil {
  7238. return err
  7239. }
  7240. defer zipfile.Close()
  7241. archive := zip.NewWriter(zipfile)
  7242. defer archive.Close()
  7243. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  7244. if err != nil {
  7245. return err
  7246. }
  7247. header, err := zip.FileInfoHeader(info)
  7248. if err != nil {
  7249. return err
  7250. }
  7251. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  7252. // header.Name = path
  7253. if info.IsDir() {
  7254. header.Name += "/"
  7255. } else {
  7256. header.Method = zip.Deflate
  7257. }
  7258. writer, err := archive.CreateHeader(header)
  7259. if err != nil {
  7260. return err
  7261. }
  7262. if !info.IsDir() {
  7263. file, err := os.Open(path)
  7264. if err != nil {
  7265. return err
  7266. }
  7267. defer file.Close()
  7268. _, err = io.Copy(writer, file)
  7269. }
  7270. return err
  7271. })
  7272. return err
  7273. }
  7274. func ReadFile(filePath string) []byte {
  7275. f, err := os.Open(filePath)
  7276. if err != nil {
  7277. fmt.Println("read file fail", err)
  7278. return nil
  7279. }
  7280. defer f.Close()
  7281. fd, err := ioutil.ReadAll(f)
  7282. if err != nil {
  7283. fmt.Println("read to fd fail", err)
  7284. return nil
  7285. }
  7286. return fd
  7287. }
  7288. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  7289. newArr = make([]*models.HisOrderInfo, 0)
  7290. for i := 0; i < len(arr); i++ {
  7291. repeat := false
  7292. for j := i + 1; j < len(arr); j++ {
  7293. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  7294. repeat = true
  7295. break
  7296. }
  7297. }
  7298. if !repeat {
  7299. newArr = append(newArr, arr[i])
  7300. }
  7301. }
  7302. return
  7303. }
  7304. func saveRegisterLog(result string) {
  7305. org_id, _ := beego.AppConfig.Int64("org_id")
  7306. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7307. dir := miConfig.OrgName + "日志"
  7308. utils.Mkdir(dir)
  7309. month := time.Unix(1557042972, 0).Format("1")
  7310. year := time.Now().Format("2006")
  7311. month = time.Now().Format("01")
  7312. day := time.Now().Format("02")
  7313. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7314. file_name := file + ".txt"
  7315. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7316. exist, _ := utils.PathExists(file_path)
  7317. if exist { //存在
  7318. fmt.Println("存在")
  7319. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7320. if err != nil {
  7321. fmt.Println("read fail")
  7322. }
  7323. content := "\r\n" + result
  7324. n, _ := f.Seek(0, 2)
  7325. _, err = f.WriteAt([]byte(content), n)
  7326. } else { //不存在
  7327. fmt.Println("文件不存在,创建文件")
  7328. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7329. defer f.Close()
  7330. if err != nil {
  7331. } else {
  7332. _, err = f.Write([]byte("记录日志"))
  7333. }
  7334. }
  7335. }
  7336. func saveLog(result string, request string, infno string, desc string) {
  7337. org_id, _ := beego.AppConfig.Int64("org_id")
  7338. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7339. dir := miConfig.OrgName + "日志"
  7340. utils.Mkdir(dir)
  7341. month := time.Unix(1557042972, 0).Format("1")
  7342. year := time.Now().Format("2006")
  7343. month = time.Now().Format("01")
  7344. day := time.Now().Format("02")
  7345. hour := time.Now().Format("15")
  7346. min := time.Now().Format("04")
  7347. sec := time.Now().Format("05")
  7348. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  7349. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7350. file_name := file + ".txt"
  7351. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7352. exist, _ := utils.PathExists(file_path)
  7353. if exist { //存在
  7354. fmt.Println("存在")
  7355. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7356. if err != nil {
  7357. fmt.Println("read fail")
  7358. }
  7359. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  7360. n, _ := f.Seek(0, 2)
  7361. _, err = f.WriteAt([]byte(content), n)
  7362. } else { //不存在
  7363. fmt.Println("文件不存在,创建文件")
  7364. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7365. defer f.Close()
  7366. if err != nil {
  7367. } else {
  7368. _, err = f.Write([]byte("记录日志"))
  7369. }
  7370. }
  7371. }
  7372. type Charset string
  7373. const (
  7374. UTF8 = Charset("UTF-8")
  7375. GB18030 = Charset("GB18030")
  7376. )
  7377. func ConvertToString(src string, srcCode string, tagCode string) string {
  7378. srcCoder := mahonia.NewDecoder(srcCode)
  7379. srcResult := srcCoder.ConvertString(src)
  7380. tagCoder := mahonia.NewDecoder(tagCode)
  7381. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  7382. result := string(cdata)
  7383. return result
  7384. }
  7385. //func (c *HisApiController)HandleCheckDetailAccount(){
  7386. // psn_no, _ := c.GetString("psn_no")
  7387. // psn_no, _ := c.GetString("psn_no")
  7388. // psn_no, _ := c.GetString("psn_no")
  7389. //
  7390. //
  7391. //
  7392. //}