his_api_controller.go 377KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. api := "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  93. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  94. resp, requestErr := http.Get(api)
  95. if requestErr != nil {
  96. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  97. return
  98. }
  99. body, ioErr := ioutil.ReadAll(resp.Body)
  100. if ioErr != nil {
  101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. var respJSON map[string]interface{}
  106. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  112. result, _ := json.Marshal(respJSON)
  113. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  114. utils.ErrorLog("解析失败:%v", err)
  115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  116. return
  117. }
  118. res.ErrMsg = res10265.ErrMsg
  119. res.Output = res10265.Output
  120. res.InfRefmsgid = res10265.InfRefmsgid
  121. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  122. res.Infcode = infocode
  123. } else {
  124. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  125. var dat map[string]interface{}
  126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  127. fmt.Println(dat)
  128. } else {
  129. fmt.Println(err)
  130. }
  131. userJSONBytes, _ := json.Marshal(dat)
  132. if miConfig.Code == "H15049901371" {
  133. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  134. utils.ErrorLog("解析失败:%v", err)
  135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  136. return
  137. }
  138. res.InfRefmsgid = res10265.InfRefmsgid
  139. res.Output = res10265.Output
  140. res.ErrMsg = res10265.ErrMsg
  141. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  142. res.Infcode = infocode
  143. } else {
  144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  145. utils.ErrorLog("解析失败:%v", err)
  146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  147. return
  148. }
  149. }
  150. }
  151. if res.Infcode == 0 {
  152. c.ServeSuccessJSON(map[string]interface{}{
  153. "result": res.Output.Result,
  154. })
  155. }
  156. }
  157. func (c *HisApiController) CheckInsutype() {
  158. his_patient_id, _ := c.GetInt64("his_patient_id")
  159. admin_user_id, _ := c.GetInt64("admin_user_id")
  160. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  161. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  162. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  163. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  164. var dat map[string]interface{}
  165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  166. fmt.Println(dat)
  167. } else {
  168. fmt.Println(err)
  169. }
  170. userJSONBytes, _ := json.Marshal(dat)
  171. var res Result90100
  172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  173. utils.ErrorLog("解析失败:%v", err)
  174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  175. return
  176. }
  177. if res.Infcode != 0 {
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "failed_code": -10,
  180. "msg": res.ErrMsg,
  181. })
  182. return
  183. } else {
  184. fmt.Println(res)
  185. }
  186. }
  187. func (c *HisApiController) CheckCardPWD() {
  188. card_pwd := c.GetString("card_pwd")
  189. his_patient_id, _ := c.GetInt64("his_patient_id")
  190. admin_user_id, _ := c.GetInt64("admin_user_id")
  191. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  193. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  194. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  195. var dat map[string]interface{}
  196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  197. fmt.Println(dat)
  198. } else {
  199. fmt.Println(err)
  200. }
  201. userJSONBytes, _ := json.Marshal(dat)
  202. var res Result90991
  203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  204. utils.ErrorLog("解析失败:%v", err)
  205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  206. return
  207. }
  208. if res.Infcode != 0 {
  209. c.ServeSuccessJSON(map[string]interface{}{
  210. "failed_code": -10,
  211. "msg": res.ErrMsg,
  212. })
  213. return
  214. } else {
  215. if res.Output.Result.CheckStat == "0" {
  216. var msg string
  217. switch res.Output.Result.CardStat {
  218. case "00":
  219. msg = "未激活"
  220. break
  221. case "10":
  222. msg = "激活"
  223. break
  224. case "20":
  225. msg = "窗口挂失"
  226. break
  227. case "21":
  228. msg = "电话挂失"
  229. break
  230. case "22":
  231. msg = "单位网上申报挂失"
  232. break
  233. case "23":
  234. msg = "保健办挂失"
  235. break
  236. case "24":
  237. msg = "个人网上挂失"
  238. break
  239. case "25":
  240. msg = "网上服务大厅挂失"
  241. break
  242. case "30":
  243. msg = "注销"
  244. break
  245. case "40":
  246. msg = "回收"
  247. break
  248. case "99":
  249. msg = "制卡中(无效卡)"
  250. break
  251. }
  252. c.ServeSuccessJSON(map[string]interface{}{
  253. "failed_code": -10,
  254. "msg": msg,
  255. })
  256. return
  257. } else {
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "msg": "校验成功",
  260. })
  261. return
  262. }
  263. }
  264. }
  265. func (c *HisApiController) ReadCard() {
  266. id_card_type, _ := c.GetInt64("id_card_type")
  267. admin_user_id, _ := c.GetInt64("admin_user_id")
  268. certificates, _ := c.GetInt64("certificates")
  269. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  270. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  271. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  272. switch id_card_type {
  273. case 1:
  274. if miConfig.MdtrtareaAdmvs == "421300" {
  275. var res ResultTwo
  276. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  277. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  278. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  279. resp, requestErr := http.Get(api)
  280. if requestErr != nil {
  281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  282. return
  283. }
  284. body, ioErr := ioutil.ReadAll(resp.Body)
  285. if ioErr != nil {
  286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. var respJSON map[string]interface{}
  291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  297. result, _ := json.Marshal(respJSON)
  298. fmt.Println("log")
  299. fmt.Println(string(result))
  300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  301. utils.ErrorLog("解析失败:%v", err)
  302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  303. return
  304. }
  305. if res.Infcode == 0 {
  306. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  307. if err == gorm.ErrRecordNotFound {
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  309. return
  310. } else if err != nil {
  311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  312. return
  313. } else {
  314. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  315. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  316. infoStr := string(Iinfos)
  317. idetinfoStr := string(Idetinfos)
  318. psn := &models.HisPsn{
  319. PsnNo: res.Output.Baseinfo.PsnNo,
  320. Age: res.Output.Baseinfo.Age,
  321. PatientId: patient.ID,
  322. Certno: res.Output.Baseinfo.Certno,
  323. Brdy: res.Output.Baseinfo.Brdy,
  324. Gend: res.Output.Baseinfo.Gend,
  325. Naty: res.Output.Baseinfo.Naty,
  326. PsnCertType: res.Output.Baseinfo.PsnCertType,
  327. PsnName: res.Output.Baseinfo.PsnName,
  328. Idetinfo: idetinfoStr,
  329. Insuinfo: infoStr,
  330. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  331. }
  332. service.CreateHisPsn(psn)
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "patient": patient,
  335. "number": res.Output.Baseinfo.Certno,
  336. })
  337. }
  338. } else {
  339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  340. return
  341. }
  342. } else if miConfig.MdtrtareaAdmvs == "320921" {
  343. api := "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  345. resp, requestErr := http.Get(api)
  346. if requestErr != nil {
  347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  348. return
  349. }
  350. body, ioErr := ioutil.ReadAll(resp.Body)
  351. if ioErr != nil {
  352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  354. return
  355. }
  356. var respJSON map[string]interface{}
  357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. var status string
  363. status = respJSON["data"].(map[string]interface{})["status"].(string)
  364. if status == "0" { //读卡成功
  365. var card_info string //卡信息
  366. var busi_card_info string
  367. var res ResultTwo //1101结果
  368. var res10265 ResultTwo10265 //1101结果
  369. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  370. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  371. fmt.Println(card_info)
  372. fmt.Println(busi_card_info)
  373. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  374. result, _ := json.Marshal(respJSON)
  375. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  376. utils.ErrorLog("解析失败:%v", err)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return
  379. }
  380. res.ErrMsg = res10265.ErrMsg
  381. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  382. res.Infcode = infocode
  383. res.Output = res10265.Output
  384. res.InfRefmsgid = res10265.InfRefmsgid
  385. if res.Infcode == 0 {
  386. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  387. if err == gorm.ErrRecordNotFound {
  388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  389. return
  390. } else if err != nil {
  391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  392. return
  393. } else {
  394. bas := strings.Split(card_info, "|")
  395. basNumber := bas[2]
  396. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  397. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  398. infoStr := string(Iinfos)
  399. idetinfoStr := string(Idetinfos)
  400. psn := &models.HisPsn{
  401. PsnNo: res.Output.Baseinfo.PsnNo,
  402. Age: res.Output.Baseinfo.Age,
  403. PatientId: patient.ID,
  404. Certno: res.Output.Baseinfo.Certno,
  405. Brdy: res.Output.Baseinfo.Brdy,
  406. Gend: res.Output.Baseinfo.Gend,
  407. Naty: res.Output.Baseinfo.Naty,
  408. PsnCertType: res.Output.Baseinfo.PsnCertType,
  409. PsnName: res.Output.Baseinfo.PsnName,
  410. Idetinfo: idetinfoStr,
  411. Insuinfo: infoStr,
  412. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  413. CardInfo: card_info,
  414. VerifyNumber: busi_card_info,
  415. }
  416. service.CreateHisPsn(psn)
  417. c.ServeSuccessJSON(map[string]interface{}{
  418. "patient": patient,
  419. "number": basNumber,
  420. })
  421. }
  422. } else {
  423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  424. return
  425. }
  426. } else { //读卡失败
  427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  428. return
  429. }
  430. } else {
  431. if initFlag == 0 {
  432. c.TestGetBasBaseInit()
  433. }
  434. basStr := c.GetBasBaseInfo()
  435. if len(basStr) == 0 {
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  437. return
  438. }
  439. fmt.Println(basStr)
  440. bas := strings.Split(basStr, "|")
  441. basNumber := bas[1]
  442. fmt.Println(basNumber)
  443. card_sn := bas[3]
  444. fmt.Println(card_sn)
  445. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  446. var dat map[string]interface{}
  447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  448. fmt.Println(dat)
  449. } else {
  450. fmt.Println(err)
  451. }
  452. userJSONBytes, _ := json.Marshal(dat)
  453. var res ResultTwo
  454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  455. utils.ErrorLog("解析失败:%v", err)
  456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  457. return
  458. }
  459. if res.Infcode == 0 {
  460. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  461. if err == gorm.ErrRecordNotFound {
  462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  463. return
  464. } else if err != nil {
  465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  466. return
  467. } else {
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "patient": patient,
  470. "number": basNumber,
  471. })
  472. }
  473. } else {
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  475. return
  476. }
  477. break
  478. }
  479. case 2:
  480. SFZStr := c.GetSFZBaseInfo()
  481. id_card_str := strings.Split(SFZStr, "^")
  482. id_card_number := id_card_str[0]
  483. card_sn := ""
  484. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  485. var dat map[string]interface{}
  486. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  487. fmt.Println(dat)
  488. } else {
  489. fmt.Println(err)
  490. }
  491. userJSONBytes, _ := json.Marshal(dat)
  492. var res ResultTwo
  493. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  494. utils.ErrorLog("解析失败:%v", err)
  495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  496. return
  497. }
  498. if res.Infcode == 0 {
  499. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  500. if err == gorm.ErrRecordNotFound {
  501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  502. return
  503. } else if err != nil {
  504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  505. return
  506. } else {
  507. c.ServeSuccessJSON(map[string]interface{}{
  508. "patient": patient,
  509. "number": id_card_number,
  510. })
  511. }
  512. } else {
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  514. return
  515. }
  516. break
  517. case 3:
  518. break
  519. }
  520. }
  521. var initFlag int64 = 0
  522. func (c *HisApiController) TestGetBasBaseInit() {
  523. DllDef := syscall.MustLoadDLL("SSCard.dll")
  524. Iinit := DllDef.MustFindProc("Init")
  525. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  526. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  527. if ret != 0 {
  528. fmt.Println("SSCard的报错原因:", err)
  529. fmt.Println("SSCard的运算结果为:", ret)
  530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  531. return
  532. }
  533. result := int(ret)
  534. fmt.Println("SSCard的运算结果为1:", result)
  535. initFlag = 1
  536. return
  537. }
  538. func (c *HisApiController) GetSFZBaseInfo() string {
  539. DllDef := syscall.MustLoadDLL("SSCard.dll")
  540. readCard := DllDef.MustFindProc("ReadSFZ")
  541. if readCard == nil {
  542. fmt.Println("readcard is nil")
  543. readCard = DllDef.MustFindProc("ReadSFZ")
  544. }
  545. str := make([]byte, 256)
  546. str1 := make([]byte, 256)
  547. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  548. fmt.Println(r)
  549. return string(str)
  550. }
  551. func (c *HisApiController) GetBasBaseInfo() string {
  552. DllDef := syscall.MustLoadDLL("SSCard.dll")
  553. readCard := DllDef.MustFindProc("ReadCardBas")
  554. if readCard == nil {
  555. fmt.Println("readcard is nil")
  556. readCard = DllDef.MustFindProc("ReadCardBas")
  557. }
  558. str := make([]byte, 1024)
  559. str1 := make([]byte, 1024)
  560. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  561. fmt.Println(string(str1))
  562. fmt.Println(string(str))
  563. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  564. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  565. if ret2 != 0 {
  566. return ""
  567. }
  568. return string(str)
  569. }
  570. type CustomFundPay struct {
  571. FundPayType string `json:"fund_pay_type"`
  572. FundPayamt float64 `json:"fund_payamt"`
  573. }
  574. func (c *HisApiController) GetSettleList() {
  575. order_id, _ := c.GetInt64("order_id")
  576. admin_user_id, _ := c.GetInt64("admin_user_id")
  577. order, _ := service.GetHisOrderByIDTwo(order_id)
  578. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  579. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  580. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  581. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  582. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  583. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  584. if order.ID == 0 {
  585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  586. return
  587. }
  588. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  589. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  590. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  591. fmt.Println(count)
  592. var zero string
  593. number := count + 1
  594. if number >= 1000 {
  595. zero = "0000" + strconv.FormatInt(number, 10)
  596. } else if number >= 10000 {
  597. zero = "000" + strconv.FormatInt(number, 10)
  598. } else if number >= 100000 {
  599. zero = "00" + strconv.FormatInt(number, 10)
  600. } else if number >= 1000000 {
  601. zero = "0" + strconv.FormatInt(number, 10)
  602. } else {
  603. zero = strconv.FormatInt(number, 10)
  604. }
  605. fmt.Println(zero)
  606. struct4101 := service.Struct4101{
  607. PsnNo: order.PsnNo,
  608. MdtrtId: order.MdtrtId,
  609. SetlId: order.SetlId,
  610. PsnName: order.PsnName,
  611. Gend: order.Gend,
  612. Brdy: his.Brdy,
  613. Age: his.Age,
  614. Naty: order.Naty,
  615. PatnCertType: "01",
  616. Certno: order.Certno,
  617. Prfs: "90",
  618. ConerName: roles[0].UserName,
  619. PatnRlts: "99",
  620. ConerAddr: miConfig.OrgName,
  621. ConerTel: admin.Mobile,
  622. HiType: order.Insutype,
  623. Insuplc: miConfig.InsuplcAdmdvs,
  624. MaindiagFlag: "1",
  625. BillCode: last_order.FaPiaoCode,
  626. BillNo: zero,
  627. BizSn: order.Number,
  628. PsnSelfPay: order.PsnPartAmt,
  629. PsnOwnPay: order.PsnPartAmt,
  630. AcctPay: order.AcctPay,
  631. PsnCashpay: order.PsnCashPay,
  632. HiPaymtd: "1",
  633. Hsorg: miConfig.InsuplcAdmdvs,
  634. HsorgOpter: miConfig.InsuplcAdmdvs,
  635. MedinsFillPsn: curRoles.UserName,
  636. MedinsFillDept: depart.Name,
  637. IptMedType: "2",
  638. }
  639. struct4101.SetlBegnDate = order.SetlTime
  640. struct4101.SetlEndDate = order.SetlTime
  641. var rf []CustomFundPay
  642. json.Unmarshal([]byte(order.SetlDetail), &rf)
  643. var tempFunPays []service.CustomStruct
  644. for _, item := range rf {
  645. var tempFunPay service.CustomStruct
  646. tempFunPay.FundPayamt = item.FundPayamt
  647. tempFunPay.FundPayType = item.FundPayType
  648. tempFunPays = append(tempFunPays, tempFunPay)
  649. }
  650. struct4101.CustomStruct = tempFunPays
  651. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  652. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  653. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  654. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  655. var config []*models.HisXtDiagnoseConfig
  656. for _, item := range diagnosis_ids {
  657. id, _ := strconv.ParseInt(item, 10, 64)
  658. diagnosisConfig, _ := service.FindDiagnoseById(id)
  659. config = append(config, &diagnosisConfig)
  660. }
  661. for _, item := range config {
  662. var tempOpspdiseinfo service.OpspdiseinfoStruct
  663. tempOpspdiseinfo.DiagCode = item.CountryCode
  664. tempOpspdiseinfo.DiagName = item.CountryContentName
  665. tempOpspdiseinfo.MaindiagFlag = "1"
  666. tempOpspdiseinfo.OprnOprtCode = ""
  667. tempOpspdiseinfo.OprnOprtName = ""
  668. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  669. }
  670. sickConfigTwo, _ := service.FindSickById(his.SickType)
  671. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  672. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  673. tempOpspdiseinfo2.MaindiagFlag = "2"
  674. tempOpspdiseinfo2.OprnOprtCode = ""
  675. tempOpspdiseinfo2.OprnOprtName = ""
  676. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  677. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  678. var iteminfo service.IteminfoStruct
  679. var bedCostTotal float64 = 0 //床位总费
  680. var bedCostSelfTotal float64 = 0 //床位自费
  681. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  682. var operationCostTotal float64 = 0 //手术费
  683. var operationCostSelfTotal float64 = 0 //手术费
  684. var operationCostPartSelfTotal float64 = 0 //手术费
  685. var otherCostTotal float64 = 0 //其他费用
  686. var otherCostSelfTotal float64 = 0 //其他费用
  687. var otherCostPartSelfTotal float64 = 0 //其他费用
  688. var materialCostTotal float64 = 0 //材料费
  689. var materialCostSelfTotal float64 = 0 //材料费
  690. var materialCostPartSelfTotal float64 = 0 //材料费
  691. var westernMedicineCostTotal float64 = 0 //西药费
  692. var westernMedicineCostSelfTotal float64 = 0 //西药费
  693. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  694. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  695. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  696. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  697. var checkCostTotal float64 = 0 //检查费
  698. var checkCostSelfTotal float64 = 0 //检查费
  699. var checkCostPartSelfTotal float64 = 0 //检查费
  700. var laboratoryCostTotal float64 = 0 //化验费
  701. var laboratoryCostSelfTotal float64 = 0 //化验费
  702. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  703. var treatCostTotal float64 = 0 //治疗费用
  704. var treatCostSelfTotal float64 = 0 //治疗费用
  705. var treatCostPartSelfTotal float64 = 0 //治疗费用
  706. decimal.DivisionPrecision = 2
  707. var bed_fulamt_ownpay_amt float64 = 0
  708. var operation_fulamt_ownpay_amt float64 = 0
  709. var other_fulamt_ownpay_amt float64 = 0
  710. var westernMedicine_fulamt_ownpay_amt float64 = 0
  711. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  712. var check_fulamt_ownpay_amt float64 = 0
  713. var material_fulamt_ownpay_amt float64 = 0
  714. var laboratory_fulamt_ownpay_amt float64 = 0
  715. var treat_fulamt_ownpay_amt float64 = 0
  716. var bed_claa_sunmfee float64 = 0
  717. var bed_clab_amt float64 = 0
  718. var bed_other_amt float64 = 0
  719. var operation_claa_sunmfee float64 = 0
  720. var operation_clab_amt float64 = 0
  721. var operation_other_amt float64 = 0
  722. var other_claa_sunmfee float64 = 0
  723. var other_clab_amt float64 = 0
  724. var other_other_amt float64 = 0
  725. var westernMedicine_claa_sunmfee float64 = 0
  726. var westernMedicine_clab_amt float64 = 0
  727. var westernMedicine_other_amt float64 = 0
  728. var chineseTraditional_claa_sunmfee float64 = 0
  729. var chineseTraditional_clab_amt float64 = 0
  730. var chineseTraditional_other_amt float64 = 0
  731. var check_claa_sunmfee float64 = 0
  732. var check_clab_amt float64 = 0
  733. var check_other_amt float64 = 0
  734. var material_claa_sunmfee float64 = 0
  735. var material_clab_amt float64 = 0
  736. var material_other_amt float64 = 0
  737. var laboratory_claa_sunmfee float64 = 0
  738. var laboratory_clab_amt float64 = 0
  739. var laboratory_other_amt float64 = 0
  740. var treat_claa_sunmfee float64 = 0
  741. var treat_clab_amt float64 = 0
  742. var treat_other_amt float64 = 0
  743. for _, item := range order.HisOrderInfo {
  744. if item.MedChrgitmType == "01" { //床位费
  745. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  746. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  747. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  748. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  749. if item.ChrgitmLv == "1" {
  750. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  751. }
  752. if item.ChrgitmLv == "2" {
  753. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  754. }
  755. if item.ChrgitmLv == "3" {
  756. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  757. }
  758. }
  759. if item.MedChrgitmType == "03" { //检查费
  760. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  761. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  762. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  763. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  764. if item.ChrgitmLv == "1" {
  765. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  766. }
  767. if item.ChrgitmLv == "2" {
  768. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  769. }
  770. if item.ChrgitmLv == "3" {
  771. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  772. }
  773. }
  774. if item.MedChrgitmType == "04" { //化验费
  775. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  776. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  777. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  778. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  779. if item.ChrgitmLv == "1" {
  780. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  781. }
  782. if item.ChrgitmLv == "2" {
  783. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  784. }
  785. if item.ChrgitmLv == "3" {
  786. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  787. }
  788. }
  789. if item.MedChrgitmType == "05" { //治疗费
  790. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  791. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  792. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  793. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  794. if item.ChrgitmLv == "1" {
  795. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  796. }
  797. if item.ChrgitmLv == "2" {
  798. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  799. }
  800. if item.ChrgitmLv == "3" {
  801. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  802. }
  803. }
  804. if item.MedChrgitmType == "06" { //手术费
  805. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  806. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  807. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  808. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  809. if item.ChrgitmLv == "1" {
  810. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  811. }
  812. if item.ChrgitmLv == "2" {
  813. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  814. }
  815. if item.ChrgitmLv == "3" {
  816. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  817. }
  818. }
  819. if item.MedChrgitmType == "08" { //材料费
  820. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  821. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  822. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  823. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  824. if item.ChrgitmLv == "1" {
  825. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  826. }
  827. if item.ChrgitmLv == "2" {
  828. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  829. }
  830. if item.ChrgitmLv == "3" {
  831. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  832. }
  833. }
  834. if item.MedChrgitmType == "09" { //西药费
  835. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  836. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  837. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  838. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  839. if item.ChrgitmLv == "1" {
  840. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  841. }
  842. if item.ChrgitmLv == "2" {
  843. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  844. }
  845. if item.ChrgitmLv == "3" {
  846. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  847. }
  848. }
  849. if item.MedChrgitmType == "11" { //中成费
  850. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  851. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  852. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  853. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  854. if item.ChrgitmLv == "1" {
  855. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  856. }
  857. if item.ChrgitmLv == "2" {
  858. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  859. }
  860. if item.ChrgitmLv == "3" {
  861. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  862. }
  863. }
  864. if item.MedChrgitmType == "14" { //其他费
  865. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  866. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  867. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  868. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  869. if item.ChrgitmLv == "1" {
  870. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  871. }
  872. if item.ChrgitmLv == "2" {
  873. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  874. }
  875. if item.ChrgitmLv == "3" {
  876. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  877. }
  878. }
  879. }
  880. var iteminfoStructs []service.IteminfoStruct
  881. if bedCostTotal != 0 {
  882. iteminfo.MedChrgitm = "01"
  883. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  884. iteminfo.Amt = bedCostTotal
  885. iteminfo.ClaaSumfee = bed_claa_sunmfee
  886. iteminfo.ClabAmt = bed_clab_amt
  887. iteminfo.OthAmt = bed_other_amt
  888. iteminfoStructs = append(iteminfoStructs, iteminfo)
  889. }
  890. if checkCostTotal != 0 {
  891. iteminfo.MedChrgitm = "03"
  892. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  893. iteminfo.Amt = checkCostTotal
  894. iteminfo.ClaaSumfee = check_claa_sunmfee
  895. iteminfo.ClabAmt = check_clab_amt
  896. iteminfo.OthAmt = check_other_amt
  897. iteminfoStructs = append(iteminfoStructs, iteminfo)
  898. }
  899. if laboratoryCostTotal != 0 {
  900. iteminfo.MedChrgitm = "04"
  901. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  902. iteminfo.Amt = laboratoryCostTotal
  903. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  904. iteminfo.ClabAmt = laboratory_clab_amt
  905. iteminfo.OthAmt = laboratory_other_amt
  906. iteminfoStructs = append(iteminfoStructs, iteminfo)
  907. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  908. }
  909. if treatCostTotal != 0 {
  910. iteminfo.MedChrgitm = "05"
  911. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  912. iteminfo.Amt = treatCostTotal
  913. iteminfo.ClaaSumfee = treat_claa_sunmfee
  914. iteminfo.ClabAmt = treat_clab_amt
  915. iteminfo.OthAmt = treat_other_amt
  916. iteminfoStructs = append(iteminfoStructs, iteminfo)
  917. //(struct4101.IteminfoStruct, iteminfo)
  918. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  919. }
  920. if operationCostTotal != 0 {
  921. iteminfo.MedChrgitm = "06"
  922. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  923. iteminfo.Amt = operationCostTotal
  924. iteminfo.ClaaSumfee = operation_claa_sunmfee
  925. iteminfo.ClabAmt = operation_clab_amt
  926. iteminfo.OthAmt = operation_other_amt
  927. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  928. iteminfoStructs = append(iteminfoStructs, iteminfo)
  929. }
  930. if materialCostTotal != 0 {
  931. iteminfo.MedChrgitm = "08"
  932. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  933. iteminfo.Amt = materialCostTotal
  934. iteminfo.ClaaSumfee = material_claa_sunmfee
  935. iteminfo.ClabAmt = material_clab_amt
  936. iteminfo.OthAmt = material_other_amt
  937. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  939. }
  940. if westernMedicineCostTotal != 0 {
  941. iteminfo.MedChrgitm = "09"
  942. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  943. iteminfo.Amt = westernMedicineCostTotal
  944. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  945. iteminfo.ClabAmt = westernMedicine_clab_amt
  946. iteminfo.OthAmt = westernMedicine_other_amt
  947. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  948. iteminfoStructs = append(iteminfoStructs, iteminfo)
  949. }
  950. if chineseTraditionalMedicineCostTotal != 0 {
  951. iteminfo.MedChrgitm = "11"
  952. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  953. iteminfo.Amt = westernMedicineCostTotal
  954. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  955. iteminfo.ClabAmt = westernMedicine_clab_amt
  956. iteminfo.OthAmt = westernMedicine_other_amt
  957. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  958. iteminfoStructs = append(iteminfoStructs, iteminfo)
  959. }
  960. if otherCostTotal != 0 {
  961. iteminfo.MedChrgitm = "14"
  962. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  963. iteminfo.Amt = otherCostTotal
  964. iteminfo.ClaaSumfee = other_claa_sunmfee
  965. iteminfo.ClabAmt = other_clab_amt
  966. iteminfo.OthAmt = other_other_amt
  967. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  968. iteminfoStructs = append(iteminfoStructs, iteminfo)
  969. }
  970. struct4101.IteminfoStruct = iteminfoStructs
  971. struct4101.Ntly = "中国"
  972. struct4101.AdmCaty = "A03.06"
  973. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  974. fmt.Println(result)
  975. var dat map[string]interface{}
  976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  977. fmt.Println(dat)
  978. } else {
  979. fmt.Println(err)
  980. }
  981. userJSONBytes, _ := json.Marshal(dat)
  982. var res ResultSeventeen
  983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  984. utils.ErrorLog("解析失败:%v", err)
  985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  986. return
  987. }
  988. if res.Infcode != 0 {
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "failed_code": -10,
  991. "msg": res.ErrMsg,
  992. })
  993. return
  994. } else {
  995. order.FaPiaoNumber = zero
  996. order.FaPiaoCode = last_order.FaPiaoCode
  997. service.UpdateOrder(order)
  998. hisFundSettleListResult := &models.HisFundSettleListResult{
  999. Number: res.Output.SetlListId,
  1000. Status: 1,
  1001. Ctime: time.Now().Unix(),
  1002. Mtime: time.Now().Unix(),
  1003. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1004. IsUpload: 1,
  1005. OrderId: order_id,
  1006. }
  1007. service.CreateUploadRecord(hisFundSettleListResult)
  1008. c.ServeSuccessJSON(map[string]interface{}{
  1009. "msg": "上传成功",
  1010. "result": hisFundSettleListResult,
  1011. })
  1012. return
  1013. }
  1014. }
  1015. func (c *HisApiController) GetSettleListHospital() {
  1016. order_id, _ := c.GetInt64("order_id")
  1017. admin_user_id, _ := c.GetInt64("admin_user_id")
  1018. order, _ := service.GetHisOrderByIDTwo(order_id)
  1019. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1020. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1021. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1022. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1023. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1024. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1025. if order.ID == 0 {
  1026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1027. return
  1028. }
  1029. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1030. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1031. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1032. fmt.Println(count)
  1033. var zero string
  1034. number := count + 1
  1035. if number >= 1000 {
  1036. zero = "0000" + strconv.FormatInt(number, 10)
  1037. } else if number >= 10000 {
  1038. zero = "000" + strconv.FormatInt(number, 10)
  1039. } else if number >= 100000 {
  1040. zero = "00" + strconv.FormatInt(number, 10)
  1041. } else if number >= 1000000 {
  1042. zero = "0" + strconv.FormatInt(number, 10)
  1043. } else {
  1044. zero = strconv.FormatInt(number, 10)
  1045. }
  1046. fmt.Println(zero)
  1047. struct4101 := service.Struct4101{
  1048. PsnNo: order.PsnNo,
  1049. MdtrtId: order.MdtrtId,
  1050. SetlId: order.SetlId,
  1051. PsnName: order.PsnName,
  1052. Gend: order.Gend,
  1053. Brdy: his.Brdy,
  1054. Age: int64(order.Age),
  1055. Naty: order.Naty,
  1056. PatnCertType: "01",
  1057. Certno: order.Certno,
  1058. Prfs: "90",
  1059. ConerName: roles[0].UserName,
  1060. PatnRlts: "99",
  1061. ConerAddr: miConfig.OrgName,
  1062. ConerTel: admin.Mobile,
  1063. HiType: order.Insutype,
  1064. Insuplc: miConfig.InsuplcAdmdvs,
  1065. MaindiagFlag: "1",
  1066. BillCode: last_order.FaPiaoCode,
  1067. BillNo: zero,
  1068. BizSn: order.Number,
  1069. PsnSelfPay: order.PsnPartAmt,
  1070. PsnOwnPay: order.PsnPartAmt,
  1071. AcctPay: order.AcctPay,
  1072. PsnCashpay: order.PsnCashPay,
  1073. HiPaymtd: "1",
  1074. Hsorg: miConfig.InsuplcAdmdvs,
  1075. HsorgOpter: miConfig.InsuplcAdmdvs,
  1076. MedinsFillPsn: curRoles.UserName,
  1077. MedinsFillDept: depart.Name,
  1078. IptMedType: "2",
  1079. }
  1080. struct4101.SetlBegnDate = order.SetlTime
  1081. struct4101.SetlEndDate = order.SetlTime
  1082. var rf []CustomFundPay
  1083. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1084. var tempFunPays []service.CustomStruct
  1085. for _, item := range rf {
  1086. var tempFunPay service.CustomStruct
  1087. tempFunPay.FundPayamt = item.FundPayamt
  1088. tempFunPay.FundPayType = item.FundPayType
  1089. tempFunPays = append(tempFunPays, tempFunPay)
  1090. }
  1091. struct4101.CustomStruct = tempFunPays
  1092. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1093. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1094. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1095. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1096. var config []*models.HisXtDiagnoseConfig
  1097. for _, item := range diagnosis_ids {
  1098. id, _ := strconv.ParseInt(item, 10, 64)
  1099. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1100. config = append(config, &diagnosisConfig)
  1101. }
  1102. for _, item := range config {
  1103. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1104. tempOpspdiseinfo.DiagCode = item.CountryCode
  1105. tempOpspdiseinfo.DiagName = item.CountryContentName
  1106. tempOpspdiseinfo.MaindiagFlag = "1"
  1107. tempOpspdiseinfo.OprnOprtCode = ""
  1108. tempOpspdiseinfo.OprnOprtName = ""
  1109. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1110. }
  1111. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1112. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1113. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1114. tempOpspdiseinfo2.MaindiagFlag = "2"
  1115. tempOpspdiseinfo2.OprnOprtCode = ""
  1116. tempOpspdiseinfo2.OprnOprtName = ""
  1117. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1118. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1119. var iteminfo service.IteminfoStruct
  1120. var bedCostTotal float64 = 0 //床位总费
  1121. var bedCostSelfTotal float64 = 0 //床位自费
  1122. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1123. var operationCostTotal float64 = 0 //手术费
  1124. var operationCostSelfTotal float64 = 0 //手术费
  1125. var operationCostPartSelfTotal float64 = 0 //手术费
  1126. var otherCostTotal float64 = 0 //其他费用
  1127. var otherCostSelfTotal float64 = 0 //其他费用
  1128. var otherCostPartSelfTotal float64 = 0 //其他费用
  1129. var materialCostTotal float64 = 0 //材料费
  1130. var materialCostSelfTotal float64 = 0 //材料费
  1131. var materialCostPartSelfTotal float64 = 0 //材料费
  1132. var westernMedicineCostTotal float64 = 0 //西药费
  1133. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1134. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1135. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1136. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1137. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1138. var checkCostTotal float64 = 0 //检查费
  1139. var checkCostSelfTotal float64 = 0 //检查费
  1140. var checkCostPartSelfTotal float64 = 0 //检查费
  1141. var laboratoryCostTotal float64 = 0 //化验费
  1142. var laboratoryCostSelfTotal float64 = 0 //化验费
  1143. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1144. var treatCostTotal float64 = 0 //治疗费用
  1145. var treatCostSelfTotal float64 = 0 //治疗费用
  1146. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1147. decimal.DivisionPrecision = 2
  1148. var bed_fulamt_ownpay_amt float64 = 0
  1149. var operation_fulamt_ownpay_amt float64 = 0
  1150. var other_fulamt_ownpay_amt float64 = 0
  1151. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1152. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1153. var check_fulamt_ownpay_amt float64 = 0
  1154. var material_fulamt_ownpay_amt float64 = 0
  1155. var laboratory_fulamt_ownpay_amt float64 = 0
  1156. var treat_fulamt_ownpay_amt float64 = 0
  1157. var bed_claa_sunmfee float64 = 0
  1158. var bed_clab_amt float64 = 0
  1159. var bed_other_amt float64 = 0
  1160. var operation_claa_sunmfee float64 = 0
  1161. var operation_clab_amt float64 = 0
  1162. var operation_other_amt float64 = 0
  1163. var other_claa_sunmfee float64 = 0
  1164. var other_clab_amt float64 = 0
  1165. var other_other_amt float64 = 0
  1166. var westernMedicine_claa_sunmfee float64 = 0
  1167. var westernMedicine_clab_amt float64 = 0
  1168. var westernMedicine_other_amt float64 = 0
  1169. var chineseTraditional_claa_sunmfee float64 = 0
  1170. var chineseTraditional_clab_amt float64 = 0
  1171. var chineseTraditional_other_amt float64 = 0
  1172. var check_claa_sunmfee float64 = 0
  1173. var check_clab_amt float64 = 0
  1174. var check_other_amt float64 = 0
  1175. var material_claa_sunmfee float64 = 0
  1176. var material_clab_amt float64 = 0
  1177. var material_other_amt float64 = 0
  1178. var laboratory_claa_sunmfee float64 = 0
  1179. var laboratory_clab_amt float64 = 0
  1180. var laboratory_other_amt float64 = 0
  1181. var treat_claa_sunmfee float64 = 0
  1182. var treat_clab_amt float64 = 0
  1183. var treat_other_amt float64 = 0
  1184. for _, item := range order.HisOrderInfo {
  1185. if item.MedChrgitmType == "01" { //床位费
  1186. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1187. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1188. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1189. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1190. if item.ChrgitmLv == "1" {
  1191. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1192. }
  1193. if item.ChrgitmLv == "2" {
  1194. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1195. }
  1196. if item.ChrgitmLv == "3" {
  1197. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1198. }
  1199. }
  1200. if item.MedChrgitmType == "03" { //检查费
  1201. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1202. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1203. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1204. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1205. if item.ChrgitmLv == "1" {
  1206. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1207. }
  1208. if item.ChrgitmLv == "2" {
  1209. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1210. }
  1211. if item.ChrgitmLv == "3" {
  1212. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1213. }
  1214. }
  1215. if item.MedChrgitmType == "04" { //化验费
  1216. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1217. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1218. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1219. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1220. if item.ChrgitmLv == "1" {
  1221. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1222. }
  1223. if item.ChrgitmLv == "2" {
  1224. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1225. }
  1226. if item.ChrgitmLv == "3" {
  1227. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1228. }
  1229. }
  1230. if item.MedChrgitmType == "05" { //治疗费
  1231. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1232. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1233. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1234. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1235. if item.ChrgitmLv == "1" {
  1236. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1237. }
  1238. if item.ChrgitmLv == "2" {
  1239. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1240. }
  1241. if item.ChrgitmLv == "3" {
  1242. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1243. }
  1244. }
  1245. if item.MedChrgitmType == "06" { //手术费
  1246. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1247. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1248. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1249. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1250. if item.ChrgitmLv == "1" {
  1251. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1252. }
  1253. if item.ChrgitmLv == "2" {
  1254. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1255. }
  1256. if item.ChrgitmLv == "3" {
  1257. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1258. }
  1259. }
  1260. if item.MedChrgitmType == "08" { //材料费
  1261. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1262. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1263. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1264. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1265. if item.ChrgitmLv == "1" {
  1266. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1267. }
  1268. if item.ChrgitmLv == "2" {
  1269. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1270. }
  1271. if item.ChrgitmLv == "3" {
  1272. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1273. }
  1274. }
  1275. if item.MedChrgitmType == "09" { //西药费
  1276. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1277. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1278. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1279. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1280. if item.ChrgitmLv == "1" {
  1281. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1282. }
  1283. if item.ChrgitmLv == "2" {
  1284. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1285. }
  1286. if item.ChrgitmLv == "3" {
  1287. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1288. }
  1289. }
  1290. if item.MedChrgitmType == "11" { //中成费
  1291. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1292. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1293. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1294. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1295. if item.ChrgitmLv == "1" {
  1296. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1297. }
  1298. if item.ChrgitmLv == "2" {
  1299. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1300. }
  1301. if item.ChrgitmLv == "3" {
  1302. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1303. }
  1304. }
  1305. if item.MedChrgitmType == "14" { //其他费
  1306. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1307. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1308. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1309. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1310. if item.ChrgitmLv == "1" {
  1311. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1312. }
  1313. if item.ChrgitmLv == "2" {
  1314. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1315. }
  1316. if item.ChrgitmLv == "3" {
  1317. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1318. }
  1319. }
  1320. }
  1321. var iteminfoStructs []service.IteminfoStruct
  1322. if bedCostTotal != 0 {
  1323. iteminfo.MedChrgitm = "01"
  1324. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1325. iteminfo.Amt = bedCostTotal
  1326. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1327. iteminfo.ClabAmt = bed_clab_amt
  1328. iteminfo.OthAmt = bed_other_amt
  1329. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1330. }
  1331. if checkCostTotal != 0 {
  1332. iteminfo.MedChrgitm = "03"
  1333. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1334. iteminfo.Amt = checkCostTotal
  1335. iteminfo.ClaaSumfee = check_claa_sunmfee
  1336. iteminfo.ClabAmt = check_clab_amt
  1337. iteminfo.OthAmt = check_other_amt
  1338. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1339. }
  1340. if laboratoryCostTotal != 0 {
  1341. iteminfo.MedChrgitm = "04"
  1342. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1343. iteminfo.Amt = laboratoryCostTotal
  1344. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1345. iteminfo.ClabAmt = laboratory_clab_amt
  1346. iteminfo.OthAmt = laboratory_other_amt
  1347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1348. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1349. }
  1350. if treatCostTotal != 0 {
  1351. iteminfo.MedChrgitm = "05"
  1352. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1353. iteminfo.Amt = treatCostTotal
  1354. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1355. iteminfo.ClabAmt = treat_clab_amt
  1356. iteminfo.OthAmt = treat_other_amt
  1357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1358. //(struct4101.IteminfoStruct, iteminfo)
  1359. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1360. }
  1361. if operationCostTotal != 0 {
  1362. iteminfo.MedChrgitm = "06"
  1363. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1364. iteminfo.Amt = operationCostTotal
  1365. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1366. iteminfo.ClabAmt = operation_clab_amt
  1367. iteminfo.OthAmt = operation_other_amt
  1368. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1369. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1370. }
  1371. if materialCostTotal != 0 {
  1372. iteminfo.MedChrgitm = "08"
  1373. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1374. iteminfo.Amt = materialCostTotal
  1375. iteminfo.ClaaSumfee = material_claa_sunmfee
  1376. iteminfo.ClabAmt = material_clab_amt
  1377. iteminfo.OthAmt = material_other_amt
  1378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1380. }
  1381. if westernMedicineCostTotal != 0 {
  1382. iteminfo.MedChrgitm = "09"
  1383. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1384. iteminfo.Amt = westernMedicineCostTotal
  1385. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1386. iteminfo.ClabAmt = westernMedicine_clab_amt
  1387. iteminfo.OthAmt = westernMedicine_other_amt
  1388. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1389. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1390. }
  1391. if chineseTraditionalMedicineCostTotal != 0 {
  1392. iteminfo.MedChrgitm = "11"
  1393. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1394. iteminfo.Amt = westernMedicineCostTotal
  1395. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1396. iteminfo.ClabAmt = westernMedicine_clab_amt
  1397. iteminfo.OthAmt = westernMedicine_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, miConfig.UserOrgId)
  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. return
  1428. }
  1429. if res.Infcode != 0 {
  1430. c.ServeSuccessJSON(map[string]interface{}{
  1431. "failed_code": -10,
  1432. "msg": res.ErrMsg,
  1433. })
  1434. return
  1435. } else {
  1436. order.FaPiaoNumber = zero
  1437. order.FaPiaoCode = last_order.FaPiaoCode
  1438. service.UpdateOrder(order)
  1439. hisFundSettleListResult := &models.HisFundSettleListResult{
  1440. Number: res.Output.SetlListId,
  1441. Status: 1,
  1442. Ctime: time.Now().Unix(),
  1443. Mtime: time.Now().Unix(),
  1444. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1445. IsUpload: 1,
  1446. OrderId: order_id,
  1447. }
  1448. service.CreateUploadRecord(hisFundSettleListResult)
  1449. c.ServeSuccessJSON(map[string]interface{}{
  1450. "msg": "上传成功",
  1451. "result": hisFundSettleListResult,
  1452. })
  1453. return
  1454. }
  1455. }
  1456. func (c *HisApiController) GetBatchSettleList() {
  1457. org_id, _ := beego.AppConfig.Int64("org_id")
  1458. //stage, _ := c.GetInt64("stage")
  1459. orders, _ := service.GetAllHisOrder(org_id)
  1460. for _, item := range orders {
  1461. order_id := item.ID
  1462. order, _ := service.GetHisOrderByIDTwo(order_id)
  1463. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1464. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1465. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1466. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2500)
  1467. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1468. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1469. if order.ID == 0 {
  1470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1471. return
  1472. }
  1473. if his.BalanceAccountsType == 2 {
  1474. continue
  1475. }
  1476. struct4101 := service.Struct4101{
  1477. PsnNo: order.PsnNo,
  1478. MdtrtId: order.MdtrtId,
  1479. SetlId: order.SetlId,
  1480. PsnName: order.PsnName,
  1481. Gend: order.Gend,
  1482. Brdy: his.Brdy,
  1483. Age: his.Age,
  1484. Naty: order.Naty,
  1485. PatnCertType: "01",
  1486. Certno: order.Certno,
  1487. Prfs: "90",
  1488. ConerName: roles[0].UserName,
  1489. PatnRlts: "99",
  1490. ConerAddr: miConfig.OrgName,
  1491. ConerTel: admin.Mobile,
  1492. HiType: order.Insutype,
  1493. Insuplc: his.InsuplcAdmdvs,
  1494. MaindiagFlag: "1",
  1495. BillCode: order.FaPiaoCode,
  1496. BillNo: order.FaPiaoNumber,
  1497. BizSn: order.Number,
  1498. PsnSelfPay: order.PsnPartAmt,
  1499. PsnOwnPay: order.PsnPartAmt,
  1500. AcctPay: order.AcctPay,
  1501. PsnCashpay: order.PsnCashPay,
  1502. HiPaymtd: "1",
  1503. Hsorg: his.InsuplcAdmdvs,
  1504. HsorgOpter: his.InsuplcAdmdvs,
  1505. MedinsFillPsn: curRoles.UserName,
  1506. MedinsFillDept: depart.Name,
  1507. IptMedType: "2",
  1508. }
  1509. struct4101.SetlBegnDate = order.SetlTime
  1510. struct4101.SetlEndDate = order.SetlTime
  1511. //if order.SettleType == 1 {
  1512. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1513. // dateStr := t.Format("2006-01-02")
  1514. // struct4101.SetlBegnDate = dateStr
  1515. // struct4101.SetlEndDate = dateStr
  1516. //} else {
  1517. // t := time.Unix(int64(order.SettleStartTime), 0)
  1518. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1519. // dateStartStr := t.Format("2006-01-02")
  1520. // dateEndStr := t2.Format("2006-01-02")
  1521. // struct4101.SetlBegnDate = dateStartStr
  1522. // struct4101.SetlEndDate = dateEndStr
  1523. //}
  1524. var rf []CustomFundPay
  1525. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1526. var tempFunPays []service.CustomStruct
  1527. var tempFunPay610100 service.CustomStruct
  1528. for _, item := range rf {
  1529. if item.FundPayType == "610100" {
  1530. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1531. tempFunPay610100.FundPayType = item.FundPayType
  1532. } else {
  1533. var tempFunPay service.CustomStruct
  1534. tempFunPay.FundPayamt = item.FundPayamt
  1535. tempFunPay.FundPayType = item.FundPayType
  1536. tempFunPays = append(tempFunPays, tempFunPay)
  1537. }
  1538. }
  1539. tempFunPays = append(tempFunPays, tempFunPay610100)
  1540. struct4101.CustomStruct = tempFunPays
  1541. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1542. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1543. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1544. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1545. var config []*models.HisXtDiagnoseConfig
  1546. for _, item := range diagnosis_ids {
  1547. id, _ := strconv.ParseInt(item, 10, 64)
  1548. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1549. config = append(config, &diagnosisConfig)
  1550. }
  1551. for _, item := range config {
  1552. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1553. tempOpspdiseinfo.DiagCode = item.CountryCode
  1554. tempOpspdiseinfo.DiagName = item.CountryContentName
  1555. tempOpspdiseinfo.MaindiagFlag = "1"
  1556. tempOpspdiseinfo.OprnOprtCode = ""
  1557. tempOpspdiseinfo.OprnOprtName = ""
  1558. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1559. }
  1560. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1561. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1562. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1563. tempOpspdiseinfo2.MaindiagFlag = "2"
  1564. tempOpspdiseinfo2.OprnOprtCode = ""
  1565. tempOpspdiseinfo2.OprnOprtName = ""
  1566. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1567. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1568. var iteminfo service.IteminfoStruct
  1569. var bedCostTotal float64 = 0 //床位总费
  1570. var bedCostSelfTotal float64 = 0 //床位自费
  1571. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1572. var examineCostTotal float64 = 0 //诊查总费
  1573. var examineCostSelfTotal float64 = 0 //诊查自费
  1574. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1575. var nursingCostTotal float64 = 0 //护理总费
  1576. var nursingCostSelfTotal float64 = 0 //护理自费
  1577. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1578. var chineseMedicineCostTotal float64 = 0 //中成药
  1579. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1580. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1581. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1582. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1583. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1584. var registerCostTotal float64 = 0 //一般诊疗费
  1585. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1586. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1587. var operationCostTotal float64 = 0 //手术费
  1588. var operationCostSelfTotal float64 = 0 //手术费
  1589. var operationCostPartSelfTotal float64 = 0 //手术费
  1590. var otherCostTotal float64 = 0 //其他费用
  1591. var otherCostSelfTotal float64 = 0 //其他费用
  1592. var otherCostPartSelfTotal float64 = 0 //其他费用
  1593. var materialCostTotal float64 = 0 //材料费
  1594. var materialCostSelfTotal float64 = 0 //材料费
  1595. var materialCostPartSelfTotal float64 = 0 //材料费
  1596. var westernMedicineCostTotal float64 = 0 //西药费
  1597. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1598. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1599. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1600. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1601. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1602. var checkCostTotal float64 = 0 //检查费
  1603. var checkCostSelfTotal float64 = 0 //检查费
  1604. var checkCostPartSelfTotal float64 = 0 //检查费
  1605. var laboratoryCostTotal float64 = 0 //化验费
  1606. var laboratoryCostSelfTotal float64 = 0 //化验费
  1607. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1608. var treatCostTotal float64 = 0 //治疗费用
  1609. var treatCostSelfTotal float64 = 0 //治疗费用
  1610. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1611. decimal.DivisionPrecision = 2
  1612. var bed_fulamt_ownpay_amt float64 = 0
  1613. var examine_fulamt_ownpay_amt float64 = 0
  1614. var nursing_fulamt_ownpay_amt float64 = 0
  1615. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1616. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1617. var register_fulamt_ownpay_amt float64 = 0
  1618. var operation_fulamt_ownpay_amt float64 = 0
  1619. var other_fulamt_ownpay_amt float64 = 0
  1620. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1621. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1622. var check_fulamt_ownpay_amt float64 = 0
  1623. var material_fulamt_ownpay_amt float64 = 0
  1624. var laboratory_fulamt_ownpay_amt float64 = 0
  1625. var treat_fulamt_ownpay_amt float64 = 0
  1626. var bed_claa_sunmfee float64 = 0
  1627. var bed_clab_amt float64 = 0
  1628. var bed_other_amt float64 = 0
  1629. var examine_claa_sunmfee float64 = 0
  1630. var examine_clab_amt float64 = 0
  1631. var examine_other_amt float64 = 0
  1632. var nursing_claa_sunmfee float64 = 0
  1633. var nursing_clab_amt float64 = 0
  1634. var nursing_other_amt float64 = 0
  1635. var chinese_medicine_claa_sunmfee float64 = 0
  1636. var chinese_medicine_clab_amt float64 = 0
  1637. var chinese_medicine_other_amt float64 = 0
  1638. var commonly_treatment_claa_sunmfee float64 = 0
  1639. var commonly_treatment_clab_amt float64 = 0
  1640. var commonly_treatment_other_amt float64 = 0
  1641. var operation_claa_sunmfee float64 = 0
  1642. var operation_clab_amt float64 = 0
  1643. var operation_other_amt float64 = 0
  1644. var other_claa_sunmfee float64 = 0
  1645. var other_clab_amt float64 = 0
  1646. var other_other_amt float64 = 0
  1647. var westernMedicine_claa_sunmfee float64 = 0
  1648. var westernMedicine_clab_amt float64 = 0
  1649. var westernMedicine_other_amt float64 = 0
  1650. var chineseTraditional_claa_sunmfee float64 = 0
  1651. var chineseTraditional_clab_amt float64 = 0
  1652. var chineseTraditional_other_amt float64 = 0
  1653. var check_claa_sunmfee float64 = 0
  1654. var check_clab_amt float64 = 0
  1655. var check_other_amt float64 = 0
  1656. var material_claa_sunmfee float64 = 0
  1657. var material_clab_amt float64 = 0
  1658. var material_other_amt float64 = 0
  1659. var laboratory_claa_sunmfee float64 = 0
  1660. var laboratory_clab_amt float64 = 0
  1661. var laboratory_other_amt float64 = 0
  1662. var treat_claa_sunmfee float64 = 0
  1663. var treat_clab_amt float64 = 0
  1664. var treat_other_amt float64 = 0
  1665. var register_claa_sunmfee float64 = 0
  1666. var register_clab_amt float64 = 0
  1667. var register_other_amt float64 = 0
  1668. for _, item := range order.HisOrderInfo {
  1669. if item.MedChrgitmType == "01" { //床位费
  1670. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1671. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1672. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1673. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1674. if item.ChrgitmLv == "1" {
  1675. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1676. }
  1677. if item.ChrgitmLv == "2" {
  1678. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1679. }
  1680. if item.ChrgitmLv == "3" {
  1681. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1682. }
  1683. }
  1684. if item.MedChrgitmType == "02" { //诊查
  1685. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1686. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1687. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1688. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1689. if item.ChrgitmLv == "1" {
  1690. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1691. }
  1692. if item.ChrgitmLv == "2" {
  1693. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1694. }
  1695. if item.ChrgitmLv == "3" {
  1696. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1697. }
  1698. }
  1699. if item.MedChrgitmType == "03" { //检查费
  1700. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1701. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1702. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1703. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1704. if item.ChrgitmLv == "1" {
  1705. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1706. }
  1707. if item.ChrgitmLv == "2" {
  1708. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1709. }
  1710. if item.ChrgitmLv == "3" {
  1711. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1712. }
  1713. }
  1714. if item.MedChrgitmType == "04" { //化验费
  1715. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1716. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1717. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1718. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1719. if item.ChrgitmLv == "1" {
  1720. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1721. }
  1722. if item.ChrgitmLv == "2" {
  1723. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1724. }
  1725. if item.ChrgitmLv == "3" {
  1726. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1727. }
  1728. }
  1729. if item.MedChrgitmType == "05" { //治疗费
  1730. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1731. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1732. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1733. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1734. if item.ChrgitmLv == "1" {
  1735. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1736. }
  1737. if item.ChrgitmLv == "2" {
  1738. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1739. }
  1740. if item.ChrgitmLv == "3" {
  1741. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1742. }
  1743. }
  1744. if item.MedChrgitmType == "06" { //手术费
  1745. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1746. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1747. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1748. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1749. if item.ChrgitmLv == "1" {
  1750. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1751. }
  1752. if item.ChrgitmLv == "2" {
  1753. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1754. }
  1755. if item.ChrgitmLv == "3" {
  1756. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1757. }
  1758. }
  1759. if item.MedChrgitmType == "07" { //手术费
  1760. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1761. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1762. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1763. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1764. if item.ChrgitmLv == "1" {
  1765. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1766. }
  1767. if item.ChrgitmLv == "2" {
  1768. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1769. }
  1770. if item.ChrgitmLv == "3" {
  1771. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1772. }
  1773. }
  1774. if item.MedChrgitmType == "08" { //材料费
  1775. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1776. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1777. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1778. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1779. if item.ChrgitmLv == "1" {
  1780. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1781. }
  1782. if item.ChrgitmLv == "2" {
  1783. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1784. }
  1785. if item.ChrgitmLv == "3" {
  1786. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1787. }
  1788. }
  1789. if item.MedChrgitmType == "09" { //西药费
  1790. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1791. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1792. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1793. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1794. if item.ChrgitmLv == "1" {
  1795. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1796. }
  1797. if item.ChrgitmLv == "2" {
  1798. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1799. }
  1800. if item.ChrgitmLv == "3" {
  1801. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1802. }
  1803. }
  1804. if item.MedChrgitmType == "10" { //中药饮片
  1805. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1806. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1807. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1808. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1809. if item.ChrgitmLv == "1" {
  1810. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1811. }
  1812. if item.ChrgitmLv == "2" {
  1813. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1814. }
  1815. if item.ChrgitmLv == "3" {
  1816. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1817. }
  1818. }
  1819. if item.MedChrgitmType == "11" { //中成费
  1820. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1821. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1822. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1823. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1824. if item.ChrgitmLv == "1" {
  1825. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1826. }
  1827. if item.ChrgitmLv == "2" {
  1828. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1829. }
  1830. if item.ChrgitmLv == "3" {
  1831. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1832. }
  1833. }
  1834. if item.MedChrgitmType == "12" { //中成费
  1835. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1836. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1837. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1838. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1839. if item.ChrgitmLv == "1" {
  1840. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1841. }
  1842. if item.ChrgitmLv == "2" {
  1843. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1844. }
  1845. if item.ChrgitmLv == "3" {
  1846. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1847. }
  1848. }
  1849. if item.MedChrgitmType == "13" { //中成费
  1850. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1851. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1852. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1853. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1854. if item.ChrgitmLv == "1" {
  1855. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1856. }
  1857. if item.ChrgitmLv == "2" {
  1858. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1859. }
  1860. if item.ChrgitmLv == "3" {
  1861. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1862. }
  1863. }
  1864. if item.MedChrgitmType == "14" { //其他费
  1865. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1866. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1867. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1868. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1869. if item.ChrgitmLv == "1" {
  1870. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1871. }
  1872. if item.ChrgitmLv == "2" {
  1873. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1874. }
  1875. if item.ChrgitmLv == "3" {
  1876. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1877. }
  1878. }
  1879. }
  1880. var iteminfoStructs []service.IteminfoStruct
  1881. if bedCostTotal != 0 {
  1882. iteminfo.MedChrgitm = "01"
  1883. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1884. iteminfo.Amt = bedCostTotal
  1885. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1886. iteminfo.ClabAmt = bed_clab_amt
  1887. iteminfo.OthAmt = bed_other_amt
  1888. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1889. }
  1890. if examineCostTotal != 0 {
  1891. iteminfo.MedChrgitm = "02"
  1892. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1893. iteminfo.Amt = examineCostTotal
  1894. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1895. iteminfo.ClabAmt = examine_clab_amt
  1896. iteminfo.OthAmt = examine_other_amt
  1897. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1898. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1899. }
  1900. if checkCostTotal != 0 {
  1901. iteminfo.MedChrgitm = "03"
  1902. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1903. iteminfo.Amt = checkCostTotal
  1904. iteminfo.ClaaSumfee = check_claa_sunmfee
  1905. iteminfo.ClabAmt = check_clab_amt
  1906. iteminfo.OthAmt = check_other_amt
  1907. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1908. }
  1909. if laboratoryCostTotal != 0 {
  1910. iteminfo.MedChrgitm = "04"
  1911. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1912. iteminfo.Amt = laboratoryCostTotal
  1913. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1914. iteminfo.ClabAmt = laboratory_clab_amt
  1915. iteminfo.OthAmt = laboratory_other_amt
  1916. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1917. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1918. }
  1919. if treatCostTotal != 0 {
  1920. iteminfo.MedChrgitm = "05"
  1921. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1922. iteminfo.Amt = treatCostTotal
  1923. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1924. iteminfo.ClabAmt = treat_clab_amt
  1925. iteminfo.OthAmt = treat_other_amt
  1926. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1927. //(struct4101.IteminfoStruct, iteminfo)
  1928. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1929. }
  1930. if operationCostTotal != 0 {
  1931. iteminfo.MedChrgitm = "06"
  1932. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1933. iteminfo.Amt = operationCostTotal
  1934. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1935. iteminfo.ClabAmt = operation_clab_amt
  1936. iteminfo.OthAmt = operation_other_amt
  1937. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1939. }
  1940. if nursingCostTotal != 0 {
  1941. iteminfo.MedChrgitm = "07"
  1942. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1943. iteminfo.Amt = nursingCostTotal
  1944. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1945. iteminfo.ClabAmt = nursing_clab_amt
  1946. iteminfo.OthAmt = nursing_other_amt
  1947. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1948. }
  1949. if materialCostTotal != 0 {
  1950. iteminfo.MedChrgitm = "08"
  1951. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1952. iteminfo.Amt = materialCostTotal
  1953. iteminfo.ClaaSumfee = material_claa_sunmfee
  1954. iteminfo.ClabAmt = material_clab_amt
  1955. iteminfo.OthAmt = material_other_amt
  1956. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1957. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1958. }
  1959. if westernMedicineCostTotal != 0 {
  1960. iteminfo.MedChrgitm = "09"
  1961. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1962. iteminfo.Amt = westernMedicineCostTotal
  1963. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1964. iteminfo.ClabAmt = westernMedicine_clab_amt
  1965. iteminfo.OthAmt = westernMedicine_other_amt
  1966. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1967. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1968. }
  1969. if chineseMedicineCostTotal != 0 {
  1970. iteminfo.MedChrgitm = "10"
  1971. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1972. iteminfo.Amt = chineseMedicineCostTotal
  1973. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1974. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1975. iteminfo.OthAmt = chinese_medicine_other_amt
  1976. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1977. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1978. }
  1979. if chineseTraditionalMedicineCostTotal != 0 {
  1980. iteminfo.MedChrgitm = "11"
  1981. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1982. iteminfo.Amt = westernMedicineCostTotal
  1983. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1984. iteminfo.ClabAmt = westernMedicine_clab_amt
  1985. iteminfo.OthAmt = westernMedicine_other_amt
  1986. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1987. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1988. }
  1989. if commonlyTreatmentCostTotal != 0 {
  1990. iteminfo.MedChrgitm = "12"
  1991. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  1992. iteminfo.Amt = commonlyTreatmentCostTotal
  1993. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  1994. iteminfo.ClabAmt = commonly_treatment_clab_amt
  1995. iteminfo.OthAmt = commonly_treatment_other_amt
  1996. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1997. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1998. }
  1999. if registerCostTotal != 0 {
  2000. iteminfo.MedChrgitm = "13"
  2001. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2002. iteminfo.Amt = registerCostTotal
  2003. iteminfo.ClaaSumfee = register_claa_sunmfee
  2004. iteminfo.ClabAmt = register_clab_amt
  2005. iteminfo.OthAmt = register_other_amt
  2006. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2007. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2008. }
  2009. if otherCostTotal != 0 {
  2010. iteminfo.MedChrgitm = "14"
  2011. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2012. iteminfo.Amt = otherCostTotal
  2013. iteminfo.ClaaSumfee = other_claa_sunmfee
  2014. iteminfo.ClabAmt = other_clab_amt
  2015. iteminfo.OthAmt = other_other_amt
  2016. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2017. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2018. }
  2019. struct4101.IteminfoStruct = iteminfoStructs
  2020. struct4101.Ntly = "中国"
  2021. struct4101.AdmCaty = "A03.06"
  2022. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  2023. fmt.Println(result)
  2024. var dat map[string]interface{}
  2025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2026. fmt.Println(dat)
  2027. } else {
  2028. fmt.Println(err)
  2029. }
  2030. userJSONBytes, _ := json.Marshal(dat)
  2031. var res ResultSeventeen
  2032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2033. utils.ErrorLog("解析失败:%v", err)
  2034. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2035. adminUser := c.GetAdminUserInfo()
  2036. errlog := &models.HisOrderError{
  2037. UserOrgId: adminUser.CurrentOrgId,
  2038. Ctime: time.Now().Unix(),
  2039. Mtime: time.Now().Unix(),
  2040. ErrMsg: res.ErrMsg + "解析失败",
  2041. Status: 1,
  2042. PatientId: order_id,
  2043. Stage: 120,
  2044. }
  2045. service.CreateErrMsgLog(errlog)
  2046. continue
  2047. }
  2048. if res.Infcode != 0 {
  2049. adminUser := c.GetAdminUserInfo()
  2050. errlog := &models.HisOrderError{
  2051. UserOrgId: adminUser.CurrentOrgId,
  2052. Ctime: time.Now().Unix(),
  2053. Mtime: time.Now().Unix(),
  2054. ErrMsg: res.ErrMsg,
  2055. Status: 1,
  2056. PatientId: order_id,
  2057. Stage: 200,
  2058. }
  2059. service.CreateErrMsgLog(errlog)
  2060. continue
  2061. } else {
  2062. hisFundSettleListResult := &models.HisFundSettleListResult{
  2063. Number: res.Output.SetlListId,
  2064. Status: 1,
  2065. Ctime: time.Now().Unix(),
  2066. Mtime: time.Now().Unix(),
  2067. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2068. IsUpload: 1,
  2069. OrderId: order_id,
  2070. }
  2071. service.CreateUploadRecord(hisFundSettleListResult)
  2072. continue
  2073. }
  2074. }
  2075. }
  2076. func (c *HisApiController) GetOrgInfo() {
  2077. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2078. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2079. }
  2080. func (c *HisApiController) GetHisPatientInfo() {
  2081. medical_insurance_card := c.GetString("medical_insurance_card")
  2082. id_card_type, _ := c.GetInt64("id_card_type")
  2083. id_card := c.GetString("id_card")
  2084. adminInfo := c.GetAdminUserInfo()
  2085. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2086. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2087. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2088. IdCardNo := ""
  2089. if id_card_type == 1 {
  2090. IdCardNo = medical_insurance_card
  2091. } else if id_card_type == 2 {
  2092. IdCardNo = id_card
  2093. }
  2094. if config.IsOpen == 1 {
  2095. 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
  2096. resp, requestErr := http.Get(api)
  2097. if requestErr != nil {
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2099. return
  2100. }
  2101. defer resp.Body.Close()
  2102. body, ioErr := ioutil.ReadAll(resp.Body)
  2103. if ioErr != nil {
  2104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. return
  2107. }
  2108. var respJSON map[string]interface{}
  2109. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2112. return
  2113. }
  2114. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2115. userJSONBytes, _ := json.Marshal(userJSON)
  2116. var res ResultTwo
  2117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2118. utils.ErrorLog("解析失败:%v", err)
  2119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2120. return
  2121. }
  2122. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2123. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2124. infoStr := string(Iinfos)
  2125. idetinfoStr := string(Idetinfos)
  2126. if res.Infcode == 0 {
  2127. his := models.VMHisPatient{
  2128. Status: 1,
  2129. Ctime: time.Now().Unix(),
  2130. Mtime: time.Now().Unix(),
  2131. PsnNo: res.Output.Baseinfo.PsnNo,
  2132. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2133. Certno: res.Output.Baseinfo.Certno,
  2134. PsnName: res.Output.Baseinfo.PsnName,
  2135. Gend: res.Output.Baseinfo.Gend,
  2136. Naty: res.Output.Baseinfo.Naty,
  2137. Brdy: res.Output.Baseinfo.Brdy,
  2138. Age: res.Output.Baseinfo.Age,
  2139. Iinfo: infoStr,
  2140. Idetinfo: idetinfoStr,
  2141. UserOrgId: adminInfo.CurrentOrgId,
  2142. IsReturn: 1,
  2143. IdCardType: id_card_type,
  2144. }
  2145. c.ServeSuccessJSON(map[string]interface{}{
  2146. "info": his,
  2147. })
  2148. } else {
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2150. return
  2151. }
  2152. }
  2153. }
  2154. //func GetBasBaseInfo() (jsonStr string, err error) {
  2155. //
  2156. // handle := syscall.NewLazyDLL("SSCard.dll")
  2157. // add := handle.NewProc("ReadCardBas")
  2158. // str := make([]byte, 1024)
  2159. // str1 := make([]byte, 1024)
  2160. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2161. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2162. //
  2163. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2164. //
  2165. // fmt.Println("> Add(4,5)的结果为:", ret)
  2166. // handle.Release()
  2167. //
  2168. // return "", nil
  2169. //
  2170. //}
  2171. //func GetQRBaseInfo() (jsonStr string, err error) {
  2172. // handle := syscall.LoadDLL("SSCard.dll")
  2173. // ReadCardBas := handle.FindProc("GetQRBase")
  2174. //
  2175. // str := make([]byte, 256)
  2176. // str1 := make([]byte, 256)
  2177. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2178. //
  2179. // fmt.Println(string(str))
  2180. // fmt.Println(r)
  2181. // return string(str), nil
  2182. //}
  2183. //func CardInit() int {
  2184. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2185. // add := DllTestDef.MustFindProc("Init")
  2186. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2187. // if err != nil {
  2188. // fmt.Println("SSCard的运算结果为:", ret)
  2189. // }
  2190. // result := int(ret)
  2191. // return result
  2192. //}
  2193. //func CardInit() int {
  2194. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2195. // if err != nil {
  2196. // fmt.Println("SSCard的运算结果为:", ret)
  2197. // }
  2198. // fmt.Println(err)
  2199. // result := int(ret)
  2200. // return result
  2201. //}
  2202. func IntPtr(n int) uintptr {
  2203. return uintptr(n)
  2204. }
  2205. func StrPtr(s string) uintptr {
  2206. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2207. }
  2208. type Result2001 struct {
  2209. Cainfo interface{} `json:"cainfo"`
  2210. ErrMsg string `json:"err_msg"`
  2211. InfRefmsgid string `json:"inf_refmsgid"`
  2212. Infcode int64 `json:"infcode"`
  2213. Output struct {
  2214. Trtinfo struct {
  2215. PsnNo string `json:"psn_no"`
  2216. TrtChkType string `json:"trt_chk_type"`
  2217. FundPayType string `json:"fund_pay_type"`
  2218. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2219. Begndate string `json:"begndate"`
  2220. Enddate string `json:"enddate"`
  2221. TrtChkRslt string `json:"trt_chk_rslt"`
  2222. } `json:"trtinfo"`
  2223. } `json:"output"`
  2224. RefmsgTime string `json:"refmsg_time"`
  2225. RespondTime string `json:"respond_time"`
  2226. Signtype interface{} `json:"signtype"`
  2227. WarnMsg interface{} `json:"warn_msg"`
  2228. }
  2229. type Result2001Org10265 struct {
  2230. Cainfo interface{} `json:"cainfo"`
  2231. ErrMsg string `json:"err_msg"`
  2232. InfRefmsgid string `json:"inf_refmsgid"`
  2233. Infcode string `json:"infcode"`
  2234. Output struct {
  2235. Trtinfo struct {
  2236. PsnNo string `json:"psn_no"`
  2237. TrtChkType string `json:"trt_chk_type"`
  2238. FundPayType string `json:"fund_pay_type"`
  2239. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2240. Begndate string `json:"begndate"`
  2241. Enddate string `json:"enddate"`
  2242. TrtChkRslt string `json:"trt_chk_rslt"`
  2243. } `json:"trtinfo"`
  2244. } `json:"output"`
  2245. RefmsgTime string `json:"refmsg_time"`
  2246. RespondTime string `json:"respond_time"`
  2247. Signtype interface{} `json:"signtype"`
  2248. WarnMsg interface{} `json:"warn_msg"`
  2249. }
  2250. type ResultTwo struct {
  2251. ErrMsg string `json:"err_msg"`
  2252. InfRefmsgid string `json:"inf_refmsgid"`
  2253. Infcode int64 `json:"infcode"`
  2254. Output struct {
  2255. Baseinfo struct {
  2256. Age float64 `json:"age"`
  2257. Brdy string `json:"brdy"`
  2258. Certno string `json:"certno"`
  2259. Gend string `json:"gend"`
  2260. Naty string `json:"naty"`
  2261. PsnCertType string `json:"psn_cert_type"`
  2262. PsnName string `json:"psn_name"`
  2263. PsnNo string `json:"psn_no"`
  2264. } `json:"baseinfo"`
  2265. Idetinfo []interface{} `json:"idetinfo"`
  2266. Iinfo []struct {
  2267. Balc float64 `json:"balc"`
  2268. CvlservFlag string `json:"cvlserv_flag"`
  2269. EmpName string `json:"emp_name"`
  2270. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2271. Insutype string `json:"insutype"`
  2272. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2273. PausInsuDate string `json:"paus_insu_date"`
  2274. PsnInsuDate string `json:"psn_insu_date"`
  2275. PsnInsuStas string `json:"psn_insu_stas"`
  2276. PsnType string `json:"psn_type"`
  2277. } `json:"insuinfo"`
  2278. } `json:"output"`
  2279. RefmsgTime string `json:"refmsg_time"`
  2280. RespondTime string `json:"respond_time"`
  2281. Signtype interface{} `json:"signtype"`
  2282. WarnInfo interface{} `json:"warn_info"`
  2283. }
  2284. type ResultTwo10265 struct {
  2285. ErrMsg string `json:"err_msg"`
  2286. InfRefmsgid string `json:"inf_refmsgid"`
  2287. Infcode string `json:"infcode"`
  2288. Output struct {
  2289. Baseinfo struct {
  2290. Age float64 `json:"age"`
  2291. Brdy string `json:"brdy"`
  2292. Certno string `json:"certno"`
  2293. Gend string `json:"gend"`
  2294. Naty string `json:"naty"`
  2295. PsnCertType string `json:"psn_cert_type"`
  2296. PsnName string `json:"psn_name"`
  2297. PsnNo string `json:"psn_no"`
  2298. } `json:"baseinfo"`
  2299. Idetinfo []interface{} `json:"idetinfo"`
  2300. Iinfo []struct {
  2301. Balc float64 `json:"balc"`
  2302. CvlservFlag string `json:"cvlserv_flag"`
  2303. EmpName string `json:"emp_name"`
  2304. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2305. Insutype string `json:"insutype"`
  2306. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2307. PausInsuDate string `json:"paus_insu_date"`
  2308. PsnInsuDate string `json:"psn_insu_date"`
  2309. PsnInsuStas string `json:"psn_insu_stas"`
  2310. PsnType string `json:"psn_type"`
  2311. } `json:"insuinfo"`
  2312. } `json:"output"`
  2313. RefmsgTime string `json:"refmsg_time"`
  2314. RespondTime string `json:"respond_time"`
  2315. Signtype interface{} `json:"signtype"`
  2316. WarnInfo interface{} `json:"warn_info"`
  2317. }
  2318. type ResultThree struct {
  2319. Cainfo interface{} `json:"cainfo"`
  2320. ErrMsg string `json:"err_msg"`
  2321. InfRefmsgid string `json:"inf_refmsgid"`
  2322. Infcode int64 `json:"infcode"`
  2323. Output struct {
  2324. Data struct {
  2325. IptOtpNo string `json:"ipt_otp_no"`
  2326. MdtrtID string `json:"mdtrt_id"`
  2327. PsnNo string `json:"psn_no"`
  2328. } `json:"data"`
  2329. } `json:"output"`
  2330. RefmsgTime string `json:"refmsg_time"`
  2331. RespondTime string `json:"respond_time"`
  2332. Signtype interface{} `json:"signtype"`
  2333. WarnMsg interface{} `json:"warn_msg"`
  2334. }
  2335. type ResultThree10265 struct {
  2336. Cainfo interface{} `json:"cainfo"`
  2337. ErrMsg string `json:"err_msg"`
  2338. InfRefmsgid string `json:"inf_refmsgid"`
  2339. Infcode string `json:"infcode"`
  2340. Output struct {
  2341. Data struct {
  2342. IptOtpNo string `json:"ipt_otp_no"`
  2343. MdtrtID string `json:"mdtrt_id"`
  2344. PsnNo string `json:"psn_no"`
  2345. } `json:"data"`
  2346. } `json:"output"`
  2347. RefmsgTime string `json:"refmsg_time"`
  2348. RespondTime string `json:"respond_time"`
  2349. Signtype interface{} `json:"signtype"`
  2350. WarnMsg interface{} `json:"warn_msg"`
  2351. }
  2352. type ResultFour struct {
  2353. Cainfo string `json:"cainfo"`
  2354. ErrMsg string `json:"err_msg"`
  2355. InfRefmsgid string `json:"inf_refmsgid"`
  2356. Infcode int64 `json:"infcode"`
  2357. Output struct {
  2358. Result []struct {
  2359. BasMednFlag string `json:"bas_medn_flag"`
  2360. ChldMedcFlag string `json:"chld_medc_flag"`
  2361. ChrgitmLv string `json:"chrgitm_lv"`
  2362. Cnt float64 `json:"cnt"`
  2363. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2364. DrtReimFlag string `json:"drt_reim_flag"`
  2365. FeedetlSn string `json:"feedetl_sn"`
  2366. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2367. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2368. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2369. ListSpItemFlag string `json:"list_sp_item_flag"`
  2370. LmtUsedFlag string `json:"lmt_used_flag"`
  2371. MedChrgitmType string `json:"med_chrgitm_type"`
  2372. Memo string `json:"memo"`
  2373. OverlmtAmt float64 `json:"overlmt_amt"`
  2374. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2375. Pric float64 `json:"pric"`
  2376. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2377. SelfpayProp float64 `json:"selfpay_prop"`
  2378. } `json:"result"`
  2379. } `json:"output"`
  2380. RefmsgTime string `json:"refmsg_time"`
  2381. RespondTime string `json:"respond_time"`
  2382. Signtype string `json:"signtype"`
  2383. WarnMsg string `json:"warn_msg"`
  2384. }
  2385. type ResultFour10265 struct {
  2386. Cainfo string `json:"cainfo"`
  2387. ErrMsg string `json:"err_msg"`
  2388. InfRefmsgid string `json:"inf_refmsgid"`
  2389. Infcode string `json:"infcode"`
  2390. Output struct {
  2391. Result []struct {
  2392. BasMednFlag string `json:"bas_medn_flag"`
  2393. ChldMedcFlag string `json:"chld_medc_flag"`
  2394. ChrgitmLv string `json:"chrgitm_lv"`
  2395. Cnt float64 `json:"cnt"`
  2396. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2397. DrtReimFlag string `json:"drt_reim_flag"`
  2398. FeedetlSn string `json:"feedetl_sn"`
  2399. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2400. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2401. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2402. ListSpItemFlag string `json:"list_sp_item_flag"`
  2403. LmtUsedFlag string `json:"lmt_used_flag"`
  2404. MedChrgitmType string `json:"med_chrgitm_type"`
  2405. Memo string `json:"memo"`
  2406. OverlmtAmt float64 `json:"overlmt_amt"`
  2407. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2408. Pric float64 `json:"pric"`
  2409. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2410. SelfpayProp float64 `json:"selfpay_prop"`
  2411. } `json:"result"`
  2412. } `json:"output"`
  2413. RefmsgTime string `json:"refmsg_time"`
  2414. RespondTime string `json:"respond_time"`
  2415. Signtype string `json:"signtype"`
  2416. WarnMsg string `json:"warn_msg"`
  2417. }
  2418. type ResultFive struct {
  2419. Balc float64 `json:"balc"`
  2420. CvlservFlag string `json:"cvlserv_flag"`
  2421. EmpName string `json:"emp_name"`
  2422. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2423. Insutype string `json:"insutype"`
  2424. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2425. PausInsuDate string `json:"paus_insu_date"`
  2426. PsnInsuDate string `json:"psn_insu_date"`
  2427. PsnInsuStas string `json:"psn_insu_stas"`
  2428. PsnType string `json:"psn_type"`
  2429. }
  2430. type ResultSix struct {
  2431. Cainfo interface{} `json:"cainfo"`
  2432. ErrMsg string `json:"err_msg"`
  2433. InfRefmsgid string `json:"inf_refmsgid"`
  2434. Infcode int64 `json:"infcode"`
  2435. Output struct {
  2436. } `json:"output"`
  2437. RefmsgTime string `json:"refmsg_time"`
  2438. RespondTime string `json:"respond_time"`
  2439. Signtype interface{} `json:"signtype"`
  2440. WarnMsg interface{} `json:"warn_msg"`
  2441. }
  2442. type ResultSix10265 struct {
  2443. Cainfo interface{} `json:"cainfo"`
  2444. ErrMsg string `json:"err_msg"`
  2445. InfRefmsgid string `json:"inf_refmsgid"`
  2446. Infcode string `json:"infcode"`
  2447. Output struct {
  2448. } `json:"output"`
  2449. RefmsgTime string `json:"refmsg_time"`
  2450. RespondTime string `json:"respond_time"`
  2451. Signtype interface{} `json:"signtype"`
  2452. WarnMsg interface{} `json:"warn_msg"`
  2453. }
  2454. type ResultSeven struct {
  2455. Cainfo string `json:"cainfo"`
  2456. ErrMsg string `json:"err_msg"`
  2457. InfRefmsgid string `json:"inf_refmsgid"`
  2458. Infcode int64 `json:"infcode"`
  2459. Output struct {
  2460. Setldetail []interface{} `json:"setldetail"`
  2461. Setlinfo struct {
  2462. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2463. AcctPay float64 `json:"acct_pay"`
  2464. ActPayDedc float64 `json:"act_pay_dedc"`
  2465. Age float64 `json:"age"`
  2466. Balc float64 `json:"balc"`
  2467. Brdy string `json:"brdy"`
  2468. Certno string `json:"certno"`
  2469. ClrOptins string `json:"clr_optins"`
  2470. ClrType string `json:"clr_type"`
  2471. ClrWay string `json:"clr_way"`
  2472. CvlservFlag string `json:"cvlserv_flag"`
  2473. CvlservPay float64 `json:"cvlserv_pay"`
  2474. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2475. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2476. Gend string `json:"gend"`
  2477. HifesPay float64 `json:"hifes_pay"`
  2478. HifmiPay float64 `json:"hifmi_pay"`
  2479. HifpPay float64 `json:"hifp_pay"`
  2480. HospPartAmt float64 `json:"hosp_part_amt"`
  2481. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2482. Insutype string `json:"insutype"`
  2483. MafPay float64 `json:"maf_pay"`
  2484. MdtrtCertType string `json:"mdtrt_cert_type"`
  2485. HifobPay float64 `json:"hifob_pay"`
  2486. MdtrtID string `json:"mdtrt_id"`
  2487. MedType string `json:"med_type"`
  2488. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2489. MedinsSetlID string `json:"medins_setl_id"`
  2490. Naty string `json:"naty"`
  2491. OthPay float64 `json:"oth_pay"`
  2492. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2493. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2494. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2495. PsnCashPay float64 `json:"psn_cash_pay"`
  2496. PsnCertType string `json:"psn_cert_type"`
  2497. PsnName string `json:"psn_name"`
  2498. PsnNo string `json:"psn_no"`
  2499. PsnPartAmt float64 `json:"psn_part_amt"`
  2500. PsnType string `json:"psn_type"`
  2501. SetlID string `json:"setl_id"`
  2502. SetlTime string `json:"setl_time"`
  2503. } `json:"setlinfo"`
  2504. } `json:"output"`
  2505. RefmsgTime string `json:"refmsg_time"`
  2506. RespondTime string `json:"respond_time"`
  2507. Signtype interface{} `json:"signtype"`
  2508. WarnMsg interface{} `json:"warn_msg"`
  2509. }
  2510. type ResultSeven10265 struct {
  2511. Cainfo string `json:"cainfo"`
  2512. ErrMsg string `json:"err_msg"`
  2513. InfRefmsgid string `json:"inf_refmsgid"`
  2514. Infcode string `json:"infcode"`
  2515. Output struct {
  2516. Setldetail []interface{} `json:"setldetail"`
  2517. Setlinfo struct {
  2518. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2519. AcctPay float64 `json:"acct_pay"`
  2520. ActPayDedc float64 `json:"act_pay_dedc"`
  2521. Age float64 `json:"age"`
  2522. Balc float64 `json:"balc"`
  2523. Brdy string `json:"brdy"`
  2524. Certno string `json:"certno"`
  2525. ClrOptins string `json:"clr_optins"`
  2526. ClrType string `json:"clr_type"`
  2527. ClrWay string `json:"clr_way"`
  2528. CvlservFlag string `json:"cvlserv_flag"`
  2529. CvlservPay float64 `json:"cvlserv_pay"`
  2530. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2531. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2532. Gend string `json:"gend"`
  2533. HifesPay float64 `json:"hifes_pay"`
  2534. HifmiPay float64 `json:"hifmi_pay"`
  2535. HifpPay float64 `json:"hifp_pay"`
  2536. HospPartAmt float64 `json:"hosp_part_amt"`
  2537. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2538. Insutype string `json:"insutype"`
  2539. MafPay float64 `json:"maf_pay"`
  2540. MdtrtCertType string `json:"mdtrt_cert_type"`
  2541. HifobPay float64 `json:"hifob_pay"`
  2542. MdtrtID string `json:"mdtrt_id"`
  2543. MedType string `json:"med_type"`
  2544. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2545. MedinsSetlID string `json:"medins_setl_id"`
  2546. Naty string `json:"naty"`
  2547. OthPay float64 `json:"oth_pay"`
  2548. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2549. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2550. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2551. PsnCashPay float64 `json:"psn_cash_pay"`
  2552. PsnCertType string `json:"psn_cert_type"`
  2553. PsnName string `json:"psn_name"`
  2554. PsnNo string `json:"psn_no"`
  2555. PsnPartAmt float64 `json:"psn_part_amt"`
  2556. PsnType string `json:"psn_type"`
  2557. SetlID string `json:"setl_id"`
  2558. SetlTime string `json:"setl_time"`
  2559. } `json:"setlinfo"`
  2560. } `json:"output"`
  2561. RefmsgTime string `json:"refmsg_time"`
  2562. RespondTime string `json:"respond_time"`
  2563. Signtype interface{} `json:"signtype"`
  2564. WarnMsg interface{} `json:"warn_msg"`
  2565. }
  2566. type ResultEight struct {
  2567. Cainfo string `json:"cainfo"`
  2568. ErrMsg string `json:"err_msg"`
  2569. InfRefmsgid string `json:"inf_refmsgid"`
  2570. Infcode int64 `json:"infcode"`
  2571. Output struct {
  2572. Stmtinfo struct {
  2573. SetlOptins string `json:"setl_optins"`
  2574. StmtRslt string `json:"stmt_rslt"`
  2575. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2576. } `json:"stmtinfo"`
  2577. } `json:"output"`
  2578. RefmsgTime string `json:"refmsg_time"`
  2579. RespondTime string `json:"respond_time"`
  2580. Signtype interface{} `json:"signtype"`
  2581. WarnMsg interface{} `json:"warn_msg"`
  2582. }
  2583. type ResultEightFor10188 struct {
  2584. Cainfo string `json:"cainfo"`
  2585. ErrMsg string `json:"err_msg"`
  2586. InfRefmsgid string `json:"inf_refmsgid"`
  2587. Infcode string `json:"infcode"`
  2588. Output struct {
  2589. Stmtinfo struct {
  2590. SetlOptins string `json:"setl_optins"`
  2591. StmtRslt string `json:"stmt_rslt"`
  2592. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2593. } `json:"stmtinfo"`
  2594. } `json:"output"`
  2595. RefmsgTime string `json:"refmsg_time"`
  2596. RespondTime string `json:"respond_time"`
  2597. Signtype interface{} `json:"signtype"`
  2598. WarnMsg interface{} `json:"warn_msg"`
  2599. }
  2600. type ResultNine struct {
  2601. Cainfo string `json:"cainfo"`
  2602. ErrMsg string `json:"err_msg"`
  2603. InfRefmsgid string `json:"inf_refmsgid"`
  2604. Infcode int64 `json:"infcode"`
  2605. Output struct {
  2606. FileQuryNo string `json:"file_qury_no"`
  2607. } `json:"output"`
  2608. RefmsgTime string `json:"refmsg_time"`
  2609. RespondTime string `json:"respond_time"`
  2610. Signtype interface{} `json:"signtype"`
  2611. WarnMsg interface{} `json:"warn_msg"`
  2612. }
  2613. type ResultTen struct {
  2614. Cainfo string `json:"cainfo"`
  2615. ErrMsg string `json:"err_msg"`
  2616. InfRefmsgid string `json:"inf_refmsgid"`
  2617. Infcode int64 `json:"infcode"`
  2618. Output struct {
  2619. DldEndtime string `json:"dld_endtime"`
  2620. FileQuryNo string `json:"file_qury_no"`
  2621. Filename string `json:"filename"`
  2622. } `json:"output"`
  2623. RefmsgTime string `json:"refmsg_time"`
  2624. RespondTime string `json:"respond_time"`
  2625. Signtype interface{} `json:"signtype"`
  2626. WarnMsg interface{} `json:"warn_msg"`
  2627. }
  2628. //type Autogenerated struct {
  2629. // Output struct {
  2630. // Setlinfo struct {
  2631. // SetlTime string `json:"setl_time"`
  2632. // CvlservPay float64 `json:"cvlserv_pay"`
  2633. // Year string `json:"year"`
  2634. // MedType string `json:"med_type"`
  2635. // PsnPay float64 `json:"psn_pay"`
  2636. // OpterID string `json:"opter_id"`
  2637. // Begndate string `json:"begndate"`
  2638. // FlxempeFlag string `json:"flxempe_flag"`
  2639. // HifmiPay float64 `json:"hifmi_pay"`
  2640. // PsnNo string `json:"psn_no"`
  2641. // ActPayDedc float64 `json:"act_pay_dedc"`
  2642. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2643. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2644. // ClrWay string `json:"clr_way"`
  2645. // OthPay float64 `json:"oth_pay"`
  2646. // Gend string `json:"gend"`
  2647. // MdtrtID string `json:"mdtrt_id"`
  2648. // AcctPay float64 `json:"acct_pay"`
  2649. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2650. // Insutype string `json:"insutype"`
  2651. // Invono interface{} `json:"invono"`
  2652. // Enddate string `json:"enddate"`
  2653. // CashPayamt float64 `json:"cash_payamt"`
  2654. // PsnType string `json:"psn_type"`
  2655. // FixmedinsName string `json:"fixmedins_name"`
  2656. // HifpPay float64 `json:"hifp_pay"`
  2657. // NewFlag interface{} `json:"new_flag"`
  2658. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2659. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2660. // PayLoc string `json:"pay_loc"`
  2661. // ClrType string `json:"clr_type"`
  2662. // RefdSetlFlag string `json:"refd_setl_flag"`
  2663. // CvlservFlag string `json:"cvlserv_flag"`
  2664. // EmpName string `json:"emp_name"`
  2665. // Brdy string `json:"brdy"`
  2666. // Naty string `json:"naty"`
  2667. // Certno string `json:"certno"`
  2668. // DiseCode string `json:"dise_code"`
  2669. // FixmedinsCode string `json:"fixmedins_code"`
  2670. // DedcHospLv string `json:"dedc_hosp_lv"`
  2671. // OpterName string `json:"opter_name"`
  2672. // Balc float64 `json:"balc"`
  2673. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2674. // PsnCertType string `json:"psn_cert_type"`
  2675. // HifobPay float64 `json:"hifob_pay"`
  2676. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2677. // HifesPay float64 `json:"hifes_pay"`
  2678. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2679. // OptTime string `json:"opt_time"`
  2680. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2681. // SetlID string `json:"setl_id"`
  2682. // MafPay float64 `json:"maf_pay"`
  2683. // PsnName string `json:"psn_name"`
  2684. // InsuOptins interface{} `json:"insu_optins"`
  2685. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2686. // ClrOptins string `json:"clr_optins"`
  2687. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2688. // DiseName string `json:"dise_name"`
  2689. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2690. // Age float64 `json:"age"`
  2691. // DtrtCertType string `json:"dtrt_cert_type"`
  2692. // HospLv string `json:"hosp_lv"`
  2693. // } `json:"setlinfo"`
  2694. // Setldetail []struct {
  2695. // FundPayType string `json:"fund_pay_type"`
  2696. // FundPayamt float64 `json:"fund_payamt"`
  2697. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2698. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2699. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2700. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2701. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2702. // } `json:"setldetail"`
  2703. // } `json:"output"`
  2704. // Infcode int `json:"infcode"`
  2705. // WarnMsg interface{} `json:"warn_msg"`
  2706. // Cainfo interface{} `json:"cainfo"`
  2707. // ErrMsg interface{} `json:"err_msg"`
  2708. // RefmsgTime string `json:"refmsg_time"`
  2709. // Signtype interface{} `json:"signtype"`
  2710. // RespondTime string `json:"respond_time"`
  2711. // InfRefmsgid string `json:"inf_refmsgid"`
  2712. //}
  2713. type ResultEleven struct {
  2714. Cainfo string `json:"cainfo"`
  2715. ErrMsg string `json:"err_msg"`
  2716. InfRefmsgid string `json:"inf_refmsgid"`
  2717. Infcode int64 `json:"infcode"`
  2718. Output struct {
  2719. Setlinfo struct {
  2720. SetlTime string `json:"setl_time"`
  2721. CvlservPay float64 `json:"cvlserv_pay"`
  2722. Year string `json:"year"`
  2723. MedType string `json:"med_type"`
  2724. PsnPay float64 `json:"psn_pay"`
  2725. OpterID string `json:"opter_id"`
  2726. Begndate string `json:"begndate"`
  2727. FlxempeFlag string `json:"flxempe_flag"`
  2728. HifmiPay float64 `json:"hifmi_pay"`
  2729. PsnNo string `json:"psn_no"`
  2730. ActPayDedc float64 `json:"act_pay_dedc"`
  2731. MedinsSetlID interface{} `json:"medins_setl_id"`
  2732. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2733. ClrWay string `json:"clr_way"`
  2734. OthPay float64 `json:"oth_pay"`
  2735. Gend string `json:"gend"`
  2736. MdtrtID string `json:"mdtrt_id"`
  2737. AcctPay float64 `json:"acct_pay"`
  2738. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2739. Insutype string `json:"insutype"`
  2740. Invono interface{} `json:"invono"`
  2741. Enddate string `json:"enddate"`
  2742. CashPayamt float64 `json:"cash_payamt"`
  2743. PsnType string `json:"psn_type"`
  2744. FixmedinsName string `json:"fixmedins_name"`
  2745. HifpPay float64 `json:"hifp_pay"`
  2746. NewFlag interface{} `json:"new_flag"`
  2747. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2748. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2749. PayLoc string `json:"pay_loc"`
  2750. ClrType string `json:"clr_type"`
  2751. RefdSetlFlag string `json:"refd_setl_flag"`
  2752. CvlservFlag string `json:"cvlserv_flag"`
  2753. EmpName string `json:"emp_name"`
  2754. Brdy string `json:"brdy"`
  2755. Naty string `json:"naty"`
  2756. Certno string `json:"certno"`
  2757. DiseCode string `json:"dise_code"`
  2758. FixmedinsCode string `json:"fixmedins_code"`
  2759. DedcHospLv string `json:"dedc_hosp_lv"`
  2760. OpterName string `json:"opter_name"`
  2761. Balc float64 `json:"balc"`
  2762. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2763. PsnCertType string `json:"psn_cert_type"`
  2764. HifobPay float64 `json:"hifob_pay"`
  2765. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2766. HifesPay float64 `json:"hifes_pay"`
  2767. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2768. OptTime string `json:"opt_time"`
  2769. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2770. SetlID string `json:"setl_id"`
  2771. MafPay float64 `json:"maf_pay"`
  2772. PsnName string `json:"psn_name"`
  2773. InsuOptins interface{} `json:"insu_optins"`
  2774. PrefFundPay interface{} `json:"pref_fund_pay"`
  2775. ClrOptins string `json:"clr_optins"`
  2776. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2777. DiseName string `json:"dise_name"`
  2778. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2779. Age float64 `json:"age"`
  2780. DtrtCertType string `json:"dtrt_cert_type"`
  2781. HospLv string `json:"hosp_lv"`
  2782. } `json:"setlinfo"`
  2783. } `json:"output"`
  2784. RefmsgTime string `json:"refmsg_time"`
  2785. RespondTime string `json:"respond_time"`
  2786. Signtype interface{} `json:"signtype"`
  2787. WarnMsg interface{} `json:"warn_msg"`
  2788. }
  2789. type ResultEleven10265 struct {
  2790. Cainfo string `json:"cainfo"`
  2791. ErrMsg string `json:"err_msg"`
  2792. InfRefmsgid string `json:"inf_refmsgid"`
  2793. Infcode string `json:"infcode"`
  2794. Output struct {
  2795. Setlinfo struct {
  2796. SetlTime string `json:"setl_time"`
  2797. CvlservPay float64 `json:"cvlserv_pay"`
  2798. Year string `json:"year"`
  2799. MedType string `json:"med_type"`
  2800. PsnPay float64 `json:"psn_pay"`
  2801. OpterID string `json:"opter_id"`
  2802. Begndate string `json:"begndate"`
  2803. FlxempeFlag string `json:"flxempe_flag"`
  2804. HifmiPay float64 `json:"hifmi_pay"`
  2805. PsnNo string `json:"psn_no"`
  2806. ActPayDedc float64 `json:"act_pay_dedc"`
  2807. MedinsSetlID interface{} `json:"medins_setl_id"`
  2808. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2809. ClrWay string `json:"clr_way"`
  2810. OthPay float64 `json:"oth_pay"`
  2811. Gend string `json:"gend"`
  2812. MdtrtID string `json:"mdtrt_id"`
  2813. AcctPay float64 `json:"acct_pay"`
  2814. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2815. Insutype string `json:"insutype"`
  2816. Invono interface{} `json:"invono"`
  2817. Enddate string `json:"enddate"`
  2818. CashPayamt float64 `json:"cash_payamt"`
  2819. PsnType string `json:"psn_type"`
  2820. FixmedinsName string `json:"fixmedins_name"`
  2821. HifpPay float64 `json:"hifp_pay"`
  2822. NewFlag interface{} `json:"new_flag"`
  2823. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2824. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2825. PayLoc string `json:"pay_loc"`
  2826. ClrType string `json:"clr_type"`
  2827. RefdSetlFlag string `json:"refd_setl_flag"`
  2828. CvlservFlag string `json:"cvlserv_flag"`
  2829. EmpName string `json:"emp_name"`
  2830. Brdy string `json:"brdy"`
  2831. Naty string `json:"naty"`
  2832. Certno string `json:"certno"`
  2833. DiseCode string `json:"dise_code"`
  2834. FixmedinsCode string `json:"fixmedins_code"`
  2835. DedcHospLv string `json:"dedc_hosp_lv"`
  2836. OpterName string `json:"opter_name"`
  2837. Balc float64 `json:"balc"`
  2838. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2839. PsnCertType string `json:"psn_cert_type"`
  2840. HifobPay float64 `json:"hifob_pay"`
  2841. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2842. HifesPay float64 `json:"hifes_pay"`
  2843. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2844. OptTime string `json:"opt_time"`
  2845. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2846. SetlID string `json:"setl_id"`
  2847. MafPay float64 `json:"maf_pay"`
  2848. PsnName string `json:"psn_name"`
  2849. InsuOptins interface{} `json:"insu_optins"`
  2850. PrefFundPay interface{} `json:"pref_fund_pay"`
  2851. ClrOptins string `json:"clr_optins"`
  2852. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2853. DiseName string `json:"dise_name"`
  2854. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2855. Age float64 `json:"age"`
  2856. DtrtCertType string `json:"dtrt_cert_type"`
  2857. HospLv string `json:"hosp_lv"`
  2858. } `json:"setlinfo"`
  2859. } `json:"output"`
  2860. RefmsgTime string `json:"refmsg_time"`
  2861. RespondTime string `json:"respond_time"`
  2862. Signtype interface{} `json:"signtype"`
  2863. WarnMsg interface{} `json:"warn_msg"`
  2864. }
  2865. type ResultTwelve struct {
  2866. Cainfo string `json:"cainfo"`
  2867. ErrMsg string `json:"err_msg"`
  2868. InfRefmsgid string `json:"inf_refmsgid"`
  2869. Infcode int64 `json:"infcode"`
  2870. Output struct {
  2871. MdtrtId string `json:"mdtrt_id"`
  2872. ChrgBchno string `json:"chrg_bchno"`
  2873. PsnNo string `json:"psn_no"`
  2874. } `json:"output"`
  2875. RefmsgTime string `json:"refmsg_time"`
  2876. RespondTime string `json:"respond_time"`
  2877. Signtype interface{} `json:"signtype"`
  2878. WarnMsg interface{} `json:"warn_msg"`
  2879. }
  2880. type ResultThirteen struct {
  2881. ErrMsg string `json:"err_msg"`
  2882. InfRefmsgid string `json:"inf_refmsgid"`
  2883. Infcode int64 `json:"infcode"`
  2884. Output struct {
  2885. Result struct {
  2886. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2887. } `json:"result"`
  2888. } `json:"output"`
  2889. RefmsgTime string `json:"refmsg_time"`
  2890. RespondTime string `json:"respond_time"`
  2891. Signtype interface{} `json:"signtype"`
  2892. WarnInfo interface{} `json:"warn_info"`
  2893. }
  2894. type ResultThirteen10265 struct {
  2895. ErrMsg string `json:"err_msg"`
  2896. InfRefmsgid string `json:"inf_refmsgid"`
  2897. Infcode string `json:"infcode"`
  2898. Output struct {
  2899. Result struct {
  2900. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2901. } `json:"result"`
  2902. } `json:"output"`
  2903. RefmsgTime string `json:"refmsg_time"`
  2904. RespondTime string `json:"respond_time"`
  2905. Signtype interface{} `json:"signtype"`
  2906. WarnInfo interface{} `json:"warn_info"`
  2907. }
  2908. type ResultFourteen struct {
  2909. ErrMsg string `json:"err_msg"`
  2910. InfRefmsgid string `json:"inf_refmsgid"`
  2911. Infcode int64 `json:"infcode"`
  2912. Output struct {
  2913. } `json:"output"`
  2914. RefmsgTime string `json:"refmsg_time"`
  2915. RespondTime string `json:"respond_time"`
  2916. Signtype interface{} `json:"signtype"`
  2917. WarnInfo interface{} `json:"warn_info"`
  2918. }
  2919. type ResultFourteen10265 struct {
  2920. ErrMsg string `json:"err_msg"`
  2921. InfRefmsgid string `json:"inf_refmsgid"`
  2922. Infcode string `json:"infcode"`
  2923. Output struct {
  2924. } `json:"output"`
  2925. RefmsgTime string `json:"refmsg_time"`
  2926. RespondTime string `json:"respond_time"`
  2927. Signtype interface{} `json:"signtype"`
  2928. WarnInfo interface{} `json:"warn_info"`
  2929. }
  2930. type ResultSixteen struct {
  2931. Cainfo string `json:"cainfo"`
  2932. ErrMsg string `json:"err_msg"`
  2933. InfRefmsgid string `json:"inf_refmsgid"`
  2934. Infcode int64 `json:"infcode"`
  2935. Output struct {
  2936. Setldetail []interface{} `json:"setldetail"`
  2937. Setlinfo struct {
  2938. MdtrtID string `json:"mdtrt_id"`
  2939. SetlID string `json:"setl_id"`
  2940. ClrOptins string `json:"clr_optins"`
  2941. SetlTime string `json:"setl_time"`
  2942. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2943. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2944. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2945. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2946. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2947. ActPayDedc float64 `json:"act_pay_dedc"`
  2948. HifpPay float64 `json:"hifp_pay"`
  2949. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2950. Lfpay float64 `json:"selfpay"`
  2951. CvlservPay float64 `json:"cvlserv_pay"`
  2952. HifesPay float64 `json:"hifes_pay"`
  2953. HifmiPay float64 `json:"hifmi_pay"`
  2954. HifobPay float64 `json:"hifob_pay"`
  2955. MafPay float64 `json:"maf_pay"`
  2956. OthPay float64 `json:"oth_pay"`
  2957. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2958. PsnPartAmt float64 `json:"psn_part_amt"`
  2959. AcctPay float64 `json:"acct_pay"`
  2960. Balc float64 `json:"balc"`
  2961. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2962. HospPartAmt float64 `json:"hosp_part_amt"`
  2963. MedinsSetlID string `json:"medins_setl_id"`
  2964. PdnCashPay string `json:"pdn_cash_pay"`
  2965. } `json:"setlinfo"`
  2966. } `json:"output"`
  2967. RefmsgTime string `json:"refmsg_time"`
  2968. RespondTime string `json:"respond_time"`
  2969. Signtype interface{} `json:"signtype"`
  2970. WarnMsg interface{} `json:"warn_msg"`
  2971. }
  2972. type ResultSixteen10265 struct {
  2973. Cainfo string `json:"cainfo"`
  2974. ErrMsg string `json:"err_msg"`
  2975. InfRefmsgid string `json:"inf_refmsgid"`
  2976. Infcode string `json:"infcode"`
  2977. Output struct {
  2978. Setldetail []interface{} `json:"setldetail"`
  2979. Setlinfo struct {
  2980. MdtrtID string `json:"mdtrt_id"`
  2981. SetlID string `json:"setl_id"`
  2982. ClrOptins string `json:"clr_optins"`
  2983. SetlTime string `json:"setl_time"`
  2984. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2985. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2986. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2987. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2988. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2989. ActPayDedc float64 `json:"act_pay_dedc"`
  2990. HifpPay float64 `json:"hifp_pay"`
  2991. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2992. Lfpay float64 `json:"selfpay"`
  2993. CvlservPay float64 `json:"cvlserv_pay"`
  2994. HifesPay float64 `json:"hifes_pay"`
  2995. HifmiPay float64 `json:"hifmi_pay"`
  2996. HifobPay float64 `json:"hifob_pay"`
  2997. MafPay float64 `json:"maf_pay"`
  2998. OthPay float64 `json:"oth_pay"`
  2999. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3000. PsnPartAmt float64 `json:"psn_part_amt"`
  3001. AcctPay float64 `json:"acct_pay"`
  3002. Balc float64 `json:"balc"`
  3003. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3004. HospPartAmt float64 `json:"hosp_part_amt"`
  3005. MedinsSetlID string `json:"medins_setl_id"`
  3006. PdnCashPay string `json:"pdn_cash_pay"`
  3007. } `json:"setlinfo"`
  3008. } `json:"output"`
  3009. RefmsgTime string `json:"refmsg_time"`
  3010. RespondTime string `json:"respond_time"`
  3011. Signtype interface{} `json:"signtype"`
  3012. WarnMsg interface{} `json:"warn_msg"`
  3013. }
  3014. type ResultSeventeen struct {
  3015. ErrMsg string `json:"err_msg"`
  3016. InfRefmsgid string `json:"inf_refmsgid"`
  3017. Infcode int64 `json:"infcode"`
  3018. Output struct {
  3019. SetlListId string `json:"setl_list_id"`
  3020. } `json:"output"`
  3021. RefmsgTime string `json:"refmsg_time"`
  3022. RespondTime string `json:"respond_time"`
  3023. Signtype string `json:"signtype"`
  3024. WarnInfo string `json:"warn_info"`
  3025. }
  3026. type Result90991 struct {
  3027. ErrMsg string `json:"err_msg"`
  3028. InfRefmsgid string `json:"inf_refmsgid"`
  3029. Infcode int64 `json:"infcode"`
  3030. Output struct {
  3031. Result struct {
  3032. PsnNo string `json:"psn_no"`
  3033. CardStat string `json:"card_stat"`
  3034. Certno string `json:"certno"`
  3035. PsnName string `json:"psn_name"`
  3036. CheckStat string `json:"check_stat"`
  3037. } `json:"result"`
  3038. } `json:"output"`
  3039. RefmsgTime string `json:"refmsg_time"`
  3040. RespondTime string `json:"respond_time"`
  3041. Signtype interface{} `json:"signtype"`
  3042. WarnInfo interface{} `json:"warn_info"`
  3043. }
  3044. type Result90100 struct {
  3045. ErrMsg string `json:"err_msg"`
  3046. InfRefmsgid string `json:"inf_refmsgid"`
  3047. Infcode int64 `json:"infcode"`
  3048. Output struct {
  3049. PoolareaNo string `json:"poolarea_no"`
  3050. PoolareaNoName string `json:"poolarea_no_name"`
  3051. Insutype string `json:"insutype"`
  3052. InsutypeName string `json:"insutype_name"`
  3053. ClctType string `json:"clct_type"`
  3054. ClctTypeName string `json:"clct_type_name"`
  3055. ClctFlag string `json:"clct_flag"`
  3056. ClctFlagName string `json:"clct_flag_name"`
  3057. AccrymBegn string `json:"accrym_begn"`
  3058. AccrymEnd string `json:"accrym_end"`
  3059. ClctTime string `json:"clct_time"`
  3060. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3061. } `json:"output"`
  3062. RefmsgTime string `json:"refmsg_time"`
  3063. RespondTime string `json:"respond_time"`
  3064. Signtype interface{} `json:"signtype"`
  3065. WarnInfo interface{} `json:"warn_info"`
  3066. }
  3067. type Custom struct {
  3068. DetItemFeeSumamt string
  3069. Cut string
  3070. FeedetlSn string
  3071. Price string
  3072. MedListCodg string
  3073. Type int64
  3074. AdviceId int64
  3075. ProjectId int64
  3076. ItemId int64
  3077. }
  3078. type Result5301 struct {
  3079. ErrMsg string `json:"err_msg"`
  3080. InfRefmsgid string `json:"inf_refmsgid"`
  3081. Infcode int64 `json:"infcode"`
  3082. Output struct {
  3083. Result []struct {
  3084. OpspDiseCode string `json:"opsp_dise_code"`
  3085. OpspDiseName string `json:"opsp_dise_name"`
  3086. Begndate string `json:"begndate"`
  3087. Enddate string `json:"enddate"`
  3088. } `json:"feedetail"`
  3089. } `json:"output"`
  3090. RefmsgTime string `json:"refmsg_time"`
  3091. RespondTime string `json:"respond_time"`
  3092. Signtype interface{} `json:"signtype"`
  3093. WarnInfo interface{} `json:"warn_info"`
  3094. }
  3095. type Result5301For10265 struct {
  3096. ErrMsg string `json:"err_msg"`
  3097. InfRefmsgid string `json:"inf_refmsgid"`
  3098. Infcode string `json:"infcode"`
  3099. Output struct {
  3100. Result []struct {
  3101. OpspDiseCode string `json:"opsp_dise_code"`
  3102. OpspDiseName string `json:"opsp_dise_name"`
  3103. Begndate string `json:"begndate"`
  3104. Enddate string `json:"enddate"`
  3105. } `json:"feedetail"`
  3106. } `json:"output"`
  3107. RefmsgTime string `json:"refmsg_time"`
  3108. RespondTime string `json:"respond_time"`
  3109. Signtype interface{} `json:"signtype"`
  3110. WarnInfo interface{} `json:"warn_info"`
  3111. }
  3112. //获取个人信息----挂号-----上传就诊信息
  3113. func (c *HisApiController) GetRegisterInfo() {
  3114. id, _ := c.GetInt64("id")
  3115. record_time := c.GetString("record_time")
  3116. settlementValue, _ := c.GetInt64("settlement_value")
  3117. medical_insurance_card := c.GetString("medical_insurance_card")
  3118. name := c.GetString("name")
  3119. id_card_type, _ := c.GetInt64("id_card_type")
  3120. certificates, _ := c.GetInt64("certificates")
  3121. medical_care, _ := c.GetInt64("medical_care")
  3122. birthday := c.GetString("birthday")
  3123. id_card := c.GetString("id_card")
  3124. register_type, _ := c.GetInt64("register")
  3125. doctor, _ := c.GetInt64("doctor")
  3126. department, _ := c.GetInt64("department")
  3127. gender, _ := c.GetInt64("sex")
  3128. registration_fee, _ := c.GetFloat("registration_fee")
  3129. medical_expenses, _ := c.GetFloat("medical_expenses")
  3130. social_type, _ := c.GetInt64("social_type")
  3131. med_type := c.GetString("social_type")
  3132. admin_user_id, _ := c.GetInt64("admin_user_id")
  3133. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3134. timeLayout := "2006-01-02"
  3135. loc, _ := time.LoadLocation("Local")
  3136. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3137. birthUnix := birthdays.Unix()
  3138. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3139. if err != nil {
  3140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3141. return
  3142. }
  3143. recordDateTime := theTime.Unix()
  3144. adminInfo := c.GetAdminUserInfo()
  3145. var patient service.Patients
  3146. if id == 0 {
  3147. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3148. } else {
  3149. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3150. }
  3151. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3152. if patientPrescription.ID == 0 {
  3153. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3154. }
  3155. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3156. if patient.ID == 0 {
  3157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3158. return
  3159. }
  3160. if len(patient.IdCardNo) == 0 {
  3161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3162. return
  3163. }
  3164. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3165. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3166. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3167. //就诊结算未完成,不能进行二次挂号
  3168. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3169. if len(his) >= 1 {
  3170. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3171. if len(his) >= 1 && order.ID == 0 {
  3172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3173. return
  3174. }
  3175. }
  3176. //var register_log string
  3177. if config.IsOpen == 1 {
  3178. var res ResultTwo
  3179. var res10265 ResultTwo10265
  3180. var PsnNo string
  3181. var PsnCertType string
  3182. var Certno string
  3183. var PsnName string
  3184. var Gend string
  3185. var Naty string
  3186. var Brdy string
  3187. var Age float64
  3188. var infoStr string
  3189. var idetinfoStr string
  3190. var infocode int64
  3191. var verify_number string
  3192. fmt.Println(verify_number)
  3193. if miConfig.MdtrtareaAdmvs == "421300" {
  3194. psn_info, _ := service.GetPsnByPatientId(id)
  3195. PsnNo = psn_info.PsnNo
  3196. PsnCertType = psn_info.PsnCertType
  3197. Certno = psn_info.Certno
  3198. PsnName = psn_info.PsnName
  3199. Gend = psn_info.Gend
  3200. Naty = psn_info.Naty
  3201. Brdy = psn_info.Brdy
  3202. Age = psn_info.Age
  3203. infoStr = psn_info.Insuinfo
  3204. idetinfoStr = psn_info.Idetinfo
  3205. infocode = 0
  3206. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3207. psn_info, _ := service.GetPsnByPatientId(id)
  3208. PsnNo = psn_info.PsnNo
  3209. PsnCertType = psn_info.PsnCertType
  3210. Certno = psn_info.Certno
  3211. PsnName = psn_info.PsnName
  3212. Gend = psn_info.Gend
  3213. Naty = psn_info.Naty
  3214. Brdy = psn_info.Brdy
  3215. Age = psn_info.Age
  3216. infoStr = psn_info.Insuinfo
  3217. idetinfoStr = psn_info.Idetinfo
  3218. infocode = 0
  3219. verify_number = psn_info.VerifyNumber
  3220. } else {
  3221. var result string
  3222. var requestLog string
  3223. if miConfig.UserOrgId == 10138 {
  3224. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3225. } else {
  3226. 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)
  3227. }
  3228. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3229. if miConfig.Code == "H15049901371" {
  3230. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3231. utils.ErrorLog("解析失败:%v", err)
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3233. return
  3234. }
  3235. res.ErrMsg = res10265.ErrMsg
  3236. res.Output = res10265.Output
  3237. res.InfRefmsgid = res10265.InfRefmsgid
  3238. } else {
  3239. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3240. utils.ErrorLog("解析失败:%v", err)
  3241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3242. return
  3243. }
  3244. }
  3245. PsnNo = res.Output.Baseinfo.PsnNo
  3246. PsnCertType = res.Output.Baseinfo.PsnCertType
  3247. Certno = res.Output.Baseinfo.Certno
  3248. PsnName = res.Output.Baseinfo.PsnName
  3249. Gend = res.Output.Baseinfo.Gend
  3250. Naty = res.Output.Baseinfo.Naty
  3251. Brdy = res.Output.Baseinfo.Brdy
  3252. Age = res.Output.Baseinfo.Age
  3253. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3254. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3255. infoStr = string(Iinfos)
  3256. idetinfoStr = string(Idetinfos)
  3257. if miConfig.Code == "H15049901371" {
  3258. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3259. } else {
  3260. infocode = res.Infcode
  3261. }
  3262. }
  3263. if infocode == 0 {
  3264. his := models.VMHisPatient{
  3265. Name: name,
  3266. Gender: gender,
  3267. Birthday: birthUnix,
  3268. MedicalTreatmentType: medical_care,
  3269. IdType: certificates,
  3270. IdCardNo: id_card,
  3271. BalanceAccountsType: settlementValue,
  3272. SocialType: social_type,
  3273. MedicalInsuranceNumber: medical_insurance_card,
  3274. RegisterType: register_type,
  3275. RegisterCost: registration_fee,
  3276. TreatmentCost: medical_expenses,
  3277. Status: 1,
  3278. Ctime: time.Now().Unix(),
  3279. Mtime: time.Now().Unix(),
  3280. PsnNo: PsnNo,
  3281. PsnCertType: PsnCertType,
  3282. Certno: Certno,
  3283. PsnName: PsnName,
  3284. Gend: Gend,
  3285. Naty: Naty,
  3286. Brdy: Brdy,
  3287. Age: Age,
  3288. Iinfo: infoStr,
  3289. Idetinfo: idetinfoStr,
  3290. PatientId: patient.ID,
  3291. RecordDate: theTime.Unix(),
  3292. UserOrgId: adminInfo.CurrentOrgId,
  3293. AdminUserId: admin_user_id,
  3294. IsReturn: 1,
  3295. IdCardType: id_card_type,
  3296. Doctor: doctor,
  3297. Departments: department,
  3298. }
  3299. timestamp := time.Now().Unix()
  3300. tempTime := time.Unix(timestamp, 0)
  3301. timeFormat := tempTime.Format("20060102150405")
  3302. chrgBchno := rand.Intn(100000) + 10000
  3303. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3304. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3305. department, _ := service.GetDepartMentDetail(department)
  3306. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3307. IdCardNo := ""
  3308. if id_card_type == 1 {
  3309. // IdCardNo = medical_insurance_card
  3310. IdCardNo = patient.IdCardNo
  3311. } else {
  3312. IdCardNo = patient.IdCardNo
  3313. }
  3314. var rf []*ResultFive
  3315. json.Unmarshal([]byte(his.Iinfo), &rf)
  3316. var insutypes []*ResultFive
  3317. var insutype string
  3318. var insuplc_admdvs_temp string
  3319. var is390 int = 0
  3320. var is310 int = 0
  3321. for _, item := range rf {
  3322. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3323. insutypes = append(insutypes, item)
  3324. }
  3325. }
  3326. if len(insutypes) == 1 {
  3327. insutype = insutypes[0].Insutype
  3328. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3329. } else {
  3330. for _, i := range insutypes {
  3331. if i.Insutype == "390" {
  3332. is390 = 1
  3333. }
  3334. if i.Insutype == "310" {
  3335. is310 = 1
  3336. }
  3337. }
  3338. }
  3339. if is390 == 1 {
  3340. insutype = "390"
  3341. }
  3342. if is310 == 1 {
  3343. insutype = "310"
  3344. }
  3345. if len(insutypes) == 0 {
  3346. insutype = "310"
  3347. }
  3348. if len(insutypes) == 2 {
  3349. insutype = med_type
  3350. }
  3351. if len(med_type) > 0 {
  3352. insutype = med_type
  3353. }
  3354. //for _, item := range rf {
  3355. // if item.Insutype == insutype {
  3356. // insuplc_admdvs = item.InsuplcAdmdvs
  3357. // }
  3358. //}
  3359. var infocode int64
  3360. var resThree ResultThree
  3361. var resThree10265 ResultThree10265
  3362. if len(insuplc_admdvs) == 0 {
  3363. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3364. } else {
  3365. insuplc_admdvs_temp = insuplc_admdvs
  3366. }
  3367. if miConfig.MdtrtareaAdmvs == "421300" {
  3368. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3369. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3370. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  3371. resp, requestErr := http.Get(api)
  3372. if requestErr != nil {
  3373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3374. return
  3375. }
  3376. body, ioErr := ioutil.ReadAll(resp.Body)
  3377. if ioErr != nil {
  3378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3380. return
  3381. }
  3382. var respJSON map[string]interface{}
  3383. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3386. return
  3387. }
  3388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3389. result, _ := json.Marshal(respJSON)
  3390. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3391. utils.ErrorLog("解析失败:%v", err)
  3392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3393. return
  3394. }
  3395. infocode = resThree.Infcode
  3396. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3397. psn_info, _ := service.GetPsnByPatientId(id)
  3398. bas := strings.Split(psn_info.CardInfo, "|")
  3399. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3400. api := "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3401. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3402. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3403. resp, requestErr := http.Get(api)
  3404. if requestErr != nil {
  3405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3406. return
  3407. }
  3408. body, ioErr := ioutil.ReadAll(resp.Body)
  3409. if ioErr != nil {
  3410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. var respJSON map[string]interface{}
  3415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3418. return
  3419. }
  3420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3421. result, _ := json.Marshal(respJSON)
  3422. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3423. utils.ErrorLog("解析失败:%v", err)
  3424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3425. return
  3426. }
  3427. resThree.ErrMsg = resThree10265.ErrMsg
  3428. resThree.Output = resThree10265.Output
  3429. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3430. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3431. } else {
  3432. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3433. saveLog(result, requestLog, "2201", "挂号")
  3434. if miConfig.Code == "H15049901371" {
  3435. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3436. utils.ErrorLog("解析失败:%v", err)
  3437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3438. return
  3439. }
  3440. resThree.ErrMsg = resThree10265.ErrMsg
  3441. resThree.Output = resThree10265.Output
  3442. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3443. } else {
  3444. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3445. utils.ErrorLog("解析失败:%v", err)
  3446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3447. return
  3448. }
  3449. }
  3450. if miConfig.Code == "H15049901371" {
  3451. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3452. } else {
  3453. infocode = resThree.Infcode
  3454. }
  3455. }
  3456. if infocode != 0 {
  3457. adminUser := c.GetAdminUserInfo()
  3458. errlog := &models.HisOrderError{
  3459. UserOrgId: adminUser.CurrentOrgId,
  3460. Ctime: time.Now().Unix(),
  3461. Mtime: time.Now().Unix(),
  3462. ErrMsg: resThree.ErrMsg,
  3463. Status: 1,
  3464. PatientId: id,
  3465. RecordTime: recordDateTime,
  3466. Stage: 2,
  3467. }
  3468. service.CreateErrMsgLog(errlog)
  3469. c.ServeSuccessJSON(map[string]interface{}{
  3470. "failed_code": -10,
  3471. "msg": resThree.ErrMsg,
  3472. })
  3473. return
  3474. }
  3475. his.Number = resThree.Output.Data.MdtrtID
  3476. his.PsnNo = resThree.Output.Data.PsnNo
  3477. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3478. his.IdCardNo = patient.IdCardNo
  3479. his.PhoneNumber = patient.Phone
  3480. his.UserOrgId = adminInfo.CurrentOrgId
  3481. his.Insutype = insutype
  3482. his.Ctime = time.Now().Unix()
  3483. his.Mtime = time.Now().Unix()
  3484. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3485. his.Status = 1
  3486. service.UpdateHisPatientStatus(&his)
  3487. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3488. c.ServeSuccessJSON(map[string]interface{}{
  3489. "his_info": his,
  3490. })
  3491. } else {
  3492. adminUser := c.GetAdminUserInfo()
  3493. errlog := &models.HisOrderError{
  3494. UserOrgId: adminUser.CurrentOrgId,
  3495. Ctime: time.Now().Unix(),
  3496. Mtime: time.Now().Unix(),
  3497. ErrMsg: res.ErrMsg,
  3498. Status: 1,
  3499. PatientId: id,
  3500. RecordTime: recordDateTime,
  3501. Stage: 1,
  3502. }
  3503. service.CreateErrMsgLog(errlog)
  3504. c.ServeSuccessJSON(map[string]interface{}{
  3505. "failed_code": -10,
  3506. "msg": res.ErrMsg,
  3507. })
  3508. return
  3509. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3510. }
  3511. }
  3512. }
  3513. //上传明细----预结算----确认订单
  3514. func (c *HisApiController) GetUploadInfo() {
  3515. id, _ := c.GetInt64("id")
  3516. record_time := c.GetString("record_time")
  3517. his_patient_id, _ := c.GetInt64("his_patient_id")
  3518. order_id, _ := c.GetInt64("order_id")
  3519. pay_way, _ := c.GetInt64("pay_way")
  3520. pay_price, _ := c.GetFloat("pay_price")
  3521. pay_card_no := c.GetString("pay_card_no")
  3522. discount_price, _ := c.GetFloat("discount_price")
  3523. preferential_price, _ := c.GetFloat("preferential_price")
  3524. reality_price, _ := c.GetFloat("reality_price")
  3525. found_price, _ := c.GetFloat("found_price")
  3526. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3527. private_price, _ := c.GetFloat("private_price")
  3528. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3529. admin_user_id, _ := c.GetInt64("admin_user_id")
  3530. fapiao_code := c.GetString("fapiao_code")
  3531. fapiao_number := c.GetString("fapiao_number")
  3532. diagnosis_id := c.GetString("diagnosis")
  3533. sick_type, _ := c.GetInt64("sick_type")
  3534. reg_type, _ := c.GetInt64("p_type")
  3535. begin_time := c.GetString("begin_time")
  3536. id_str := c.GetString("ids")
  3537. ids_arr := strings.Split(id_str, ",")
  3538. timeLayout := "2006-01-02"
  3539. loc, _ := time.LoadLocation("Local")
  3540. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3541. if err != nil {
  3542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3543. return
  3544. }
  3545. recordDateTime := theTime.Unix()
  3546. adminUser := c.GetAdminUserInfo()
  3547. var tempOrder models.HisOrder
  3548. tempOrder, _ = service.GetHisOrderByID(order_id)
  3549. var prescriptions []*models.HisPrescription
  3550. var start_time int64
  3551. var end_time int64
  3552. //if adminUser.CurrentOrgId == 10106{
  3553. // if len(fapiao_code) == 0{
  3554. // fapiao_code = "144072080589"
  3555. // }
  3556. // if len(fapiao_number) == 0{
  3557. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3558. // if order.ID == 0{
  3559. // fapiao_number = "00001520"
  3560. // }else{
  3561. // //fapiao_code = "00001520"
  3562. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3563. // var zero string
  3564. // if fpNumber >= 1000{
  3565. // zero = "0000" + strconv.Itoa(fpNumber)
  3566. // }else if fpNumber >= 10000{
  3567. // zero = "000" + strconv.Itoa(fpNumber)
  3568. // } else if fpNumber >= 100000{
  3569. // zero = "00" + strconv.Itoa(fpNumber)
  3570. // } else if fpNumber >= 1000000{
  3571. // zero = "0" + strconv.Itoa(fpNumber)
  3572. // }else {
  3573. // zero = strconv.Itoa(fpNumber)
  3574. // }
  3575. // fapiao_number = zero
  3576. // }
  3577. // }
  3578. //}
  3579. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3580. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3581. var patientPrescription models.HisPrescriptionInfo
  3582. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3583. if patientPrescription.ID == 0 {
  3584. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3585. }
  3586. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3587. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3588. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3589. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3590. var config []*models.HisXtDiagnoseConfig
  3591. for _, item := range diagnosis_ids {
  3592. id, _ := strconv.ParseInt(item, 10, 64)
  3593. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3594. config = append(config, &diagnosisConfig)
  3595. }
  3596. sickConfig, _ := service.FindSickById(sick_type)
  3597. if tempOrder.ID == 0 {
  3598. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3599. }
  3600. if tempOrder.ID == 0 {
  3601. var result string
  3602. var requestLog string
  3603. var res2 ResultSix
  3604. var ressix10265 ResultSix10265
  3605. if miConfig.MdtrtareaAdmvs == "421300" {
  3606. data := make(map[string]interface{})
  3607. client := &http.Client{}
  3608. data["psn_no"] = his.PsnNo
  3609. data["mdtrt_id"] = his.Number
  3610. data["doctor"] = roles.UserName
  3611. data["department"] = department.Name
  3612. data["org_name"] = miConfig.OrgName
  3613. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3614. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3615. data["fixmedins_code"] = miConfig.Code
  3616. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3617. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3618. data["secret_key"] = miConfig.SecretKey
  3619. data["sick_code"] = sickConfig.CountryCode
  3620. data["sick_name"] = sickConfig.ClassName
  3621. data["dept"] = strconv.FormatInt(department.ID, 10)
  3622. data["config"] = config
  3623. data["begin_time"] = begin_time
  3624. bytesData, _ := json.Marshal(data)
  3625. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3626. resp, _ := client.Do(req)
  3627. defer resp.Body.Close()
  3628. body, ioErr := ioutil.ReadAll(resp.Body)
  3629. if ioErr != nil {
  3630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3632. return
  3633. }
  3634. var respJSON map[string]interface{}
  3635. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3638. return
  3639. }
  3640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3641. userJSONBytes, _ := json.Marshal(respJSON)
  3642. fmt.Println("log")
  3643. fmt.Println(string(userJSONBytes))
  3644. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3645. utils.ErrorLog("解析失败:%v", err)
  3646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3647. return
  3648. }
  3649. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3650. //江苏地区国家医保医疗类别
  3651. //职工透析:医疗类别选特殊情况门诊9933
  3652. //居民血透门慢: 医疗类别选门诊慢病1402
  3653. //var med_type string
  3654. //if his.Insutype == "310" {
  3655. // if reg_type == 14 {
  3656. // med_type = "9933"
  3657. // } else if reg_type == 11 {
  3658. // med_type = "11"
  3659. //
  3660. // }
  3661. //} else if his.Insutype == "390" {
  3662. // if reg_type == 14 {
  3663. // med_type = "1402"
  3664. // } else if reg_type == 11 {
  3665. // med_type = "11"
  3666. // }
  3667. //}
  3668. data := make(map[string]interface{})
  3669. client := &http.Client{}
  3670. data["psn_no"] = his.PsnNo
  3671. data["mdtrt_id"] = his.Number
  3672. data["doctor"] = roles.UserName
  3673. data["department"] = department.Name
  3674. data["org_name"] = miConfig.OrgName
  3675. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3676. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3677. data["fixmedins_code"] = miConfig.Code
  3678. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3679. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3680. data["secret_key"] = miConfig.SecretKey
  3681. data["sick_code"] = sickConfig.CountryCode
  3682. data["sick_name"] = sickConfig.ClassName
  3683. data["url"] = miConfig.Url
  3684. data["ak"] = miConfig.AccessKey
  3685. data["begin_time"] = begin_time
  3686. data["cainfo"] = miConfig.Cainfo
  3687. data["dept"] = strconv.FormatInt(department.ID, 10)
  3688. data["config"] = config
  3689. bytesData, _ := json.Marshal(data)
  3690. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3691. resp, _ := client.Do(req)
  3692. defer resp.Body.Close()
  3693. body, ioErr := ioutil.ReadAll(resp.Body)
  3694. if ioErr != nil {
  3695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3697. return
  3698. }
  3699. var respJSON map[string]interface{}
  3700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3703. return
  3704. }
  3705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3706. userJSONBytes, _ := json.Marshal(respJSON)
  3707. fmt.Println("log")
  3708. fmt.Println(string(userJSONBytes))
  3709. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3710. utils.ErrorLog("解析失败:%v", err)
  3711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3712. return
  3713. }
  3714. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3715. res2.Output = ressix10265.Output
  3716. res2.ErrMsg = ressix10265.ErrMsg
  3717. res2.Cainfo = ressix10265.Cainfo
  3718. res2.WarnMsg = ressix10265.WarnMsg
  3719. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3720. res2.Infcode = infocode
  3721. } else {
  3722. if miConfig.MdtrtareaAdmvs == "440781" { //
  3723. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3724. } else {
  3725. if miConfig.Code == "H15049901371" {
  3726. //赤峰地区国家医保医疗类别
  3727. //职工透析:医疗类别选特殊情况门诊990502
  3728. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3729. var med_type string
  3730. if his.Insutype == "390" {
  3731. if reg_type == 14 {
  3732. med_type = "9933"
  3733. } else if reg_type == 11 {
  3734. med_type = "11"
  3735. }
  3736. } else if his.Insutype == "310" {
  3737. if reg_type == 14 {
  3738. med_type = "990502"
  3739. } else if reg_type == 11 {
  3740. med_type = "11"
  3741. }
  3742. }
  3743. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3744. } else {
  3745. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3746. }
  3747. }
  3748. saveLog(result, requestLog, "2203", "上传就诊信息")
  3749. var respJSON2 map[string]interface{}
  3750. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3753. return
  3754. }
  3755. userJSONBytes2, _ := json.Marshal(respJSON2)
  3756. if miConfig.Code == "H15049901371" {
  3757. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3758. utils.ErrorLog("解析失败:%v", err)
  3759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3760. return
  3761. }
  3762. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3763. res2.Output = ressix10265.Output
  3764. res2.ErrMsg = ressix10265.ErrMsg
  3765. res2.Cainfo = ressix10265.Cainfo
  3766. res2.WarnMsg = ressix10265.WarnMsg
  3767. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3768. res2.Infcode = infocode
  3769. } else {
  3770. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3771. utils.ErrorLog("解析失败:%v", err)
  3772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3773. return
  3774. }
  3775. }
  3776. }
  3777. if res2.Infcode != 0 {
  3778. adminUser := c.GetAdminUserInfo()
  3779. errlog := &models.HisOrderError{
  3780. UserOrgId: adminUser.CurrentOrgId,
  3781. Ctime: time.Now().Unix(),
  3782. Mtime: time.Now().Unix(),
  3783. ErrMsg: res2.ErrMsg,
  3784. Status: 1,
  3785. PatientId: id,
  3786. RecordTime: recordDateTime,
  3787. Stage: 3,
  3788. }
  3789. service.CreateErrMsgLog(errlog)
  3790. c.ServeSuccessJSON(map[string]interface{}{
  3791. "failed_code": -10,
  3792. "msg": res2.ErrMsg,
  3793. })
  3794. return
  3795. } else {
  3796. his.Diagnosis = diagnosis_id
  3797. his.SickType = sickConfig.ID
  3798. var p_type int64
  3799. if reg_type == 1111 || reg_type == 1112 {
  3800. p_type = 11
  3801. }
  3802. his.PType = fmt.Sprintf("%d", p_type)
  3803. service.UpdateHisPatientThree(&his)
  3804. data := make(map[string]interface{})
  3805. if settle_accounts_type == 1 { //日结
  3806. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3807. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3808. } else {
  3809. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3810. }
  3811. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3812. data["pre"] = prescriptions
  3813. } else { //月结
  3814. start_time_str := c.GetString("start_time")
  3815. end_time_str := c.GetString("end_time")
  3816. timeLayout := "2006-01-02"
  3817. loc, _ := time.LoadLocation("Local")
  3818. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3819. if err != nil {
  3820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3821. return
  3822. }
  3823. recordStartTime := theStartTime.Unix()
  3824. start_time = recordStartTime
  3825. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3826. if err != nil {
  3827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3828. return
  3829. }
  3830. recordEndTime := theEndTime.Unix()
  3831. end_time = recordEndTime
  3832. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3833. data["pre"] = prescriptions
  3834. }
  3835. timestamp := time.Now().Unix()
  3836. tempTime := time.Unix(timestamp, 0)
  3837. timeFormat := tempTime.Format("20060102150405")
  3838. chrgBchno := rand.Intn(100000) + 10000
  3839. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  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. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3851. // data["dept_code"] = "15"
  3852. //} else {
  3853. data["dept_code"] = department.Number
  3854. //}
  3855. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3856. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3857. data["secret_key"] = miConfig.SecretKey
  3858. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3859. data["url"] = miConfig.Url
  3860. data["ak"] = miConfig.AccessKey
  3861. data["new_doctor_name"] = patientPrescription.Doctor
  3862. data["diag_code"] = sickConfig.CountryCode
  3863. data["cainfo"] = miConfig.Cainfo
  3864. var ids []int64
  3865. for _, item := range prescriptions {
  3866. ids = append(ids, item.ID)
  3867. }
  3868. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3869. if config.IsOpen == 1 { //对接了医保,走医保流程
  3870. var res ResultFour
  3871. var resFour10265 ResultFour10265
  3872. if miConfig.MdtrtareaAdmvs == "421300" {
  3873. bytesData, _ := json.Marshal(data)
  3874. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3875. resp, _ := client.Do(req)
  3876. defer resp.Body.Close()
  3877. body, ioErr := ioutil.ReadAll(resp.Body)
  3878. if ioErr != nil {
  3879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3881. return
  3882. }
  3883. var respJSON map[string]interface{}
  3884. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3887. return
  3888. }
  3889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3890. userJSONBytes, _ := json.Marshal(respJSON)
  3891. fmt.Println("log")
  3892. fmt.Println(string(userJSONBytes))
  3893. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3894. utils.ErrorLog("解析失败:%v", err)
  3895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3896. return
  3897. }
  3898. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3899. bytesData, _ := json.Marshal(data)
  3900. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3901. resp, _ := client.Do(req)
  3902. defer resp.Body.Close()
  3903. body, ioErr := ioutil.ReadAll(resp.Body)
  3904. if ioErr != nil {
  3905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3907. return
  3908. }
  3909. var respJSON map[string]interface{}
  3910. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3913. return
  3914. }
  3915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3916. userJSONBytes, _ := json.Marshal(respJSON)
  3917. fmt.Println("log")
  3918. fmt.Println(string(userJSONBytes))
  3919. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3920. utils.ErrorLog("解析失败:%v", err)
  3921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3922. return
  3923. }
  3924. res.InfRefmsgid = resFour10265.InfRefmsgid
  3925. res.Output = resFour10265.Output
  3926. res.ErrMsg = resFour10265.ErrMsg
  3927. res.Cainfo = resFour10265.Cainfo
  3928. res.WarnMsg = resFour10265.WarnMsg
  3929. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3930. res.Infcode = infocode
  3931. } else {
  3932. if miConfig.Code == "H15049901371" {
  3933. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3934. var dat map[string]interface{}
  3935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3936. fmt.Println(dat)
  3937. } else {
  3938. fmt.Println(err)
  3939. }
  3940. saveLog(result, request_log, "2204", "上传费用明细")
  3941. userJSONBytes, _ := json.Marshal(dat)
  3942. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3943. utils.ErrorLog("解析失败:%v", err)
  3944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3945. return
  3946. }
  3947. res.InfRefmsgid = resFour10265.InfRefmsgid
  3948. res.Output = resFour10265.Output
  3949. res.ErrMsg = resFour10265.ErrMsg
  3950. res.Cainfo = resFour10265.Cainfo
  3951. res.WarnMsg = resFour10265.WarnMsg
  3952. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3953. res.Infcode = infocode
  3954. } else {
  3955. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3956. var dat map[string]interface{}
  3957. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3958. fmt.Println(dat)
  3959. } else {
  3960. fmt.Println(err)
  3961. }
  3962. saveLog(result, request_log, "2204", "上传费用明细")
  3963. userJSONBytes, _ := json.Marshal(dat)
  3964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3965. utils.ErrorLog("解析失败:%v", err)
  3966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3967. return
  3968. }
  3969. }
  3970. }
  3971. if res.Infcode == 0 {
  3972. order := &models.HisOrder{
  3973. UserOrgId: adminUser.CurrentOrgId,
  3974. HisPatientId: his.ID,
  3975. PatientId: his.PatientId,
  3976. SettleAccountsDate: recordDateTime,
  3977. MdtrtId: his.Number,
  3978. PsnNo: his.PsnNo,
  3979. MedType: strconv.FormatInt(reg_type, 10),
  3980. Ctime: time.Now().Unix(),
  3981. Mtime: time.Now().Unix(),
  3982. Status: 1,
  3983. Number: chrg_bchno,
  3984. Infcode: res.Infcode,
  3985. WarnMsg: res.WarnMsg,
  3986. Cainfo: res.Cainfo,
  3987. ErrMsg: res.ErrMsg,
  3988. RespondTime: res.RefmsgTime,
  3989. InfRefmsgid: res.InfRefmsgid,
  3990. OrderStatus: 1,
  3991. PayWay: pay_way,
  3992. PayPrice: pay_price,
  3993. PayCardNo: pay_card_no,
  3994. DiscountPrice: discount_price,
  3995. PreferentialPrice: preferential_price,
  3996. RealityPrice: reality_price,
  3997. FoundPrice: found_price,
  3998. MedicalInsurancePrice: medical_insurance_price,
  3999. PrivatePrice: private_price,
  4000. IsMedicineInsurance: 1,
  4001. SettleType: settle_accounts_type,
  4002. SettleStartTime: start_time,
  4003. SettleEndTime: end_time,
  4004. Creator: roles.AdminUserId,
  4005. Modify: roles.AdminUserId,
  4006. FaPiaoNumber: fapiao_number,
  4007. FaPiaoCode: fapiao_code,
  4008. PType: 2,
  4009. Diagnosis: diagnosis_id,
  4010. }
  4011. err = service.CreateOrder(order)
  4012. if err != nil {
  4013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4014. return
  4015. }
  4016. for _, item := range res.Output.Result {
  4017. temp := strings.Split(item.FeedetlSn, "-")
  4018. var advice_id int64 = 0
  4019. var project_id int64 = 0
  4020. var types int64 = 0
  4021. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4022. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4023. if temp[1] == "1" {
  4024. advice_id = id
  4025. project_id = 0
  4026. } else if temp[1] == "2" {
  4027. advice_id = 0
  4028. project_id = id
  4029. }
  4030. info := &models.HisOrderInfo{
  4031. OrderNumber: order.Number,
  4032. FeedetlSn: item.FeedetlSn,
  4033. UploadDate: time.Now().Unix(),
  4034. AdviceId: advice_id,
  4035. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4036. Cnt: item.Cnt,
  4037. Pric: float64(item.Pric),
  4038. PatientId: his.PatientId,
  4039. PricUplmtAmt: item.PricUplmtAmt,
  4040. SelfpayProp: item.SelfpayProp,
  4041. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4042. OverlmtAmt: item.OverlmtAmt,
  4043. PreselfpayAmt: item.PreselfpayAmt,
  4044. BasMednFlag: item.BasMednFlag,
  4045. MedChrgitmType: item.MedChrgitmType,
  4046. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4047. Status: 1,
  4048. Memo: item.Memo,
  4049. Mtime: time.Now().Unix(),
  4050. InscpScpAmt: item.InscpScpAmt,
  4051. DrtReimFlag: item.DrtReimFlag,
  4052. Ctime: time.Now().Unix(),
  4053. ListSpItemFlag: item.ListSpItemFlag,
  4054. ChldMedcFlag: item.ChldMedcFlag,
  4055. LmtUsedFlag: item.LmtUsedFlag,
  4056. ChrgitmLv: item.ChrgitmLv,
  4057. UserOrgId: adminUser.CurrentOrgId,
  4058. HisPatientId: his.ID,
  4059. OrderId: order.ID,
  4060. ProjectId: project_id,
  4061. Type: types,
  4062. }
  4063. service.CreateOrderInfo(info)
  4064. }
  4065. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4066. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4067. var total float64
  4068. for _, item := range prescriptions {
  4069. if item.Type == 1 { //药品
  4070. for _, subItem := range item.HisDoctorAdviceInfo {
  4071. total = total + (subItem.Price * subItem.PrescribingNumber)
  4072. }
  4073. }
  4074. if item.Type == 2 { //项目
  4075. for _, subItem := range item.HisPrescriptionProject {
  4076. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4077. total = total + (subItem.Price * cnt)
  4078. }
  4079. }
  4080. }
  4081. for _, item := range prescriptions {
  4082. for _, subItem := range item.HisAdditionalCharge {
  4083. total = total + (subItem.Price * float64(subItem.Count))
  4084. }
  4085. }
  4086. var allTotal string
  4087. if adminUser.CurrentOrgId == 9919 {
  4088. allTotal = fmt.Sprintf("%.4f", total)
  4089. } else {
  4090. allTotal = fmt.Sprintf("%.4f", total)
  4091. }
  4092. if res.Infcode == 0 {
  4093. var rf []*ResultFive
  4094. json.Unmarshal([]byte(his.Iinfo), &rf)
  4095. chrg_bchno := chrg_bchno
  4096. cert_no := his.Certno
  4097. var insutypes []string
  4098. var insutype string
  4099. var is390 int = 0
  4100. var is310 int = 0
  4101. for _, item := range rf {
  4102. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4103. insutypes = append(insutypes, item.Insutype)
  4104. }
  4105. }
  4106. if len(insutypes) == 1 {
  4107. insutype = insutypes[0]
  4108. } else {
  4109. for _, i := range insutypes {
  4110. if i == "390" {
  4111. is390 = 1
  4112. }
  4113. if i == "310" {
  4114. is310 = 1
  4115. }
  4116. }
  4117. }
  4118. if is390 == 1 {
  4119. insutype = "390"
  4120. }
  4121. if is310 == 1 {
  4122. insutype = "310"
  4123. }
  4124. if len(insutypes) == 0 {
  4125. insutype = "310"
  4126. }
  4127. if len(insutypes) == 2 {
  4128. insutype = strconv.FormatInt(his.SocialType, 10)
  4129. }
  4130. insutype = strconv.FormatInt(his.SocialType, 10)
  4131. //insutype = "390"
  4132. if his.IdCardType == 1 {
  4133. // cert_no = his.MedicalInsuranceNumber
  4134. cert_no = his.Certno
  4135. } else {
  4136. cert_no = his.Certno
  4137. }
  4138. var res ResultSeven
  4139. var resSeven10265 ResultSeven10265
  4140. var src_resquest string
  4141. var result2 string
  4142. var acct_used_flag string
  4143. fmt.Println("pay_way")
  4144. fmt.Println(pay_way)
  4145. fmt.Println("pay_way")
  4146. if pay_way == 4 {
  4147. acct_used_flag = "1"
  4148. } else {
  4149. acct_used_flag = "0"
  4150. }
  4151. if miConfig.MdtrtareaAdmvs == "421300" {
  4152. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4153. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4154. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4155. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4156. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4157. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4158. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4159. resp, requestErr := http.Get(api)
  4160. if requestErr != nil {
  4161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4162. return
  4163. }
  4164. body, ioErr := ioutil.ReadAll(resp.Body)
  4165. if ioErr != nil {
  4166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4168. return
  4169. }
  4170. var respJSON map[string]interface{}
  4171. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4174. return
  4175. }
  4176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4177. result, _ := json.Marshal(respJSON)
  4178. if miConfig.Code == "H15049901371" {
  4179. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4180. utils.ErrorLog("解析失败:%v", err)
  4181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4182. return
  4183. }
  4184. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4185. res.Output = resSeven10265.Output
  4186. res.ErrMsg = resSeven10265.ErrMsg
  4187. res.Cainfo = resSeven10265.Cainfo
  4188. res.WarnMsg = resSeven10265.WarnMsg
  4189. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4190. res.Infcode = infocode
  4191. } else {
  4192. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4193. utils.ErrorLog("解析失败:%v", err)
  4194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4195. return
  4196. }
  4197. }
  4198. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4199. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4200. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4201. //psn_info, _ := service.GetPsnByPatientId(id)
  4202. bas := strings.Split(psn_info.CardInfo, "|")
  4203. if his.IdCardType == 1 {
  4204. cert_no = bas[2]
  4205. } else {
  4206. cert_no = bas[1]
  4207. }
  4208. //江苏地区国家医保医疗类别
  4209. //职工透析:医疗类别选特殊情况门诊9933
  4210. //居民血透门慢: 医疗类别选门诊慢病1402
  4211. //var med_type string
  4212. //if his.Insutype == "310" {
  4213. // if reg_type == 14 {
  4214. // med_type = "9933"
  4215. // } else if reg_type == 11 {
  4216. // med_type = "11"
  4217. //
  4218. // }
  4219. //} else if his.Insutype == "390" {
  4220. // if reg_type == 14 {
  4221. // med_type = "1402"
  4222. // } else if reg_type == 11 {
  4223. // med_type = "11"
  4224. // }
  4225. //}
  4226. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4227. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4228. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4229. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4230. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4231. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4232. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4233. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4234. resp, requestErr := http.Get(api)
  4235. if requestErr != nil {
  4236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4237. return
  4238. }
  4239. body, ioErr := ioutil.ReadAll(resp.Body)
  4240. if ioErr != nil {
  4241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4243. return
  4244. }
  4245. var respJSON map[string]interface{}
  4246. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4249. return
  4250. }
  4251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4252. result, _ := json.Marshal(respJSON)
  4253. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4254. utils.ErrorLog("解析失败:%v", err)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. return
  4257. }
  4258. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4259. res.Output = resSeven10265.Output
  4260. res.ErrMsg = resSeven10265.ErrMsg
  4261. res.Cainfo = resSeven10265.Cainfo
  4262. res.WarnMsg = resSeven10265.WarnMsg
  4263. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4264. res.Infcode = infocode
  4265. } else {
  4266. if miConfig.Code == "H15049901371" {
  4267. //赤峰地区国家医保医疗类别
  4268. //职工透析:医疗类别选特殊情况门诊990502
  4269. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4270. var med_type string
  4271. if his.Insutype == "390" {
  4272. if reg_type == 14 {
  4273. med_type = "9933"
  4274. } else if reg_type == 11 {
  4275. med_type = "11"
  4276. }
  4277. } else if his.Insutype == "310" {
  4278. if reg_type == 14 {
  4279. med_type = "990502"
  4280. } else if reg_type == 11 {
  4281. med_type = "11"
  4282. }
  4283. }
  4284. 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)
  4285. } else {
  4286. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4287. }
  4288. //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)
  4289. var dat map[string]interface{}
  4290. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4291. fmt.Println(dat)
  4292. } else {
  4293. fmt.Println(err)
  4294. }
  4295. saveLog(result2, src_resquest, "2207", "结算")
  4296. userJSONBytes, _ := json.Marshal(dat)
  4297. if miConfig.Code == "H15049901371" {
  4298. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4299. utils.ErrorLog("解析失败:%v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4304. res.Output = resSeven10265.Output
  4305. res.ErrMsg = resSeven10265.ErrMsg
  4306. res.Cainfo = resSeven10265.Cainfo
  4307. res.WarnMsg = resSeven10265.WarnMsg
  4308. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4309. res.Infcode = infocode
  4310. } else {
  4311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4312. utils.ErrorLog("解析失败:%v", err)
  4313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4314. return
  4315. }
  4316. }
  4317. }
  4318. if res.Infcode != 0 {
  4319. errlog := &models.HisOrderError{
  4320. UserOrgId: adminUser.CurrentOrgId,
  4321. Ctime: time.Now().Unix(),
  4322. Mtime: time.Now().Unix(),
  4323. Number: chrg_bchno,
  4324. ErrMsg: res.ErrMsg,
  4325. Status: 1,
  4326. PatientId: id,
  4327. RecordTime: recordDateTime,
  4328. Stage: 6,
  4329. }
  4330. service.CreateErrMsgLog(errlog)
  4331. c.ServeSuccessJSON(map[string]interface{}{
  4332. "failed_code": -10,
  4333. "msg": res.ErrMsg,
  4334. })
  4335. return
  4336. } else {
  4337. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4338. order.OrderStatus = 2
  4339. order.Status = 1
  4340. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4341. order.SetlId = res.Output.Setlinfo.SetlID
  4342. order.PsnNo = res.Output.Setlinfo.PsnNo
  4343. order.PsnName = res.Output.Setlinfo.PsnName
  4344. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4345. order.Certno = res.Output.Setlinfo.Certno
  4346. order.Gend = res.Output.Setlinfo.Gend
  4347. order.Naty = res.Output.Setlinfo.Naty
  4348. order.Age = res.Output.Setlinfo.Age
  4349. order.Insutype = res.Output.Setlinfo.Insutype
  4350. order.PsnType = res.Output.Setlinfo.PsnType
  4351. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4352. order.SetlTime = res.Output.Setlinfo.SetlTime
  4353. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4354. if res.Output.Setlinfo.MedType == "140101" {
  4355. order.MedType = "14"
  4356. } else {
  4357. order.MedType = res.Output.Setlinfo.MedType
  4358. }
  4359. if reg_type == 1112 {
  4360. order.MedType = "1112"
  4361. }
  4362. if reg_type == 1111 {
  4363. order.MedType = "1111"
  4364. }
  4365. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4366. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4367. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4368. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4369. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4370. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4371. order.HifpPay = res.Output.Setlinfo.HifpPay
  4372. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4373. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4374. order.HifesPay = res.Output.Setlinfo.HifesPay
  4375. order.HifobPay = res.Output.Setlinfo.HifobPay
  4376. order.MafPay = res.Output.Setlinfo.MafPay
  4377. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4378. order.OthPay = res.Output.Setlinfo.OthPay
  4379. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4380. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4381. order.AcctPay = res.Output.Setlinfo.AcctPay
  4382. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4383. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4384. order.Balc = res.Output.Setlinfo.Balc
  4385. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4386. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4387. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4388. order.ClrType = res.Output.Setlinfo.ClrType
  4389. order.ClrWay = res.Output.Setlinfo.ClrWay
  4390. order.Creator = order.Creator
  4391. order.Modify = roles.AdminUserId
  4392. order.RequestLog = src_resquest
  4393. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4394. detailStr := string(setlDetail)
  4395. order.SetlDetail = detailStr
  4396. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4397. err = service.UpDateOrder(order)
  4398. if err == nil {
  4399. c.ServeSuccessJSON(map[string]interface{}{
  4400. "msg": "结算成功",
  4401. })
  4402. } else {
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4404. return
  4405. }
  4406. }
  4407. } else {
  4408. adminUser := c.GetAdminUserInfo()
  4409. errlog := &models.HisOrderError{
  4410. UserOrgId: adminUser.CurrentOrgId,
  4411. Ctime: time.Now().Unix(),
  4412. Mtime: time.Now().Unix(),
  4413. ErrMsg: res.ErrMsg,
  4414. Status: 1,
  4415. PatientId: id,
  4416. RecordTime: recordDateTime,
  4417. Stage: 4,
  4418. }
  4419. service.CreateErrMsgLog(errlog)
  4420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4421. return
  4422. }
  4423. } else {
  4424. adminUser := c.GetAdminUserInfo()
  4425. errlog := &models.HisOrderError{
  4426. UserOrgId: adminUser.CurrentOrgId,
  4427. Ctime: time.Now().Unix(),
  4428. Mtime: time.Now().Unix(),
  4429. ErrMsg: res.ErrMsg,
  4430. Status: 1,
  4431. PatientId: id,
  4432. RecordTime: recordDateTime,
  4433. Stage: 4,
  4434. }
  4435. service.CreateErrMsgLog(errlog)
  4436. c.ServeSuccessJSON(map[string]interface{}{
  4437. "failed_code": -10,
  4438. "msg": res.ErrMsg,
  4439. })
  4440. return
  4441. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4442. //return
  4443. }
  4444. }
  4445. }
  4446. } else if tempOrder.ID > 0 {
  4447. if tempOrder.IsPre == 1 {
  4448. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4449. var rf []*ResultFive
  4450. json.Unmarshal([]byte(his.Iinfo), &rf)
  4451. chrg_bchno := tempOrder.Number
  4452. cert_no := his.Certno
  4453. var insutypes []string
  4454. var insutype string
  4455. var is390 int = 0
  4456. var is310 int = 0
  4457. for _, item := range rf {
  4458. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4459. insutypes = append(insutypes, item.Insutype)
  4460. }
  4461. }
  4462. if len(insutypes) == 1 {
  4463. insutype = insutypes[0]
  4464. } else {
  4465. for _, i := range insutypes {
  4466. if i == "390" {
  4467. is390 = 1
  4468. }
  4469. if i == "310" {
  4470. is310 = 1
  4471. }
  4472. }
  4473. }
  4474. if is390 == 1 {
  4475. insutype = "390"
  4476. }
  4477. if is310 == 1 {
  4478. insutype = "310"
  4479. }
  4480. if len(insutypes) == 0 {
  4481. insutype = "310"
  4482. }
  4483. if len(insutypes) == 2 {
  4484. insutype = strconv.FormatInt(his.SocialType, 64)
  4485. }
  4486. //insutype = "390"
  4487. if his.IdCardType == 1 {
  4488. // cert_no = his.MedicalInsuranceNumber
  4489. cert_no = his.Certno
  4490. } else {
  4491. cert_no = his.Certno
  4492. }
  4493. var res ResultSeven
  4494. var resSeven10265 ResultSeven10265
  4495. var src_resquest string
  4496. var result2 string
  4497. var acct_used_flag string
  4498. fmt.Println("pay_way")
  4499. fmt.Println(pay_way)
  4500. fmt.Println("pay_way")
  4501. if pay_way == 4 {
  4502. acct_used_flag = "1"
  4503. } else {
  4504. acct_used_flag = "0"
  4505. }
  4506. if miConfig.MdtrtareaAdmvs == "421300" {
  4507. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4508. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4509. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4510. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4511. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4512. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4513. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4514. resp, requestErr := http.Get(api)
  4515. if requestErr != nil {
  4516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4517. return
  4518. }
  4519. body, ioErr := ioutil.ReadAll(resp.Body)
  4520. if ioErr != nil {
  4521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4523. return
  4524. }
  4525. var respJSON map[string]interface{}
  4526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4532. result, _ := json.Marshal(respJSON)
  4533. fmt.Println("log")
  4534. fmt.Println(string(result))
  4535. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4536. utils.ErrorLog("解析失败:%v", err)
  4537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4538. return
  4539. }
  4540. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4541. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4542. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4543. //psn_info, _ := service.GetPsnByPatientId(id)
  4544. bas := strings.Split(psn_info.CardInfo, "|")
  4545. if his.IdCardType == 1 {
  4546. cert_no = bas[2]
  4547. } else {
  4548. cert_no = bas[1]
  4549. }
  4550. //江苏地区国家医保医疗类别
  4551. //职工透析:医疗类别选特殊情况门诊9933
  4552. //居民血透门慢: 医疗类别选门诊慢病1402
  4553. //var med_type string
  4554. //if his.Insutype == "310" {
  4555. // if reg_type == 14 {
  4556. // med_type = "9933"
  4557. // } else if reg_type == 11 {
  4558. // med_type = "11"
  4559. //
  4560. // }
  4561. //} else if his.Insutype == "390" {
  4562. // if reg_type == 14 {
  4563. // med_type = "1402"
  4564. // } else if reg_type == 11 {
  4565. // med_type = "11"
  4566. // }
  4567. //}
  4568. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4569. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4570. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4572. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4573. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4574. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4575. resp, requestErr := http.Get(api)
  4576. if requestErr != nil {
  4577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4578. return
  4579. }
  4580. body, ioErr := ioutil.ReadAll(resp.Body)
  4581. if ioErr != nil {
  4582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4584. return
  4585. }
  4586. var respJSON map[string]interface{}
  4587. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4590. return
  4591. }
  4592. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4593. result, _ := json.Marshal(respJSON)
  4594. fmt.Println("log")
  4595. fmt.Println(string(result))
  4596. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4597. utils.ErrorLog("解析失败:%v", err)
  4598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4599. return
  4600. }
  4601. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4602. res.Output = resSeven10265.Output
  4603. res.ErrMsg = resSeven10265.ErrMsg
  4604. res.Cainfo = resSeven10265.Cainfo
  4605. res.WarnMsg = resSeven10265.WarnMsg
  4606. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4607. res.Infcode = infocode
  4608. } else {
  4609. var src_resquest string
  4610. if miConfig.Code == "H15049901371" {
  4611. //赤峰地区国家医保医疗类别
  4612. //职工透析:医疗类别选特殊情况门诊990502
  4613. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4614. var med_type string
  4615. if his.Insutype == "390" {
  4616. if reg_type == 14 {
  4617. med_type = "9933"
  4618. } else if reg_type == 11 {
  4619. med_type = "11"
  4620. }
  4621. } else if his.Insutype == "310" {
  4622. if reg_type == 14 {
  4623. med_type = "990502"
  4624. } else if reg_type == 11 {
  4625. med_type = "11"
  4626. }
  4627. }
  4628. 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)
  4629. } else {
  4630. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4631. }
  4632. var dat map[string]interface{}
  4633. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4634. fmt.Println(dat)
  4635. } else {
  4636. fmt.Println(err)
  4637. }
  4638. saveLog(result2, src_resquest, "2207", "结算")
  4639. userJSONBytes, _ := json.Marshal(dat)
  4640. if miConfig.Code == "H15049901371" {
  4641. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4647. res.Output = resSeven10265.Output
  4648. res.ErrMsg = resSeven10265.ErrMsg
  4649. res.Cainfo = resSeven10265.Cainfo
  4650. res.WarnMsg = resSeven10265.WarnMsg
  4651. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4652. res.Infcode = infocode
  4653. } else {
  4654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4655. utils.ErrorLog("解析失败:%v", err)
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4657. return
  4658. }
  4659. }
  4660. }
  4661. if res.Infcode != 0 {
  4662. errlog := &models.HisOrderError{
  4663. UserOrgId: adminUser.CurrentOrgId,
  4664. Ctime: time.Now().Unix(),
  4665. Mtime: time.Now().Unix(),
  4666. Number: chrg_bchno,
  4667. ErrMsg: res.ErrMsg,
  4668. Status: 1,
  4669. PatientId: id,
  4670. RecordTime: recordDateTime,
  4671. Stage: 6,
  4672. }
  4673. service.CreateErrMsgLog(errlog)
  4674. c.ServeSuccessJSON(map[string]interface{}{
  4675. "failed_code": -10,
  4676. "msg": res.ErrMsg,
  4677. })
  4678. return
  4679. } else {
  4680. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4681. order.OrderStatus = 2
  4682. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4683. order.SetlId = res.Output.Setlinfo.SetlID
  4684. order.PsnNo = res.Output.Setlinfo.PsnNo
  4685. order.PsnName = res.Output.Setlinfo.PsnName
  4686. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4687. order.Certno = res.Output.Setlinfo.Certno
  4688. order.Gend = res.Output.Setlinfo.Gend
  4689. order.Naty = res.Output.Setlinfo.Naty
  4690. order.Age = res.Output.Setlinfo.Age
  4691. order.Insutype = res.Output.Setlinfo.Insutype
  4692. order.PsnType = res.Output.Setlinfo.PsnType
  4693. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4694. order.SetlTime = res.Output.Setlinfo.SetlTime
  4695. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4696. //order.MedType = res.Output.Setlinfo.MedType
  4697. if reg_type == 1112 {
  4698. order.MedType = "1112"
  4699. }
  4700. if reg_type == 1111 {
  4701. order.MedType = "1111"
  4702. }
  4703. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4704. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4705. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4706. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4707. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4708. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4709. order.HifpPay = res.Output.Setlinfo.HifpPay
  4710. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4711. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4712. order.HifesPay = res.Output.Setlinfo.HifesPay
  4713. order.HifobPay = res.Output.Setlinfo.HifobPay
  4714. order.MafPay = res.Output.Setlinfo.MafPay
  4715. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4716. order.OthPay = res.Output.Setlinfo.OthPay
  4717. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4718. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4719. order.AcctPay = res.Output.Setlinfo.AcctPay
  4720. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4721. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4722. order.Balc = res.Output.Setlinfo.Balc
  4723. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4724. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4725. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4726. order.ClrWay = res.Output.Setlinfo.ClrWay
  4727. order.Creator = order.Creator
  4728. order.Modify = roles.AdminUserId
  4729. order.RequestLog = src_resquest
  4730. order.Diagnosis = diagnosis_id
  4731. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4732. detailStr := string(setlDetail)
  4733. order.SetlDetail = detailStr
  4734. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4735. err = service.UpDateOrder(order)
  4736. if err == nil {
  4737. c.ServeSuccessJSON(map[string]interface{}{
  4738. "msg": "结算成功",
  4739. })
  4740. } else {
  4741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4742. return
  4743. }
  4744. }
  4745. }
  4746. }
  4747. }
  4748. //func (c *HisApiController) GetPreUploadInfo() {
  4749. // id, _ := c.GetInt64("id")
  4750. // record_time := c.GetString("record_time")
  4751. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4752. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4753. //
  4754. // timeLayout := "2006-01-02"
  4755. // loc, _ := time.LoadLocation("Local")
  4756. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4757. // if err != nil {
  4758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4759. // return
  4760. // }
  4761. // recordDateTime := theTime.Unix()
  4762. // adminUser := c.GetAdminUserInfo()
  4763. //
  4764. // var prescriptions []*models.HisPrescription
  4765. //
  4766. // var start_time int64
  4767. // var end_time int64
  4768. //
  4769. // data := make(map[string]interface{})
  4770. // if settle_accounts_type == 1 { //日结
  4771. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4772. // data["pre"] = prescriptions
  4773. //
  4774. // } else { //月结
  4775. // start_time_str := c.GetString("start_time")
  4776. // end_time_str := c.GetString("end_time")
  4777. // timeLayout := "2006-01-02"
  4778. // loc, _ := time.LoadLocation("Local")
  4779. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4780. // if err != nil {
  4781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4782. // return
  4783. // }
  4784. // recordStartTime := theStartTime.Unix()
  4785. // start_time = recordStartTime
  4786. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4787. // if err != nil {
  4788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4789. // return
  4790. // }
  4791. // recordEndTime := theEndTime.Unix()
  4792. // end_time = recordEndTime
  4793. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4794. // data["pre"] = prescriptions
  4795. //
  4796. // }
  4797. //
  4798. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4799. //
  4800. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4801. // timestamp := time.Now().Unix()
  4802. // tempTime := time.Unix(timestamp, 0)
  4803. // timeFormat := tempTime.Format("20060102150405")
  4804. // chrgBchno := rand.Intn(100000) + 10000
  4805. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4806. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4807. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4808. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4809. // strconv.FormatInt(his.PatientId, 10)
  4810. // client := &http.Client{}
  4811. // data["psn_no"] = his.PsnNo
  4812. // data["mdtrt_id"] = his.Number
  4813. // data["chrg_bchno"] = chrg_bchno
  4814. // data["org_name"] = miConfig.OrgName
  4815. // data["doctor"] = roles.UserName
  4816. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4817. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4818. // data["fixmedins_code"] = miConfig.Code
  4819. // data["dept_code"] = department.Number
  4820. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4821. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4822. // data["secret_key"] = miConfig.SecretKey
  4823. // var ids []int64
  4824. //
  4825. // for _, item := range prescriptions {
  4826. // ids = append(ids, item.ID)
  4827. // }
  4828. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4829. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4830. // bytesData, _ := json.Marshal(data)
  4831. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4832. // resp, _ := client.Do(req)
  4833. // defer resp.Body.Close()
  4834. // body, ioErr := ioutil.ReadAll(resp.Body)
  4835. // if ioErr != nil {
  4836. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4838. // return
  4839. // }
  4840. // var respJSON map[string]interface{}
  4841. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4842. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4843. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4844. // return
  4845. // }
  4846. //
  4847. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4848. // userJSONBytes, _ := json.Marshal(respJSON)
  4849. // var res ResultFour
  4850. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4851. // utils.ErrorLog("解析失败:%v", err)
  4852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4853. // return
  4854. // }
  4855. //
  4856. // if res.Infcode == 0 {
  4857. // order := &models.HisOrder{
  4858. // UserOrgId: adminUser.CurrentOrgId,
  4859. // HisPatientId: his.ID,
  4860. // PatientId: his.PatientId,
  4861. // SettleAccountsDate: recordDateTime,
  4862. // Ctime: time.Now().Unix(),
  4863. // Mtime: time.Now().Unix(),
  4864. // Status: 1,
  4865. // Number: chrg_bchno,
  4866. // Infcode: res.Infcode,
  4867. // WarnMsg: res.WarnMsg,
  4868. // Cainfo: res.Cainfo,
  4869. // ErrMsg: res.ErrMsg,
  4870. // RespondTime: res.RefmsgTime,
  4871. // InfRefmsgid: res.InfRefmsgid,
  4872. // OrderStatus: 1,
  4873. // IsMedicineInsurance: 1,
  4874. // SettleType: settle_accounts_type,
  4875. // SettleStartTime: start_time,
  4876. // SettleEndTime: end_time,
  4877. // Creator: roles.ID,
  4878. // Modify: roles.ID,
  4879. // PType: 2,
  4880. // }
  4881. // err = service.CreateOrder(order)
  4882. // if err != nil {
  4883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4884. // return
  4885. // }
  4886. //
  4887. // for _, item := range res.Output.Result {
  4888. // temp := strings.Split(item.FeedetlSn, "-")
  4889. // var advice_id int64 = 0
  4890. // var project_id int64 = 0
  4891. // var types int64 = 0
  4892. //
  4893. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4894. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4895. //
  4896. // if temp[1] == "1" {
  4897. // advice_id = id
  4898. // project_id = 0
  4899. // } else if temp[1] == "2" {
  4900. // advice_id = 0
  4901. // project_id = id
  4902. // }
  4903. //
  4904. // info := &models.HisOrderInfo{
  4905. // OrderNumber: order.Number,
  4906. // FeedetlSn: item.FeedetlSn,
  4907. // UploadDate: time.Now().Unix(),
  4908. // AdviceId: advice_id,
  4909. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4910. // Cnt: item.Cnt,
  4911. // Pric: float64(item.Pric),
  4912. // PatientId: his.PatientId,
  4913. // PricUplmtAmt: item.PricUplmtAmt,
  4914. // SelfpayProp: item.SelfpayProp,
  4915. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4916. // OverlmtAmt: item.OverlmtAmt,
  4917. // PreselfpayAmt: item.PreselfpayAmt,
  4918. // BasMednFlag: item.BasMednFlag,
  4919. // MedChrgitmType: item.MedChrgitmType,
  4920. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4921. // Status: 1,
  4922. // Memo: item.Memo,
  4923. // Mtime: time.Now().Unix(),
  4924. // InscpScpAmt: item.InscpScpAmt,
  4925. // DrtReimFlag: item.DrtReimFlag,
  4926. // Ctime: time.Now().Unix(),
  4927. // ListSpItemFlag: item.ListSpItemFlag,
  4928. // ChldMedcFlag: item.ChldMedcFlag,
  4929. // LmtUsedFlag: item.LmtUsedFlag,
  4930. // ChrgitmLv: item.ChrgitmLv,
  4931. // UserOrgId: adminUser.CurrentOrgId,
  4932. // HisPatientId: his.ID,
  4933. // OrderId: order.ID,
  4934. // ProjectId: project_id,
  4935. // Type: types,
  4936. // }
  4937. // service.CreateOrderInfo(info)
  4938. //
  4939. // }
  4940. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4941. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4942. //
  4943. // var total float64
  4944. // for _, item := range prescriptions {
  4945. // if item.Type == 1 { //药品
  4946. // for _, subItem := range item.HisDoctorAdviceInfo {
  4947. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4948. // }
  4949. // }
  4950. // if item.Type == 2 { //项目
  4951. // for _, subItem := range item.HisPrescriptionProject {
  4952. // total = total + (subItem.Price * float64(subItem.Count))
  4953. // }
  4954. // }
  4955. // }
  4956. //
  4957. // for _, item := range prescriptions {
  4958. // for _, subItem := range item.HisAdditionalCharge {
  4959. // total = total + (subItem.Price * float64(subItem.Count))
  4960. // }
  4961. // }
  4962. //
  4963. // allTotal := fmt.Sprintf("%.2f", total)
  4964. // if res.Infcode == 0 {
  4965. // var rf []*ResultFive
  4966. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4967. // psn_no := his.PsnNo
  4968. // mdtrt_id := his.Number
  4969. // chrg_bchno := chrg_bchno
  4970. // cert_no := his.Certno
  4971. // insutype := rf[0].Insutype
  4972. //
  4973. // if his.IdCardType == 1 {
  4974. // cert_no = his.MedicalInsuranceNumber
  4975. //
  4976. // } else {
  4977. //
  4978. // cert_no = his.Certno
  4979. //
  4980. // }
  4981. //
  4982. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4983. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4984. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4985. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4986. // resp, requestErr := http.Get(api)
  4987. // if requestErr != nil {
  4988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4989. // return
  4990. // }
  4991. // defer resp.Body.Close()
  4992. // body, ioErr := ioutil.ReadAll(resp.Body)
  4993. // if ioErr != nil {
  4994. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4996. // return
  4997. // }
  4998. // var respJSON map[string]interface{}
  4999. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5000. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5002. // return
  5003. // }
  5004. // fmt.Println(respJSON)
  5005. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5006. // userJSONBytes, _ := json.Marshal(respJSON)
  5007. // var res ResultSeven
  5008. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5009. // utils.ErrorLog("解析失败:%v", err)
  5010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5011. // return
  5012. // }
  5013. // if res.Infcode != 0 {
  5014. // errlog := &models.HisOrderError{
  5015. // UserOrgId: adminUser.CurrentOrgId,
  5016. // Ctime: time.Now().Unix(),
  5017. // Mtime: time.Now().Unix(),
  5018. // Number: chrg_bchno,
  5019. // ErrMsg: res.ErrMsg,
  5020. // Status: 1,
  5021. // PatientId: id,
  5022. // RecordTime: recordDateTime,
  5023. // Stage: 7,
  5024. // }
  5025. // service.CreateErrMsgLog(errlog)
  5026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5027. // return
  5028. // } else {
  5029. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5030. // order.OrderStatus = 1
  5031. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5032. // order.SetlId = res.Output.Setlinfo.SetlID
  5033. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5034. // order.PsnName = res.Output.Setlinfo.PsnName
  5035. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5036. // order.Certno = res.Output.Setlinfo.Certno
  5037. // order.Gend = res.Output.Setlinfo.Gend
  5038. // order.Naty = res.Output.Setlinfo.Naty
  5039. // order.Age = res.Output.Setlinfo.Age
  5040. // order.Insutype = res.Output.Setlinfo.Insutype
  5041. // order.PsnType = res.Output.Setlinfo.PsnType
  5042. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5043. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5044. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5045. // order.MedType = res.Output.Setlinfo.MedType
  5046. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5047. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5048. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5049. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5050. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5051. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5052. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5053. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5054. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5055. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5056. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5057. // order.MafPay = res.Output.Setlinfo.MafPay
  5058. // order.OthPay = res.Output.Setlinfo.OthPay
  5059. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5060. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5061. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5062. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5063. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5064. // order.Balc = res.Output.Setlinfo.Balc
  5065. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5066. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5067. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5068. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5069. // order.Creator = order.Creator
  5070. // order.Modify = roles.ID
  5071. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5072. // detailStr := string(setlDetail)
  5073. // order.SetlDetail = detailStr
  5074. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5075. // err = service.UpDateOrder(order)
  5076. // if err == nil {
  5077. // c.ServeSuccessJSON(map[string]interface{}{
  5078. // "msg": "预结算成功",
  5079. // })
  5080. // } else {
  5081. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5082. // return
  5083. // }
  5084. // }
  5085. // } else {
  5086. // adminUser := c.GetAdminUserInfo()
  5087. // errlog := &models.HisOrderError{
  5088. // UserOrgId: adminUser.CurrentOrgId,
  5089. // Ctime: time.Now().Unix(),
  5090. // Mtime: time.Now().Unix(),
  5091. // ErrMsg: res.ErrMsg,
  5092. // Status: 1,
  5093. // PatientId: id,
  5094. // RecordTime: recordDateTime,
  5095. // Stage: 4,
  5096. // }
  5097. // service.CreateErrMsgLog(errlog)
  5098. //
  5099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5100. // return
  5101. // }
  5102. // } else {
  5103. // adminUser := c.GetAdminUserInfo()
  5104. // errlog := &models.HisOrderError{
  5105. // UserOrgId: adminUser.CurrentOrgId,
  5106. // Ctime: time.Now().Unix(),
  5107. // Mtime: time.Now().Unix(),
  5108. // ErrMsg: res.ErrMsg,
  5109. // Status: 1,
  5110. // PatientId: id,
  5111. // RecordTime: recordDateTime,
  5112. // Stage: 4,
  5113. // }
  5114. // service.CreateErrMsgLog(errlog)
  5115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5116. // return
  5117. // }
  5118. //
  5119. // } else {
  5120. // var total float64
  5121. // for _, item := range prescriptions {
  5122. // if item.Type == 1 { //药品
  5123. // for _, subItem := range item.HisDoctorAdviceInfo {
  5124. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5125. // }
  5126. // }
  5127. // if item.Type == 2 { //项目
  5128. // for _, subItem := range item.HisPrescriptionProject {
  5129. // total = total + (subItem.Price * float64(subItem.Count))
  5130. // }
  5131. // }
  5132. //
  5133. // for _, subItem := range item.HisAdditionalCharge {
  5134. // total = total + (subItem.Price * float64(subItem.Count))
  5135. // }
  5136. // }
  5137. //
  5138. // allTotal := fmt.Sprintf("%.2f", total)
  5139. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5140. // order := &models.HisOrder{
  5141. // UserOrgId: adminUser.CurrentOrgId,
  5142. // HisPatientId: his.ID,
  5143. // PatientId: id,
  5144. // SettleAccountsDate: recordDateTime,
  5145. // Ctime: time.Now().Unix(),
  5146. // Mtime: time.Now().Unix(),
  5147. // Status: 1,
  5148. // OrderStatus: 2,
  5149. // Number: chrg_bchno,
  5150. // MedfeeSumamt: totals,
  5151. // }
  5152. // err = service.CreateOrder(order)
  5153. // if err != nil {
  5154. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5155. // return
  5156. // }
  5157. //
  5158. // var customs []*Custom
  5159. // for _, item := range prescriptions {
  5160. //
  5161. // if item.Type == 1 { //药品
  5162. // for _, subItem := range item.HisDoctorAdviceInfo {
  5163. // cus := &Custom{
  5164. // AdviceId: subItem.ID,
  5165. // ProjectId: 0,
  5166. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5167. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5168. // FeedetlSn: subItem.FeedetlSn,
  5169. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5170. // MedListCodg: subItem.MedListCodg,
  5171. // Type: 1,
  5172. // }
  5173. // customs = append(customs, cus)
  5174. // }
  5175. // }
  5176. //
  5177. // if item.Type == 2 { //项目
  5178. // for _, subItem := range item.HisPrescriptionProject {
  5179. //
  5180. // cus := &Custom{
  5181. // AdviceId: 0,
  5182. // ProjectId: subItem.ID,
  5183. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5184. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5185. // FeedetlSn: subItem.FeedetlSn,
  5186. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5187. // MedListCodg: subItem.MedListCodg,
  5188. // Type: 2,
  5189. // }
  5190. //
  5191. // customs = append(customs, cus)
  5192. // }
  5193. // }
  5194. //
  5195. // for _, item := range item.HisAdditionalCharge {
  5196. // cus := &Custom{
  5197. // ItemId: item.ID,
  5198. // AdviceId: 0,
  5199. // ProjectId: 0,
  5200. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5201. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5202. // FeedetlSn: item.FeedetlSn,
  5203. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5204. // MedListCodg: item.XtHisAddtionConfig.Code,
  5205. // Type: 3,
  5206. // }
  5207. //
  5208. // customs = append(customs, cus)
  5209. // }
  5210. //
  5211. // }
  5212. //
  5213. // for _, item := range customs {
  5214. // var advice_id int64 = 0
  5215. // var project_id int64 = 0
  5216. // var item_id int64 = 0
  5217. //
  5218. // var types int64 = 0
  5219. //
  5220. // if item.Type == 1 {
  5221. // advice_id = item.AdviceId
  5222. // project_id = 0
  5223. // item_id = 0
  5224. // } else if item.Type == 2 {
  5225. // advice_id = 0
  5226. // item_id = 0
  5227. //
  5228. // project_id = item.ProjectId
  5229. // } else if item.Type == 3 {
  5230. // advice_id = 0
  5231. // item_id = item.ItemId
  5232. // project_id = 0
  5233. // }
  5234. //
  5235. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5236. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5237. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5238. //
  5239. // info := &models.HisOrderInfo{
  5240. // OrderNumber: order.Number,
  5241. // UploadDate: time.Now().Unix(),
  5242. // AdviceId: advice_id,
  5243. // DetItemFeeSumamt: detItemFeeSumamt,
  5244. // Cnt: cut,
  5245. // Pric: pric,
  5246. // PatientId: id,
  5247. // Status: 1,
  5248. // Mtime: time.Now().Unix(),
  5249. // Ctime: time.Now().Unix(),
  5250. // UserOrgId: adminUser.CurrentOrgId,
  5251. // HisPatientId: his.ID,
  5252. // OrderId: order.ID,
  5253. // ProjectId: project_id,
  5254. // Type: types,
  5255. // ItemId: item_id,
  5256. // }
  5257. // service.CreateOrderInfo(info)
  5258. // }
  5259. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5260. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5261. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5262. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5263. // if err == nil {
  5264. // c.ServeSuccessJSON(map[string]interface{}{
  5265. // "msg": "结算成功",
  5266. // })
  5267. // } else {
  5268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5269. // return
  5270. // }
  5271. // }
  5272. //}
  5273. //上传明细-预结算-
  5274. func (c *HisApiController) GetPreUploadInfo() {
  5275. id, _ := c.GetInt64("id")
  5276. record_time := c.GetString("record_time")
  5277. his_patient_id, _ := c.GetInt64("his_patient_id")
  5278. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5279. admin_user_id, _ := c.GetInt64("admin_user_id")
  5280. diagnosis_id := c.GetString("diagnosis")
  5281. sick_type, _ := c.GetInt64("sick_type")
  5282. reg_type, _ := c.GetInt64("p_type")
  5283. begin_time := c.GetString("begin_time")
  5284. id_str := c.GetString("ids")
  5285. ids_arr := strings.Split(id_str, ",")
  5286. timeLayout := "2006-01-02"
  5287. loc, _ := time.LoadLocation("Local")
  5288. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5289. if err != nil {
  5290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5291. return
  5292. }
  5293. recordDateTime := theTime.Unix()
  5294. adminUser := c.GetAdminUserInfo()
  5295. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5296. var config []*models.HisXtDiagnoseConfig
  5297. for _, item := range diagnosis_ids {
  5298. id, _ := strconv.ParseInt(item, 10, 64)
  5299. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5300. config = append(config, &diagnosisConfig)
  5301. }
  5302. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5303. sickConfig, _ := service.FindSickById(sick_type)
  5304. var prescriptions []*models.HisPrescription
  5305. var start_time int64
  5306. var end_time int64
  5307. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5308. fmt.Println(his_patient_id)
  5309. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5310. timestamp := time.Now().Unix()
  5311. tempTime := time.Unix(timestamp, 0)
  5312. timeFormat := tempTime.Format("20060102150405")
  5313. chrgBchno := rand.Intn(100000) + 10000
  5314. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5315. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5316. var patientPrescription models.HisPrescriptionInfo
  5317. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5318. if patientPrescription.ID == 0 {
  5319. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5320. }
  5321. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5322. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5323. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5324. strconv.FormatInt(his.PatientId, 10)
  5325. var res2 ResultSix
  5326. var resSix10265 ResultSix10265
  5327. var time_stamp string
  5328. if miConfig.MdtrtareaAdmvs == "421300" {
  5329. data := make(map[string]interface{})
  5330. client := &http.Client{}
  5331. data["psn_no"] = his.PsnNo
  5332. data["mdtrt_id"] = his.Number
  5333. data["doctor"] = roles.UserName
  5334. data["department"] = department.Name
  5335. data["org_name"] = miConfig.OrgName
  5336. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5337. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5338. data["fixmedins_code"] = miConfig.Code
  5339. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5340. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5341. data["secret_key"] = miConfig.SecretKey
  5342. data["sick_code"] = sickConfig.CountryCode
  5343. data["sick_name"] = sickConfig.ClassName
  5344. data["begin_time"] = begin_time
  5345. data["dept"] = strconv.FormatInt(department.ID, 10)
  5346. data["config"] = config
  5347. fmt.Println(data)
  5348. bytesData, _ := json.Marshal(data)
  5349. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5350. resp, _ := client.Do(req)
  5351. defer resp.Body.Close()
  5352. body, ioErr := ioutil.ReadAll(resp.Body)
  5353. if ioErr != nil {
  5354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5356. return
  5357. }
  5358. var respJSON map[string]interface{}
  5359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5362. return
  5363. }
  5364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5365. userJSONBytes, _ := json.Marshal(respJSON)
  5366. fmt.Println("log")
  5367. fmt.Println(string(userJSONBytes))
  5368. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5369. utils.ErrorLog("解析失败:%v", err)
  5370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5371. return
  5372. }
  5373. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5374. //江苏地区国家医保医疗类别
  5375. //职工透析:医疗类别选特殊情况门诊9933
  5376. //居民血透门慢: 医疗类别选门诊慢病1402
  5377. //var med_type string
  5378. //if his.Insutype == "310" {
  5379. // if reg_type == 14 {
  5380. // med_type = "9933"
  5381. // } else if reg_type == 11 {
  5382. // med_type = "11"
  5383. //
  5384. // }
  5385. //} else if his.Insutype == "390" {
  5386. // if reg_type == 14 {
  5387. // med_type = "1402"
  5388. // } else if reg_type == 11 {
  5389. // med_type = "11"
  5390. // }
  5391. //}
  5392. data := make(map[string]interface{})
  5393. client := &http.Client{}
  5394. data["psn_no"] = his.PsnNo
  5395. data["mdtrt_id"] = his.Number
  5396. data["doctor"] = roles.UserName
  5397. data["department"] = department.Name
  5398. data["org_name"] = miConfig.OrgName
  5399. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5400. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5401. data["fixmedins_code"] = miConfig.Code
  5402. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5403. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5404. data["secret_key"] = miConfig.SecretKey
  5405. data["sick_code"] = sickConfig.CountryCode
  5406. data["sick_name"] = sickConfig.ClassName
  5407. data["begin_time"] = begin_time
  5408. data["dept"] = strconv.FormatInt(department.ID, 10)
  5409. data["config"] = config
  5410. data["url"] = miConfig.Url
  5411. data["ak"] = miConfig.AccessKey
  5412. data["cainfo"] = miConfig.Cainfo
  5413. bytesData, _ := json.Marshal(data)
  5414. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5415. resp, _ := client.Do(req)
  5416. defer resp.Body.Close()
  5417. body, ioErr := ioutil.ReadAll(resp.Body)
  5418. if ioErr != nil {
  5419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5421. return
  5422. }
  5423. var respJSON map[string]interface{}
  5424. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5427. return
  5428. }
  5429. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5430. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5431. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5433. userJSONBytes, _ := json.Marshal(respJSON)
  5434. fmt.Println("log")
  5435. fmt.Println(string(userJSONBytes))
  5436. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5437. utils.ErrorLog("解析失败:%v", err)
  5438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5439. return
  5440. }
  5441. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5442. res2.Output = resSix10265.Output
  5443. res2.ErrMsg = resSix10265.ErrMsg
  5444. res2.Cainfo = resSix10265.Cainfo
  5445. res2.WarnMsg = resSix10265.WarnMsg
  5446. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5447. res2.Infcode = infocode
  5448. } else {
  5449. var result string
  5450. var requestLog string
  5451. if miConfig.MdtrtareaAdmvs == "440781" { //
  5452. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5453. } else {
  5454. if miConfig.Code == "H15049901371" {
  5455. //赤峰地区国家医保医疗类别
  5456. //职工透析:医疗类别选特殊情况门诊990502
  5457. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5458. var med_type string
  5459. if his.Insutype == "390" {
  5460. if reg_type == 14 {
  5461. med_type = "9933"
  5462. } else if reg_type == 11 {
  5463. med_type = "11"
  5464. }
  5465. } else if his.Insutype == "310" {
  5466. if reg_type == 14 {
  5467. med_type = "990502"
  5468. } else if reg_type == 11 {
  5469. med_type = "11"
  5470. }
  5471. }
  5472. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5473. } else {
  5474. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5475. }
  5476. saveLog(result, requestLog, "2203", "上传就诊信息")
  5477. var respJSON2 map[string]interface{}
  5478. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5481. return
  5482. }
  5483. userJSONBytes2, _ := json.Marshal(respJSON2)
  5484. if miConfig.Code == "H15049901371" {
  5485. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5486. utils.ErrorLog("解析失败:%v", err)
  5487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5488. return
  5489. }
  5490. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5491. res2.Output = resSix10265.Output
  5492. res2.ErrMsg = resSix10265.ErrMsg
  5493. res2.Cainfo = resSix10265.Cainfo
  5494. res2.WarnMsg = resSix10265.WarnMsg
  5495. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5496. res2.Infcode = infocode
  5497. } else {
  5498. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5499. utils.ErrorLog("解析失败:%v", err)
  5500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5501. return
  5502. }
  5503. }
  5504. }
  5505. }
  5506. if res2.Infcode != 0 {
  5507. adminUser := c.GetAdminUserInfo()
  5508. errlog := &models.HisOrderError{
  5509. UserOrgId: adminUser.CurrentOrgId,
  5510. Ctime: time.Now().Unix(),
  5511. Mtime: time.Now().Unix(),
  5512. ErrMsg: res2.ErrMsg,
  5513. Status: 1,
  5514. PatientId: id,
  5515. RecordTime: recordDateTime,
  5516. Stage: 3,
  5517. }
  5518. service.CreateErrMsgLog(errlog)
  5519. c.ServeSuccessJSON(map[string]interface{}{
  5520. "failed_code": -10,
  5521. "msg": res2.ErrMsg,
  5522. })
  5523. return
  5524. } else {
  5525. his.Diagnosis = diagnosis_id
  5526. his.SickType = sickConfig.ID
  5527. his.PType = fmt.Sprintf("%d", reg_type)
  5528. service.UpdateHisPatientThree(&his)
  5529. data := make(map[string]interface{})
  5530. if settle_accounts_type == 1 { //日结
  5531. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5532. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5533. } else {
  5534. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5535. }
  5536. data["pre"] = prescriptions
  5537. } else { //月结
  5538. start_time_str := c.GetString("start_time")
  5539. end_time_str := c.GetString("end_time")
  5540. timeLayout := "2006-01-02"
  5541. loc, _ := time.LoadLocation("Local")
  5542. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5543. if err != nil {
  5544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5545. return
  5546. }
  5547. recordStartTime := theStartTime.Unix()
  5548. start_time = recordStartTime
  5549. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5550. if err != nil {
  5551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5552. return
  5553. }
  5554. recordEndTime := theEndTime.Unix()
  5555. end_time = recordEndTime
  5556. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5557. data["pre"] = prescriptions
  5558. }
  5559. client := &http.Client{}
  5560. data["psn_no"] = his.PsnNo
  5561. data["mdtrt_id"] = his.Number
  5562. data["chrg_bchno"] = chrg_bchno
  5563. data["org_name"] = miConfig.OrgName
  5564. data["doctor"] = roles.UserName
  5565. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5566. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5567. data["fixmedins_code"] = miConfig.Code
  5568. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5569. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5570. data["dept_code"] = "15"
  5571. } else {
  5572. data["dept_code"] = department.Number
  5573. }
  5574. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5575. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5576. data["secret_key"] = miConfig.SecretKey
  5577. data["url"] = miConfig.Url
  5578. data["ak"] = miConfig.AccessKey
  5579. data["new_doctor_name"] = patientPrescription.Doctor
  5580. data["diag_code"] = sickConfig.CountryCode
  5581. data["time_stamp"] = time_stamp
  5582. data["cainfo"] = miConfig.Cainfo
  5583. var ids []int64
  5584. for _, item := range prescriptions {
  5585. ids = append(ids, item.ID)
  5586. }
  5587. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5588. if config.IsOpen == 1 { //对接了医保,走医保流程
  5589. var res ResultFour
  5590. var resFour10265 ResultFour10265
  5591. if miConfig.MdtrtareaAdmvs == "421300" {
  5592. bytesData, _ := json.Marshal(data)
  5593. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5594. resp, _ := client.Do(req)
  5595. defer resp.Body.Close()
  5596. body, ioErr := ioutil.ReadAll(resp.Body)
  5597. if ioErr != nil {
  5598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5600. return
  5601. }
  5602. var respJSON map[string]interface{}
  5603. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5606. return
  5607. }
  5608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5609. userJSONBytes, _ := json.Marshal(respJSON)
  5610. fmt.Println("log")
  5611. fmt.Println(string(userJSONBytes))
  5612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5613. utils.ErrorLog("解析失败:%v", err)
  5614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5615. return
  5616. }
  5617. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5618. bytesData, _ := json.Marshal(data)
  5619. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5620. resp, _ := client.Do(req)
  5621. defer resp.Body.Close()
  5622. body, ioErr := ioutil.ReadAll(resp.Body)
  5623. if ioErr != nil {
  5624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5626. return
  5627. }
  5628. var respJSON map[string]interface{}
  5629. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5632. return
  5633. }
  5634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5635. userJSONBytes, _ := json.Marshal(respJSON)
  5636. fmt.Println("log")
  5637. fmt.Println(string(userJSONBytes))
  5638. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5639. utils.ErrorLog("解析失败:%v", err)
  5640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5641. return
  5642. }
  5643. res.InfRefmsgid = resFour10265.InfRefmsgid
  5644. res.Output = resFour10265.Output
  5645. res.ErrMsg = resFour10265.ErrMsg
  5646. res.Cainfo = resFour10265.Cainfo
  5647. res.WarnMsg = resFour10265.WarnMsg
  5648. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5649. res.Infcode = infocode
  5650. } else {
  5651. if miConfig.Code == "H15049901371" {
  5652. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  5653. var dat map[string]interface{}
  5654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5655. fmt.Println(dat)
  5656. } else {
  5657. fmt.Println(err)
  5658. }
  5659. saveLog(result, request_log, "2204", "上传费用明细")
  5660. userJSONBytes, _ := json.Marshal(dat)
  5661. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5662. utils.ErrorLog("解析失败:%v", err)
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5664. return
  5665. }
  5666. res.InfRefmsgid = resFour10265.InfRefmsgid
  5667. res.Output = resFour10265.Output
  5668. res.ErrMsg = resFour10265.ErrMsg
  5669. res.Cainfo = resFour10265.Cainfo
  5670. res.WarnMsg = resFour10265.WarnMsg
  5671. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5672. res.Infcode = infocode
  5673. } else {
  5674. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  5675. var dat map[string]interface{}
  5676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5677. fmt.Println(dat)
  5678. } else {
  5679. fmt.Println(err)
  5680. }
  5681. saveLog(result, request_log, "2204", "上传费用明细")
  5682. userJSONBytes, _ := json.Marshal(dat)
  5683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5684. utils.ErrorLog("解析失败:%v", err)
  5685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5686. return
  5687. }
  5688. }
  5689. }
  5690. if res.Infcode == 0 {
  5691. order := &models.HisOrder{
  5692. UserOrgId: adminUser.CurrentOrgId,
  5693. HisPatientId: his.ID,
  5694. PatientId: his.PatientId,
  5695. SettleAccountsDate: recordDateTime,
  5696. Ctime: time.Now().Unix(),
  5697. Mtime: time.Now().Unix(),
  5698. MdtrtId: his.Number,
  5699. PsnNo: his.PsnNo,
  5700. MedType: strconv.FormatInt(reg_type, 10),
  5701. Status: 1,
  5702. Number: chrg_bchno,
  5703. Infcode: res.Infcode,
  5704. WarnMsg: res.WarnMsg,
  5705. Cainfo: res.Cainfo,
  5706. ErrMsg: res.ErrMsg,
  5707. RespondTime: res.RefmsgTime,
  5708. InfRefmsgid: res.InfRefmsgid,
  5709. OrderStatus: 1,
  5710. IsMedicineInsurance: 1,
  5711. SettleType: settle_accounts_type,
  5712. SettleStartTime: start_time,
  5713. SettleEndTime: end_time,
  5714. Creator: roles.AdminUserId,
  5715. Modify: roles.AdminUserId,
  5716. PType: 2,
  5717. Diagnosis: diagnosis_id,
  5718. }
  5719. err = service.CreateOrder(order)
  5720. if err != nil {
  5721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5722. return
  5723. }
  5724. for _, item := range res.Output.Result {
  5725. temp := strings.Split(item.FeedetlSn, "-")
  5726. var advice_id int64 = 0
  5727. var project_id int64 = 0
  5728. var types int64 = 0
  5729. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5730. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5731. if temp[1] == "1" {
  5732. advice_id = id
  5733. project_id = 0
  5734. } else if temp[1] == "2" {
  5735. advice_id = 0
  5736. project_id = id
  5737. }
  5738. info := &models.HisOrderInfo{
  5739. OrderNumber: order.Number,
  5740. FeedetlSn: item.FeedetlSn,
  5741. UploadDate: time.Now().Unix(),
  5742. AdviceId: advice_id,
  5743. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5744. Cnt: item.Cnt,
  5745. Pric: float64(item.Pric),
  5746. PatientId: his.PatientId,
  5747. PricUplmtAmt: item.PricUplmtAmt,
  5748. SelfpayProp: item.SelfpayProp,
  5749. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5750. OverlmtAmt: item.OverlmtAmt,
  5751. PreselfpayAmt: item.PreselfpayAmt,
  5752. BasMednFlag: item.BasMednFlag,
  5753. MedChrgitmType: item.MedChrgitmType,
  5754. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5755. Status: 1,
  5756. Memo: item.Memo,
  5757. Mtime: time.Now().Unix(),
  5758. InscpScpAmt: item.InscpScpAmt,
  5759. DrtReimFlag: item.DrtReimFlag,
  5760. Ctime: time.Now().Unix(),
  5761. ListSpItemFlag: item.ListSpItemFlag,
  5762. ChldMedcFlag: item.ChldMedcFlag,
  5763. LmtUsedFlag: item.LmtUsedFlag,
  5764. ChrgitmLv: item.ChrgitmLv,
  5765. UserOrgId: adminUser.CurrentOrgId,
  5766. HisPatientId: his.ID,
  5767. OrderId: order.ID,
  5768. ProjectId: project_id,
  5769. Type: types,
  5770. }
  5771. service.CreateOrderInfo(info)
  5772. }
  5773. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5774. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5775. var total float64
  5776. for _, item := range prescriptions {
  5777. if item.Type == 1 { //药品
  5778. for _, subItem := range item.HisDoctorAdviceInfo {
  5779. total = total + (subItem.Price * subItem.PrescribingNumber)
  5780. }
  5781. }
  5782. if item.Type == 2 { //项目
  5783. for _, subItem := range item.HisPrescriptionProject {
  5784. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5785. total = total + (subItem.Price * cnt)
  5786. }
  5787. }
  5788. }
  5789. for _, item := range prescriptions {
  5790. for _, subItem := range item.HisAdditionalCharge {
  5791. total = total + (subItem.Price * float64(subItem.Count))
  5792. }
  5793. }
  5794. allTotal := fmt.Sprintf("%.4f", total)
  5795. if res.Infcode == 0 {
  5796. var rf []*ResultFive
  5797. json.Unmarshal([]byte(his.Iinfo), &rf)
  5798. chrg_bchno := chrg_bchno
  5799. cert_no := his.Certno
  5800. var insutypes []string
  5801. var insutype string
  5802. var is390 int = 0
  5803. var is310 int = 0
  5804. for _, item := range rf {
  5805. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5806. insutypes = append(insutypes, item.Insutype)
  5807. }
  5808. }
  5809. if len(insutypes) == 1 {
  5810. insutype = insutypes[0]
  5811. } else {
  5812. for _, i := range insutypes {
  5813. if i == "390" {
  5814. is390 = 1
  5815. }
  5816. if i == "310" {
  5817. is310 = 1
  5818. }
  5819. }
  5820. }
  5821. if is390 == 1 {
  5822. insutype = "390"
  5823. }
  5824. if is310 == 1 {
  5825. insutype = "310"
  5826. }
  5827. if len(insutypes) == 0 {
  5828. insutype = "310"
  5829. }
  5830. if len(insutypes) == 2 {
  5831. insutype = strconv.FormatInt(his.SocialType, 64)
  5832. }
  5833. //insutype = "390"
  5834. if his.IdCardType == 1 {
  5835. cert_no = his.MedicalInsuranceNumber
  5836. } else {
  5837. cert_no = his.Certno
  5838. }
  5839. var res ResultSeven
  5840. var resSeven10265 ResultSeven10265
  5841. if miConfig.MdtrtareaAdmvs == "421300" {
  5842. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5843. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5844. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5845. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5846. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5847. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5848. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5849. resp, requestErr := http.Get(api)
  5850. if requestErr != nil {
  5851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5852. return
  5853. }
  5854. body, ioErr := ioutil.ReadAll(resp.Body)
  5855. if ioErr != nil {
  5856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5858. return
  5859. }
  5860. var respJSON map[string]interface{}
  5861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5864. return
  5865. }
  5866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5867. result, _ := json.Marshal(respJSON)
  5868. fmt.Println("log")
  5869. fmt.Println(string(result))
  5870. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5871. utils.ErrorLog("解析失败:%v", err)
  5872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5873. return
  5874. }
  5875. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5876. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5877. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5878. bas := strings.Split(psn_info.CardInfo, "|")
  5879. if his.IdCardType == 1 {
  5880. cert_no = bas[2]
  5881. } else {
  5882. cert_no = bas[1]
  5883. }
  5884. //江苏地区国家医保医疗类别
  5885. //职工透析:医疗类别选特殊情况门诊9933
  5886. //居民血透门慢: 医疗类别选门诊慢病1402
  5887. //var med_type string
  5888. //if his.Insutype == "310" {
  5889. // if reg_type == 14 {
  5890. // med_type = "9933"
  5891. // } else if reg_type == 11 {
  5892. // med_type = "11"
  5893. //
  5894. // }
  5895. //} else if his.Insutype == "390" {
  5896. // if reg_type == 14 {
  5897. // med_type = "1402"
  5898. // } else if reg_type == 11 {
  5899. // med_type = "11"
  5900. // }
  5901. //}
  5902. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5903. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5904. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5905. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5906. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5907. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5908. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5909. resp, requestErr := http.Get(api)
  5910. if requestErr != nil {
  5911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5912. return
  5913. }
  5914. body, ioErr := ioutil.ReadAll(resp.Body)
  5915. if ioErr != nil {
  5916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5918. return
  5919. }
  5920. var respJSON map[string]interface{}
  5921. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5924. return
  5925. }
  5926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5927. result, _ := json.Marshal(respJSON)
  5928. fmt.Println("log")
  5929. fmt.Println(string(result))
  5930. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5931. utils.ErrorLog("解析失败:%v", err)
  5932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5933. return
  5934. }
  5935. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5936. res.Output = resSeven10265.Output
  5937. res.ErrMsg = resSeven10265.ErrMsg
  5938. res.Cainfo = resSeven10265.Cainfo
  5939. res.WarnMsg = resSeven10265.WarnMsg
  5940. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5941. res.Infcode = infocode
  5942. } else {
  5943. var result string
  5944. var request_log string
  5945. if miConfig.Code == "H15049901371" {
  5946. //赤峰地区国家医保医疗类别
  5947. //职工透析:医疗类别选特殊情况门诊990502
  5948. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5949. var med_type string
  5950. if his.Insutype == "390" {
  5951. if reg_type == 14 {
  5952. med_type = "9933"
  5953. } else if reg_type == 11 {
  5954. med_type = "11"
  5955. }
  5956. } else if his.Insutype == "310" {
  5957. if reg_type == 14 {
  5958. med_type = "990502"
  5959. } else if reg_type == 11 {
  5960. med_type = "11"
  5961. }
  5962. }
  5963. 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)
  5964. } else {
  5965. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  5966. }
  5967. var dat map[string]interface{}
  5968. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5969. fmt.Println(dat)
  5970. } else {
  5971. fmt.Println(err)
  5972. }
  5973. saveLog(result, request_log, "2206", "预结算")
  5974. //userJSONBytes, _ := json.Marshal(dat)
  5975. //
  5976. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5977. // utils.ErrorLog("解析失败:%v", err)
  5978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5979. // return
  5980. //}
  5981. userJSONBytes, _ := json.Marshal(dat)
  5982. if miConfig.Code == "H15049901371" {
  5983. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5984. utils.ErrorLog("解析失败:%v", err)
  5985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5986. return
  5987. }
  5988. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5989. res.Output = resSeven10265.Output
  5990. res.ErrMsg = resSeven10265.ErrMsg
  5991. res.Cainfo = resSeven10265.Cainfo
  5992. res.WarnMsg = resSeven10265.WarnMsg
  5993. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5994. res.Infcode = infocode
  5995. } else {
  5996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5997. utils.ErrorLog("解析失败:%v", err)
  5998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5999. return
  6000. }
  6001. }
  6002. }
  6003. if res.Infcode != 0 {
  6004. errlog := &models.HisOrderError{
  6005. UserOrgId: adminUser.CurrentOrgId,
  6006. Ctime: time.Now().Unix(),
  6007. Mtime: time.Now().Unix(),
  6008. Number: chrg_bchno,
  6009. ErrMsg: res.ErrMsg,
  6010. Status: 1,
  6011. PatientId: id,
  6012. RecordTime: recordDateTime,
  6013. Stage: 20,
  6014. }
  6015. service.CreateErrMsgLog(errlog)
  6016. c.ServeSuccessJSON(map[string]interface{}{
  6017. "failed_code": -10,
  6018. "msg": res.ErrMsg,
  6019. })
  6020. return
  6021. } else {
  6022. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6023. order.OrderStatus = 1
  6024. order.IsPre = 1
  6025. order.Status = 1
  6026. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6027. order.SetlId = res.Output.Setlinfo.SetlID
  6028. order.PsnNo = res.Output.Setlinfo.PsnNo
  6029. order.PsnName = res.Output.Setlinfo.PsnName
  6030. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6031. order.Certno = res.Output.Setlinfo.Certno
  6032. order.Gend = res.Output.Setlinfo.Gend
  6033. order.Naty = res.Output.Setlinfo.Naty
  6034. order.Age = res.Output.Setlinfo.Age
  6035. order.Insutype = res.Output.Setlinfo.Insutype
  6036. order.PsnType = res.Output.Setlinfo.PsnType
  6037. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6038. order.SetlTime = res.Output.Setlinfo.SetlTime
  6039. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6040. if res.Output.Setlinfo.MedType == "140101" {
  6041. order.MedType = "14"
  6042. } else {
  6043. order.MedType = res.Output.Setlinfo.MedType
  6044. }
  6045. if reg_type == 1112 {
  6046. order.MedType = "1112"
  6047. }
  6048. if reg_type == 1111 {
  6049. order.MedType = "1111"
  6050. }
  6051. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6052. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6053. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6054. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6055. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6056. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6057. order.HifpPay = res.Output.Setlinfo.HifpPay
  6058. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6059. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6060. order.HifesPay = res.Output.Setlinfo.HifesPay
  6061. order.HifobPay = res.Output.Setlinfo.HifobPay
  6062. order.MafPay = res.Output.Setlinfo.MafPay
  6063. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6064. order.OthPay = res.Output.Setlinfo.OthPay
  6065. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6066. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6067. order.AcctPay = res.Output.Setlinfo.AcctPay
  6068. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6069. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6070. order.Balc = res.Output.Setlinfo.Balc
  6071. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6072. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6073. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6074. order.ClrWay = res.Output.Setlinfo.ClrWay
  6075. order.Creator = order.Creator
  6076. order.Modify = roles.AdminUserId
  6077. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6078. detailStr := string(setlDetail)
  6079. order.SetlDetail = detailStr
  6080. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6081. err = service.UpDateOrder(order)
  6082. if err == nil {
  6083. c.ServeSuccessJSON(map[string]interface{}{
  6084. "msg": "预结算成功",
  6085. })
  6086. } else {
  6087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6088. return
  6089. }
  6090. }
  6091. } else {
  6092. adminUser := c.GetAdminUserInfo()
  6093. errlog := &models.HisOrderError{
  6094. UserOrgId: adminUser.CurrentOrgId,
  6095. Ctime: time.Now().Unix(),
  6096. Mtime: time.Now().Unix(),
  6097. ErrMsg: res.ErrMsg,
  6098. Status: 1,
  6099. PatientId: id,
  6100. RecordTime: recordDateTime,
  6101. Stage: 4,
  6102. }
  6103. service.CreateErrMsgLog(errlog)
  6104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6105. return
  6106. }
  6107. } else {
  6108. adminUser := c.GetAdminUserInfo()
  6109. errlog := &models.HisOrderError{
  6110. UserOrgId: adminUser.CurrentOrgId,
  6111. Ctime: time.Now().Unix(),
  6112. Mtime: time.Now().Unix(),
  6113. ErrMsg: res.ErrMsg,
  6114. Status: 1,
  6115. PatientId: id,
  6116. RecordTime: recordDateTime,
  6117. Stage: 4,
  6118. }
  6119. service.CreateErrMsgLog(errlog)
  6120. c.ServeSuccessJSON(map[string]interface{}{
  6121. "failed_code": -10,
  6122. "msg": res.ErrMsg,
  6123. })
  6124. return
  6125. }
  6126. }
  6127. }
  6128. }
  6129. //func (c *HisApiController) GetSettleInfo() {
  6130. // id, _ := c.GetInt64("id")
  6131. // order_id, _ := c.GetInt64("order_id")
  6132. //
  6133. // record_time := c.GetString("record_time")
  6134. // pay_way, _ := c.GetInt64("pay_way")
  6135. // pay_price, _ := c.GetFloat("pay_price")
  6136. // pay_card_no := c.GetString("pay_card_no")
  6137. // discount_price, _ := c.GetFloat("discount_price")
  6138. // preferential_price, _ := c.GetFloat("preferential_price")
  6139. // reality_price, _ := c.GetFloat("reality_price")
  6140. // found_price, _ := c.GetFloat("found_price")
  6141. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6142. // private_price, _ := c.GetFloat("private_price")
  6143. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6144. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6145. //
  6146. // timeLayout := "2006-01-02"
  6147. // loc, _ := time.LoadLocation("Local")
  6148. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6149. // if err != nil {
  6150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6151. // return
  6152. // }
  6153. // recordDateTime := theTime.Unix()
  6154. // adminUser := c.GetAdminUserInfo()
  6155. //
  6156. // var prescriptions []*models.HisPrescription
  6157. //
  6158. // data := make(map[string]interface{})
  6159. // if settle_accounts_type == 1 { //日结
  6160. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6161. // data["pre"] = prescriptions
  6162. //
  6163. // } else { //月结
  6164. // start_time_str := c.GetString("start_time")
  6165. // end_time_str := c.GetString("end_time")
  6166. // timeLayout := "2006-01-02"
  6167. // loc, _ := time.LoadLocation("Local")
  6168. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6169. // if err != nil {
  6170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6171. // return
  6172. // }
  6173. // recordStartTime := theStartTime.Unix()
  6174. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6175. // if err != nil {
  6176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6177. // return
  6178. // }
  6179. // recordEndTime := theEndTime.Unix()
  6180. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6181. // data["pre"] = prescriptions
  6182. //
  6183. // }
  6184. //
  6185. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6186. //
  6187. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6188. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6189. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6190. // strconv.FormatInt(his.PatientId, 10)
  6191. //
  6192. // order_src, _ := service.GetHisOrderByID(order_id)
  6193. //
  6194. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6195. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6196. //
  6197. // var total float64
  6198. // for _, item := range prescriptions {
  6199. // if item.Type == 1 { //药品
  6200. // for _, subItem := range item.HisDoctorAdviceInfo {
  6201. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6202. // }
  6203. // }
  6204. // if item.Type == 2 { //项目
  6205. // for _, subItem := range item.HisPrescriptionProject {
  6206. // total = total + (subItem.Price * float64(subItem.Count))
  6207. // }
  6208. // }
  6209. // }
  6210. //
  6211. // for _, item := range prescriptions {
  6212. // for _, subItem := range item.HisAdditionalCharge {
  6213. // total = total + (subItem.Price * float64(subItem.Count))
  6214. // }
  6215. // }
  6216. //
  6217. // allTotal := fmt.Sprintf("%.2f", total)
  6218. // var rf []*ResultFive
  6219. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6220. // psn_no := order_src.PsnNo
  6221. // mdtrt_id := order_src.MdtrtId
  6222. // chrg_bchno := order_src.Number
  6223. // cert_no := order_src.Certno
  6224. // insutype := rf[0].Insutype
  6225. //
  6226. // if his.IdCardType == 1 {
  6227. // cert_no = his.MedicalInsuranceNumber
  6228. // } else {
  6229. // cert_no = his.Certno
  6230. // }
  6231. //
  6232. // 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)
  6233. // var dat map[string]interface{}
  6234. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6235. // fmt.Println(dat)
  6236. // } else {
  6237. // fmt.Println(err)
  6238. // }
  6239. //
  6240. // userJSONBytes, _ := json.Marshal(dat)
  6241. //
  6242. //
  6243. //
  6244. // var res ResultSeven
  6245. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6246. // utils.ErrorLog("解析失败:%v", err)
  6247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6248. // return
  6249. // }
  6250. // if res.Infcode == -1 {
  6251. // errlog := &models.HisOrderError{
  6252. // UserOrgId: adminUser.CurrentOrgId,
  6253. // Ctime: time.Now().Unix(),
  6254. // Mtime: time.Now().Unix(),
  6255. // Number: chrg_bchno,
  6256. // ErrMsg: res.ErrMsg,
  6257. // Status: 1,
  6258. // PatientId: id,
  6259. // RecordTime: recordDateTime,
  6260. // Stage: 6,
  6261. // }
  6262. // service.CreateErrMsgLog(errlog)
  6263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6264. // return
  6265. // } else {
  6266. // order_src.OrderStatus = 2
  6267. // order_src.PayWay = pay_way
  6268. // order_src.PayPrice = pay_price
  6269. // order_src.PayCardNo = pay_card_no
  6270. // order_src.DiscountPrice = discount_price
  6271. // order_src.PreferentialPrice = preferential_price
  6272. // order_src.RealityPrice = reality_price
  6273. // order_src.FoundPrice = found_price
  6274. // order_src.MedicalInsurancePrice = medical_insurance_price
  6275. // order_src.PrivatePrice = private_price
  6276. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6277. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6278. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6279. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6280. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6281. // order_src.Certno = res.Output.Setlinfo.Certno
  6282. // order_src.Gend = res.Output.Setlinfo.Gend
  6283. // order_src.Naty = res.Output.Setlinfo.Naty
  6284. // order_src.Age = res.Output.Setlinfo.Age
  6285. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6286. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6287. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6288. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6289. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6290. // order_src.MedType = res.Output.Setlinfo.MedType
  6291. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6292. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6293. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6294. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6295. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6296. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6297. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6298. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6299. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6300. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6301. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6302. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6303. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6304. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6305. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6306. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6307. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6308. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6309. // order_src.Balc = res.Output.Setlinfo.Balc
  6310. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6311. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6312. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6313. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6314. // order_src.Creator = order_src.Creator
  6315. // order_src.Modify = roles.ID
  6316. // order_src.RequestLog = src_resquest
  6317. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6318. // detailStr := string(setlDetail)
  6319. // order_src.SetlDetail = detailStr
  6320. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6321. // err = service.UpDateOrder(order_src)
  6322. //
  6323. // if err == nil {
  6324. // c.ServeSuccessJSON(map[string]interface{}{
  6325. // "msg": "结算成功",
  6326. // })
  6327. // } else {
  6328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6329. // return
  6330. // }
  6331. // }
  6332. // }
  6333. //}
  6334. //退款
  6335. func (c *HisApiController) Refund() {
  6336. order_id, _ := c.GetInt64("order_id")
  6337. admin_user_id, _ := c.GetInt64("admin_user_id")
  6338. adminUser := c.GetAdminUserInfo()
  6339. var order models.HisOrder
  6340. order, _ = service.GetHisOrderByID(order_id)
  6341. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6342. if order.ID == 0 {
  6343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6344. return
  6345. }
  6346. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6348. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6349. if config.IsOpen == 1 { //对接了医保,走医保流程
  6350. var res ResultSixteen
  6351. var resSixteen10265 ResultSixteen10265
  6352. var src_resquest string
  6353. var result string
  6354. if miConfig.MdtrtareaAdmvs == "421300" {
  6355. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6356. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6357. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6358. resp3, requestErr3 := http.Get(api3)
  6359. if requestErr3 != nil {
  6360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6361. return
  6362. }
  6363. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6364. if ioErr3 != nil {
  6365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. return
  6368. }
  6369. var respJSON3 map[string]interface{}
  6370. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6373. return
  6374. }
  6375. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6376. userJSONBytes3, _ := json.Marshal(respJSON3)
  6377. fmt.Println("log")
  6378. fmt.Println(string(userJSONBytes3))
  6379. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6380. utils.ErrorLog("解析失败:%v", err)
  6381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6382. return
  6383. }
  6384. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6385. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6386. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6387. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6388. resp3, requestErr3 := http.Get(api3)
  6389. if requestErr3 != nil {
  6390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6391. return
  6392. }
  6393. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6394. if ioErr3 != nil {
  6395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6397. return
  6398. }
  6399. var respJSON3 map[string]interface{}
  6400. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6403. return
  6404. }
  6405. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6406. userJSONBytes3, _ := json.Marshal(respJSON3)
  6407. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6408. utils.ErrorLog("解析失败:%v", err)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. return
  6411. }
  6412. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6413. res.Output = resSixteen10265.Output
  6414. res.ErrMsg = resSixteen10265.ErrMsg
  6415. res.Cainfo = resSixteen10265.Cainfo
  6416. res.WarnMsg = resSixteen10265.WarnMsg
  6417. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6418. res.Infcode = infocode
  6419. } else {
  6420. if miConfig.Code == "H15049901371" {
  6421. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6422. var dat map[string]interface{}
  6423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6424. fmt.Println(dat)
  6425. } else {
  6426. fmt.Println(err)
  6427. }
  6428. saveLog(result, src_resquest, "2208", "退费")
  6429. userJSONBytes, _ := json.Marshal(dat)
  6430. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6431. utils.ErrorLog("解析失败:%v", err)
  6432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6433. return
  6434. }
  6435. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6436. res.Output = resSixteen10265.Output
  6437. res.ErrMsg = resSixteen10265.ErrMsg
  6438. res.Cainfo = resSixteen10265.Cainfo
  6439. res.WarnMsg = resSixteen10265.WarnMsg
  6440. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6441. res.Infcode = infocode
  6442. } else {
  6443. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6444. var dat map[string]interface{}
  6445. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6446. fmt.Println(dat)
  6447. } else {
  6448. fmt.Println(err)
  6449. }
  6450. saveLog(result, src_resquest, "2208", "退费")
  6451. userJSONBytes, _ := json.Marshal(dat)
  6452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6453. utils.ErrorLog("解析失败:%v", err)
  6454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6455. return
  6456. }
  6457. }
  6458. }
  6459. if res.Infcode == 0 {
  6460. var res2 ResultSix
  6461. var resSix10265 ResultSix10265
  6462. if miConfig.MdtrtareaAdmvs == "421300" {
  6463. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6464. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6465. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6466. resp3, requestErr3 := http.Get(api3)
  6467. if requestErr3 != nil {
  6468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6469. return
  6470. }
  6471. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6472. if ioErr3 != nil {
  6473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6475. return
  6476. }
  6477. var respJSON3 map[string]interface{}
  6478. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6481. return
  6482. }
  6483. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6484. userJSONBytes3, _ := json.Marshal(respJSON3)
  6485. fmt.Println("log")
  6486. fmt.Println(string(userJSONBytes3))
  6487. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6488. utils.ErrorLog("解析失败:%v", err)
  6489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6490. return
  6491. }
  6492. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6493. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6494. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6495. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6496. resp3, requestErr3 := http.Get(api3)
  6497. if requestErr3 != nil {
  6498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6499. return
  6500. }
  6501. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6502. if ioErr3 != nil {
  6503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. return
  6506. }
  6507. var respJSON3 map[string]interface{}
  6508. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6511. return
  6512. }
  6513. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6514. userJSONBytes3, _ := json.Marshal(respJSON3)
  6515. fmt.Println("log")
  6516. fmt.Println(string(userJSONBytes3))
  6517. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6518. utils.ErrorLog("解析失败:%v", err)
  6519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6520. return
  6521. }
  6522. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6523. res2.Output = resSix10265.Output
  6524. res2.ErrMsg = resSix10265.ErrMsg
  6525. res2.Cainfo = resSix10265.Cainfo
  6526. res2.WarnMsg = resSix10265.WarnMsg
  6527. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6528. res2.Infcode = infocode
  6529. } else {
  6530. if miConfig.Code == "H15049901371" {
  6531. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6532. var dat map[string]interface{}
  6533. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6534. fmt.Println(dat)
  6535. } else {
  6536. fmt.Println(err)
  6537. }
  6538. saveLog(result2, src_request, "2205", "撤销明细")
  6539. userJSONBytes, _ := json.Marshal(dat)
  6540. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6541. utils.ErrorLog("解析失败:%v", err)
  6542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6543. return
  6544. }
  6545. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6546. res2.Output = resSix10265.Output
  6547. res2.ErrMsg = resSix10265.ErrMsg
  6548. res2.Cainfo = resSix10265.Cainfo
  6549. res2.WarnMsg = resSix10265.WarnMsg
  6550. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6551. res2.Infcode = infocode
  6552. } else {
  6553. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6554. var dat map[string]interface{}
  6555. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6556. fmt.Println(dat)
  6557. } else {
  6558. fmt.Println(err)
  6559. }
  6560. saveLog(result2, src_request, "2205", "撤销明细")
  6561. userJSONBytes, _ := json.Marshal(dat)
  6562. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6563. utils.ErrorLog("解析失败:%v", err)
  6564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6565. return
  6566. }
  6567. }
  6568. }
  6569. if res2.Infcode == 0 {
  6570. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6571. if err == nil {
  6572. c.ServeSuccessJSON(map[string]interface{}{
  6573. "msg": "退费成功",
  6574. })
  6575. } else {
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. return
  6578. }
  6579. } else {
  6580. c.ServeSuccessJSON(map[string]interface{}{
  6581. "code": -10,
  6582. "msg": res2.ErrMsg,
  6583. })
  6584. }
  6585. } else {
  6586. c.ServeSuccessJSON(map[string]interface{}{
  6587. "code": -10,
  6588. "msg": res.ErrMsg,
  6589. })
  6590. }
  6591. }
  6592. }
  6593. func (c *HisApiController) RefundNumber() {
  6594. record_time := c.GetString("record_time")
  6595. //patient_id, _ := c.GetInt64("patient_id")
  6596. admin_user_id, _ := c.GetInt64("admin_user_id")
  6597. his_patient_id, _ := c.GetInt64("id")
  6598. timeLayout := "2006-01-02"
  6599. loc, _ := time.LoadLocation("Local")
  6600. adminUser := c.GetAdminUserInfo()
  6601. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6602. fmt.Println(err)
  6603. if err != nil {
  6604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6605. return
  6606. }
  6607. recordDateTime := theTime.Unix()
  6608. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6609. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6610. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6611. //order, _ := service.GetHisOrderByID(order_id)
  6612. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6613. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6614. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6615. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6616. if count > 0 {
  6617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6618. return
  6619. }
  6620. if config.IsOpen == 1 { //对接了医保,走医保流程
  6621. var res2 ResultSix
  6622. var resSix10265 ResultSix10265
  6623. if miConfig.MdtrtareaAdmvs == "421300" {
  6624. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6625. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6626. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6627. resp3, requestErr3 := http.Get(api3)
  6628. if requestErr3 != nil {
  6629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6630. return
  6631. }
  6632. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6633. if ioErr3 != nil {
  6634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6636. return
  6637. }
  6638. var respJSON3 map[string]interface{}
  6639. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6642. return
  6643. }
  6644. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6645. userJSONBytes3, _ := json.Marshal(respJSON3)
  6646. fmt.Println("log")
  6647. fmt.Println(string(userJSONBytes3))
  6648. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6649. utils.ErrorLog("解析失败:%v", err)
  6650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6651. return
  6652. }
  6653. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6654. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6655. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6656. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6657. resp3, requestErr3 := http.Get(api3)
  6658. if requestErr3 != nil {
  6659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6660. return
  6661. }
  6662. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6663. if ioErr3 != nil {
  6664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6666. return
  6667. }
  6668. var respJSON3 map[string]interface{}
  6669. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6672. return
  6673. }
  6674. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6675. userJSONBytes3, _ := json.Marshal(respJSON3)
  6676. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6677. utils.ErrorLog("解析失败:%v", err)
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6682. res2.Output = resSix10265.Output
  6683. res2.ErrMsg = resSix10265.ErrMsg
  6684. res2.Cainfo = resSix10265.Cainfo
  6685. res2.WarnMsg = resSix10265.WarnMsg
  6686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6687. res2.Infcode = infocode
  6688. } else {
  6689. var api3 string
  6690. if miConfig.Code == "H15049901371" {
  6691. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6692. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6694. } else {
  6695. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6696. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6698. }
  6699. resp3, requestErr3 := http.Get(api3)
  6700. if requestErr3 != nil {
  6701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6702. return
  6703. }
  6704. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6705. if ioErr3 != nil {
  6706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. return
  6709. }
  6710. var respJSON3 map[string]interface{}
  6711. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6714. return
  6715. }
  6716. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6717. userJSONBytes3, _ := json.Marshal(respJSON3)
  6718. if miConfig.Code == "H15049901371" {
  6719. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6720. utils.ErrorLog("解析失败:%v", err)
  6721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6722. return
  6723. }
  6724. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6725. res2.Output = resSix10265.Output
  6726. res2.ErrMsg = resSix10265.ErrMsg
  6727. res2.Cainfo = resSix10265.Cainfo
  6728. res2.WarnMsg = resSix10265.WarnMsg
  6729. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6730. res2.Infcode = infocode
  6731. } else {
  6732. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6733. utils.ErrorLog("解析失败:%v", err)
  6734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6735. return
  6736. }
  6737. }
  6738. }
  6739. if res2.Infcode == 0 {
  6740. if err == nil {
  6741. c.ServeSuccessJSON(map[string]interface{}{
  6742. "msg": "退号成功",
  6743. })
  6744. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6745. } else {
  6746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6747. return
  6748. }
  6749. } else {
  6750. c.ServeSuccessJSON(map[string]interface{}{
  6751. "code": -10,
  6752. "msg": res2.ErrMsg,
  6753. })
  6754. }
  6755. } else {
  6756. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6757. //if err == nil {
  6758. // c.ServeSuccessJSON(map[string]interface{}{
  6759. // "msg": "退费成功",
  6760. // })
  6761. //} else {
  6762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6763. // return
  6764. //}
  6765. }
  6766. }
  6767. func (c *HisApiController) RefundDetail() {
  6768. order_id, _ := c.GetInt64("order_id")
  6769. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6770. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6771. number := c.GetString("number")
  6772. record_time := c.GetString("record_time")
  6773. patient_id, _ := c.GetInt64("patient_id")
  6774. timeLayout := "2006-01-02"
  6775. loc, _ := time.LoadLocation("Local")
  6776. adminUser := c.GetAdminUserInfo()
  6777. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6778. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6779. fmt.Println(err)
  6780. if err != nil {
  6781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6782. return
  6783. }
  6784. recordDateTime := theTime.Unix()
  6785. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6786. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6788. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6789. var order models.HisOrder
  6790. order, _ = service.GetHisOrderByID(order_id)
  6791. if order.ID == 0 {
  6792. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6793. }
  6794. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6795. if config.IsOpen == 1 { //对接了医保,走医保流程
  6796. var res2 ResultSix
  6797. if miConfig.MdtrtareaAdmvs == "421300" {
  6798. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6799. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6801. resp3, requestErr3 := http.Get(api3)
  6802. if requestErr3 != nil {
  6803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6804. return
  6805. }
  6806. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6807. if ioErr3 != nil {
  6808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6810. return
  6811. }
  6812. var respJSON3 map[string]interface{}
  6813. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6816. return
  6817. }
  6818. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6819. userJSONBytes3, _ := json.Marshal(respJSON3)
  6820. fmt.Println("log")
  6821. fmt.Println(string(userJSONBytes3))
  6822. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6823. utils.ErrorLog("解析失败:%v", err)
  6824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6825. return
  6826. }
  6827. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6828. if err == nil {
  6829. c.ServeSuccessJSON(map[string]interface{}{
  6830. "msg": "撤销明细成功",
  6831. })
  6832. return
  6833. } else {
  6834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6835. return
  6836. }
  6837. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6838. var resSix10265 ResultSix10265
  6839. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6840. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6841. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6842. resp3, requestErr3 := http.Get(api3)
  6843. if requestErr3 != nil {
  6844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6845. return
  6846. }
  6847. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6848. if ioErr3 != nil {
  6849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6851. return
  6852. }
  6853. var respJSON3 map[string]interface{}
  6854. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6857. return
  6858. }
  6859. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6860. userJSONBytes3, _ := json.Marshal(respJSON3)
  6861. fmt.Println("log")
  6862. fmt.Println(string(userJSONBytes3))
  6863. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6864. utils.ErrorLog("解析失败:%v", err)
  6865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6866. return
  6867. }
  6868. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6869. res2.Output = resSix10265.Output
  6870. res2.ErrMsg = resSix10265.ErrMsg
  6871. res2.Cainfo = resSix10265.Cainfo
  6872. res2.WarnMsg = resSix10265.WarnMsg
  6873. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6874. res2.Infcode = infocode
  6875. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6876. if err == nil {
  6877. c.ServeSuccessJSON(map[string]interface{}{
  6878. "msg": "撤销明细成功",
  6879. })
  6880. return
  6881. } else {
  6882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6883. return
  6884. }
  6885. } else {
  6886. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6887. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6889. resp2, requestErr2 := http.Get(api2)
  6890. if requestErr2 != nil {
  6891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6892. return
  6893. }
  6894. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6895. if ioErr2 != nil {
  6896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6898. return
  6899. }
  6900. var respJSON2 map[string]interface{}
  6901. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6904. return
  6905. }
  6906. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6907. if err == nil {
  6908. c.ServeSuccessJSON(map[string]interface{}{
  6909. "msg": "撤销明细成功",
  6910. })
  6911. return
  6912. } else {
  6913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6914. return
  6915. }
  6916. }
  6917. } else {
  6918. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6919. if err == nil {
  6920. c.ServeSuccessJSON(map[string]interface{}{
  6921. "msg": "退费成功",
  6922. })
  6923. } else {
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return
  6926. }
  6927. }
  6928. }
  6929. //对账
  6930. func (c *HisApiController) GetCheckAccount() {
  6931. start_time := c.GetString("start_time")
  6932. end_time := c.GetString("end_time")
  6933. insutype := c.GetString("insutype")
  6934. clr_type := c.GetString("clr_type")
  6935. clr_org := c.GetString("clr_optins")
  6936. admin_user_id, _ := c.GetInt64("admin_user_id")
  6937. adminUser := c.GetAdminUserInfo()
  6938. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6939. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6940. if len(clr_org) == 0 {
  6941. clr_org = miConfig.MdtrtareaAdmvs
  6942. }
  6943. timeLayout := "2006-01-02"
  6944. loc, _ := time.LoadLocation("Local")
  6945. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6946. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6947. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6948. fixmedins_setl_cnt := int64(len(orders))
  6949. var medfee_sumamt float64
  6950. var acct_pay float64
  6951. var fund_pay_sumamt float64
  6952. for _, item := range orders {
  6953. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6954. acct_pay = acct_pay + item.AcctPay
  6955. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6956. }
  6957. var user_name string
  6958. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6959. if role.ID == 0 {
  6960. user_name = "xxx"
  6961. } else {
  6962. user_name = role.UserName
  6963. }
  6964. var res ResultEight
  6965. var res10188 ResultEightFor10188
  6966. if config.IsOpen == 1 {
  6967. if miConfig.MdtrtareaAdmvs == "320921" {
  6968. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  6969. "insutype=" + insutype +
  6970. "&clr_type=" + clr_type +
  6971. "&setl_optins=" + clr_org +
  6972. "&stmt_begndate=" + start_time +
  6973. "&stm_enddate=" + end_time +
  6974. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6975. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6976. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6977. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6978. "&fixmedins_code=" + miConfig.Code +
  6979. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6980. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6981. "&secret_key=" + miConfig.SecretKey +
  6982. "&org_name=" + miConfig.OrgName +
  6983. "&doctor=" + user_name +
  6984. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6985. fmt.Println(api)
  6986. resp, requestErr := http.Get(api)
  6987. if requestErr != nil {
  6988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6989. return
  6990. }
  6991. body, ioErr := ioutil.ReadAll(resp.Body)
  6992. fmt.Println(body)
  6993. if ioErr != nil {
  6994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6996. return
  6997. }
  6998. var respJSON map[string]interface{}
  6999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7002. return
  7003. }
  7004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7005. userJSONBytes, _ := json.Marshal(respJSON)
  7006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7007. utils.ErrorLog("解析失败:%v", err)
  7008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7009. return
  7010. }
  7011. res.InfRefmsgid = res10188.InfRefmsgid
  7012. res.Output = res10188.Output
  7013. res.ErrMsg = res10188.ErrMsg
  7014. res.Cainfo = res10188.Cainfo
  7015. res.WarnMsg = res10188.WarnMsg
  7016. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7017. res.Infcode = infocode
  7018. } else {
  7019. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7020. "insutype=" + insutype +
  7021. "&clr_type=" + clr_type +
  7022. "&setl_optins=" + clr_org +
  7023. "&stmt_begndate=" + start_time +
  7024. "&stm_enddate=" + end_time +
  7025. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7026. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7027. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7028. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7029. "&fixmedins_code=" + miConfig.Code +
  7030. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7031. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7032. "&secret_key=" + miConfig.SecretKey +
  7033. "&org_name=" + miConfig.OrgName +
  7034. "&doctor=" + user_name
  7035. fmt.Println(api)
  7036. resp, requestErr := http.Get(api)
  7037. if requestErr != nil {
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. return
  7040. }
  7041. body, ioErr := ioutil.ReadAll(resp.Body)
  7042. fmt.Println(body)
  7043. if ioErr != nil {
  7044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. return
  7047. }
  7048. var respJSON map[string]interface{}
  7049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7055. userJSONBytes, _ := json.Marshal(respJSON)
  7056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7057. utils.ErrorLog("解析失败:%v", err)
  7058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7059. return
  7060. }
  7061. }
  7062. if res.Infcode == 0 {
  7063. if res.Output.Stmtinfo.StmtRslt == "0" {
  7064. micc := &models.MedicalInsuranceCostCompare{
  7065. StartTime: startime.Unix(),
  7066. EndTime: endtime.Unix(),
  7067. Insutype: insutype,
  7068. CheckType: 1,
  7069. Num: fixmedins_setl_cnt,
  7070. Mtime: time.Now().Unix(),
  7071. Status: 1,
  7072. UserOrgId: adminUser.CurrentOrgId,
  7073. CostTotal: medfee_sumamt,
  7074. FuncTotal: fund_pay_sumamt,
  7075. PsnPay: acct_pay,
  7076. Creator: admin_user_id,
  7077. Ctime: time.Now().Unix(),
  7078. }
  7079. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7080. if err == nil {
  7081. c.ServeSuccessJSON(map[string]interface{}{
  7082. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7083. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7084. })
  7085. } else {
  7086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7087. }
  7088. } else {
  7089. c.ServeSuccessJSON(map[string]interface{}{
  7090. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7091. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7092. })
  7093. }
  7094. } else {
  7095. c.ServeSuccessJSON(map[string]interface{}{
  7096. "code": -10,
  7097. "msg": res.ErrMsg,
  7098. })
  7099. }
  7100. }
  7101. }
  7102. func (c *HisApiController) Check310() {
  7103. adminUser := c.GetAdminUserInfo()
  7104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7105. var user_name string
  7106. user_name = "高慧裕"
  7107. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7108. "insutype=" + "310" +
  7109. "&clr_type=" + "11" +
  7110. "&setl_optins=" + "441202" +
  7111. "&stmt_begndate=" + "2022-02-01" +
  7112. "&stm_enddate=" + "2022-02-28" +
  7113. "&medfee_sumamt=" + "155812.88" +
  7114. "&fund_pay_sumamt=" + "151026.15" +
  7115. "&acct_pay=" + "0" +
  7116. "&fixmedins_setl_cnt=" + "73" +
  7117. "&fixmedins_code=" + miConfig.Code +
  7118. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7119. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7120. "&secret_key=" + miConfig.SecretKey +
  7121. "&org_name=" + miConfig.OrgName +
  7122. "&doctor=" + user_name
  7123. fmt.Println(api)
  7124. resp, requestErr := http.Get(api)
  7125. if requestErr != nil {
  7126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7127. return
  7128. }
  7129. body, ioErr := ioutil.ReadAll(resp.Body)
  7130. fmt.Println(body)
  7131. if ioErr != nil {
  7132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7134. return
  7135. }
  7136. var respJSON map[string]interface{}
  7137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. return
  7141. }
  7142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7143. userJSONBytes, _ := json.Marshal(respJSON)
  7144. var res ResultEight
  7145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7146. utils.ErrorLog("解析失败:%v", err)
  7147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7148. return
  7149. }
  7150. }
  7151. func (c *HisApiController) Check390() {
  7152. adminUser := c.GetAdminUserInfo()
  7153. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7154. var user_name string
  7155. user_name = "高慧裕"
  7156. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7157. "insutype=" + "390" +
  7158. "&clr_type=" + "11" +
  7159. "&setl_optins=" + "441202" +
  7160. "&stmt_begndate=" + "2022-02-01" +
  7161. "&stm_enddate=" + "2022-02-28" +
  7162. "&medfee_sumamt=" + "933920.08" +
  7163. "&fund_pay_sumamt=" + "887153.34" +
  7164. "&acct_pay=" + "0" +
  7165. "&fixmedins_setl_cnt=" + "396" +
  7166. "&fixmedins_code=" + miConfig.Code +
  7167. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7168. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7169. "&secret_key=" + miConfig.SecretKey +
  7170. "&org_name=" + miConfig.OrgName +
  7171. "&doctor=" + user_name
  7172. fmt.Println(api)
  7173. resp, requestErr := http.Get(api)
  7174. if requestErr != nil {
  7175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7176. return
  7177. }
  7178. body, ioErr := ioutil.ReadAll(resp.Body)
  7179. fmt.Println(body)
  7180. if ioErr != nil {
  7181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. return
  7184. }
  7185. var respJSON map[string]interface{}
  7186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7189. return
  7190. }
  7191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7192. userJSONBytes, _ := json.Marshal(respJSON)
  7193. var res ResultEight
  7194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7195. utils.ErrorLog("解析失败:%v", err)
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. }
  7200. //对账明细
  7201. func (c *HisApiController) GetCheckDetailAccount() {
  7202. start_time := c.GetString("start_time")
  7203. end_time := c.GetString("end_time")
  7204. admin_user_id, _ := c.GetInt64("admin_user_id")
  7205. adminUser := c.GetAdminUserInfo()
  7206. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7207. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7208. timeLayout := "2006-01-02"
  7209. loc, _ := time.LoadLocation("Local")
  7210. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7211. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7212. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7213. Mkdir(miConfig.OrgName)
  7214. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7215. file_name := file + ".txt"
  7216. zip_name := file + ".zip"
  7217. zip_path := miConfig.OrgName + "/" + zip_name
  7218. file_path := miConfig.OrgName + "/" + file_name
  7219. decimal.DivisionPrecision = 2
  7220. var medfee_sumamt float64
  7221. var psn_cash_pay float64
  7222. var fund_pay_sumamt float64
  7223. fixmedins_setl_cnt := int64(len(orders))
  7224. for _, item := range orders {
  7225. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7226. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7227. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7228. }
  7229. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7230. defer f.Close()
  7231. if err != nil {
  7232. fmt.Println(err.Error())
  7233. } else {
  7234. for _, item := range orders {
  7235. var refd_setl_flag string
  7236. if item.OrderStatus == 2 {
  7237. refd_setl_flag = "0"
  7238. var str string
  7239. str = item.SetlId + " " +
  7240. item.MdtrtId + " " +
  7241. item.PsnNo + " " +
  7242. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7243. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7244. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7245. _, err = f.Write([]byte(str))
  7246. }
  7247. if item.OrderStatus == 3 {
  7248. var str string
  7249. str = item.SetlId + " " +
  7250. item.MdtrtId + " " +
  7251. item.PsnNo + " " +
  7252. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7253. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7254. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7255. _, err = f.Write([]byte(str))
  7256. var str2 string
  7257. str2 = item.SetlId + " " +
  7258. item.MdtrtId + " " +
  7259. item.PsnNo + " " +
  7260. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7261. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7262. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7263. _, err = f.Write([]byte(str2))
  7264. }
  7265. }
  7266. }
  7267. Zip(file_path, zip_path)
  7268. fmt.Println(ReadFile(zip_path))
  7269. fmt.Println(string(ReadFile(zip_path)))
  7270. if config.IsOpen == 1 {
  7271. var user_name string
  7272. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7273. if role.ID == 0 {
  7274. user_name = "管理员"
  7275. } else {
  7276. user_name = role.UserName
  7277. }
  7278. baseParams := models.BaseParams{
  7279. SecretKey: miConfig.SecretKey,
  7280. FixmedinsCode: miConfig.Code,
  7281. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7282. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7283. OrgName: miConfig.OrgName,
  7284. Doctor: user_name,
  7285. }
  7286. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7287. var dat map[string]interface{}
  7288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7289. fmt.Println(dat)
  7290. } else {
  7291. fmt.Println(err)
  7292. }
  7293. userJSONBytes, _ := json.Marshal(dat)
  7294. var res ResultNine
  7295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7296. utils.ErrorLog("解析失败:%v", err)
  7297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7298. return
  7299. }
  7300. if res.Infcode == 0 {
  7301. fileNo := res.Output.FileQuryNo
  7302. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7303. "file_qury_no=" + fileNo +
  7304. "&setl_optins=" + "定点医保中心" +
  7305. "&stmt_begndate=" + start_time +
  7306. "&stm_enddate=" + end_time +
  7307. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7308. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7309. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7310. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7311. "&fixmedins_code=" + miConfig.Code +
  7312. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7313. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7314. "&secret_key=" + miConfig.SecretKey +
  7315. "&org_name=" + miConfig.OrgName +
  7316. "&doctor=" + user_name
  7317. resp, requestErr := http.Get(api)
  7318. if requestErr != nil {
  7319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7320. return
  7321. }
  7322. body, ioErr := ioutil.ReadAll(resp.Body)
  7323. if ioErr != nil {
  7324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7326. return
  7327. }
  7328. var respJSON map[string]interface{}
  7329. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7332. return
  7333. }
  7334. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7335. userJSONBytes, _ := json.Marshal(respJSON)
  7336. var res ResultTen
  7337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7338. utils.ErrorLog("解析失败:%v", err)
  7339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7340. return
  7341. }
  7342. if res.Infcode == 0 {
  7343. service.Gdyb9102(baseParams, zip_name, fileNo)
  7344. micc := &models.MedicalInsuranceCostCompare{
  7345. StartTime: startime.Unix(),
  7346. EndTime: endtime.Unix(),
  7347. Insutype: "0",
  7348. CheckType: 2,
  7349. Num: fixmedins_setl_cnt,
  7350. Mtime: time.Now().Unix(),
  7351. Status: 1,
  7352. UserOrgId: adminUser.CurrentOrgId,
  7353. CostTotal: medfee_sumamt,
  7354. FuncTotal: fund_pay_sumamt,
  7355. PsnPay: psn_cash_pay,
  7356. Creator: admin_user_id,
  7357. Ctime: time.Now().Unix(),
  7358. }
  7359. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7360. c.ServeSuccessJSON(map[string]interface{}{
  7361. "msg": "明细对账成功",
  7362. })
  7363. }
  7364. } else {
  7365. }
  7366. }
  7367. }
  7368. type CustomOrderInfo struct {
  7369. Name string
  7370. Spec string
  7371. Unit string
  7372. Count float64
  7373. Price float64
  7374. Total float64
  7375. }
  7376. func (c *HisApiController) GetSettleAccounts() {
  7377. //id, _ := c.GetInt64("id")
  7378. //record_time := c.GetString("record_time")
  7379. order_id, _ := c.GetInt64("order_id")
  7380. admin_user_id, _ := c.GetInt64("admin_user_id")
  7381. //timeLayout := "2006-01-02"
  7382. //loc, _ := time.LoadLocation("Local")
  7383. //
  7384. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7385. //if err != nil {
  7386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7387. // return
  7388. //}
  7389. //recordDateTime := theTime.Unix()
  7390. adminUser := c.GetAdminUserInfo()
  7391. order, _ := service.GetHisOrderByID(order_id)
  7392. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7393. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7394. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7395. orderInfos = append(orderInfos, orderInfos_two...)
  7396. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7397. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7398. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7399. //var config []*models.HisXtDiagnoseConfig
  7400. var name string
  7401. for _, item := range diagnosis_ids {
  7402. id, _ := strconv.ParseInt(item, 10, 64)
  7403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7404. if len(name) == 0 {
  7405. name = diagnosisConfig.ClassName
  7406. } else {
  7407. name = name + "," + diagnosisConfig.ClassName
  7408. }
  7409. }
  7410. var bedCostTotal float64 = 0 //床位总费
  7411. var bedCostSelfTotal float64 = 0 //床位自费
  7412. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7413. var operationCostTotal float64 = 0 //手术费
  7414. var operationCostSelfTotal float64 = 0 //手术费
  7415. var operationCostPartSelfTotal float64 = 0 //手术费
  7416. var otherCostTotal float64 = 0 //其他费用
  7417. var otherCostSelfTotal float64 = 0 //其他费用
  7418. var otherCostPartSelfTotal float64 = 0 //其他费用
  7419. var materialCostTotal float64 = 0 //材料费
  7420. var materialCostSelfTotal float64 = 0 //材料费
  7421. var materialCostPartSelfTotal float64 = 0 //材料费
  7422. var westernMedicineCostTotal float64 = 0 //西药费
  7423. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7424. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7425. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7426. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7427. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7428. var checkCostTotal float64 = 0 //检查费
  7429. var checkCostSelfTotal float64 = 0 //检查费
  7430. var checkCostPartSelfTotal float64 = 0 //检查费
  7431. var laboratoryCostTotal float64 = 0 //化验费
  7432. var laboratoryCostSelfTotal float64 = 0 //化验费
  7433. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7434. var treatCostTotal float64 = 0 //治疗费用
  7435. var treatCostSelfTotal float64 = 0 //治疗费用
  7436. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7437. decimal.DivisionPrecision = 2
  7438. for _, item := range orderInfos {
  7439. if item.MedChrgitmType == "01" { //床位费
  7440. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7441. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7442. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7443. }
  7444. if item.MedChrgitmType == "03" { //检查费
  7445. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7446. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7447. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7448. }
  7449. if item.MedChrgitmType == "04" { //化验费
  7450. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7451. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7452. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7453. }
  7454. if item.MedChrgitmType == "05" { //治疗费
  7455. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7456. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7457. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7458. }
  7459. if item.MedChrgitmType == "06" { //手术费
  7460. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7461. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7462. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7463. }
  7464. if item.MedChrgitmType == "08" { //材料费
  7465. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7466. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7467. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7468. }
  7469. if item.MedChrgitmType == "09" { //西药费
  7470. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7471. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7472. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7473. }
  7474. if item.MedChrgitmType == "11" { //中成费
  7475. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7476. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7477. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7478. }
  7479. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7480. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7481. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7482. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7483. }
  7484. }
  7485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7486. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7487. var user_name string
  7488. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7489. if role.ID == 0 {
  7490. user_name = "管理员"
  7491. } else {
  7492. user_name = role.UserName
  7493. }
  7494. baseParams := models.BaseParams{
  7495. SecretKey: miConfig.SecretKey,
  7496. FixmedinsCode: miConfig.Code,
  7497. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7498. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7499. OrgName: miConfig.OrgName,
  7500. Doctor: user_name,
  7501. }
  7502. businessParams := models.BusinessParams{
  7503. PsnNo: order.PsnNo,
  7504. MdtrtId: order.MdtrtId,
  7505. SetlId: order.SetlId,
  7506. }
  7507. var res ResultEleven
  7508. var resEleven10265 ResultEleven10265
  7509. if config.IsOpen == 1 {
  7510. if miConfig.MdtrtareaAdmvs == "421300" {
  7511. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7512. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7513. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7514. resp, requestErr := http.Get(api)
  7515. if requestErr != nil {
  7516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7517. return
  7518. }
  7519. body, ioErr := ioutil.ReadAll(resp.Body)
  7520. if ioErr != nil {
  7521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7523. return
  7524. }
  7525. var respJSON map[string]interface{}
  7526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7529. return
  7530. }
  7531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7532. result, _ := json.Marshal(respJSON)
  7533. fmt.Println("log")
  7534. fmt.Println(string(result))
  7535. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7536. utils.ErrorLog("解析失败:%v", err)
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7538. return
  7539. }
  7540. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7541. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7542. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7543. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7544. resp, requestErr := http.Get(api)
  7545. if requestErr != nil {
  7546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7547. return
  7548. }
  7549. body, ioErr := ioutil.ReadAll(resp.Body)
  7550. if ioErr != nil {
  7551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. return
  7554. }
  7555. var respJSON map[string]interface{}
  7556. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7559. return
  7560. }
  7561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7562. result, _ := json.Marshal(respJSON)
  7563. fmt.Println("log")
  7564. fmt.Println(string(result))
  7565. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7566. utils.ErrorLog("解析失败:%v", err)
  7567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7568. return
  7569. }
  7570. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7571. res.Output = resEleven10265.Output
  7572. res.ErrMsg = resEleven10265.ErrMsg
  7573. res.Cainfo = resEleven10265.Cainfo
  7574. res.WarnMsg = resEleven10265.WarnMsg
  7575. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7576. res.Infcode = infocode
  7577. } else {
  7578. result2 := service.Gdyb5204(baseParams, businessParams)
  7579. saveLog(result2, "", "5204", "查询")
  7580. result := service.Gdyb5203(baseParams, businessParams)
  7581. var dat map[string]interface{}
  7582. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7583. fmt.Println(dat)
  7584. } else {
  7585. fmt.Println(err)
  7586. }
  7587. userJSONBytes, _ := json.Marshal(dat)
  7588. if miConfig.Code == "H15049901371" {
  7589. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7590. utils.ErrorLog("解析失败:%v", err)
  7591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7592. return
  7593. }
  7594. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7595. res.Output = resEleven10265.Output
  7596. res.ErrMsg = resEleven10265.ErrMsg
  7597. res.Cainfo = resEleven10265.Cainfo
  7598. res.WarnMsg = resEleven10265.WarnMsg
  7599. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7600. res.Infcode = infocode
  7601. } else {
  7602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7603. utils.ErrorLog("解析失败:%v", err)
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7605. return
  7606. }
  7607. }
  7608. }
  7609. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7610. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7611. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7612. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7613. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7614. var doctor_name string
  7615. if roles.ID == 0 {
  7616. doctor_name = "管理员"
  7617. } else {
  7618. doctor_name = roles.UserName
  7619. }
  7620. yiliao_leibie := ""
  7621. switch order.MedType {
  7622. case "11":
  7623. yiliao_leibie = "普通门诊"
  7624. break
  7625. case "12":
  7626. yiliao_leibie = "门诊挂号"
  7627. break
  7628. case "13":
  7629. yiliao_leibie = "急诊"
  7630. break
  7631. case "14":
  7632. yiliao_leibie = "门诊特殊病"
  7633. break
  7634. case "15":
  7635. yiliao_leibie = "门诊统筹"
  7636. break
  7637. case "16":
  7638. yiliao_leibie = "门诊慢性病"
  7639. break
  7640. case "21":
  7641. yiliao_leibie = "普通住院"
  7642. break
  7643. }
  7644. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7645. if res.Infcode == 0 {
  7646. c.ServeSuccessJSON(map[string]interface{}{
  7647. "diagnosis": name,
  7648. "order_infos": orderInfos,
  7649. "number": order.MdtrtId,
  7650. "date": order.SettleAccountsDate,
  7651. "charge_admin": charge_admin,
  7652. "printor_admin": printor_admin,
  7653. "info": res.Output.Setlinfo,
  7654. "bedCostTotal": bedCostTotal,
  7655. "bedCostSelfTotal": bedCostSelfTotal,
  7656. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7657. "operationCostTotal": operationCostTotal,
  7658. "operationCostSelfTotal": operationCostSelfTotal,
  7659. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7660. "otherCostTotal": otherCostTotal,
  7661. "otherCostSelfTotal": otherCostSelfTotal,
  7662. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7663. "materialCostTotal": materialCostTotal,
  7664. "materialCostSelfTotal": materialCostSelfTotal,
  7665. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7666. "westernMedicineCostTotal": westernMedicineCostTotal,
  7667. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7668. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7669. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7670. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7671. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7672. "checkCostTotal": checkCostTotal,
  7673. "checkCostSelfTotal": checkCostSelfTotal,
  7674. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7675. "laboratoryCostTotal": laboratoryCostTotal,
  7676. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7677. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7678. "treatCostTotal": treatCostTotal,
  7679. "treatCostSelfTotal": treatCostSelfTotal,
  7680. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7681. "doctor_code": adminRole_two.DoctorCode,
  7682. "doctor_name": doctor_name,
  7683. "health_card_no": order.PsnNo,
  7684. "department": departments.Name,
  7685. "yiliao_leibie": yiliao_leibie,
  7686. "after_money": order.AccountPrice,
  7687. "patient": patient,
  7688. "org_name": miConfig.OrgName,
  7689. "org_code": miConfig.Code,
  7690. "order_number": order.Number,
  7691. //"check_order_info": cus_slice,
  7692. })
  7693. }
  7694. }
  7695. }
  7696. func (c *HisApiController) CheckTreatment() {
  7697. patient_id, _ := c.GetInt64("patient_id")
  7698. id_card_no := c.GetString("id_card_no")
  7699. insutype := c.GetString("insutype")
  7700. med_type := c.GetString("med_type")
  7701. admin_user_id, _ := c.GetInt64("admin_user_id")
  7702. adminUser := c.GetAdminUserInfo()
  7703. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7705. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7706. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7707. if miConfig.MdtrtareaAdmvs == "421300" {
  7708. var res ResultTwo
  7709. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7710. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7711. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(2, 10)
  7712. resp, requestErr := http.Get(api)
  7713. if requestErr != nil {
  7714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7715. return
  7716. }
  7717. body, ioErr := ioutil.ReadAll(resp.Body)
  7718. if ioErr != nil {
  7719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7721. return
  7722. }
  7723. var respJSON map[string]interface{}
  7724. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7727. return
  7728. }
  7729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7730. result, _ := json.Marshal(respJSON)
  7731. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7732. utils.ErrorLog("解析失败:%v", err)
  7733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7734. return
  7735. }
  7736. if res.Infcode == 0 {
  7737. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7738. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7739. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7740. resp, requestErr := http.Get(api)
  7741. if requestErr != nil {
  7742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7743. return
  7744. }
  7745. body, ioErr := ioutil.ReadAll(resp.Body)
  7746. if ioErr != nil {
  7747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7749. return
  7750. }
  7751. var respJSON map[string]interface{}
  7752. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7755. return
  7756. }
  7757. var res Result2001
  7758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7759. result2, _ := json.Marshal(respJSON)
  7760. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7761. utils.ErrorLog("解析失败:%v", err)
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7763. return
  7764. }
  7765. if res.Infcode == 0 {
  7766. c.ServeSuccessJSON(map[string]interface{}{
  7767. "msg": res.Output.Trtinfo,
  7768. })
  7769. }
  7770. } else {
  7771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7772. return
  7773. }
  7774. } else {
  7775. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7776. var dat map[string]interface{}
  7777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7778. fmt.Println(dat)
  7779. } else {
  7780. fmt.Println(err)
  7781. }
  7782. userJSONBytes, _ := json.Marshal(dat)
  7783. var res ResultTwo
  7784. var res10265 ResultTwo10265
  7785. if miConfig.Code == "H15049901371" {
  7786. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7787. utils.ErrorLog("解析失败:%v", err)
  7788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7789. return
  7790. }
  7791. res.ErrMsg = res10265.ErrMsg
  7792. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7793. res.Infcode = infocode
  7794. res.Output = res10265.Output
  7795. res.InfRefmsgid = res10265.InfRefmsgid
  7796. } else {
  7797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7798. utils.ErrorLog("解析失败:%v", err)
  7799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7800. return
  7801. }
  7802. }
  7803. var user_name string
  7804. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7805. if role.ID == 0 {
  7806. user_name = "xxx"
  7807. } else {
  7808. user_name = role.UserName
  7809. }
  7810. baseParams := models.BaseParams{
  7811. SecretKey: miConfig.SecretKey,
  7812. FixmedinsCode: miConfig.Code,
  7813. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7814. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7815. OrgName: miConfig.OrgName,
  7816. Doctor: user_name,
  7817. }
  7818. if config.IsOpen == 1 {
  7819. if miConfig.Code == "H15049901371" {
  7820. if med_type == "14" {
  7821. if insutype == "390" {
  7822. med_type = "9933"
  7823. } else if insutype == "310" {
  7824. med_type = "990502"
  7825. }
  7826. } else if med_type == "11" {
  7827. med_type = "11"
  7828. }
  7829. }
  7830. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7831. var dat map[string]interface{}
  7832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7833. fmt.Println(dat)
  7834. } else {
  7835. fmt.Println(err)
  7836. }
  7837. var res Result2001
  7838. var res10265 Result2001Org10265
  7839. if miConfig.Code == "H15049901371" {
  7840. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7841. utils.ErrorLog("解析失败:%v", err)
  7842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7843. return
  7844. }
  7845. res.ErrMsg = res10265.ErrMsg
  7846. res.Output = res10265.Output
  7847. res.InfRefmsgid = res10265.InfRefmsgid
  7848. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7849. res.Infcode = infocode
  7850. } else {
  7851. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7852. utils.ErrorLog("解析失败:%v", err)
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7854. return
  7855. }
  7856. }
  7857. if res.Infcode == 0 {
  7858. c.ServeSuccessJSON(map[string]interface{}{
  7859. "msg": res.Output.Trtinfo,
  7860. })
  7861. }
  7862. }
  7863. }
  7864. }
  7865. //func (c *HisApiController) PutRecord() {
  7866. // id, _ := c.GetInt64("id")
  7867. // record_time := c.GetString("record_time")
  7868. // timeLayout := "2006-01-02"
  7869. // loc, _ := time.LoadLocation("Local")
  7870. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7871. // if err != nil {
  7872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7873. // return
  7874. // }
  7875. // recordDateTime := theTime.Unix()
  7876. //
  7877. // adminInfo := c.GetAdminUserInfo()
  7878. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7879. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7880. //
  7881. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7882. //
  7883. // fmt.Println(miConfig.SecretKey)
  7884. //
  7885. // if patient == nil {
  7886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7887. // return
  7888. // }
  7889. // if len(patient.IdCardNo) == 0 {
  7890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7891. // return
  7892. // }
  7893. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7894. // if config.IsOpen == 1 {
  7895. // 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
  7896. // resp, requestErr := http.Get(api)
  7897. // if requestErr != nil {
  7898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7899. // return
  7900. // }
  7901. // defer resp.Body.Close()
  7902. // body, ioErr := ioutil.ReadAll(resp.Body)
  7903. // if ioErr != nil {
  7904. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. // return
  7907. // }
  7908. // var respJSON map[string]interface{}
  7909. //
  7910. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7911. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7913. // return
  7914. // }
  7915. //
  7916. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7917. // userJSONBytes, _ := json.Marshal(userJSON)
  7918. // var res ResultTwo
  7919. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7920. // utils.ErrorLog("解析失败:%v", err)
  7921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7922. // return
  7923. // }
  7924. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7925. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7926. // infoStr := string(Iinfos)
  7927. // idetinfoStr := string(Idetinfos)
  7928. //
  7929. // if res.Infcode == 0 {
  7930. // his := models.VMHisPatient{
  7931. // Status: 1,
  7932. // Ctime: time.Now().Unix(),
  7933. // Mtime: time.Now().Unix(),
  7934. // PsnNo: res.Output.Baseinfo.PsnNo,
  7935. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7936. // Certno: res.Output.Baseinfo.Certno,
  7937. // PsnName: res.Output.Baseinfo.PsnName,
  7938. // Gend: res.Output.Baseinfo.Gend,
  7939. // Naty: res.Output.Baseinfo.Naty,
  7940. // Brdy: res.Output.Baseinfo.Brdy,
  7941. // Age: res.Output.Baseinfo.Age,
  7942. // Iinfo: infoStr,
  7943. // Idetinfo: idetinfoStr,
  7944. // PatientId: patient.ID,
  7945. // RecordDate: theTime.Unix(),
  7946. // UserOrgId: adminInfo.CurrentOrgId,
  7947. // AdminUserId: adminInfo.AdminUser.Id,
  7948. // IsReturn: 1,
  7949. // }
  7950. //
  7951. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7952. // //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")
  7953. // //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")
  7954. //
  7955. // //var dat map[string]interface{}
  7956. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7957. // // fmt.Println(dat)
  7958. // //} else {
  7959. // // fmt.Println(err)
  7960. // //}
  7961. //
  7962. // var dat2 map[string]interface{}
  7963. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7964. // fmt.Println(dat2)
  7965. // } else {
  7966. // fmt.Println(err)
  7967. // }
  7968. //
  7969. // } else {
  7970. // adminUser := c.GetAdminUserInfo()
  7971. // errlog := &models.HisOrderError{
  7972. // UserOrgId: adminUser.CurrentOrgId,
  7973. // Ctime: time.Now().Unix(),
  7974. // Mtime: time.Now().Unix(),
  7975. // ErrMsg: res.ErrMsg,
  7976. // Status: 1,
  7977. // PatientId: id,
  7978. // RecordTime: recordDateTime,
  7979. // Stage: 1,
  7980. // }
  7981. // service.CreateErrMsgLog(errlog)
  7982. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7983. // return
  7984. // }
  7985. // }
  7986. //
  7987. //}
  7988. //func (c *HisApiController) GetUploadDiag() {
  7989. // id, _ := c.GetInt64("id")
  7990. // record_time := c.GetString("record_time")
  7991. //
  7992. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7993. // sick_type, _ := c.GetInt64("sick_type")
  7994. // reg_type, _ := c.GetInt64("reg_type")
  7995. //
  7996. // timeLayout := "2006-01-02"
  7997. // loc, _ := time.LoadLocation("Local")
  7998. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7999. // if err != nil {
  8000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8001. // return
  8002. // }
  8003. //
  8004. // var patientPrescription models.HisPrescriptionInfo
  8005. // recordDateTime := theTime.Unix()
  8006. // adminInfo := c.GetAdminUserInfo()
  8007. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8008. //
  8009. // if patientPrescription.ID == 0 {
  8010. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8011. // }
  8012. //
  8013. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8014. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8015. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8016. // sickConfig, _ := service.FindSickById(sick_type)
  8017. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8018. //
  8019. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8020. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8021. // "&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 +
  8022. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8023. // resp2, requestErr2 := http.Get(api2)
  8024. // if requestErr2 != nil {
  8025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8026. // return
  8027. // }
  8028. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8029. // if ioErr2 != nil {
  8030. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8032. // return
  8033. // }
  8034. // var respJSON2 map[string]interface{}
  8035. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8036. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8037. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8038. // return
  8039. // }
  8040. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8041. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8042. //
  8043. // var res2 ResultSix
  8044. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8045. // utils.ErrorLog("解析失败:%v", err)
  8046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8047. // return
  8048. // }
  8049. // if res2.Infcode != 0 {
  8050. // adminUser := c.GetAdminUserInfo()
  8051. // errlog := &models.HisOrderError{
  8052. // UserOrgId: adminUser.CurrentOrgId,
  8053. // Ctime: time.Now().Unix(),
  8054. // Mtime: time.Now().Unix(),
  8055. // ErrMsg: res2.ErrMsg,
  8056. // Status: 1,
  8057. // PatientId: id,
  8058. // RecordTime: recordDateTime,
  8059. // Stage: 3,
  8060. // }
  8061. // service.CreateErrMsgLog(errlog)
  8062. //
  8063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8064. // return
  8065. // }
  8066. //
  8067. // c.ServeSuccessJSON(map[string]interface{}{
  8068. // "msg": "上传成功",
  8069. // })
  8070. //
  8071. //}
  8072. type QueryResult struct {
  8073. ID int64
  8074. Name string
  8075. Code string
  8076. List_type_code string
  8077. }
  8078. func (c *HisApiController) GetCheckCode() {
  8079. ids_str := c.GetString("ids")
  8080. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8081. ids_arr := strings.Split(ids_str, ",")
  8082. var queryResult []QueryResult
  8083. ids := make([]int64, 0)
  8084. for _, item := range ids_arr {
  8085. id, _ := strconv.ParseInt(item, 10, 64)
  8086. ids = append(ids, id)
  8087. }
  8088. if record_type == 1 {
  8089. drugs, _ := service.GetBatchDrugList(ids)
  8090. for _, item := range drugs {
  8091. result := QueryResult{
  8092. ID: item.ID,
  8093. Name: item.DrugName,
  8094. Code: item.MedicalInsuranceNumber,
  8095. List_type_code: "101",
  8096. }
  8097. queryResult = append(queryResult, result)
  8098. }
  8099. } else if record_type == 2 {
  8100. goods, _ := service.GetBatchGoodInformationList(ids)
  8101. for _, item := range goods {
  8102. result := QueryResult{
  8103. ID: item.ID,
  8104. Name: item.GoodName,
  8105. Code: item.MedicalInsuranceNumber,
  8106. List_type_code: "301",
  8107. }
  8108. queryResult = append(queryResult, result)
  8109. }
  8110. } else if record_type == 3 {
  8111. projects, _ := service.GetBathchMyPorjecgList(ids)
  8112. for _, item := range projects {
  8113. result := QueryResult{
  8114. ID: item.ID,
  8115. Name: item.ProjectName,
  8116. Code: item.MedicalCode,
  8117. List_type_code: "201",
  8118. }
  8119. queryResult = append(queryResult, result)
  8120. }
  8121. }
  8122. admin_user_id, _ := c.GetInt64("admin_user_id")
  8123. adminUser := c.GetAdminUserInfo()
  8124. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8125. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8126. var user_name string
  8127. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8128. if role.ID == 0 {
  8129. user_name = "xxx"
  8130. } else {
  8131. user_name = role.UserName
  8132. }
  8133. baseParams := &models.BaseParams{
  8134. SecretKey: miConfig.SecretKey,
  8135. FixmedinsCode: miConfig.Code,
  8136. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8137. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8138. OrgName: miConfig.OrgName,
  8139. Doctor: user_name,
  8140. }
  8141. if config.IsOpen == 1 {
  8142. for _, item := range queryResult {
  8143. var result string
  8144. if record_type == 1 {
  8145. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8146. } else if record_type == 2 {
  8147. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8148. } else if record_type == 3 {
  8149. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8150. }
  8151. var dat map[string]interface{}
  8152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8153. fmt.Println(dat)
  8154. } else {
  8155. fmt.Println(err)
  8156. }
  8157. userJSONBytes, _ := json.Marshal(dat)
  8158. var res ResultSix
  8159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8160. utils.ErrorLog("解析失败:%v", err)
  8161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8162. return
  8163. }
  8164. if res.Infcode == 0 {
  8165. if record_type == 1 {
  8166. service.UpdateBaseDrugById(item.ID)
  8167. } else if record_type == 2 {
  8168. service.UpdateGoodInformaitonByDetail(item.ID)
  8169. } else if record_type == 3 {
  8170. service.UpdateProjectById(item.ID)
  8171. }
  8172. c.ServeSuccessJSON(map[string]interface{}{
  8173. "failed_code": 0,
  8174. "msg": "目录对照成功",
  8175. })
  8176. } else {
  8177. c.ServeSuccessJSON(map[string]interface{}{
  8178. "failed_code": -10,
  8179. "msg": res.ErrMsg,
  8180. })
  8181. }
  8182. }
  8183. }
  8184. }
  8185. func (c *HisApiController) UnCheckCode() {
  8186. ids_str := c.GetString("ids")
  8187. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8188. admin_user_id, _ := c.GetInt64("admin_user_id")
  8189. ids_arr := strings.Split(ids_str, ",")
  8190. var queryResult []QueryResult
  8191. ids := make([]int64, 0)
  8192. for _, item := range ids_arr {
  8193. id, _ := strconv.ParseInt(item, 10, 64)
  8194. ids = append(ids, id)
  8195. }
  8196. if record_type == 1 {
  8197. drugs, _ := service.GetBatchDrugList(ids)
  8198. for _, item := range drugs {
  8199. result := QueryResult{
  8200. ID: item.ID,
  8201. Name: item.DrugName,
  8202. Code: item.MedicalInsuranceNumber,
  8203. List_type_code: "101",
  8204. }
  8205. queryResult = append(queryResult, result)
  8206. }
  8207. } else if record_type == 2 {
  8208. goods, _ := service.GetBatchGoodInformationList(ids)
  8209. for _, item := range goods {
  8210. result := QueryResult{
  8211. ID: item.ID,
  8212. Name: item.GoodName,
  8213. Code: item.MedicalInsuranceNumber,
  8214. List_type_code: "301",
  8215. }
  8216. queryResult = append(queryResult, result)
  8217. }
  8218. } else if record_type == 3 {
  8219. projects, _ := service.GetBathchMyPorjecgList(ids)
  8220. for _, item := range projects {
  8221. result := QueryResult{
  8222. ID: item.ID,
  8223. Name: item.ProjectName,
  8224. Code: item.MedicalCode,
  8225. List_type_code: "201",
  8226. }
  8227. queryResult = append(queryResult, result)
  8228. }
  8229. }
  8230. adminUser := c.GetAdminUserInfo()
  8231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8232. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8233. var user_name string
  8234. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8235. if role.ID == 0 {
  8236. user_name = "xxx"
  8237. } else {
  8238. user_name = role.UserName
  8239. }
  8240. baseParams := &models.BaseParams{
  8241. SecretKey: miConfig.SecretKey,
  8242. FixmedinsCode: miConfig.Code,
  8243. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8244. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8245. OrgName: miConfig.OrgName,
  8246. Doctor: user_name,
  8247. }
  8248. if config.IsOpen == 1 {
  8249. for _, item := range queryResult {
  8250. var result string
  8251. if record_type == 1 {
  8252. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8253. } else if record_type == 2 {
  8254. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8255. } else if record_type == 3 {
  8256. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8257. }
  8258. var dat2 map[string]interface{}
  8259. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8260. fmt.Println(dat2)
  8261. } else {
  8262. fmt.Println(err)
  8263. }
  8264. userJSONBytes, _ := json.Marshal(dat2)
  8265. var res ResultSix
  8266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8267. utils.ErrorLog("解析失败:%v", err)
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8269. return
  8270. }
  8271. if res.Infcode == 0 {
  8272. if record_type == 1 {
  8273. service.UpdateDrugByIdDetail(item.ID)
  8274. } else if record_type == 2 {
  8275. service.UpdateGoodInfoById(item.ID)
  8276. } else if record_type == 3 {
  8277. service.UpdateMyProjectById(item.ID)
  8278. }
  8279. c.ServeSuccessJSON(map[string]interface{}{
  8280. "failed_code": 0,
  8281. "msg": "撤销目录对照成功",
  8282. })
  8283. } else {
  8284. c.ServeSuccessJSON(map[string]interface{}{
  8285. "failed_code": -10,
  8286. "msg": res.ErrMsg,
  8287. })
  8288. }
  8289. }
  8290. }
  8291. }
  8292. func (c *HisApiController) GetPatientInfo() {
  8293. id_card_no := c.GetString("id_card_no")
  8294. admin_user_id, _ := c.GetInt64("admin_user_id")
  8295. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8296. if patient.ID == 0 {
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8298. return
  8299. }
  8300. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8302. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8303. if config.IsOpen == 1 {
  8304. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8305. var dat map[string]interface{}
  8306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8307. fmt.Println(dat)
  8308. } else {
  8309. fmt.Println(err)
  8310. }
  8311. userJSONBytes, _ := json.Marshal(dat)
  8312. var res ResultTwo
  8313. var res10265 ResultTwo10265
  8314. if miConfig.Code == "H15049901371" {
  8315. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8316. utils.ErrorLog("解析失败:%v", err)
  8317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8318. return
  8319. }
  8320. res.ErrMsg = res10265.ErrMsg
  8321. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8322. res.Infcode = infocode
  8323. res.Output = res10265.Output
  8324. res.InfRefmsgid = res10265.InfRefmsgid
  8325. } else {
  8326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8327. utils.ErrorLog("解析失败:%v", err)
  8328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8329. return
  8330. }
  8331. }
  8332. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8333. // utils.ErrorLog("解析失败:%v", err)
  8334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8335. // return
  8336. //}
  8337. if res.Infcode != 0 {
  8338. c.ServeSuccessJSON(map[string]interface{}{
  8339. "failed_code": -10,
  8340. "msg": res.ErrMsg,
  8341. })
  8342. } else {
  8343. c.ServeSuccessJSON(map[string]interface{}{
  8344. "failed_code": 0,
  8345. "info": res,
  8346. })
  8347. }
  8348. }
  8349. }
  8350. func (c *HisApiController) PsnPutOnRecord() {
  8351. record_type, _ := c.GetInt64("type")
  8352. patient_id, _ := c.GetInt64("patient_id")
  8353. admin_user_id, _ := c.GetInt64("admin_user_id")
  8354. start_time := c.GetString("start_time")
  8355. end_time := c.GetString("end_time")
  8356. adminUser := c.GetAdminUserInfo()
  8357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8358. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8359. var patients []*models.Patients
  8360. if record_type == 1 { //全部备案
  8361. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8362. patients = append(patients, patient...)
  8363. } else { //单个备案
  8364. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8365. patients = append(patients, patient)
  8366. }
  8367. var user_name string
  8368. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8369. if role.ID == 0 {
  8370. user_name = "xxx"
  8371. } else {
  8372. user_name = role.UserName
  8373. }
  8374. if config.IsOpen == 1 {
  8375. for _, item := range patients {
  8376. 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
  8377. resp, requestErr := http.Get(api)
  8378. if requestErr != nil {
  8379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8380. return
  8381. }
  8382. defer resp.Body.Close()
  8383. body, ioErr := ioutil.ReadAll(resp.Body)
  8384. if ioErr != nil {
  8385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8387. return
  8388. }
  8389. var respJSON map[string]interface{}
  8390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8393. return
  8394. }
  8395. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8396. userJSONBytes, _ := json.Marshal(userJSON)
  8397. var res ResultTwo
  8398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8399. utils.ErrorLog("解析失败:%v", err)
  8400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8401. return
  8402. }
  8403. if res.Infcode == 0 {
  8404. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8405. var dat map[string]interface{}
  8406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8407. fmt.Println(dat)
  8408. } else {
  8409. fmt.Println(err)
  8410. }
  8411. userJSONBytes, _ := json.Marshal(dat)
  8412. var res2 ResultThirteen
  8413. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8414. utils.ErrorLog("解析失败:%v", err)
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. if res2.Infcode == 0 {
  8419. psnResult := &models.GdybPsnRecord{
  8420. UserOrgId: adminUser.CurrentOrgId,
  8421. PatientId: item.ID,
  8422. PsnNo: res.Output.Baseinfo.PsnNo,
  8423. Ctime: time.Now().Unix(),
  8424. Mtime: time.Now().Unix(),
  8425. Status: 1,
  8426. IsCancel: 1,
  8427. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8428. }
  8429. service.CreatePsnRecord(psnResult)
  8430. } else {
  8431. c.ServeSuccessJSON(map[string]interface{}{
  8432. "failed_code": -10,
  8433. "msg": res2.ErrMsg,
  8434. })
  8435. return
  8436. }
  8437. }
  8438. }
  8439. }
  8440. }
  8441. func (c *HisApiController) PsnUnPutOnRecord() {
  8442. id, _ := c.GetInt64("id")
  8443. //record_type, _ := c.GetInt64("type")
  8444. admin_user_id, _ := c.GetInt64("admin_user_id")
  8445. adminUser := c.GetAdminUserInfo()
  8446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8447. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8448. var user_name string
  8449. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8450. if role.ID == 0 {
  8451. user_name = "xxx"
  8452. } else {
  8453. user_name = role.UserName
  8454. }
  8455. psn_record, _ := service.GetPsnRecordById(id)
  8456. if psn_record.ID == 0 {
  8457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8458. return
  8459. }
  8460. if config.IsOpen == 1 {
  8461. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8462. var dat map[string]interface{}
  8463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8464. fmt.Println(dat)
  8465. } else {
  8466. fmt.Println(err)
  8467. }
  8468. userJSONBytes, _ := json.Marshal(dat)
  8469. var res ResultFourteen
  8470. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8471. utils.ErrorLog("解析失败:%v", err)
  8472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8473. return
  8474. }
  8475. if res.Infcode == 0 {
  8476. psn_record.IsCancel = 2
  8477. service.CreatePsnRecord(&psn_record)
  8478. } else {
  8479. c.ServeSuccessJSON(map[string]interface{}{
  8480. "failed_code": -10,
  8481. "msg": res.ErrMsg,
  8482. })
  8483. return
  8484. }
  8485. }
  8486. }
  8487. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8488. patient_id, _ := c.GetInt64("patient_id")
  8489. insutype_two := c.GetString("insutype")
  8490. psn_no := c.GetString("psn_no")
  8491. doctor_id, _ := c.GetInt64("doctor_id")
  8492. sick_id, _ := c.GetInt64("sick_id")
  8493. department_id, _ := c.GetInt64("department_id")
  8494. start_time := c.GetString("start_time")
  8495. end_time := c.GetString("end_time")
  8496. check_time := c.GetString("check_time")
  8497. adminUser := c.GetAdminUserInfo()
  8498. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8499. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8500. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8501. sick, _ := service.FindSickById(sick_id)
  8502. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8503. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8504. var res ResultTwo
  8505. var res10265 ResultTwo10265
  8506. if miConfig.MdtrtareaAdmvs == "320921" {
  8507. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8508. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8509. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8510. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8511. resp, requestErr := http.Get(api)
  8512. if requestErr != nil {
  8513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8514. return
  8515. }
  8516. body, ioErr := ioutil.ReadAll(resp.Body)
  8517. if ioErr != nil {
  8518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8520. return
  8521. }
  8522. var respJSON map[string]interface{}
  8523. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8529. result, _ := json.Marshal(respJSON)
  8530. fmt.Println("log")
  8531. fmt.Println(string(result))
  8532. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8533. utils.ErrorLog("解析失败:%v", err)
  8534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8535. return
  8536. }
  8537. res.ErrMsg = res10265.ErrMsg
  8538. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8539. res.Infcode = infocode
  8540. res.Output = res10265.Output
  8541. res.InfRefmsgid = res10265.InfRefmsgid
  8542. } else {
  8543. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8544. if miConfig.Code == "H15049901371" {
  8545. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8546. utils.ErrorLog("解析失败:%v", err)
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. res.ErrMsg = res10265.ErrMsg
  8551. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8552. res.Infcode = infocode
  8553. res.Output = res10265.Output
  8554. res.InfRefmsgid = res10265.InfRefmsgid
  8555. } else {
  8556. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8557. utils.ErrorLog("解析失败:%v", err)
  8558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8559. return
  8560. }
  8561. }
  8562. }
  8563. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8564. infoStr := string(Iinfos)
  8565. var rf []*ResultFive
  8566. json.Unmarshal([]byte(infoStr), &rf)
  8567. var insuplc_admdvs string
  8568. var insutype string
  8569. var is390 int = 0
  8570. var is310 int = 0
  8571. var insutypes []*ResultFive
  8572. for _, item := range rf {
  8573. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8574. insutypes = append(insutypes, item)
  8575. }
  8576. }
  8577. if len(insutypes) == 1 {
  8578. insutype = insutypes[0].Insutype
  8579. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8580. } else {
  8581. for _, i := range insutypes {
  8582. if i.Insutype == "390" {
  8583. is390 = 1
  8584. }
  8585. if i.Insutype == "310" {
  8586. is310 = 1
  8587. }
  8588. }
  8589. }
  8590. if is390 == 1 {
  8591. insutype = "390"
  8592. }
  8593. if is310 == 1 {
  8594. insutype = "310"
  8595. }
  8596. if len(insutypes) == 2 {
  8597. insutype = insutype_two
  8598. }
  8599. if len(insutypes) == 0 {
  8600. insutype = "310"
  8601. }
  8602. insutype = insutype_two
  8603. fmt.Println(insutype)
  8604. for _, item := range rf {
  8605. fmt.Println(item.Insutype)
  8606. fmt.Println(insutype)
  8607. if item.Insutype == insutype {
  8608. fmt.Println(item.Insutype)
  8609. fmt.Println(insutype)
  8610. insuplc_admdvs = item.InsuplcAdmdvs
  8611. }
  8612. }
  8613. fmt.Println(insuplc_admdvs)
  8614. var res2 ResultThirteen
  8615. var res10265_2 ResultThirteen10265
  8616. if config.IsOpen == 1 {
  8617. if miConfig.MdtrtareaAdmvs == "320921" {
  8618. } else {
  8619. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  8620. var dat map[string]interface{}
  8621. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8622. fmt.Println(dat)
  8623. } else {
  8624. fmt.Println(err)
  8625. }
  8626. userJSONBytes, _ := json.Marshal(dat)
  8627. if miConfig.Code == "H15049901371" {
  8628. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8629. utils.ErrorLog("解析失败:%v", err)
  8630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8631. return
  8632. }
  8633. res2.ErrMsg = res10265_2.ErrMsg
  8634. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8635. res2.Infcode = infocode
  8636. res2.Output = res10265_2.Output
  8637. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8638. } else {
  8639. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8640. utils.ErrorLog("解析失败:%v", err)
  8641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8642. return
  8643. }
  8644. }
  8645. }
  8646. if res2.Infcode == 0 {
  8647. psnResult := &models.GdybPsnNcdsRecord{
  8648. UserOrgId: adminUser.CurrentOrgId,
  8649. PatientId: patient.ID,
  8650. PsnNo: psn_no,
  8651. DoctorId: doctor.AdminUserId,
  8652. DepartmentId: department_id,
  8653. SickType: sick_id,
  8654. Insutype: insutype,
  8655. Ctime: time.Now().Unix(),
  8656. Mtime: time.Now().Unix(),
  8657. Status: 1,
  8658. IsCancel: 1,
  8659. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8660. }
  8661. service.CreatePsnNCDSRecord(psnResult)
  8662. c.ServeSuccessJSON(map[string]interface{}{
  8663. "failed_code": 0,
  8664. "msg": "备案成功",
  8665. "result": psnResult,
  8666. })
  8667. } else {
  8668. c.ServeSuccessJSON(map[string]interface{}{
  8669. "failed_code": -10,
  8670. "msg": res2.ErrMsg,
  8671. })
  8672. return
  8673. }
  8674. }
  8675. }
  8676. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8677. id, _ := c.GetInt64("id")
  8678. admin_user_id, _ := c.GetInt64("admin_user_id")
  8679. adminUser := c.GetAdminUserInfo()
  8680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8681. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8682. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8683. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8684. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8685. //var user_name string
  8686. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8687. //if role.ID == 0 {
  8688. // user_name = "xxx"
  8689. //} else {
  8690. // user_name = role.UserName
  8691. //}
  8692. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8693. if psn_record.ID == 0 {
  8694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8695. return
  8696. }
  8697. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8698. var res ResultTwo
  8699. var res10265 ResultTwo10265
  8700. if miConfig.Code == "H15049901371" {
  8701. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8702. utils.ErrorLog("解析失败:%v", err)
  8703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8704. return
  8705. }
  8706. res.ErrMsg = res10265.ErrMsg
  8707. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8708. res.Infcode = infocode
  8709. res.Output = res10265.Output
  8710. res.InfRefmsgid = res10265.InfRefmsgid
  8711. } else {
  8712. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8713. utils.ErrorLog("解析失败:%v", err)
  8714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8715. return
  8716. }
  8717. }
  8718. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8719. infoStr := string(Iinfos)
  8720. var rf []*ResultFive
  8721. json.Unmarshal([]byte(infoStr), &rf)
  8722. var insuplc_admdvs string
  8723. var insutype string
  8724. var is390 int = 0
  8725. var is310 int = 0
  8726. var insutypes []*ResultFive
  8727. for _, item := range rf {
  8728. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8729. insutypes = append(insutypes, item)
  8730. }
  8731. }
  8732. if len(insutypes) == 1 {
  8733. insutype = insutypes[0].Insutype
  8734. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8735. } else {
  8736. for _, i := range insutypes {
  8737. if i.Insutype == "390" {
  8738. is390 = 1
  8739. }
  8740. if i.Insutype == "310" {
  8741. is310 = 1
  8742. }
  8743. }
  8744. }
  8745. if is390 == 1 {
  8746. insutype = "390"
  8747. }
  8748. if is310 == 1 {
  8749. insutype = "310"
  8750. }
  8751. if len(insutypes) == 0 {
  8752. insutype = "310"
  8753. }
  8754. insutype = psn_record.Insutype
  8755. for _, item := range rf {
  8756. if item.Insutype == insutype {
  8757. insuplc_admdvs = item.InsuplcAdmdvs
  8758. }
  8759. }
  8760. if config.IsOpen == 1 {
  8761. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8762. var dat map[string]interface{}
  8763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8764. fmt.Println(dat)
  8765. } else {
  8766. fmt.Println(err)
  8767. }
  8768. userJSONBytes, _ := json.Marshal(dat)
  8769. var res ResultFourteen
  8770. var res10265 ResultFourteen10265
  8771. if miConfig.Code == "H15049901371" {
  8772. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8773. utils.ErrorLog("解析失败:%v", err)
  8774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8775. return
  8776. }
  8777. res.ErrMsg = res10265.ErrMsg
  8778. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8779. res.Infcode = infocode
  8780. res.Output = res10265.Output
  8781. res.InfRefmsgid = res10265.InfRefmsgid
  8782. } else {
  8783. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8784. utils.ErrorLog("解析失败:%v", err)
  8785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8786. return
  8787. }
  8788. }
  8789. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8790. // utils.ErrorLog("解析失败:%v", err)
  8791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8792. // return
  8793. //}
  8794. if res.Infcode == 0 {
  8795. psn_record.IsCancel = 2
  8796. service.CreatePsnNCDSRecord(&psn_record)
  8797. c.ServeSuccessJSON(map[string]interface{}{
  8798. "failed_code": 0,
  8799. "msg": "撤销备案成功",
  8800. })
  8801. } else {
  8802. c.ServeSuccessJSON(map[string]interface{}{
  8803. "failed_code": -10,
  8804. "msg": res.ErrMsg,
  8805. })
  8806. return
  8807. }
  8808. }
  8809. }
  8810. func (c *HisApiController) TestTest() {
  8811. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8812. fmt.Println(patient.Iinfo)
  8813. }
  8814. type CustomData struct {
  8815. MsgId string
  8816. PsnNo string
  8817. Info string
  8818. }
  8819. func (c *HisApiController) ReversalData() {
  8820. var customData []*CustomData
  8821. custom := &CustomData{
  8822. MsgId: "H44022900158202103301714472004",
  8823. PsnNo: "44020000001101329945",
  8824. Info: "2207",
  8825. }
  8826. customData = append(customData, custom)
  8827. custom1 := &CustomData{
  8828. MsgId: "H4402290015820210330172057803",
  8829. PsnNo: "44020000001101161813",
  8830. Info: "2207",
  8831. }
  8832. customData = append(customData, custom1)
  8833. custom2 := &CustomData{
  8834. MsgId: "H44022900158202103301705198813",
  8835. PsnNo: "44190000133097375417",
  8836. Info: "2207",
  8837. }
  8838. customData = append(customData, custom2)
  8839. custom3 := &CustomData{
  8840. MsgId: "H44022900158202103301715524756",
  8841. PsnNo: "44020000001100187221",
  8842. Info: "2207",
  8843. }
  8844. customData = append(customData, custom3)
  8845. custom4 := &CustomData{
  8846. MsgId: "H44022900158202103301730376224",
  8847. PsnNo: "44020000001101959155",
  8848. Info: "2207",
  8849. }
  8850. customData = append(customData, custom4)
  8851. custom5 := &CustomData{
  8852. MsgId: "H44022900158202103301748008725",
  8853. PsnNo: "44020000001104246641",
  8854. Info: "2207",
  8855. }
  8856. customData = append(customData, custom5)
  8857. custom6 := &CustomData{
  8858. MsgId: "H44022900158202103301718096755",
  8859. PsnNo: "44020000001102211860",
  8860. Info: "2207",
  8861. }
  8862. customData = append(customData, custom6)
  8863. custom7 := &CustomData{
  8864. MsgId: "H44022900158202103301736551640",
  8865. PsnNo: "44020000001102687718",
  8866. Info: "2207",
  8867. }
  8868. customData = append(customData, custom7)
  8869. custom8 := &CustomData{
  8870. MsgId: "H44022900158202103301743097676",
  8871. PsnNo: "44020000001102127785",
  8872. Info: "2207",
  8873. }
  8874. customData = append(customData, custom8)
  8875. custom9 := &CustomData{
  8876. MsgId: "H44022900158202103301712304203",
  8877. PsnNo: "44020000001101518097",
  8878. Info: "2207",
  8879. }
  8880. customData = append(customData, custom9)
  8881. custom10 := &CustomData{
  8882. MsgId: "H44022900158202103301738448785",
  8883. PsnNo: "44020000001100500813",
  8884. Info: "2207",
  8885. }
  8886. customData = append(customData, custom10)
  8887. custom11 := &CustomData{
  8888. MsgId: "H44022900158202103301732455843",
  8889. PsnNo: "44020000001102690557",
  8890. Info: "2207",
  8891. }
  8892. customData = append(customData, custom11)
  8893. custom12 := &CustomData{
  8894. MsgId: "H44022900158202103301745421708",
  8895. PsnNo: "44020000001102211928",
  8896. Info: "2207",
  8897. }
  8898. customData = append(customData, custom12)
  8899. custom1212 := &CustomData{
  8900. MsgId: "H440229001582021033017351627",
  8901. PsnNo: "44020000001102481733",
  8902. Info: "2207",
  8903. }
  8904. customData = append(customData, custom1212)
  8905. custom13 := &CustomData{
  8906. MsgId: "H44022900158202103301740327951",
  8907. PsnNo: "44020000001103174866",
  8908. Info: "2207",
  8909. }
  8910. customData = append(customData, custom13)
  8911. custom14 := &CustomData{
  8912. MsgId: "H4402290015820210330174922668",
  8913. PsnNo: "44020000001102927272",
  8914. Info: "2207",
  8915. }
  8916. customData = append(customData, custom14)
  8917. custom15 := &CustomData{
  8918. MsgId: "H44022900158202103301752362273",
  8919. PsnNo: "44020000001102942890",
  8920. Info: "2207",
  8921. }
  8922. customData = append(customData, custom15)
  8923. custom16 := &CustomData{
  8924. MsgId: "H44022900158202103301751082917",
  8925. PsnNo: "44020000001101662162",
  8926. Info: "2207",
  8927. }
  8928. customData = append(customData, custom16)
  8929. custom17 := &CustomData{
  8930. MsgId: "H44022900158202103301754147728",
  8931. PsnNo: "44020000000229014511",
  8932. Info: "2207",
  8933. }
  8934. customData = append(customData, custom17)
  8935. adminUser := c.GetAdminUserInfo()
  8936. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8937. for _, item := range customData {
  8938. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8939. fmt.Println(result)
  8940. }
  8941. }
  8942. func (c *HisApiController) GetAllopatry() {
  8943. year := c.GetString("year")
  8944. month := c.GetString("month")
  8945. admin_user_id, _ := c.GetInt64("admin_user_id")
  8946. adminUser := c.GetAdminUserInfo()
  8947. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8948. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8949. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8950. var dat map[string]interface{}
  8951. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8952. fmt.Println(dat)
  8953. } else {
  8954. fmt.Println(err)
  8955. }
  8956. userJSONBytes, _ := json.Marshal(dat)
  8957. var res models.Result9001
  8958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8959. utils.ErrorLog("解析失败:%v", err)
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8961. return
  8962. }
  8963. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  8964. var dat2 map[string]interface{}
  8965. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8966. fmt.Println(dat)
  8967. } else {
  8968. fmt.Println(err)
  8969. }
  8970. userJSONBytes2, _ := json.Marshal(dat2)
  8971. var res2 models.Result3260
  8972. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8973. utils.ErrorLog("解析失败:%v", err)
  8974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8975. return
  8976. }
  8977. if res2.Infcode == 0 {
  8978. c.ServeSuccessJSON(map[string]interface{}{
  8979. "list": res2.Output.Data,
  8980. })
  8981. return
  8982. } else {
  8983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8984. return
  8985. }
  8986. }
  8987. func (c *HisApiController) ComfirmAllopatry() {
  8988. year := c.GetString("year")
  8989. month := c.GetString("month")
  8990. admin_user_id, _ := c.GetInt64("admin_user_id")
  8991. adminUser := c.GetAdminUserInfo()
  8992. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8993. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8994. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8995. var dat map[string]interface{}
  8996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8997. fmt.Println(dat)
  8998. } else {
  8999. fmt.Println(err)
  9000. }
  9001. userJSONBytes, _ := json.Marshal(dat)
  9002. var res models.Result9001
  9003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9004. utils.ErrorLog("解析失败:%v", err)
  9005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9006. return
  9007. }
  9008. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9009. var dat2 map[string]interface{}
  9010. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9011. fmt.Println(dat)
  9012. } else {
  9013. fmt.Println(err)
  9014. }
  9015. userJSONBytes2, _ := json.Marshal(dat2)
  9016. var res2 models.Result3260
  9017. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9018. utils.ErrorLog("解析失败:%v", err)
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9020. return
  9021. }
  9022. if res2.Infcode == 0 {
  9023. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9024. var dat map[string]interface{}
  9025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9026. fmt.Println(dat)
  9027. } else {
  9028. fmt.Println(err)
  9029. }
  9030. userJSONBytes, _ := json.Marshal(dat)
  9031. var res3 models.Result3261
  9032. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9033. utils.ErrorLog("解析失败:%v", err)
  9034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9035. return
  9036. }
  9037. if res3.Infcode == 0 {
  9038. record := &models.HisYidiClearRecord{
  9039. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9040. Ctime: time.Now().Unix(),
  9041. Mtime: time.Now().Unix(),
  9042. Status: 1,
  9043. MsgId: msgId,
  9044. }
  9045. service.SaveClearRecord(record)
  9046. c.ServeSuccessJSON(map[string]interface{}{
  9047. "msg": "提取成功",
  9048. })
  9049. }
  9050. }
  9051. }
  9052. func (c *HisApiController) RefundAllopatry() {
  9053. year := c.GetString("year")
  9054. month := c.GetString("month")
  9055. id, _ := c.GetInt64("id")
  9056. admin_user_id, _ := c.GetInt64("admin_user_id")
  9057. adminUser := c.GetAdminUserInfo()
  9058. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9059. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9060. record, _ := service.GetClearRecordById(id)
  9061. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9062. var dat map[string]interface{}
  9063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9064. fmt.Println(dat)
  9065. } else {
  9066. fmt.Println(err)
  9067. }
  9068. userJSONBytes, _ := json.Marshal(dat)
  9069. var empty ResultFourteen
  9070. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9071. utils.ErrorLog("解析失败:%v", err)
  9072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9073. return
  9074. }
  9075. if empty.Infcode == 0 {
  9076. c.ServeSuccessJSON(map[string]interface{}{
  9077. "msg": "撤销成功",
  9078. })
  9079. return
  9080. }
  9081. }
  9082. func (c *HisApiController) ReversalOtherData() {
  9083. var customData []*CustomData
  9084. custom := &CustomData{
  9085. MsgId: "H44022900158202103301714472004",
  9086. PsnNo: "44020000001101329945",
  9087. Info: "2208",
  9088. }
  9089. customData = append(customData, custom)
  9090. custom1 := &CustomData{
  9091. MsgId: "H4402290015820210330172057803",
  9092. PsnNo: "44020000001101161813",
  9093. Info: "2208",
  9094. }
  9095. customData = append(customData, custom1)
  9096. custom2 := &CustomData{
  9097. MsgId: "H44022900158202103301705198813",
  9098. PsnNo: "44190000133097375417",
  9099. Info: "2208",
  9100. }
  9101. customData = append(customData, custom2)
  9102. custom3 := &CustomData{
  9103. MsgId: "H44022900158202103301715524756",
  9104. PsnNo: "44020000001100187221",
  9105. Info: "2208",
  9106. }
  9107. customData = append(customData, custom3)
  9108. custom4 := &CustomData{
  9109. MsgId: "H44022900158202103301730376224",
  9110. PsnNo: "44020000001101959155",
  9111. Info: "2208",
  9112. }
  9113. customData = append(customData, custom4)
  9114. custom5 := &CustomData{
  9115. MsgId: "H44022900158202103301748008725",
  9116. PsnNo: "44020000001104246641",
  9117. Info: "2208",
  9118. }
  9119. customData = append(customData, custom5)
  9120. custom6 := &CustomData{
  9121. MsgId: "H44022900158202103301718096755",
  9122. PsnNo: "44020000001102211860",
  9123. Info: "2208",
  9124. }
  9125. customData = append(customData, custom6)
  9126. custom7 := &CustomData{
  9127. MsgId: "H44022900158202103301736551640",
  9128. PsnNo: "44020000001102687718",
  9129. Info: "2208",
  9130. }
  9131. customData = append(customData, custom7)
  9132. custom8 := &CustomData{
  9133. MsgId: "H44022900158202103301743097676",
  9134. PsnNo: "44020000001102127785",
  9135. Info: "2208",
  9136. }
  9137. customData = append(customData, custom8)
  9138. custom9 := &CustomData{
  9139. MsgId: "H44022900158202103301712304203",
  9140. PsnNo: "44020000001101518097",
  9141. Info: "2208",
  9142. }
  9143. customData = append(customData, custom9)
  9144. custom10 := &CustomData{
  9145. MsgId: "H44022900158202103301738448785",
  9146. PsnNo: "44020000001100500813",
  9147. Info: "2208",
  9148. }
  9149. customData = append(customData, custom10)
  9150. custom11 := &CustomData{
  9151. MsgId: "H44022900158202103301732455843",
  9152. PsnNo: "44020000001102690557",
  9153. Info: "2208",
  9154. }
  9155. customData = append(customData, custom11)
  9156. custom12 := &CustomData{
  9157. MsgId: "H44022900158202103301745421708",
  9158. PsnNo: "44020000001102211928",
  9159. Info: "2208",
  9160. }
  9161. customData = append(customData, custom12)
  9162. custom1212 := &CustomData{
  9163. MsgId: "H440229001582021033017351627",
  9164. PsnNo: "44020000001102481733",
  9165. Info: "2208",
  9166. }
  9167. customData = append(customData, custom1212)
  9168. custom13 := &CustomData{
  9169. MsgId: "H44022900158202103301740327951",
  9170. PsnNo: "44020000001103174866",
  9171. Info: "2208",
  9172. }
  9173. customData = append(customData, custom13)
  9174. custom14 := &CustomData{
  9175. MsgId: "H4402290015820210330174922668",
  9176. PsnNo: "44020000001102927272",
  9177. Info: "2208",
  9178. }
  9179. customData = append(customData, custom14)
  9180. custom15 := &CustomData{
  9181. MsgId: "H44022900158202103301752362273",
  9182. PsnNo: "44020000001102942890",
  9183. Info: "2208",
  9184. }
  9185. customData = append(customData, custom15)
  9186. custom16 := &CustomData{
  9187. MsgId: "H44022900158202103301751082917",
  9188. PsnNo: "44020000001101662162",
  9189. Info: "2208",
  9190. }
  9191. customData = append(customData, custom16)
  9192. custom17 := &CustomData{
  9193. MsgId: "H44022900158202103301754147728",
  9194. PsnNo: "44020000000229014511",
  9195. Info: "2208",
  9196. }
  9197. customData = append(customData, custom17)
  9198. adminUser := c.GetAdminUserInfo()
  9199. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9200. for _, item := range customData {
  9201. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9202. fmt.Println(result)
  9203. }
  9204. }
  9205. func PathExists(path string) (bool, error) {
  9206. _, err := os.Stat(path)
  9207. if err == nil {
  9208. return true, nil
  9209. }
  9210. if os.IsNotExist(err) {
  9211. return false, nil
  9212. }
  9213. return false, err
  9214. }
  9215. //创建文件夹
  9216. func Mkdir(dir string) {
  9217. // 创建文件夹
  9218. exist, err := PathExists(dir)
  9219. if err != nil {
  9220. fmt.Println(err.Error())
  9221. } else {
  9222. if exist {
  9223. fmt.Println(dir + "文件夹已存在!")
  9224. } else {
  9225. // 文件夹名称,权限
  9226. err := os.Mkdir(dir, os.ModePerm)
  9227. if err != nil {
  9228. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9229. } else {
  9230. fmt.Println(dir + "文件夹创建成功!")
  9231. }
  9232. }
  9233. }
  9234. }
  9235. //压缩文件
  9236. func Zip(srcFile string, destZip string) error {
  9237. zipfile, err := os.Create(destZip)
  9238. if err != nil {
  9239. return err
  9240. }
  9241. defer zipfile.Close()
  9242. archive := zip.NewWriter(zipfile)
  9243. defer archive.Close()
  9244. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9245. if err != nil {
  9246. return err
  9247. }
  9248. header, err := zip.FileInfoHeader(info)
  9249. if err != nil {
  9250. return err
  9251. }
  9252. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9253. // header.Name = path
  9254. if info.IsDir() {
  9255. header.Name += "/"
  9256. } else {
  9257. header.Method = zip.Deflate
  9258. }
  9259. writer, err := archive.CreateHeader(header)
  9260. if err != nil {
  9261. return err
  9262. }
  9263. if !info.IsDir() {
  9264. file, err := os.Open(path)
  9265. if err != nil {
  9266. return err
  9267. }
  9268. defer file.Close()
  9269. _, err = io.Copy(writer, file)
  9270. }
  9271. return err
  9272. })
  9273. return err
  9274. }
  9275. func ReadFile(filePath string) []byte {
  9276. f, err := os.Open(filePath)
  9277. if err != nil {
  9278. fmt.Println("read file fail", err)
  9279. return nil
  9280. }
  9281. defer f.Close()
  9282. fd, err := ioutil.ReadAll(f)
  9283. if err != nil {
  9284. fmt.Println("read to fd fail", err)
  9285. return nil
  9286. }
  9287. return fd
  9288. }
  9289. func saveLog(result string, request string, infno string, desc string) {
  9290. org_id, _ := beego.AppConfig.Int64("org_id")
  9291. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9292. dir := miConfig.OrgName + "日志"
  9293. utils.Mkdir(dir)
  9294. month := time.Unix(1557042972, 0).Format("1")
  9295. year := time.Now().Format("2006")
  9296. month = time.Now().Format("01")
  9297. day := time.Now().Format("02")
  9298. hour := time.Now().Format("15")
  9299. min := time.Now().Format("04")
  9300. sec := time.Now().Format("05")
  9301. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9302. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9303. file_name := file + ".txt"
  9304. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9305. exist, _ := utils.PathExists(file_path)
  9306. if exist { //存在
  9307. fmt.Println("存在")
  9308. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9309. if err != nil {
  9310. fmt.Println("read fail")
  9311. }
  9312. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9313. n, _ := f.Seek(0, 2)
  9314. _, err = f.WriteAt([]byte(content), n)
  9315. } else { //不存在
  9316. fmt.Println("文件不存在,创建文件")
  9317. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9318. defer f.Close()
  9319. if err != nil {
  9320. } else {
  9321. _, err = f.Write([]byte("记录日志"))
  9322. }
  9323. }
  9324. }
  9325. type Charset string
  9326. const (
  9327. UTF8 = Charset("UTF-8")
  9328. GB18030 = Charset("GB18030")
  9329. )
  9330. func ConvertToString(src string, srcCode string, tagCode string) string {
  9331. srcCoder := mahonia.NewDecoder(srcCode)
  9332. srcResult := srcCoder.ConvertString(src)
  9333. tagCoder := mahonia.NewDecoder(tagCode)
  9334. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9335. result := string(cdata)
  9336. return result
  9337. }