his_api_controller.go 296KB

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