his_api_controller.go 335KB

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